Salome HOME
merge from branch BR_V5_DEV
[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
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   Engines::Component_ptr
85   FindOrLoad_Component(const char *containerName,
86                        const char *componentName); // for compatibility
87   
88   // Parallel extension
89   Engines::Component_ptr 
90     Load_ParallelComponent(const Engines::MachineParameters& params,
91                            const char *componentName,
92                            int studyId);
93
94   bool isKnownComponentClass(const char *componentName);
95
96   bool isMpiContainer(const Engines::MachineParameters& params)
97     throw(IncompatibleComponent);
98
99   int NbProc(const Engines::MachineParameters& params);
100
101   void preSet(Engines::MachineParameters& params);
102
103   Engines::ContainerManager_ptr getContainerManager();
104   Engines::ResourcesManager_ptr getResourcesManager();
105
106   void shutdownServers();
107   static void killOmniNames();
108
109 protected:
110
111   /*! Establish if a component called "componentName" in a container called
112    *  "containerName"
113    *  exists among the list of resources in "listOfMachines".
114    *  This method uses Naming Service to find the component.
115    */
116   Engines::Component_ptr 
117   _FindComponent(const Engines::MachineParameters& params,
118                  const char *componentName,
119                  int studyId,
120                  const Engines::MachineList& listOfMachines);
121
122   Engines::Component_ptr
123   _LoadComponent(const Engines::MachineParameters& params,
124                  const char *componentName,
125                  int studyId,
126                  const Engines::MachineList& listOfMachines);
127   
128   SALOME_NamingService *_NS;
129   Engines::ContainerManager_var _ContManager;
130   Engines::ResourcesManager_var _ResManager;
131   
132 } ;
133
134 #endif