From: ribes Date: Fri, 30 Jul 2010 13:26:22 +0000 (+0000) Subject: - can remove an observer X-Git-Tag: V6_2_0a1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=42d5ddfa37401e8789d993b0f9b57609e7d5b42d;p=modules%2Fkernel.git - can remove an observer - notify a new observer of jobs in launcher --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 364568b03..69e10274c 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -221,6 +221,7 @@ interface SalomeLauncher // Observer and introspection methods void addObserver(in Engines::SalomeLauncherObserver observer); + void removeObserver(in Engines::SalomeLauncherObserver observer); Engines::JobsList getJobsList(); Engines::JobParameters getJobParameters(in long job_id) raises (SALOME::SALOME_Exception); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 1195c2b6a..27956bded 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -929,9 +929,53 @@ SALOME_Launcher::addObserver(Engines::SalomeLauncherObserver_ptr observer) new_observer = false; break; } + iter++; } if (new_observer) _observers.push_back(Engines::SalomeLauncherObserver::_duplicate(observer)); + + // We notify the new observer with all jobs that are currently in the Launcher + std::map cpp_jobs = _l.getJobs(); + std::map::const_iterator it_job; + for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++) + { + int number = it_job->first; + std::ostringstream job_id; + job_id << number; + try + { + observer->notify("NEW_JOB", job_id.str().c_str()); + } + catch (...) + { + MESSAGE("Notify Observer, exception catch"); + } + + } +} + +//============================================================================= +/*! CORBA Method: + * Add a new observer to the launcher + */ +//============================================================================= +void +SALOME_Launcher::removeObserver(Engines::SalomeLauncherObserver_ptr observer) +{ + std::list::iterator iter = _observers.begin(); + while(iter != _observers.end()) + { + if (std::string(_orb->object_to_string(*iter)) == + std::string(_orb->object_to_string(observer))) + { + // Observer found + iter =_observers.erase(iter++); + } + else + { + iter++; + } + } } //============================================================================= diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 871488b90..fff5515e2 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -62,6 +62,7 @@ public: // Observer and introspection methods virtual void addObserver(Engines::SalomeLauncherObserver_ptr observer); + virtual void removeObserver(Engines::SalomeLauncherObserver_ptr observer); virtual Engines::JobsList * getJobsList(); virtual Engines::JobParameters * getJobParameters(CORBA::Long job_id);