Version: 6.5.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
SALOME_Container_i.hxx
1 // Copyright (C) 2007-2012 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 
23 // SALOME Container : implementation of container and engine for Kernel
24 // File : SALOME_Container_i.hxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
26 // Module : SALOME
27 // $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Container/SALOME_Container_i.hxx,v 1.17.2.3.14.5.2.1 2012-04-12 14:05:03 vsr Exp $
28 //
29 #ifndef _SALOME_CONTAINER_I_HXX_
30 #define _SALOME_CONTAINER_I_HXX_
31 
32 #include "SALOME_Container.hxx"
33 
34 #include <SALOMEconfig.h>
35 #include CORBA_SERVER_HEADER(SALOME_Component)
36 #include CORBA_SERVER_HEADER(SALOME_PyNode)
37 
38 #include <iostream>
39 #include <signal.h>
40 #include <stdlib.h>
41 #ifndef WIN32
42 #include <unistd.h>
43 #endif
44 #include <sys/types.h>
45 #include <omnithread.h>
46 #include <map>
47 #include <list>
48 #include <string>
49 
51 
52 class CONTAINER_EXPORT Engines_Container_i:
53  public virtual POA_Engines::Container,
54  public virtual PortableServer::ServantBase
55 {
56 public:
58  Engines_Container_i(CORBA::ORB_ptr orb,
59  PortableServer::POA_ptr poa,
60  char * containerName ,
61  int argc, char* argv[],
62  bool activAndRegist = true,
63  bool isServantAloneInProcess = true);
64  virtual ~Engines_Container_i();
65 
66  // --- CORBA methods
67 
68  virtual bool load_component_Library(const char* componentName, CORBA::String_out reason);
69 
70  virtual Engines::EngineComponent_ptr
71  create_component_instance( const char* componentName,
72  CORBA::Long studyId); // 0 for multiStudy
73 
74  virtual Engines::EngineComponent_ptr
75  create_component_instance_env( const char* componentName,
76  CORBA::Long studyId, // 0 for multiStudy
77  const Engines::FieldsDict& env,
78  CORBA::String_out reason);
79  Engines::EngineComponent_ptr
80  find_component_instance( const char* registeredName,
81  CORBA::Long studyId); // 0 for multiStudy
82 
83  Engines::EngineComponent_ptr
84  load_impl(const char* nameToRegister,
85  const char* componentName);
86 
87 
88  void remove_impl(Engines::EngineComponent_ptr component_i);
89  void finalize_removal();
90 
91  virtual void ping();
92  char* name();
93  char* workingdir();
94  char* logfilename();
95  void logfilename(const char* name);
96 
97  virtual void Shutdown();
98  char* getHostName();
99  CORBA::Long getPID();
101  bool Kill_impl();
102 
103  Engines::fileRef_ptr createFileRef(const char* origFileName);
104  Engines::fileTransfer_ptr getFileTransfer();
105 
106  virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
107  void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
108  Engines::PyNode_ptr createPyNode(const char* nodeName, const char* code);
109  Engines::PyScriptNode_ptr createPyScriptNode(const char* nodeName, const char* code);
110  // --- local C++ methods
111 
112  Engines::EngineComponent_ptr
113  find_or_create_instance( std::string genericRegisterName,
114  std::string componentLibraryName);
115 
116  bool load_component_CppImplementation(const char* componentName,std::string& reason);
117  bool load_component_PythonImplementation(const char* componentName,std::string& reason);
118  bool load_component_ExecutableImplementation(const char* componentName,std::string& reason);
119 
120  Engines::EngineComponent_ptr createPythonInstance(std::string CompName, int studyId, std::string& error);
121  Engines::EngineComponent_ptr createExecutableInstance(std::string CompName, int studyId, const Engines::FieldsDict& env, std::string& error);
122  Engines::EngineComponent_ptr createInstance(std::string genericRegisterName, void *handle, int studyId, std::string& error);
123 
124  static bool isPythonContainer(const char* ContainerName);
125  static void decInstanceCnt(std::string genericRegisterName);
126  //??? char* machineName();
127 
128  // --- needed for parallel components, Numerical Platon
129 
130  int getArgc() { return _argc; }
131  char **getArgv() { return _argv; }
132 
133  void registerTemporaryFile( const std::string& fileName );
134  void unregisterTemporaryFile( const std::string& fileName );
135  void clearTemporaryFiles();
136 
137 protected:
138 
139  static std::map<std::string, int> _cntInstances_map;
140  static std::map<std::string, void *> _library_map; // library names, loaded
141  static std::map<std::string, void *> _toRemove_map;// library names to remove
142  static omni_mutex _numInstanceMutex ; // lib and instance protection
143 
144  bool _isSupervContainer;
145 
146  SALOME_NamingService *_NS ;
147  std::string _library_path;
148  std::string _containerName;
149  std::string _logfilename;
150  CORBA::ORB_var _orb;
151  PortableServer::POA_var _poa;
152  PortableServer::ObjectId * _id ;
153  int _numInstance ;
154  std::map<std::string,Engines::EngineComponent_var> _listInstances_map;
155  std::map<std::string,Engines::fileRef_var> _fileRef_map;
156  std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
157  std::list<std::string> _tmp_files;
158  Engines::fileTransfer_var _fileTransfer;
159 
160  int _argc ;
161  char** _argv ;
162  long _pid;
163  bool _isServantAloneInProcess;
164 };
165 
166 #endif
A class to manage the SALOME naming service.
Definition: SALOME_NamingService.hxx:48
C++ implementation of Engines::Container interface.
Definition: SALOME_Container_i.hxx:52
Copyright © 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS