Salome HOME
BugID: IPAL9392, modified methods GetRowUnits.
[modules/kernel.git] / src / Container / SALOME_Container_i.hxx
1 //  SALOME Container : implementation of container and engine for Kernel
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_Container_i.hxx
25 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef _SALOME_CONTAINER_I_HXX_
30 #define _SALOME_CONTAINER_I_HXX_
31
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(SALOME_Component)
34
35 #include <iostream>
36 #include <signal.h>
37 #include <stdlib.h>
38 #ifndef WNT
39 #include <unistd.h>
40 #endif
41 #include <sys/types.h>
42 #include <omnithread.h>
43 #include <map>
44 #include <string>
45
46 class SALOME_NamingService;
47
48
49 #if defined CONTAINER_EXPORTS
50 #if defined WIN32
51 #define CONTAINER_EXPORT __declspec( dllexport )
52 #else
53 #define CONTAINER_EXPORT
54 #endif
55 #else
56 #if defined WNT
57 #define CONTAINER_EXPORT __declspec( dllimport )
58 #else
59 #define CONTAINER_EXPORT
60 #endif
61 #endif
62
63 class CONTAINER_EXPORT Engines_Container_i: public virtual POA_Engines::Container,
64                            public virtual PortableServer::RefCountServantBase
65 {
66 public:
67   Engines_Container_i();
68   Engines_Container_i(CORBA::ORB_ptr orb, 
69                       PortableServer::POA_ptr poa,
70                       char * containerName ,
71                       int argc, char* argv[],
72                       bool activAndRegist = true,
73                       bool isServantAloneInProcess = true);
74   virtual ~Engines_Container_i();
75
76   // --- CORBA methods
77
78   bool load_component_Library(const char* componentName);
79
80   Engines::Component_ptr
81   create_component_instance( const char* componentName,
82                              CORBA::Long studyId); // 0 for multiStudy
83
84   Engines::Component_ptr
85   find_component_instance( const char* registeredName,
86                            CORBA::Long studyId); // 0 for multiStudy
87
88   Engines::Component_ptr
89   load_impl(const char* nameToRegister,
90             const char* componentName);
91
92
93   void remove_impl(Engines::Component_ptr component_i);
94   void finalize_removal();
95   void Shutdown();
96
97   char* getHostName();
98   CORBA::Long getPID();
99   char* name();
100   void ping();
101
102   bool Kill_impl() ;
103
104   //char* machineName();
105   //Engines::Component_ptr instance(const char* nameToRegister,
106   //                               const char* componentName);
107
108   // --- local C++ methods
109
110   Engines::Component_ptr
111   find_or_create_instance( std::string genericRegisterName,
112                            std::string componentLibraryName);
113
114   Engines::Component_ptr
115   createInstance(std::string genericRegisterName,
116                  void *handle,
117                  int studyId);
118
119   static bool isPythonContainer(const char* ContainerName);
120   static std::string BuildContainerNameForNS(const char *ContainerName,
121                                              const char *hostname);
122   static void decInstanceCnt(std::string genericRegisterName);
123
124 protected:
125
126   static const char *_defaultContainerName;
127   static std::map<std::string, int> _cntInstances_map;
128   static std::map<std::string, void *> _library_map; // library names, loaded
129   static std::map<std::string, void *> _toRemove_map;// library names to remove
130   static omni_mutex _numInstanceMutex ; // lib and instance protection
131
132   bool _isSupervContainer;
133
134   SALOME_NamingService *_NS ;
135   std::string _library_path;
136   std::string _containerName;
137   CORBA::ORB_var _orb;
138   PortableServer::POA_var _poa;
139   PortableServer::ObjectId * _id ;
140   int _numInstance ;
141   std::map<std::string,Engines::Component_var> _listInstances_map;
142
143   //private: 
144
145   int    _argc ;
146   char** _argv ;
147   long   _pid;
148   bool   _isServantAloneInProcess;
149 };
150
151 #endif
152