Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/kernel.git] / src / LifeCycleCORBA / SALOME_LifeCycleCORBA.hxx
1 //  SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
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 WNT
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
43 #if defined LIFECYCLECORBA_EXPORTS
44 #if defined WIN32
45 #define LIFECYCLECORBA_EXPORT __declspec( dllexport )
46 #else
47 #define LIFECYCLECORBA_EXPORT
48 #endif
49 #else
50 #if defined WNT
51 #define LIFECYCLECORBA_EXPORT __declspec( dllimport )
52 #else
53 #define LIFECYCLECORBA_EXPORT
54 #endif
55 #endif
56
57
58 class SALOME_NamingService;
59
60 class LIFECYCLECORBA_EXPORT IncompatibleComponent : public SALOME_Exception
61 {
62 public :
63   IncompatibleComponent(void);
64   IncompatibleComponent(const IncompatibleComponent &ex);
65 };
66
67 class LIFECYCLECORBA_EXPORT SALOME_LifeCycleCORBA
68 {
69 public:
70   SALOME_LifeCycleCORBA(SALOME_NamingService *ns = 0);
71   virtual ~SALOME_LifeCycleCORBA();
72
73   Engines::Component_ptr 
74   FindComponent(const Engines::MachineParameters& params,
75                 const char *componentName,
76                 int studyId=0);
77
78   Engines::Component_ptr
79   LoadComponent(const Engines::MachineParameters& params,
80                 const char *componentName,
81                 int studyId=0);
82
83   Engines::Component_ptr 
84   FindOrLoad_Component(const Engines::MachineParameters& params,
85                        const char *componentName,
86                        int studyId =0);
87
88   Engines::Component_ptr
89   FindOrLoad_Component(const char *containerName,
90                        const char *componentName); // for compatibility
91   
92   bool isKnownComponentClass(const char *componentName);
93
94   bool isMpiContainer(const Engines::MachineParameters& params)
95     throw(IncompatibleComponent);
96
97   int NbProc(const Engines::MachineParameters& params);
98
99   void preSet(Engines::MachineParameters& params);
100
101 protected:
102
103   /*! Establish if a component called "componentName" in a container called
104    *  "containerName"
105    *  exists among the list of resources in "listOfMachines".
106    *  This method uses Naming Service to find the component.
107    */
108   Engines::Component_ptr 
109   _FindComponent(const Engines::MachineParameters& params,
110                  const char *componentName,
111                  int studyId,
112                  const Engines::MachineList& listOfMachines);
113
114   Engines::Component_ptr
115   _LoadComponent(const Engines::MachineParameters& params,
116                  const char *componentName,
117                  int studyId,
118                  const Engines::MachineList& listOfMachines);
119   
120   SALOME_NamingService *_NS;
121   Engines::ContainerManager_var _ContManager;
122   
123 } ;
124
125 #endif