]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
B4 an API modification to generalize launching of kernel containers.
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 31 Jul 2014 14:08:59 +0000 (16:08 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 31 Jul 2014 14:08:59 +0000 (16:08 +0200)
src/engine/Container.hxx
src/engine/HomogeneousPoolContainer.hxx
src/engine/ServiceNode.hxx
src/engine/Test/ContainerTest.hxx
src/runtime/CMakeLists.txt
src/runtime/SalomeContainer.cxx
src/runtime/SalomeContainer.hxx
src/runtime/SalomeContainerTools.cxx
src/runtime/SalomeContainerTools.hxx
src/runtime/SalomeHPContainer.cxx [new file with mode: 0644]
src/runtime/SalomeHPContainer.hxx

index 5e37e4a606d06b4da740fd0ae2cb1bbb55228853..00675f643737a1dffca79b0bf74745bb73651b62 100644 (file)
@@ -54,6 +54,8 @@ namespace YACS
       virtual void attachOnCloning() const;
       virtual void dettachOnCloning() const;
       bool isAttachedOnCloning() const;
+      virtual void lock() = 0;
+      virtual void unLock() = 0;
       //! \b WARNING ! clone behaviour \b MUST be in coherence with what is returned by isAttachedOnCloning() method
       virtual Container *clone() const = 0;
       virtual Container *cloneAlways() const = 0;
index 6bb2bd812e5ce90eecfb0f6008693fd24001d2d0..7ca663a7a7c3255ca6b109d261e8caa4c0cd5ae5 100644 (file)
@@ -37,6 +37,8 @@ namespace YACS
      */
     class YACSLIBENGINE_EXPORT HomogeneousPoolContainer : public Container
     {
+    public:
+      virtual void setSizeOfPool(int sz) = 0;
     protected:
       HomogeneousPoolContainer();
 #ifndef SWIG
index 9db9bb68542055b978dfe8ece71c74c71ab37c14..a079a9288aa47b24f5f19268a6d490a1ca9120c0 100644 (file)
@@ -31,7 +31,7 @@ namespace YACS
   {
     class ComponentInstance;
 
-    class YACSLIBENGINE_EXPORT ServiceNode: public ElementaryNode 
+    class YACSLIBENGINE_EXPORT ServiceNode : public ElementaryNode
     {
     protected:
       ServiceNode(const std::string& name);
@@ -45,16 +45,17 @@ namespace YACS
       virtual Container *getContainer();
       virtual void setRef(const std::string& ref);
       virtual std::string getRef();
-      virtual void setMethod(const std::string& method){ _method=method; }
+      virtual void setMethod(const std::string& method) { _method=method; }
       virtual std::string getMethod(){return _method;}
       virtual ServiceNode *createNode(const std::string& name) = 0;
       virtual ~ServiceNode();
       virtual void accept(Visitor *visitor);
       virtual std::string getKind() const;
+      virtual std::string typeName() { return "YACS__ENGINE__ServiceNode"; }
+    public:
       static const char KIND[];
-      virtual std::string typeName() {return "YACS__ENGINE__ServiceNode";}
     protected:
-      ComponentInstance_component;
+      ComponentInstance *_component;
       std::string _method;
       std::string _ref;
     };
index 9dc1f3d7eb7cae9d52c87d1bc8d108762d1a468e..d77edcce2aecfe451247833e22db0c23b67bb0b4 100644 (file)
@@ -37,6 +37,8 @@ namespace YACS
       Container *clone() const;
       Container *cloneAlways() const;
       //
+      void lock() { }
+      void unLock() { }
       void clearProperties() { }
       void setProperty(const std::string& name,const std::string& value) { }
       std::string getProperty(const std::string& name) const { }
@@ -65,6 +67,8 @@ namespace YACS
       Container *clone() const;
       Container *cloneAlways() const;
       //
+      void lock() { }
+      void unLock() { }
       void clearProperties() { }
       void setProperty(const std::string& name,const std::string& value) { }
       std::string getProperty(const std::string& name) const { }
index c5d9ef54826e9c5c4a4536aa356b37208ebf4bec..bb8e6299bb1da0c0dd5dde198f6746c040001b20 100644 (file)
@@ -119,6 +119,7 @@ SET(YACSRuntimeSALOME_HEADERS
   SalomeContainer.hxx
   SalomeContainerTools.hxx
   SalomeContainerHelper.hxx
+  SalomeHPContainer.hxx
   SALOMEDispatcher.hxx
   SalomeProc.hxx
   SalomePythonComponent.hxx
@@ -170,6 +171,7 @@ SET(YACSRuntimeSALOME_SOURCES
   SalomePythonComponent.cxx      
   SalomeContainer.cxx            
   SalomeContainerTools.cxx
+  SalomeHPContainer.cxx
   SalomeContainerHelper.cxx
   PythonPorts.cxx                
   XMLNode.cxx                    
index cea49d6a02a88905a987acdc5d3bc3b4c9b9d563..ef67c063149b2a1a3f852cfb7b047c650c0dfd5b 100644 (file)
 using namespace YACS::ENGINE;
 using namespace std;
 
-SalomeContainer::SalomeContainer():_launchMode("start"),_launchModeType(new SalomeContainerMonoHelper),_shutdownLevel(999)
+SalomeContainer::SalomeContainer():_launchModeType(new SalomeContainerMonoHelper),_shutdownLevel(999)
 {
 }
 
 SalomeContainer::SalomeContainer(const SalomeContainer& other)
 : Container(other),
-  _launchMode(other._launchMode),
   _launchModeType(other._launchModeType->deepCpyOnlyStaticInfo()),
   _shutdownLevel(other._shutdownLevel),
   _sct(other._sct)
@@ -132,7 +131,7 @@ void SalomeContainer::clearProperties()
   _sct.clearProperties();
 }
 
-void SalomeContainer::addComponentName(std::string name)
+void SalomeContainer::addComponentName(const std::string& name)
 {
   _componentNames.push_back(name);
 }
@@ -148,75 +147,7 @@ void SalomeContainer::addToResourceList(const std::string& name)
  */
 CORBA::Object_ptr SalomeContainer::loadComponent(ComponentInstance *inst)
 {
-  DEBTRACE("SalomeContainer::loadComponent ");
-  lock();//To be sure
-  if(!isAlreadyStarted(inst))
-    {
-      try
-        {
-          start(inst);
-        }
-      catch(Exception& e)
-        {
-          unLock();
-          throw e;
-        }
-    }
-  unLock();
-  lock();//To be sure
-  CORBA::Object_ptr objComponent=CORBA::Object::_nil();
-  std::string compoName=inst->getCompoName();
-  const char* componentName=compoName.c_str();
-  Engines::Container_var container(_launchModeType->getContainer(inst));
-
-  char* reason;
-
-  bool isLoadable = container->load_component_Library(componentName, reason);
-  if (isLoadable)
-    {
-      CORBA::string_free(reason);
-      int studyid=1;
-      Proc* p=getProc();
-      if(p)
-        {
-          std::string value=p->getProperty("DefaultStudyID");
-          if(!value.empty())
-            studyid= atoi(value.c_str());
-        }
-      // prepare component instance properties
-      Engines::FieldsDict_var env = new Engines::FieldsDict;
-      std::map<std::string, std::string> properties = inst->getProperties();
-      if(p)
-        {
-          std::map<std::string,std::string> procMap=p->getProperties();
-          properties.insert(procMap.begin(),procMap.end());
-        }
-
-      std::map<std::string, std::string>::const_iterator itm;
-      env->length(properties.size());
-      int item=0;
-      for(itm = properties.begin(); itm != properties.end(); ++itm, item++)
-        {
-          DEBTRACE("envname="<<itm->first<<" envvalue="<< itm->second);
-          env[item].key= CORBA::string_dup(itm->first.c_str());
-          env[item].value <<= itm->second.c_str();
-        }
-
-      objComponent=container->create_component_instance_env(componentName, studyid, env, reason);
-    }
-
-  if(CORBA::is_nil(objComponent))
-    {
-      unLock();
-      std::string text="Error while trying to create a new component: component '"+ compoName;
-      text=text+"' is not installed or it's a wrong name";
-      text += '\n';
-      text += reason;
-      CORBA::string_free(reason);
-      throw Exception(text);
-    }
-  unLock();
-  return objComponent;
+  return SalomeContainerTools::LoadComponent(_launchModeType,this,inst);
 }
 
 //! Get the container placement id for a component instance
@@ -226,23 +157,7 @@ CORBA::Object_ptr SalomeContainer::loadComponent(ComponentInstance *inst)
  */
 std::string SalomeContainer::getPlacementId(const ComponentInstance *inst) const
 {
-
-  if(isAlreadyStarted(inst))
-    {
-      Engines::Container_var container(_launchModeType->getContainer(inst));
-      const char *what="/";
-      CORBA::String_var corbaStr=container->name();
-      string ret(corbaStr);
-
-      //Salome FOREVER ...
-      std::string::size_type i=ret.find_first_of(what,0);
-      i=ret.find_first_of(what, i==std::string::npos ? i:i+1);
-      if(i!=std::string::npos)
-        return ret.substr(i+1);
-      return ret;
-    }
-  else
-    return "Not placed yet !!!";
+  return SalomeContainerTools::GetPlacementId(_launchModeType,this,inst);
 }
 
 //! Get the container full path for a component instance
@@ -252,23 +167,7 @@ std::string SalomeContainer::getPlacementId(const ComponentInstance *inst) const
  */
 std::string SalomeContainer::getFullPlacementId(const ComponentInstance *inst) const
 {
-
-  if(isAlreadyStarted(inst))
-    {
-      Engines::Container_var container(_launchModeType->getContainer(inst));
-      try
-        {
-          CORBA::String_var corbaStr=container->name();
-          string ret(corbaStr);
-          return ret;
-        }
-      catch(...)
-        {
-          return "Unknown_placement";
-        }
-    }
-  else
-    return "Not_placed_yet";
+  return SalomeContainerTools::GetFullPlacementId(_launchModeType,this,inst);
 }
 
 //! Check if the component instance container is already started
@@ -292,119 +191,7 @@ Engines::Container_ptr SalomeContainer::getContainerPtr(const ComponentInstance
  */
 void SalomeContainer::start(const ComponentInstance *inst) throw(YACS::Exception)
 {
-  CORBA::ORB_ptr orb(getSALOMERuntime()->getOrb());
-  SALOME_NamingService ns;
-  try
-    {
-      ns.init_orb(orb);
-    }
-  catch(SALOME_Exception& e)
-    {
-      throw Exception("SalomeContainer::start : Unable to contact the SALOME Naming Service");
-    }
-  CORBA::Object_var obj(ns.Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS));
-  Engines::ContainerManager_var contManager(Engines::ContainerManager::_narrow(obj));
-
-  std::string str(_sct.getContainerName());
-  DEBTRACE("SalomeContainer::start " << str <<";"<< _sct.getHostName() <<";"<<_type);
-
-  // Finalize parameters with components found in the container
-  std::vector<std::string>::iterator iter;
-  for(CORBA::ULong i=0; i < _componentNames.size();i++)
-    _sct.addToComponentList(_componentNames[i]);
-  Engines::ContainerParameters myparams(_sct.getParameters());
-
-  bool namedContainer=false;
-  if(str != "")
-    namedContainer=true;
-
-  //If a container_name is given try to find an already existing container in naming service
-  //If not found start a new container with the given parameters
-  if (dynamic_cast<SalomeContainerMonoHelper *>(_launchModeType) && str != "")
-    {
-      myparams.mode="getorstart";
-    }
-
-  if (str == "")
-  {
-    //give a almost unique name to the container : Pid_Name_Addr
-    std::ostringstream stream;
-    stream << getpid();
-    stream << "_";
-    stream << _name;
-    stream << "_";
-    stream << (void *)(this);
-    DEBTRACE("container_name="<<stream.str());
-    myparams.container_name=CORBA::string_dup(stream.str().c_str());
-    _shutdownLevel=1;
-  }
-
-  Engines::Container_var trueCont(Engines::Container::_nil());
-  if(namedContainer && _shutdownLevel==999)
-    {
-      //Make this only the first time start is called (_shutdownLevel==999)
-      //If the container is named, first try to get an existing container
-      //If there is an existing container use it and set the shutdown level to 3
-      //If there is no existing container, try to launch a new one and set the shutdown level to 2
-      myparams.mode="get";
-      try
-        { 
-          trueCont=contManager->GiveContainer(myparams);
-        }
-      catch( const SALOME::SALOME_Exception& ex )
-        {
-          std::string msg="SalomeContainer::start : no existing container : ";
-          msg += '\n';
-          msg += ex.details.text.in();
-          DEBTRACE( msg );
-        }
-      catch(...)
-        {
-        }
-
-      if(!CORBA::is_nil(trueCont))
-        {
-          _shutdownLevel=3;
-          DEBTRACE( "container found: " << str << " " << _shutdownLevel );
-        }
-      else
-        {
-          _shutdownLevel=2;
-          myparams.mode="start";
-          DEBTRACE( "container not found: " << str << " " << _shutdownLevel);
-        }
-    }
-
-  if(CORBA::is_nil(trueCont))
-    try
-      { 
-        // --- GiveContainer is used in batch mode to retreive launched containers,
-        //     and is equivalent to StartContainer when not in batch.
-        trueCont=contManager->GiveContainer(myparams);
-      }
-    catch( const SALOME::SALOME_Exception& ex )
-      {
-        std::string msg="SalomeContainer::start : Unable to launch container in Salome : ";
-        msg += '\n';
-        msg += ex.details.text.in();
-        throw Exception(msg);
-      }
-    catch(CORBA::COMM_FAILURE&)
-      {
-        throw Exception("SalomeContainer::start : Unable to launch container in Salome : CORBA Comm failure detected");
-      }
-    catch(CORBA::Exception&)
-      {
-        throw Exception("SalomeContainer::start : Unable to launch container in Salome : Unexpected CORBA failure detected");
-      }
-
-  if(CORBA::is_nil(trueCont))
-    throw Exception("SalomeContainer::start : Unable to launch container in Salome. Check your CatalogResources.xml file");
-
-  _launchModeType->setContainer(inst,trueCont);
-
-  CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
-  std::cerr << "SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() << std::endl;
+  SalomeContainerTools::Start(_componentNames,_launchModeType,_sct,_shutdownLevel,this,inst);
 }
 
 void SalomeContainer::shutdown(int level)
index fc6d6b2aa314ea767bd22405220e1b9a0a8608aa..8fd377c9f002cdabed18d0096f6f75274bdc6023 100644 (file)
@@ -56,7 +56,7 @@ namespace YACS
       void setProperty(const std::string& name, const std::string& value);
       std::string getProperty(const std::string& name) const;
       void clearProperties();
-      void addComponentName(std::string name);
+      void addComponentName(const std::string& name);
       void addToResourceList(const std::string& name);
       virtual CORBA::Object_ptr loadComponent(ComponentInstance *inst);
       void shutdown(int level);
@@ -71,7 +71,6 @@ namespace YACS
       //! thread safety in Salome ???
       YACS::BASES::Mutex _mutex;
       std::vector<std::string> _componentNames;
-      std::string _launchMode;
       SalomeContainerHelper *_launchModeType;
       int _shutdownLevel;
       SalomeContainerTools _sct;
index 8eb41946e41f83a8ca43df0e80888d70b47f1580..fd3336efdd89e71a86ad7e769796312b91dc5caf 100644 (file)
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "SALOME_NamingService.hxx"
 #include "SALOME_ResourcesManager.hxx"
+#include "SALOME_ContainerManager.hxx"
+#include "Container.hxx"
 
+#include "YacsTrace.hxx"
+#include "Proc.hxx"
+#include "ComponentInstance.hxx"
+#include "SalomeContainerHelper.hxx"
 #include "RuntimeSALOME.hxx"
 #include "Exception.hxx"
 
@@ -217,6 +223,33 @@ std::string SalomeContainerTools::getContainerName() const
   return std::string(_params.container_name);
 }
 
+void SalomeContainerTools::setContainerName(const std::string& name)
+{
+  _params.container_name=CORBA::string_dup(name.c_str());
+}
+
+std::string SalomeContainerTools::getNotNullContainerName(const Container *contPtr, bool& isEmpty) const
+{
+  isEmpty=true;
+  std::string name(_params.container_name);
+  if(!name.empty())
+    {
+      isEmpty=false;
+      return name;
+    }
+  else
+    {
+      //give a almost unique name to the container : Pid_Name_Addr
+      std::ostringstream stream;
+      stream << getpid();
+      stream << "_";
+      stream << contPtr->getName();
+      stream << "_";
+      stream << (const void *)contPtr;
+      return stream.str();
+    }
+}
+
 std::string SalomeContainerTools::getHostName() const
 {
   return std::string(_params.resource_params.hostname);
@@ -261,3 +294,226 @@ std::map<std::string,std::string> SalomeContainerTools::getResourceProperties(co
     */
   return properties;
 }
+
+/*!
+ * \param [in] compoNames
+ * \param [in,out] shutdownLevel
+ */
+void SalomeContainerTools::Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerTools& sct, int& shutdownLevel, const Container *cont, const ComponentInstance *inst)
+{
+  CORBA::ORB_ptr orb(getSALOMERuntime()->getOrb());
+  SALOME_NamingService ns;
+  try
+  {
+      ns.init_orb(orb);
+  }
+  catch(SALOME_Exception& e)
+  {
+      throw Exception("SalomeContainer::start : Unable to contact the SALOME Naming Service");
+  }
+  CORBA::Object_var obj(ns.Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS));
+  Engines::ContainerManager_var contManager(Engines::ContainerManager::_narrow(obj));
+
+  bool isEmptyName;
+  std::string str(sct.getNotNullContainerName(cont,isEmptyName));
+  DEBTRACE("SalomeContainer::start " << str <<";"<< _sct.getHostName() <<";"<<_type);
+
+  // Finalize parameters with components found in the container
+
+  for(std::vector<std::string>::const_iterator iter=compoNames.begin();iter!=compoNames.end();iter++)
+    sct.addToComponentList(*iter);
+
+  Engines::ContainerParameters myparams(sct.getParameters());
+
+  //If a container_name is given try to find an already existing container in naming service
+  //If not found start a new container with the given parameters
+  if (dynamic_cast<SalomeContainerMonoHelper *>(schelp) && str != "")
+    {
+      myparams.mode="getorstart";
+    }
+
+  if (isEmptyName)
+    {
+      shutdownLevel=1;
+    }
+  sct.setContainerName(str);
+  Engines::Container_var trueCont(Engines::Container::_nil());
+  if(!isEmptyName && shutdownLevel==999)
+    {
+      //Make this only the first time start is called (_shutdownLevel==999)
+      //If the container is named, first try to get an existing container
+      //If there is an existing container use it and set the shutdown level to 3
+      //If there is no existing container, try to launch a new one and set the shutdown level to 2
+      myparams.mode="get";
+      try
+      {
+          trueCont=contManager->GiveContainer(myparams);
+      }
+      catch( const SALOME::SALOME_Exception& ex )
+      {
+          std::string msg="SalomeContainer::start : no existing container : ";
+          msg += '\n';
+          msg += ex.details.text.in();
+          DEBTRACE( msg );
+      }
+      catch(...)
+      {
+      }
+
+      if(!CORBA::is_nil(trueCont))
+        {
+          shutdownLevel=3;
+          DEBTRACE( "container found: " << str << " " << _shutdownLevel );
+        }
+      else
+        {
+          shutdownLevel=2;
+          myparams.mode="start";
+          DEBTRACE( "container not found: " << str << " " << _shutdownLevel);
+        }
+    }
+
+  if(CORBA::is_nil(trueCont))
+    try
+  {
+        // --- GiveContainer is used in batch mode to retreive launched containers,
+        //     and is equivalent to StartContainer when not in batch.
+        trueCont=contManager->GiveContainer(myparams);
+  }
+  catch( const SALOME::SALOME_Exception& ex )
+  {
+      std::string msg="SalomeContainer::start : Unable to launch container in Salome : ";
+      msg += '\n';
+      msg += ex.details.text.in();
+      throw Exception(msg);
+  }
+  catch(CORBA::COMM_FAILURE&)
+  {
+      throw Exception("SalomeContainer::start : Unable to launch container in Salome : CORBA Comm failure detected");
+  }
+  catch(CORBA::Exception&)
+  {
+      throw Exception("SalomeContainer::start : Unable to launch container in Salome : Unexpected CORBA failure detected");
+  }
+
+  if(CORBA::is_nil(trueCont))
+    throw Exception("SalomeContainer::start : Unable to launch container in Salome. Check your CatalogResources.xml file");
+
+  schelp->setContainer(inst,trueCont);
+
+  CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
+  std::cerr << "SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() << std::endl;
+}
+
+CORBA::Object_ptr SalomeContainerTools::LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, ComponentInstance *inst)
+{
+  DEBTRACE("SalomeContainer::loadComponent ");
+  cont->lock();//To be sure
+  if(!cont->isAlreadyStarted(inst))
+    {
+      try
+        {
+          cont->start(inst);
+        }
+      catch(Exception& e)
+        {
+          cont->unLock();
+          throw e;
+        }
+    }
+  cont->unLock();
+  cont->lock();//To be sure
+  CORBA::Object_ptr objComponent=CORBA::Object::_nil();
+  std::string compoName(inst->getCompoName());
+  const char* componentName=compoName.c_str();
+  Engines::Container_var container(launchModeType->getContainer(inst));
+
+  char* reason;
+
+  bool isLoadable = container->load_component_Library(componentName, reason);
+  if (isLoadable)
+    {
+      CORBA::string_free(reason);
+      int studyid=1;
+      Proc* p(cont->getProc());
+      if(p)
+        {
+          std::string value(p->getProperty("DefaultStudyID"));
+          if(!value.empty())
+            studyid= atoi(value.c_str());
+        }
+      // prepare component instance properties
+      Engines::FieldsDict_var env = new Engines::FieldsDict;
+      std::map<std::string, std::string> properties = inst->getProperties();
+      if(p)
+        {
+          std::map<std::string,std::string> procMap=p->getProperties();
+          properties.insert(procMap.begin(),procMap.end());
+        }
+
+      std::map<std::string, std::string>::const_iterator itm;
+      env->length(properties.size());
+      int item=0;
+      for(itm = properties.begin(); itm != properties.end(); ++itm, item++)
+        {
+          DEBTRACE("envname="<<itm->first<<" envvalue="<< itm->second);
+          env[item].key= CORBA::string_dup(itm->first.c_str());
+          env[item].value <<= itm->second.c_str();
+        }
+
+      objComponent=container->create_component_instance_env(componentName, studyid, env, reason);
+    }
+
+  if(CORBA::is_nil(objComponent))
+    {
+      cont->unLock();
+      std::string text="Error while trying to create a new component: component '"+ compoName;
+      text=text+"' is not installed or it's a wrong name";
+      text += '\n';
+      text += reason;
+      CORBA::string_free(reason);
+      throw Exception(text);
+    }
+  cont->unLock();
+  return objComponent;
+}
+
+std::string SalomeContainerTools::GetPlacementId(SalomeContainerHelper *launchModeType, const Container *cont, const ComponentInstance *inst)
+{
+  if(cont->isAlreadyStarted(inst))
+    {
+      Engines::Container_var container(launchModeType->getContainer(inst));
+      const char *what="/";
+      CORBA::String_var corbaStr(container->name());
+      std::string ret(corbaStr);
+
+      //Salome FOREVER ...
+      std::string::size_type i=ret.find_first_of(what,0);
+      i=ret.find_first_of(what, i==std::string::npos ? i:i+1);
+      if(i!=std::string::npos)
+        return ret.substr(i+1);
+      return ret;
+    }
+  else
+    return "Not placed yet !!!";
+}
+
+std::string SalomeContainerTools::GetFullPlacementId(SalomeContainerHelper *launchModeType, const Container *cont, const ComponentInstance *inst)
+{
+  if(cont->isAlreadyStarted(inst))
+    {
+      Engines::Container_var container(launchModeType->getContainer(inst));
+      try
+      {
+          CORBA::String_var corbaStr(container->name());
+          std::string ret(corbaStr);
+          return ret;
+      }
+      catch(...)
+      {
+          return "Unknown_placement";
+      }
+    }
+  else
+    return "Not_placed_yet";
+}
index 0713e6d62e0df93db2e224b030f49a312181477e..1ef95fb6166ac36c8e47ee70eaa9133d317f1727 100644 (file)
 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
 
 #include <string>
+#include <vector>
 #include <map>
 
 namespace YACS
 {
   namespace ENGINE
   {
+    class Container;
+    class ComponentInstance;
+    class SalomeContainerHelper;
+
     class YACSRUNTIMESALOME_EXPORT SalomeContainerTools
     {
     public:
@@ -45,8 +50,15 @@ namespace YACS
       void addToResourceList(const std::string& name);
     public:
       std::string getContainerName() const;
+      void setContainerName(const std::string& name);
+      std::string getNotNullContainerName(const Container *contPtr, bool& isEmpty) const;
       std::string getHostName() const;
       Engines::ContainerParameters getParameters() const { return _params; }
+    public:
+      static void Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerTools& sct, int& shutdownLevel, const Container *cont, const ComponentInstance *inst);
+      static CORBA::Object_ptr LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, ComponentInstance *inst);
+      static std::string GetPlacementId(SalomeContainerHelper *launchModeType, const Container *cont, const ComponentInstance *inst);
+      static std::string GetFullPlacementId(SalomeContainerHelper *launchModeType, const Container *cont, const ComponentInstance *inst);
     protected:
       std::map<std::string,std::string> _propertyMap;
       Engines::ContainerParameters _params;
diff --git a/src/runtime/SalomeHPContainer.cxx b/src/runtime/SalomeHPContainer.cxx
new file mode 100644 (file)
index 0000000..aee80db
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SalomeHPContainer.hxx"
+
+using namespace YACS::ENGINE;
+
+SalomeHPContainer::SalomeHPContainer():_shutdownLevel(999)
+{
+}
+
+SalomeHPContainer::SalomeHPContainer(const SalomeHPContainer& other):_shutdownLevel(999)
+{
+}
+
+void SalomeHPContainer::setSizeOfPool(int sz)
+{
+  _launchModeType.resize(sz);
+}
+
+SalomeHPContainer::~SalomeHPContainer()
+{
+}
index 016ed66ed5d2912a29f197dab6c7d08841dee402..53033cd26219227c488ac4089f03f9cc4cc156c8 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "YACSRuntimeSALOMEExport.hxx"
 #include "HomogeneousPoolContainer.hxx"
+#include "SalomeContainerHelper.hxx"
+#include "SalomeContainerTools.hxx"
 #include "Mutex.hxx"
 #include <string>
 #include <vector>
@@ -39,37 +41,18 @@ namespace YACS
     {
     public:
       SalomeHPContainer();
-      SalomeHPContainer(const SalomeContainer& other);
-      bool isAlreadyStarted(const ComponentInstance *inst) const;
-      Engines::Container_ptr getContainerPtr(const ComponentInstance *inst) const;
-      void start(const ComponentInstance *inst) throw (Exception);
-      Container *clone() const;
-      Container *cloneAlways() const;
-      std::string getPlacementId(const ComponentInstance *inst) const;
-      std::string getFullPlacementId(const ComponentInstance *inst) const;
-      void checkCapabilityToDealWith(const ComponentInstance *inst) const throw (Exception);
-      virtual void setProperty(const std::string& name, const std::string& value);
-      virtual void addComponentName(std::string name);
-      virtual CORBA::Object_ptr loadComponent(ComponentInstance *inst);
-      virtual void shutdown(int level);
-      // Helper methods
-      void addToComponentList(const std::string & name);
-      void addToResourceList(const std::string & name);
-      virtual std::map<std::string,std::string> getResourceProperties(const std::string& name);
+      SalomeHPContainer(const SalomeHPContainer& other);
+      void setSizeOfPool(int sz);
     protected:
 #ifndef SWIG
-      virtual ~SalomeHPContainer();
+      ~SalomeHPContainer();
 #endif
     protected:
-      //! thread safety in Salome ???
       YACS::BASES::Mutex _mutex;
-      Engines::Container_var _trueCont;
       std::vector<std::string> _componentNames;
-      std::vector<Engines::Container_var> _trueContainers;
-      std::string _type;
+      std::vector<SalomeContainerMonoHelper> _launchModeType;
       int _shutdownLevel;
-    public:
-      Engines::ContainerParameters _params;
+      SalomeContainerTools _sct;
     };
   }
 }