1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SALOMEDispatcher.hxx"
26 #include "YacsTrace.hxx"
29 using namespace YACS::BASES;
30 using namespace YACS::ENGINE;
32 map< pair<int,string> , set<YACS_ORB::Observer_ptr> > SALOMEDispatcher::_observers;
33 SALOMEDispatcher* SALOMEDispatcher::_disp = 0;
35 SALOMEDispatcher::SALOMEDispatcher()
39 SALOMEDispatcher::~SALOMEDispatcher()
43 void SALOMEDispatcher::setSALOMEDispatcher()
45 DEBTRACE("SALOMEDispatcher::setSALOMEDispatcher");
46 _disp=new SALOMEDispatcher();
47 YACS::ENGINE::Dispatcher::setDispatcher(_disp);
50 SALOMEDispatcher* SALOMEDispatcher::getSALOMEDispatcher()
55 void SALOMEDispatcher::dispatch(Node* object, const std::string& event)
57 DEBTRACE("SALOMEDispatcher::dispatch " << event << " " << object->getNumId());
58 CORBA::Long numId = object->getNumId();
59 typedef set<YACS_ORB::Observer_ptr>::iterator jt;
60 std::pair<int,std::string> key(numId, event);
61 for(jt iter = _observers[key].begin(); iter!=_observers[key].end(); iter++)
63 if (! CORBA::is_nil(*iter))
65 DEBTRACE("numId, event " << numId << " " << event );
66 (*iter)->notifyObserver(numId, event.c_str());
69 DEBTRACE("************************** dispatch on a CORBA::nil *******************************");
73 void SALOMEDispatcher::addObserver(YACS_ORB::Observer_ptr observer,
77 _observers[std::pair<int,std::string>(numid,event)].insert(YACS_ORB::Observer::_duplicate(observer));