Salome HOME
Test EXPORTS definition with target name as suggested by cmake
[modules/kernel.git] / src / ParallelContainer / SALOME_ParallelContainer_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_ParallelContainer : implementation of container and engine for Parallel Kernel
23 //  File   : SALOME_ParallelContainer_i.hxx
24 //  Author : AndrĂ© RIBES, EDF
25 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
26 //
27 #ifndef _SALOME_PARALLEL_CONTAINER_I_HXX_
28 #define _SALOME_PARALLEL_CONTAINER_I_HXX_
29
30 #include <SALOMEconfig.h>
31
32 #include "SALOME_ComponentPaCO_Engines_Container_server.h"
33
34 #include <iostream>
35 #include <signal.h>
36 #include <stdlib.h>
37 #ifndef WIN32
38 #include <unistd.h>
39 #endif
40 #include <sys/types.h>
41 #include <omnithread.h>
42 #include <map>
43 #include <string>
44
45 class SALOME_NamingService;
46
47 #ifdef WIN32
48 # if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS
49 #  define CONTAINER_EXPORT __declspec( dllexport )
50 # else
51 #  define CONTAINER_EXPORT __declspec( dllimport )
52 # endif
53 #else
54 # define CONTAINER_EXPORT
55 #endif
56
57 class CONTAINER_EXPORT Engines_Parallel_Container_i:
58   /*  public virtual POA_Engines::Container, */
59   public Engines::Container_serv,
60   public virtual PortableServer::RefCountServantBase
61 {
62 public:
63   Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank);
64   Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank,
65                       PortableServer::POA_ptr poa,
66                       char * containerName ,
67                       int argc, char* argv[],
68                       bool activAndRegist = true,
69                       bool isServantAloneInProcess = true);
70   virtual ~Engines_Parallel_Container_i();
71
72   // --- CORBA methods
73
74   virtual bool load_component_Library(const char* componentName);
75
76   virtual Engines::Component_ptr
77   create_component_instance( const char* componentName,
78                              CORBA::Long studyId); // 0 for multiStudy
79
80   Engines::Component_ptr
81   find_component_instance( const char* registeredName,
82                            CORBA::Long studyId); // 0 for multiStudy
83
84   Engines::Component_ptr
85   load_impl(const char* nameToRegister,
86             const char* componentName);
87
88
89   void remove_impl(Engines::Component_ptr component_i);
90   void finalize_removal();
91
92   virtual void ping();
93   char* name();
94   char* workingdir();
95   char* logfilename();
96   void logfilename(const char* name);
97
98   virtual void Shutdown();
99   char* getHostName();
100   CORBA::Long getPID();
101   //! Kill current container
102   bool Kill_impl() ;
103
104   // --- local C++ methods
105
106   Engines::Component_ptr
107   find_or_create_instance( std::string genericRegisterName,
108                            std::string componentLibraryName);
109
110   Engines::Component_ptr
111   createInstance(std::string genericRegisterName,
112                  void *handle,
113                  int studyId);
114
115   Engines::Component_ptr
116   createParallelInstance(std::string genericRegisterName,
117                          void *handle,
118                          int studyId);
119
120   static bool isPythonContainer(const char* ContainerName);
121   static void decInstanceCnt(std::string genericRegisterName);
122
123   // --- needed for parallel components, Numerical Platon
124
125   int getArgc() { return _argc; }
126   char **getArgv() { return _argv; }
127
128   void set_id(PortableServer::ObjectId * id) { _id = id;}
129
130   Engines::fileRef_ptr createFileRef(const char* origFileName);
131   Engines::fileTransfer_ptr getFileTransfer();
132
133   virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
134 protected:
135
136   static std::map<std::string, int> _cntInstances_map;
137   static std::map<std::string, void *> _library_map; // library names, loaded
138   static std::map<std::string, void *> _toRemove_map;// library names to remove
139   static omni_mutex _numInstanceMutex ; // lib and instance protection
140
141   bool _isSupervContainer;
142
143   SALOME_NamingService *_NS ;
144   std::string _library_path;
145   std::string _containerName;
146   std::string _logfilename;
147   CORBA::ORB_var _orb;
148   PortableServer::POA_var _poa;
149   PortableServer::ObjectId * _id ;
150   int _numInstance ;
151   std::map<std::string,Engines::Component_var> _listInstances_map;
152   std::map<std::string,Engines::fileRef_var> _fileRef_map;
153   std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
154   Engines::fileTransfer_var _fileTransfer;
155
156   int    _argc ;
157   char** _argv ;
158   long   _pid;
159   bool   _isServantAloneInProcess;
160 };
161
162 #endif
163