]> SALOME platform Git repositories - modules/kernel.git/blob - src/Container/SALOME_Container_i.hxx
Salome HOME
CCAR: add some lacking declarations
[modules/kernel.git] / src / Container / SALOME_Container_i.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 Container : implementation of container and engine for Kernel
23 //  File   : SALOME_Container_i.hxx
24 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
25 //  Module : SALOME
26 //  $Header$
27 //
28 #ifndef _SALOME_CONTAINER_I_HXX_
29 #define _SALOME_CONTAINER_I_HXX_
30
31 #include "SALOME_Container.hxx"
32
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(SALOME_Component)
35 #include CORBA_SERVER_HEADER(SALOME_PyNode)
36
37 #include <iostream>
38 #include <signal.h>
39 #include <stdlib.h>
40 #ifndef WIN32
41 #include <unistd.h>
42 #endif
43 #include <sys/types.h>
44 #include <omnithread.h>
45 #include <map>
46 #include <string>
47
48 class SALOME_NamingService;
49
50 class CONTAINER_EXPORT Engines_Container_i:
51   public virtual POA_Engines::Container,
52   public virtual PortableServer::ServantBase
53 {
54 public:
55   Engines_Container_i();
56   Engines_Container_i(CORBA::ORB_ptr orb, 
57                       PortableServer::POA_ptr poa,
58                       char * containerName ,
59                       int argc, char* argv[],
60                       bool activAndRegist = true,
61                       bool isServantAloneInProcess = true);
62   virtual ~Engines_Container_i();
63
64   // --- CORBA methods
65
66   virtual bool load_component_Library(const char* componentName);
67
68   virtual Engines::Component_ptr
69   create_component_instance( const char* componentName,
70                              CORBA::Long studyId); // 0 for multiStudy
71
72   virtual Engines::Component_ptr
73   create_component_instance_env( const char* componentName,
74                              CORBA::Long studyId,          // 0 for multiStudy
75                              const Engines::FieldsDict& env); 
76   Engines::Component_ptr
77   find_component_instance( const char* registeredName,
78                            CORBA::Long studyId); // 0 for multiStudy
79
80   Engines::Component_ptr
81   load_impl(const char* nameToRegister,
82             const char* componentName);
83
84
85   void remove_impl(Engines::Component_ptr component_i);
86   void finalize_removal();
87
88   virtual void ping();
89   char* name();
90   char* workingdir();
91   char* logfilename();
92   void logfilename(const char* name);
93
94   virtual void Shutdown();
95   char* getHostName();
96   CORBA::Long getPID();
97   //! Kill current container
98   bool Kill_impl();
99
100   Engines::fileRef_ptr createFileRef(const char* origFileName);
101   Engines::fileTransfer_ptr getFileTransfer();
102
103   virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
104   void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
105   Engines::PyNode_ptr createPyNode(const char* nodeName, const char* code);
106   // --- local C++ methods
107
108   Engines::Component_ptr
109   find_or_create_instance( std::string genericRegisterName,
110                            std::string componentLibraryName);
111
112   Engines::Component_ptr
113   createInstance(std::string genericRegisterName,
114                  void *handle,
115                  int studyId);
116
117   static bool isPythonContainer(const char* ContainerName);
118   static void decInstanceCnt(std::string genericRegisterName);
119   //??? char* machineName();
120
121   // --- needed for parallel components, Numerical Platon
122
123   int getArgc() { return _argc; }
124   char **getArgv() { return _argv; }
125
126 protected:
127
128   static std::map<std::string, int> _cntInstances_map;
129   static std::map<std::string, void *> _library_map; // library names, loaded
130   static std::map<std::string, void *> _toRemove_map;// library names to remove
131   static omni_mutex _numInstanceMutex ; // lib and instance protection
132
133   bool _isSupervContainer;
134
135   SALOME_NamingService *_NS ;
136   std::string _library_path;
137   std::string _containerName;
138   std::string _logfilename;
139   CORBA::ORB_var _orb;
140   PortableServer::POA_var _poa;
141   PortableServer::ObjectId * _id ;
142   int _numInstance ;
143   std::map<std::string,Engines::Component_var> _listInstances_map;
144   std::map<std::string,Engines::fileRef_var> _fileRef_map;
145   std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
146   Engines::fileTransfer_var _fileTransfer;
147
148   int    _argc ;
149   char** _argv ;
150   long   _pid;
151   bool   _isServantAloneInProcess;
152 };
153
154 #endif
155