Salome HOME
On the road of homogeneous containers.
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 29 Jul 2014 15:33:26 +0000 (17:33 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 29 Jul 2014 15:33:26 +0000 (17:33 +0200)
12 files changed:
src/engine/CMakeLists.txt
src/engine/Container.hxx
src/engine/HomogeneousPoolContainer.cxx [new file with mode: 0644]
src/engine/HomogeneousPoolContainer.hxx [new file with mode: 0644]
src/engine/Test/ContainerTest.cxx
src/engine/Test/ContainerTest.hxx
src/engine_swig/pilot.i
src/hmi/guiObservers.cxx
src/runtime/CppContainer.cxx
src/runtime/CppContainer.hxx
src/runtime/SalomeContainer.cxx
src/runtime/SalomeContainer.hxx

index e9d752691af2585953cf49f858394290d83dbb22..2eb5ba3a50c9c864cde36c025dc4a88411152e52 100644 (file)
@@ -154,6 +154,7 @@ SET(YACSlibEngine_SOURCES
   ComponentInstance.cxx
   Dispatcher.cxx
   Container.cxx
+  HomogeneousPoolContainer.cxx
   DeploymentTree.cxx
   Logger.cxx
   LogRecord.cxx
index f193cbe8038099897883aa60751a41b43da60b17..9cbe7bb27088acd8e6b8139e23be26f55658e460 100644 (file)
@@ -35,6 +35,7 @@ namespace YACS
     class Proc;
     /*!
      * This is an abstract class, that represents an abstract process in which ComponentInstances can be launched and run.
+     * An instance of this will be mapped to one and only one physical container (except in the foreach context)
      */
     class YACSLIBENGINE_EXPORT Container : public RefCounter
     {
@@ -55,6 +56,7 @@ namespace YACS
       bool isAttachedOnCloning() const;
       //! \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;
       virtual bool isSupportingRTODefNbOfComp() const;
       virtual void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(Exception) = 0;
       virtual void setProperty(const std::string& name,const std::string& value);
diff --git a/src/engine/HomogeneousPoolContainer.cxx b/src/engine/HomogeneousPoolContainer.cxx
new file mode 100644 (file)
index 0000000..814a2f3
--- /dev/null
@@ -0,0 +1,30 @@
+// 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 "HomogeneousPoolContainer.hxx"
+
+using namespace YACS::ENGINE;
+
+HomogeneousPoolContainer::HomogeneousPoolContainer()
+{
+}
+
+HomogeneousPoolContainer::~HomogeneousPoolContainer()
+{
+}
diff --git a/src/engine/HomogeneousPoolContainer.hxx b/src/engine/HomogeneousPoolContainer.hxx
new file mode 100644 (file)
index 0000000..6bb2bd8
--- /dev/null
@@ -0,0 +1,49 @@
+// 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
+//
+
+#ifndef __HOMOGENEOUSPOOLCONTAINER_HXX__
+#define __HOMOGENEOUSPOOLCONTAINER_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "Exception.hxx"
+#include "Container.hxx"
+
+#include <list>
+#include <map>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    /*!
+     * This is an abstract class, that represents a set of fixed number of worker "kernelcontainers" homegenous in the sense that can be used indifferently each other.
+     * But each of those worker pool can be used once at a time.
+     */
+    class YACSLIBENGINE_EXPORT HomogeneousPoolContainer : public Container
+    {
+    protected:
+      HomogeneousPoolContainer();
+#ifndef SWIG
+      virtual ~HomogeneousPoolContainer();
+#endif
+    };
+  }
+}
+
+#endif
index 414e197c850546c54da05843f7598e713d368d0d..fbad9fa718922047dc91fa2bbe8f94a4e1910225 100644 (file)
@@ -67,6 +67,11 @@ Container *ContainerTest::clone() const
     return new ContainerTest;
 }
 
+Container *ContainerTest::cloneAlways() const
+{
+  return new ContainerTest;
+}
+
 void ContainerTest::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
 {
   if(inst->getKind()!=SUPPORTED_COMP_KIND)
@@ -105,6 +110,11 @@ Container *ContainerTest2::clone() const
     return new ContainerTest2;
 }
 
+Container *ContainerTest2::cloneAlways() const
+{
+  return new ContainerTest2;
+}
+
 void ContainerTest2::initAllContainers()
 {
   _counter=0;
index 4b023e3b65a3385f5024b530718fa150c9958771..291a9feb736fa8ed80f581d9046699250b31e7a8 100644 (file)
@@ -35,6 +35,7 @@ namespace YACS
       bool isAlreadyStarted(const ComponentInstance *inst) const;
       void start(const ComponentInstance *inst) throw(Exception);
       Container *clone() const;
+      Container *cloneAlways() const;
       std::string getPlacementId(const ComponentInstance *inst) const { return ""; }
       std::string getFullPlacementId(const ComponentInstance *inst) const { return ""; }
       static void initAllContainers();
@@ -55,6 +56,7 @@ namespace YACS
       bool isAlreadyStarted(const ComponentInstance *inst) const;
       void start(const ComponentInstance *inst) throw(Exception);
       Container *clone() const;
+      Container *cloneAlways() const;
       std::string getPlacementId(const ComponentInstance *inst) const { return ""; }
       std::string getFullPlacementId(const ComponentInstance *inst) const { return ""; }
       static void initAllContainers();
index 898af99bb64ae0210b90df063995fa84306ae6ec..f2ffcb3f06f5e10c3557cef84348647571d0640e 100644 (file)
@@ -158,6 +158,7 @@ REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
 %newobject *::createInputDataStreamPort;
 %newobject *::createOutputDataStreamPort;
 %newobject *::clone;
+%newobject *::cloneAlways;
 %newobject *::New;
 
 //Take ownership : transfer it from C++ (has to be completed)
index 1720f5d9185db7e9d14bbb742956f73b324c2a03..4888242c49bb005ffcea39da991d46cd8242443e 100644 (file)
@@ -2425,17 +2425,7 @@ void SubjectServiceNode::setComponent()
                 if (proc->containerMap.count(cont->getName()) == 0)
                   {
                     //container exists but is not in containerMap. Clone it, it's probably the result of copy paste from outside the proc
-                    Container* newcont;
-                    if(cont->isAttachedOnCloning())
-                      {
-                        cont->dettachOnCloning();
-                        newcont=cont->clone();
-                        cont->attachOnCloning();
-                        newcont->attachOnCloning();
-                      }
-                    else
-                      newcont=cont->clone();
-
+                    Container* newcont(cont->cloneAlways());
                     proc->containerMap[cont->getName()]=newcont;
                     instance->setContainer(newcont);
                     GuiContext::getCurrent()->getSubjectProc()->addSubjectContainer(newcont, newcont->getName());
index c2d151e85cbbc2273bcad1d4d332b82fd56773ad..1711814b052f66b5e43af5c83b7db4ca8f217bba 100644 (file)
@@ -94,6 +94,11 @@ Container *CppContainer::clone() const
     return new CppContainer(*this);
 }
 
+Container *CppContainer::cloneAlways() const
+{
+  return new CppContainer(*this);
+}
+
 bool CppContainer::loadComponentLibrary(const std::string & componentName) throw (YACS::Exception)
 {
     if (_trueCont) 
index 2eb24659224b8f4b6bb5d630e83dfa754299ab26..ada94cc269115be64bff0dcff71d9a1be370fa5f 100644 (file)
@@ -114,7 +114,7 @@ namespace YACS
       std::string getPlacementId(const ComponentInstance *inst) const;
       std::string getFullPlacementId(const ComponentInstance *inst) const;
       YACS::ENGINE::Container *clone() const;
-
+      Container *cloneAlways() const;
       void lock();
       void unLock();
        
index dfd755035f80f8afe0d2460623b07f2a2b355e11..1557a53d14108c1e9f3438559ff4a3b25f656d97 100644 (file)
@@ -92,6 +92,11 @@ Container *SalomeContainer::clone() const
     return new SalomeContainer(*this);
 }
 
+Container *SalomeContainer::cloneAlways() const
+{
+  return new SalomeContainer(*this);
+}
+
 void SalomeContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
 {
   if(inst->getKind()!=SalomeComponent::KIND)
index 4ab0cd9b1f5ca35bf72be97c391f4d68a0e23292..49f71878860c6738a2d75db13fa051667ac0d466 100644 (file)
@@ -49,6 +49,7 @@ namespace YACS
       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);