]> SALOME platform Git repositories - modules/kernel.git/blob - src/Container/SALOME_Container_i.hxx
Salome HOME
PR: container lifecycle, new design, try to dlclose, still not safe...
[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 #include <unistd.h>
39 #include <sys/types.h>
40 #include <omnithread.h>
41 #include <map>
42 #include <string>
43
44 class SALOME_NamingService;
45
46 class Engines_Container_i: public virtual POA_Engines::Container,
47                            public virtual PortableServer::RefCountServantBase
48 {
49 public:
50   Engines_Container_i();
51   Engines_Container_i(CORBA::ORB_ptr orb, 
52                       PortableServer::POA_ptr poa,
53                       char * containerName ,
54                       int argc, char* argv[],
55                       bool activAndRegist = true,
56                       bool isServantAloneInProcess = true);
57   virtual ~Engines_Container_i();
58
59   // --- CORBA methods
60
61   bool load_component_Library(const char* componentLibraryName);
62
63   Engines::Component_ptr
64   create_component_instance( const char* nameToRegister,
65                              const char* componentLibraryName,
66                              CORBA::Long studyId); // 0 for multiStudy
67
68   Engines::Component_ptr
69   find_component_instance( const char* registeredName,
70                            CORBA::Long studyId); // 0 for multiStudy
71
72   Engines::Component_ptr
73   load_impl(const char* nameToRegister,
74             const char* componentName);
75
76
77   void remove_impl(Engines::Component_ptr component_i);
78   void finalize_removal();
79   void Shutdown();
80
81   char* getHostName();
82   CORBA::Long getPID();
83   char* name();
84   void ping();
85
86   bool Kill_impl() ;
87
88   //char* machineName();
89   //Engines::Component_ptr instance(const char* nameToRegister,
90   //                               const char* componentName);
91
92   // --- local C++ methods
93
94   Engines::Component_ptr
95   find_or_create_instance( std::string genericRegisterName,
96                            std::string componentLibraryName);
97
98   Engines::Component_ptr
99   createInstance(std::string genericRegisterName,
100                  void *handle,
101                  int studyId);
102
103   static bool isPythonContainer(const char* ContainerName);
104   static std::string BuildContainerNameForNS(const char *ContainerName,
105                                              const char *hostname);
106   static void decInstanceCnt(std::string genericRegisterName);
107
108 protected:
109
110   static const char *_defaultContainerName;
111   static std::map<std::string, int> _cntInstances_map;
112   static std::map<std::string, void *> _library_map; // library names, loaded
113   static std::map<std::string, void *> _toRemove_map;// library names to remove
114   static omni_mutex _numInstanceMutex ; // lib and instance protection
115
116   SALOME_NamingService *_NS ;
117   std::string _library_path;
118   std::string _containerName;
119   CORBA::ORB_var _orb;
120   PortableServer::POA_var _poa;
121   PortableServer::ObjectId * _id ;
122   int _numInstance ;
123   std::map<std::string,Engines::Component_var> _listInstances_map;
124
125   //private: 
126
127   int    _argc ;
128   char** _argv ;
129   long   _pid;
130   bool   _isServantAloneInProcess;
131 };
132
133 #endif
134