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