1 // Copyright (C) 2009-2012 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.
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 #ifndef _BL_JOBSMANAGER_HXX_
21 #define _BL_JOBSMANAGER_HXX_
23 #include "BL_Engine.hxx"
25 #include "BL_SALOMEServices.hxx"
26 #include "BL_Traces.hxx"
27 #include "BL_Observer.hxx"
32 #include <omnithread.h>
38 class BL_Engine_EXPORT JobsManager
41 JobsManager(BL::SALOMEServices * salome_services);
42 virtual ~JobsManager();
45 void setObserver(BL::Observer * observer);
48 BL::Job * createJob(const std::string & name);
49 BL::Job * getJob(const std::string & name);
50 std::map<std::string, BL::Job *> & getJobs();
51 bool job_already_exist(const std::string & name);
54 void addJobToLauncher(const std::string & name);
55 void removeJob(const std::string & name);
57 virtual void start_job(const std::string & name);
58 static void starting_job_thread(void * object_ptr);
60 virtual void stop_job(const std::string & name);
61 static void stop_job_thread(void * object_ptr);
63 virtual void get_results_job(const std::string & name);
64 static void get_results_job_thread(void * object_ptr);
66 virtual void refresh_jobs();
67 static void refresh_jobs_thread(void * object_ptr);
69 virtual void load_jobs(const std::string & xml_file);
70 virtual void save_jobs(const std::string & xml_file);
71 static void load_jobs_thread(void * object_ptr);
72 static void save_jobs_thread(void * object_ptr);
74 // event from launcher
75 void launcher_event_save_jobs(const std::string & data);
76 void launcher_event_load_jobs(const std::string & data);
77 void launcher_event_new_job(const std::string & data);
78 static void launcher_event_new_job_thread(void * object_ptr);
79 void launcher_event_remove_job(const std::string & data);
80 static void launcher_event_remove_job_thread(void * object_ptr);
81 void launcher_event_update_job_state(const std::string & data);
85 BL::JobsManager * object_ptr;
89 struct thread_info_file
91 BL::JobsManager * object_ptr;
92 std::string file_name;
95 struct thread_info_new_job
97 BL::JobsManager * object_ptr;
102 BL::SALOMEServices * _salome_services;
103 BL::Observer * _observer;
106 typedef std::map<std::string, BL::Job *> _jobs_map;
108 _jobs_map::iterator _jobs_it;
110 // Mutex used for the jobs map
111 omni_mutex _thread_mutex_jobs_map;
113 // To avoid two jobs with the same name