Salome HOME
PR: embedded container C++ & Python, debug
[modules/kernel.git] / src / Container / SALOME_Container_i.hxx
index 61ce9d308a3793133cb0ad17f48977cf7e6faea7..a3840cfb615f83c6280ae1b89f432c02260f998d 100644 (file)
 #ifndef _SALOME_CONTAINER_I_HXX_
 #define _SALOME_CONTAINER_I_HXX_
 
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
 #include <iostream>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOME_Component)
 #include <omnithread.h>
 #include <map>
 #include <string>
 
 class SALOME_NamingService;
 
-class Engines_Container_i: public POA_Engines::Container,
-                public PortableServer::RefCountServantBase
+class Engines_Container_i: public virtual POA_Engines::Container,
+                          public virtual PortableServer::RefCountServantBase
 {
 public:
   Engines_Container_i();
   Engines_Container_i(CORBA::ORB_ptr orb, 
                      PortableServer::POA_ptr poa,
                      char * containerName ,
-                      int argc, char* argv[]);
-// Constructeur pour composant parallele : ne pas faire appel au naming service
-  Engines_Container_i(CORBA::ORB_ptr orb, 
-                     PortableServer::POA_ptr poa,
-                     char * containerName,
-                     int flag);
+                      int argc, char* argv[],
+                     bool activAndRegist = true,
+                     bool isServantAloneInProcess = true);
   virtual ~Engines_Container_i();
 
+  // --- CORBA methods
+
+  bool load_component_Library(const char* componentName);
+
+  Engines::Component_ptr
+  create_component_instance( const char* componentName,
+                            CORBA::Long studyId); // 0 for multiStudy
+
+  Engines::Component_ptr
+  find_component_instance( const char* registeredName,
+                          CORBA::Long studyId); // 0 for multiStudy
+
+  Engines::Component_ptr
+  load_impl(const char* nameToRegister,
+           const char* componentName);
 
-  Engines::Container_ptr start_impl(const char* ContainerName);
 
-  Engines::Component_ptr load_impl(const char* nameToRegister,
-                                  const char* componentName);
   void remove_impl(Engines::Component_ptr component_i);
   void finalize_removal();
+  void Shutdown();
 
+  char* getHostName();
+  CORBA::Long getPID();
   char* name();
-  char* machineName();
   void ping();
+
   bool Kill_impl() ;
-  char* getHostName();
-  long getPID();
+
+  //char* machineName();
+  //Engines::Component_ptr instance(const char* nameToRegister,
+  //                              const char* componentName);
+
+  // --- local C++ methods
+
+  Engines::Component_ptr
+  find_or_create_instance( std::string genericRegisterName,
+                          std::string componentLibraryName);
+
+  Engines::Component_ptr
+  createInstance(std::string genericRegisterName,
+                void *handle,
+                int studyId);
+
+  static bool isPythonContainer(const char* ContainerName);
+  static std::string BuildContainerNameForNS(const char *ContainerName,
+                                            const char *hostname);
+  static void decInstanceCnt(std::string genericRegisterName);
 
 protected:
 
+  static const char *_defaultContainerName;
+  static std::map<std::string, int> _cntInstances_map;
+  static std::map<std::string, void *> _library_map; // library names, loaded
+  static std::map<std::string, void *> _toRemove_map;// library names to remove
+  static omni_mutex _numInstanceMutex ; // lib and instance protection
+
   SALOME_NamingService *_NS ;
-  string _library_path;
-  string _containerName;
+  std::string _library_path;
+  std::string _containerName;
   CORBA::ORB_var _orb;
   PortableServer::POA_var _poa;
   PortableServer::ObjectId * _id ;
   int _numInstance ;
-  map<string, void *> handle_map ;
-  map<string, void *> remove_map ;
-  omni_mutex _numInstanceMutex ; // if several threads on the same object
+  std::map<std::string,Engines::Component_var> _listInstances_map;
 
-private: 
+  //private: 
 
-  int   _argc ;
+  int    _argc ;
   char** _argv ;
-  long _pid;
-
+  long   _pid;
+  bool   _isServantAloneInProcess;
 };
 
 #endif