Salome HOME
Add a remove working directory feature to the Launcher.
[modules/kernel.git] / src / Launcher / SALOME_Launcher.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "SALOME_Launcher.hxx"
24 #include "BatchTest.hxx"
25 #include "OpUtil.hxx"
26 #include "SALOME_ContainerManager.hxx"
27 #include "SALOME_NamingService.hxx"
28 #include "SALOME_ResourcesManager.hxx"
29 #include "Utils_CorbaException.hxx"
30
31
32 #include "Launcher_Job_Command.hxx"
33 #include "Launcher_Job_YACSFile.hxx"
34 #include "Launcher_Job_PythonSALOME.hxx"
35
36 #include "utilities.h"
37
38 #ifdef WIN32
39 # include <process.h>
40 #else
41 # include <unistd.h>
42 #endif
43 #include <sys/types.h>
44 #include <vector>
45 #include <list>
46
47 #include <stdio.h>
48 #include <sstream>
49
50 using namespace std;
51
52 const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
53
54 //=============================================================================
55 /*! 
56  *  Constructor
57  *  \param orb
58  */
59 //=============================================================================
60 SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa) : _l()
61 {
62   MESSAGE("SALOME_Launcher constructor");
63   _NS = new SALOME_NamingService(orb);
64   _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
65   _l.SetResourcesManager(_ResManager->GetImpl());
66   _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
67   _ResManager->_remove_ref();
68   _ContManager->_remove_ref();
69
70   _orb = CORBA::ORB::_duplicate(orb) ;
71   _poa = PortableServer::POA::_duplicate(poa) ;
72   PortableServer::ObjectId_var id = _poa->activate_object(this);
73   CORBA::Object_var obj = _poa->id_to_reference(id);
74   Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
75
76   _NS->Register(refContMan,_LauncherNameInNS);
77   MESSAGE("SALOME_Launcher constructor end");
78 }
79
80 //=============================================================================
81 /*! 
82  * destructor
83  */
84 //=============================================================================
85 SALOME_Launcher::~SALOME_Launcher()
86 {
87   MESSAGE("SALOME_Launcher destructor");
88   delete _NS;
89   MESSAGE("SALOME_Launcher destructor end");
90 }
91
92
93 CORBA::Long 
94 SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
95 {
96   std::string job_type = job_parameters.job_type.in();
97
98   if (job_type != "command" && job_type != "yacs_file" && job_type != "python_salome")
99   {
100     std::string message("SALOME_Launcher::createJob: bad job type: ");
101     message += job_type;
102     THROW_SALOME_CORBA_EXCEPTION(message.c_str(), SALOME::INTERNAL_ERROR);
103   }
104
105   Launcher::Job * new_job; // It is Launcher_cpp that is going to destroy it
106
107   if (job_type == "command")
108     new_job = new Launcher::Job_Command();
109   else if (job_type == "yacs_file")
110     new_job = new Launcher::Job_YACSFile();
111   else if (job_type == "python_salome")
112     new_job = new Launcher::Job_PythonSALOME();
113
114   // Name
115   new_job->setJobName(job_parameters.job_name.in());
116
117   // Directories
118   std::string work_directory = job_parameters.work_directory.in();
119   std::string local_directory = job_parameters.local_directory.in();
120   std::string result_directory = job_parameters.result_directory.in();
121   new_job->setWorkDirectory(work_directory);
122   new_job->setLocalDirectory(local_directory);
123   new_job->setResultDirectory(result_directory);
124
125   // Parameters for COORM
126   std::string launcher_file = job_parameters.launcher_file.in();
127   std::string launcher_args = job_parameters.launcher_args.in();
128   new_job->setLauncherFile(launcher_file);
129   new_job->setLauncherArgs(launcher_args);
130
131   // Job File
132   std::string job_file = job_parameters.job_file.in();
133   try
134   {
135     new_job->setJobFile(job_file);
136   }
137   catch(const LauncherException &ex)
138   {
139     INFOS(ex.msg.c_str());
140     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
141   }
142
143   // Files
144   std::string env_file = job_parameters.env_file.in();
145   new_job->setEnvFile(env_file);
146   for (CORBA::ULong i = 0; i < job_parameters.in_files.length(); i++)
147     new_job->add_in_file(job_parameters.in_files[i].in());
148   for (CORBA::ULong i = 0; i < job_parameters.out_files.length(); i++)
149     new_job->add_out_file(job_parameters.out_files[i].in());
150
151   // Expected During Time
152   try
153   {
154     std::string maximum_duration = job_parameters.maximum_duration.in();
155     new_job->setMaximumDuration(maximum_duration);
156   }
157   catch(const LauncherException &ex){
158     INFOS(ex.msg.c_str());
159     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
160   }
161
162   // Queue
163   std::string queue = job_parameters.queue.in();
164   new_job->setQueue(queue);
165
166   // Exclusive
167   new_job->setExclusive(job_parameters.exclusive);
168
169   // Memory required per CPU
170   new_job->setMemPerCpu(job_parameters.mem_per_cpu);
171
172   // WC Key
173   std::string wckey = job_parameters.wckey.in();
174   new_job->setWCKey(wckey);
175
176   // Extra params
177   std::string extra_params = job_parameters.extra_params.in();
178   new_job->setExtraParams(extra_params);
179
180   // Resources requirements
181   try
182   {
183     resourceParams p;
184     p.name = job_parameters.resource_required.name;
185     p.hostname = job_parameters.resource_required.hostname;
186     p.OS = job_parameters.resource_required.OS;
187     p.nb_proc = job_parameters.resource_required.nb_proc;
188     p.nb_node = job_parameters.resource_required.nb_node;
189     p.nb_proc_per_node = job_parameters.resource_required.nb_proc_per_node;
190     p.cpu_clock = job_parameters.resource_required.cpu_clock;
191     p.mem_mb = job_parameters.resource_required.mem_mb;
192     new_job->setResourceRequiredParams(p);
193   }
194   catch(const LauncherException &ex){
195     INFOS(ex.msg.c_str());
196     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
197   }
198
199   // Adding specific parameters to the job
200   for (CORBA::ULong i = 0; i < job_parameters.specific_parameters.length(); i++)
201     new_job->addSpecificParameter(job_parameters.specific_parameters[i].name.in(),
202                                   job_parameters.specific_parameters[i].value.in());
203   try
204   {
205     new_job->checkSpecificParameters();
206   }
207   catch(const LauncherException &ex)
208   {
209     INFOS(ex.msg.c_str());
210     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
211   }
212
213   try
214   {
215     _l.createJob(new_job);
216     std::ostringstream job_id;
217     job_id << new_job->getNumber();
218     notifyObservers("NEW_JOB", job_id.str());
219   }
220   catch(const LauncherException &ex)
221   {
222     INFOS(ex.msg.c_str());
223     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
224   }
225   return new_job->getNumber();
226 }
227
228 void 
229 SALOME_Launcher::launchJob(CORBA::Long job_id)
230 {
231   try
232   {
233     _l.launchJob(job_id);
234   }
235   catch(const LauncherException &ex)
236   {
237     INFOS(ex.msg.c_str());
238     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
239   }
240 }
241
242 char *
243 SALOME_Launcher::getJobState(CORBA::Long job_id)
244 {
245   std::string result;
246   try
247   {
248     result = _l.getJobState(job_id);
249   }
250   catch(const LauncherException &ex)
251   {
252     INFOS(ex.msg.c_str());
253     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
254   }
255   return CORBA::string_dup(result.c_str());
256 }
257
258 // Get names or ids of hosts assigned to the job
259 char *
260 SALOME_Launcher::getAssignedHostnames(CORBA::Long job_id)
261 {
262   std::string result;
263   try
264   {
265     result = _l.getAssignedHostnames(job_id);
266   }
267   catch(const LauncherException &ex)
268   {
269     INFOS(ex.msg.c_str());
270     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
271   }
272   return CORBA::string_dup(result.c_str());
273 }
274
275 void
276 SALOME_Launcher::getJobResults(CORBA::Long job_id, const char * directory)
277 {
278   try
279   {
280     _l.getJobResults(job_id, directory);
281   }
282   catch(const LauncherException &ex)
283   {
284     INFOS(ex.msg.c_str());
285     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
286   }
287 }
288
289 void
290 SALOME_Launcher::clearJobWorkingDir(CORBA::Long job_id)
291 {
292   try
293   {
294     _l.clearJobWorkingDir(job_id);
295   }
296   catch(const LauncherException &ex)
297   {
298     INFOS(ex.msg.c_str());
299     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
300   }
301 }
302
303 CORBA::Boolean
304 SALOME_Launcher::getJobDumpState(CORBA::Long job_id, const char * directory)
305 {
306   CORBA::Boolean rtn = false;
307   try
308   {
309     rtn = _l.getJobDumpState(job_id, directory);
310   }
311   catch(const LauncherException &ex)
312   {
313     INFOS(ex.msg.c_str());
314     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
315   }
316   return rtn;
317 }
318
319 CORBA::Boolean
320 SALOME_Launcher::getJobWorkFile(CORBA::Long job_id, const char * work_file, const char * directory)
321 {
322   CORBA::Boolean rtn = false;
323   try
324   {
325     rtn = _l.getJobWorkFile(job_id, work_file, directory);
326   }
327   catch(const LauncherException &ex)
328   {
329     INFOS(ex.msg.c_str());
330     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
331   }
332   return rtn;
333 }
334
335 void 
336 SALOME_Launcher::removeJob(CORBA::Long job_id)
337 {
338   try
339   {
340     _l.removeJob(job_id);
341     std::ostringstream job_id_str;
342     job_id_str << job_id;
343     notifyObservers("REMOVE_JOB", job_id_str.str());
344   }
345   catch(const LauncherException &ex)
346   {
347     INFOS(ex.msg.c_str());
348     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
349   }
350 }
351
352 void 
353 SALOME_Launcher::stopJob(CORBA::Long job_id)
354 {
355   try
356   {
357     _l.stopJob(job_id);
358     std::ostringstream job_id_str;
359     job_id_str << job_id;
360     notifyObservers("UPDATE_JOB_STATE", job_id_str.str());
361   }
362   catch(const LauncherException &ex)
363   {
364     INFOS(ex.msg.c_str());
365     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
366   }
367 }
368
369 //=============================================================================
370 /*! CORBA Method:
371  *  Create a job in the launcher with a file
372  *  \param xmlExecuteFile     : .xml to parse that contains job description
373  *  \param clusterName        : machine choosed
374  */
375 //=============================================================================
376 CORBA::Long 
377 SALOME_Launcher::createJobWithFile(const char * xmlExecuteFile,
378                                    const char * clusterName)
379 {
380   CORBA::Long jobId;
381   try{
382     jobId = _l.createJobWithFile(xmlExecuteFile, clusterName);
383   }
384   catch(const LauncherException &ex){
385     INFOS(ex.msg.c_str());
386     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
387   }
388
389   return jobId;
390 }
391
392 //=============================================================================
393 /*! CORBA Method:
394  *  the test batch configuration 
395  *  \param params             : The batch cluster
396  */
397 //=============================================================================
398 CORBA::Boolean 
399 SALOME_Launcher::testBatch(const Engines::ResourceParameters& params)
400 {
401   MESSAGE("BEGIN OF SALOME_Launcher::testBatch");
402   CORBA::Boolean rtn = false;
403   try
404   {
405     // Consider only resources that can run batch jobs
406     Engines::ResourceParameters new_params(params);
407     new_params.can_launch_batch_jobs = true;
408
409     // find a resource matching the required parameters
410     Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(new_params);
411     if (aMachineList->length() == 0)
412       throw SALOME_Exception("No resources have been found with your parameters");
413
414     const Engines::ResourceDefinition* p = _ResManager->GetResourceDefinition((*aMachineList)[0]);
415         std::string resource_name(p->name);
416     INFOS("Choose resource for test: " <<  resource_name);
417     
418     BatchTest t(*p);
419     if (t.test()) 
420     {
421       rtn = true;
422     }
423   }
424   catch(const LauncherException &ex){
425     INFOS(ex.msg.c_str());
426     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
427   }
428   return rtn;
429 }
430
431 //=============================================================================
432 /*! CORBA method:
433  *  shutdown all the containers, then the ContainerManager servant
434  */
435 //=============================================================================
436 void SALOME_Launcher::Shutdown()
437 {
438   MESSAGE("Shutdown");
439   _NS->Destroy_Name(_LauncherNameInNS);
440   _ContManager->Shutdown();
441   _ResManager->Shutdown();
442   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
443   _poa->deactivate_object(oid);
444   if(!CORBA::is_nil(_orb))
445     _orb->shutdown(0);
446 }
447
448 //=============================================================================
449 /*! CORBA Method:
450  *  Returns the PID of the process
451  */
452 //=============================================================================
453 CORBA::Long SALOME_Launcher::getPID()
454 {
455   return 
456 #ifndef WIN32
457     (CORBA::Long)getpid();
458 #else
459     (CORBA::Long)_getpid();
460 #endif
461 }
462
463 //=============================================================================
464 /*! CORBA Method:
465  *  Returns current launcher jobs list
466  */
467 //=============================================================================
468 Engines::JobsList *
469 SALOME_Launcher::getJobsList()
470 {
471   Engines::JobsList_var jobs_list = new Engines::JobsList();
472   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
473   std::map<int, Launcher::Job *>::const_iterator it_job;
474   int list_id = 0;
475   for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++)
476   {
477     int number          = it_job->first;
478     try
479     {
480       // Prepare CORBA job description
481       Engines::JobDescription_var job_descr = new Engines::JobDescription();
482       Engines::JobParameters_var job_parameters = getJobParameters(number);
483       job_descr->job_id = number;
484       job_descr->job_parameters = job_parameters;
485
486       // Add job description to the sequence
487       jobs_list->length(list_id + 1);
488       jobs_list[list_id] = job_descr;
489       list_id++;
490     }
491     catch (...) {}
492   }
493   return jobs_list._retn();
494 }
495
496 //=============================================================================
497 /*! CORBA Method:
498  * Returns the job description
499  */
500 //=============================================================================
501 Engines::JobParameters *
502 SALOME_Launcher::getJobParameters(CORBA::Long job_id)
503 {
504   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
505   std::map<int, Launcher::Job *>::const_iterator it_job = cpp_jobs.find(job_id);
506   if (it_job == cpp_jobs.end())
507   {
508     INFOS("Cannot find the job, is it created ? job number: " << job_id);
509     THROW_SALOME_CORBA_EXCEPTION("Job does not exist", SALOME::INTERNAL_ERROR);
510   }
511
512   Launcher::Job * job = it_job->second;
513   Engines::JobParameters_var job_parameters = new Engines::JobParameters;
514   job_parameters->job_name         = CORBA::string_dup(job->getJobName().c_str());
515   job_parameters->job_type         = CORBA::string_dup(job->getJobType().c_str());
516   job_parameters->job_file         = CORBA::string_dup(job->getJobFile().c_str());
517   job_parameters->env_file         = CORBA::string_dup(job->getEnvFile().c_str());
518   job_parameters->work_directory   = CORBA::string_dup(job->getWorkDirectory().c_str());
519   job_parameters->local_directory  = CORBA::string_dup(job->getLocalDirectory().c_str());
520   job_parameters->result_directory = CORBA::string_dup(job->getResultDirectory().c_str());
521
522   // Parameters for COORM
523   job_parameters->launcher_file = CORBA::string_dup(job->getLauncherFile().c_str());
524   job_parameters->launcher_args = CORBA::string_dup(job->getLauncherArgs().c_str());
525
526   int i = 0;
527   int j = 0;
528   std::list<std::string> in_files  = job->get_in_files();
529   std::list<std::string> out_files = job->get_out_files();
530   job_parameters->in_files.length(in_files.size());
531   for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
532   {
533     job_parameters->in_files[i] = CORBA::string_dup((*it).c_str());
534     i++;
535   }
536   job_parameters->out_files.length(out_files.size());
537   for(std::list<std::string>::iterator it = out_files.begin(); it != out_files.end(); it++)
538   {
539     job_parameters->out_files[j] = CORBA::string_dup((*it).c_str());
540     j++;
541   }
542
543   job_parameters->maximum_duration = CORBA::string_dup(job->getMaximumDuration().c_str());
544   job_parameters->queue            = CORBA::string_dup(job->getQueue().c_str());
545   job_parameters->exclusive        = job->getExclusive();
546   job_parameters->mem_per_cpu      = job->getMemPerCpu();
547   job_parameters->wckey            = CORBA::string_dup(job->getWCKey().c_str());
548   job_parameters->extra_params     = CORBA::string_dup(job->getExtraParams().c_str());
549
550   resourceParams resource_params = job->getResourceRequiredParams();
551   job_parameters->resource_required.name             = CORBA::string_dup(resource_params.name.c_str());
552   job_parameters->resource_required.hostname         = CORBA::string_dup(resource_params.hostname.c_str());
553   job_parameters->resource_required.OS               = CORBA::string_dup(resource_params.OS.c_str());
554   job_parameters->resource_required.nb_proc          = resource_params.nb_proc;
555   job_parameters->resource_required.nb_node          = resource_params.nb_node;
556   job_parameters->resource_required.nb_proc_per_node = resource_params.nb_proc_per_node;
557   job_parameters->resource_required.cpu_clock        = resource_params.cpu_clock;
558   job_parameters->resource_required.mem_mb           = resource_params.mem_mb;
559
560   std::map<std::string, std::string> specific_parameters = job->getSpecificParameters();
561   if (!specific_parameters.empty())
562   {
563     job_parameters->specific_parameters.length(specific_parameters.size());
564     std::map<std::string, std::string>::const_iterator it_specific;
565     CORBA::ULong i = 0;
566     for (it_specific = specific_parameters.begin() ; it_specific != specific_parameters.end(); it_specific++)
567     {
568       Engines::Parameter_var new_param = new Engines::Parameter;
569       new_param->name  = CORBA::string_dup((it_specific->first).c_str());
570       new_param->value = CORBA::string_dup((it_specific->second).c_str());
571       job_parameters->specific_parameters[i] = new_param;
572       i++;
573     }
574   }
575
576   return job_parameters._retn();
577 }
578
579 //=============================================================================
580 /*! CORBA Method:
581  *  Loads jobs saved in jobs_file
582  */
583 //=============================================================================
584 void
585 SALOME_Launcher::loadJobs(const char* jobs_file)
586 {
587   list<int> new_jobs_id_list;
588   try
589   {
590     // Load the jobs in Launcher
591     new_jobs_id_list = _l.loadJobs(jobs_file);
592   }
593   catch (const LauncherException & ex)
594   {
595     INFOS(ex.msg.c_str());
596     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(), SALOME::INTERNAL_ERROR);
597   }
598
599   // Notify observers of the new jobs
600   list<int>::const_iterator it_jobs_id;
601   for (it_jobs_id = new_jobs_id_list.begin(); it_jobs_id != new_jobs_id_list.end(); it_jobs_id++)
602   {
603     ostringstream job_id_sstr;
604     job_id_sstr << *it_jobs_id;
605     notifyObservers("NEW_JOB", job_id_sstr.str());
606   }
607   notifyObservers("LOAD_JOBS", jobs_file);
608 }
609
610 //=============================================================================
611 /*! CORBA Method:
612  *  Save jobs of Launcher (in any steps) in file jobs_file
613  */
614 //=============================================================================
615 void
616 SALOME_Launcher::saveJobs(const char* jobs_file)
617 {
618   _l.saveJobs(jobs_file);
619   notifyObservers("SAVE_JOBS", jobs_file);
620 }
621
622 //=============================================================================
623 /*! CORBA Method:
624  *  Add a new observer to the launcher
625  */
626 //=============================================================================
627 void
628 SALOME_Launcher::addObserver(Engines::SalomeLauncherObserver_ptr observer)
629 {
630   bool new_observer = true;
631   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
632   while(iter != _observers.end())
633   {
634     if (std::string(_orb->object_to_string(*iter)) ==
635         std::string(_orb->object_to_string(observer)))
636     {
637       new_observer = false;
638       break;
639     }
640     iter++;
641   }
642   if (new_observer)
643     _observers.push_back(Engines::SalomeLauncherObserver::_duplicate(observer));
644
645   // We notify the new observer with all jobs that are currently in the Launcher
646   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
647   std::map<int, Launcher::Job *>::const_iterator it_job;
648   for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++)
649   {
650     int number = it_job->first;
651     std::ostringstream job_id;
652     job_id << number;
653     try
654     {
655       observer->notify("NEW_JOB", job_id.str().c_str());
656     }
657     catch (...) 
658     {
659        MESSAGE("Notify Observer, exception catch");
660     }
661
662   }
663 }
664
665 //=============================================================================
666 /*! CORBA Method:
667  *  Add a new observer to the launcher
668  */
669 //=============================================================================
670 void
671 SALOME_Launcher::removeObserver(Engines::SalomeLauncherObserver_ptr observer)
672 {
673   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
674   while(iter != _observers.end())
675   {
676     if (std::string(_orb->object_to_string(*iter)) ==
677         std::string(_orb->object_to_string(observer)))
678     {
679       // Observer found
680       iter =_observers.erase(iter++);
681     }
682     else
683     {
684       iter++;
685     }
686   }
687 }
688
689 //=============================================================================
690 /*! Internal Method:
691  *  Notify observers on a new event
692  */
693 //=============================================================================
694 void
695 SALOME_Launcher::notifyObservers(const std::string & event_name,
696                                  const std::string & event_data)
697 {
698   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
699   while(iter != _observers.end())
700   {
701     try
702     {
703       (*iter)->notify(CORBA::string_dup(event_name.c_str()),
704                       CORBA::string_dup(event_data.c_str()));
705     }
706     catch (...) 
707     {
708        MESSAGE("Notify Observer, exception catch");
709     }
710     iter++;
711   }
712
713 }