]> SALOME platform Git repositories - modules/kernel.git/blob - src/Container/SALOME_Container_i.hxx
Salome HOME
PR: merge from branch BR_auto_V310 tag mergefrom_OCC_development_for_3_2_0a2_10mar06
[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:
64   public virtual POA_Engines::Container,
65   public virtual PortableServer::RefCountServantBase
66 {
67 public:
68   Engines_Container_i();
69   Engines_Container_i(CORBA::ORB_ptr orb, 
70                       PortableServer::POA_var poa,
71                       char * containerName ,
72                       int argc, char* argv[],
73                       bool activAndRegist = true,
74                       bool isServantAloneInProcess = true);
75   virtual ~Engines_Container_i();
76
77   // --- CORBA methods
78
79   virtual bool load_component_Library(const char* componentName);
80
81   virtual Engines::Component_ptr
82   create_component_instance( const char* componentName,
83                              CORBA::Long studyId); // 0 for multiStudy
84
85   Engines::Component_ptr
86   find_component_instance( const char* registeredName,
87                            CORBA::Long studyId); // 0 for multiStudy
88
89   Engines::Component_ptr
90   load_impl(const char* nameToRegister,
91             const char* componentName);
92
93
94   void remove_impl(Engines::Component_ptr component_i);
95   void finalize_removal();
96
97   virtual void ping();
98   char* name();
99   virtual void Shutdown();
100   char* getHostName();
101   CORBA::Long getPID();
102   //! Kill current container
103   bool Kill_impl() ;
104
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 void decInstanceCnt(std::string genericRegisterName);
121   //??? char* machineName();
122
123   // --- needed for parallel components, Numerical Platon
124
125   int getArgc() { return _argc; }
126   char **getArgv() { return _argv; }
127
128 protected:
129
130   static std::map<std::string, int> _cntInstances_map;
131   static std::map<std::string, void *> _library_map; // library names, loaded
132   static std::map<std::string, void *> _toRemove_map;// library names to remove
133   static omni_mutex _numInstanceMutex ; // lib and instance protection
134
135   bool _isSupervContainer;
136
137   SALOME_NamingService *_NS ;
138   std::string _library_path;
139   std::string _containerName;
140   CORBA::ORB_var _orb;
141   PortableServer::POA_var _poa;
142   PortableServer::ObjectId * _id ;
143   int _numInstance ;
144   std::map<std::string,Engines::Component_var> _listInstances_map;
145
146   int    _argc ;
147   char** _argv ;
148   long   _pid;
149   bool   _isServantAloneInProcess;
150 };
151
152 #endif
153