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