Salome HOME
5cf394ce0135ed11165f0a840ea08e7fa05c0d61
[modules/kernel.git] / src / LifeCycleCORBA / SALOME_LifeCycleCORBA.hxx
1 //  Copyright (C) 2007-2010  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.
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 //  SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++
23 //  File   : SALOME_LifeCycleCORBA.hxx
24 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
25 //  Module : SALOME
26
27 #ifndef _SALOME_LIFECYCLECORBA_HXX_
28 #define _SALOME_LIFECYCLECORBA_HXX_
29
30 #include <stdlib.h>
31 #ifndef WIN32
32 #include <unistd.h>
33 #endif
34 #include <string>
35
36 #include <SALOMEconfig.h>
37 #include <Utils_SALOME_Exception.hxx>
38 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
39 #include CORBA_CLIENT_HEADER(SALOME_Component)
40 #include <iostream>
41
42 #ifdef WIN32
43 # if defined LIFECYCLECORBA_EXPORTS || defined SalomeLifeCycleCORBA_EXPORTS
44 #  define LIFECYCLECORBA_EXPORT __declspec( dllexport )
45 # else
46 #  define LIFECYCLECORBA_EXPORT __declspec( dllimport )
47 # endif
48 #else
49 # define LIFECYCLECORBA_EXPORT
50 #endif
51
52
53 class SALOME_NamingService;
54
55 class LIFECYCLECORBA_EXPORT IncompatibleComponent : public SALOME_Exception
56 {
57 public :
58   IncompatibleComponent(void);
59   IncompatibleComponent(const IncompatibleComponent &ex);
60 };
61
62 class LIFECYCLECORBA_EXPORT SALOME_LifeCycleCORBA
63 {
64 public:
65   SALOME_LifeCycleCORBA(SALOME_NamingService *ns = 0);
66   virtual ~SALOME_LifeCycleCORBA();
67
68   Engines::EngineComponent_ptr 
69   FindComponent(const Engines::MachineParameters& params,
70                 const char *componentName,
71                 int studyId=0);
72
73   Engines::EngineComponent_ptr
74   LoadComponent(const Engines::MachineParameters& params,
75                 const char *componentName,
76                 int studyId=0);
77
78   Engines::EngineComponent_ptr 
79   FindOrLoad_Component(const Engines::MachineParameters& params,
80                        const char *componentName,
81                        int studyId =0);
82
83   // SALOME 6 - Interface
84   Engines::EngineComponent_ptr 
85   FindOrLoad_Component(const Engines::ContainerParameters& params,
86                        const char *componentName,
87                        int studyId =0);
88
89   Engines::EngineComponent_ptr
90   FindOrLoad_Component(const char *containerName,
91                        const char *componentName); // for compatibility
92   
93   // Parallel extension
94   Engines::EngineComponent_ptr 
95     Load_ParallelComponent(const Engines::ContainerParameters& params,
96                            const char *componentName,
97                            int studyId);
98
99   bool isKnownComponentClass(const char *componentName);
100
101   bool isMpiContainer(const Engines::ContainerParameters& params)
102     throw(IncompatibleComponent);
103
104   int NbProc(const Engines::ContainerParameters& params);
105
106   static void preSet(Engines::MachineParameters& outparams);
107   static void preSet(Engines::ResourceParameters& outparams);
108   static void preSet(Engines::ContainerParameters& outparams);
109
110   Engines::ContainerManager_ptr getContainerManager();
111   Engines::ResourcesManager_ptr getResourcesManager();
112   SALOME_NamingService * namingService();
113   CORBA::ORB_ptr orb();
114   void copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest);
115
116   void shutdownServers();
117   static void killOmniNames();
118
119   // For SALOME 5.1.x
120   // Will be deleted on SALOME 6
121   void convert(const Engines::MachineParameters& params_in, 
122                Engines::ContainerParameters& params_out);
123 protected:
124
125   /*! Establish if a component called "componentName" in a container called
126    *  "containerName"
127    *  exists among the list of resources in "listOfMachines".
128    *  This method uses Naming Service to find the component.
129    */
130   Engines::EngineComponent_ptr 
131   _FindComponent(const Engines::ContainerParameters& params,
132                  const char *componentName,
133                  int studyId,
134                  const Engines::ResourceList& listOfResources);
135
136   Engines::EngineComponent_ptr
137   _LoadComponent(const Engines::ContainerParameters& params,
138                  const char *componentName,
139                  int studyId);
140
141   SALOME_NamingService *_NS;
142   SALOME_NamingService *_NSnew;
143   Engines::ContainerManager_var _ContManager;
144   Engines::ResourcesManager_var _ResManager;
145   
146 } ;
147
148 #endif