From: Anthony Geay Date: Tue, 29 Jul 2014 15:33:26 +0000 (+0200) Subject: On the road of homogeneous containers. X-Git-Tag: V7_5_0a1~4^2~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3bda66c84e705ee4b63fe805272217b2822865af;p=modules%2Fyacs.git On the road of homogeneous containers. --- diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index e9d752691..2eb5ba3a5 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -154,6 +154,7 @@ SET(YACSlibEngine_SOURCES ComponentInstance.cxx Dispatcher.cxx Container.cxx + HomogeneousPoolContainer.cxx DeploymentTree.cxx Logger.cxx LogRecord.cxx diff --git a/src/engine/Container.hxx b/src/engine/Container.hxx index f193cbe80..9cbe7bb27 100644 --- a/src/engine/Container.hxx +++ b/src/engine/Container.hxx @@ -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 index 000000000..814a2f358 --- /dev/null +++ b/src/engine/HomogeneousPoolContainer.cxx @@ -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 index 000000000..6bb2bd812 --- /dev/null +++ b/src/engine/HomogeneousPoolContainer.hxx @@ -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 +#include + +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 diff --git a/src/engine/Test/ContainerTest.cxx b/src/engine/Test/ContainerTest.cxx index 414e197c8..fbad9fa71 100644 --- a/src/engine/Test/ContainerTest.cxx +++ b/src/engine/Test/ContainerTest.cxx @@ -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; diff --git a/src/engine/Test/ContainerTest.hxx b/src/engine/Test/ContainerTest.hxx index 4b023e3b6..291a9feb7 100644 --- a/src/engine/Test/ContainerTest.hxx +++ b/src/engine/Test/ContainerTest.hxx @@ -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(); diff --git a/src/engine_swig/pilot.i b/src/engine_swig/pilot.i index 898af99bb..f2ffcb3f0 100644 --- a/src/engine_swig/pilot.i +++ b/src/engine_swig/pilot.i @@ -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) diff --git a/src/hmi/guiObservers.cxx b/src/hmi/guiObservers.cxx index 1720f5d91..4888242c4 100644 --- a/src/hmi/guiObservers.cxx +++ b/src/hmi/guiObservers.cxx @@ -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()); diff --git a/src/runtime/CppContainer.cxx b/src/runtime/CppContainer.cxx index c2d151e85..1711814b0 100644 --- a/src/runtime/CppContainer.cxx +++ b/src/runtime/CppContainer.cxx @@ -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) diff --git a/src/runtime/CppContainer.hxx b/src/runtime/CppContainer.hxx index 2eb246592..ada94cc26 100644 --- a/src/runtime/CppContainer.hxx +++ b/src/runtime/CppContainer.hxx @@ -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(); diff --git a/src/runtime/SalomeContainer.cxx b/src/runtime/SalomeContainer.cxx index dfd755035..1557a53d1 100644 --- a/src/runtime/SalomeContainer.cxx +++ b/src/runtime/SalomeContainer.cxx @@ -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) diff --git a/src/runtime/SalomeContainer.hxx b/src/runtime/SalomeContainer.hxx index 4ab0cd9b1..49f718788 100644 --- a/src/runtime/SalomeContainer.hxx +++ b/src/runtime/SalomeContainer.hxx @@ -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);