Salome HOME
Merge Python 3 porting.
authorrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 16:45:01 +0000 (19:45 +0300)
committerrnv <rnv@opencascade.com>
Tue, 27 Jun 2017 16:29:37 +0000 (19:29 +0300)
137 files changed:
CMakeLists.txt
doc/cppsalome.rst
doc/execution.rst
doc/principes.rst
doc/schemapy.rst
doc/schemaxml.rst
doc/yacsgen.rst
src/CTestTestfileInstall.cmake
src/bases/AutoRefCnt.hxx
src/engine/AbstractPoint.hxx
src/engine/BagPoint.cxx
src/engine/BagPoint.hxx
src/engine/Bloc.cxx
src/engine/Bloc.hxx
src/engine/BlocPoint.cxx
src/engine/BlocPoint.hxx
src/engine/Bloc_impl.cxx [new file with mode: 0644]
src/engine/CMakeLists.txt
src/engine/Container.hxx
src/engine/DynParaLoop.cxx
src/engine/DynParaLoop.hxx
src/engine/ElementaryNode.hxx
src/engine/ElementaryPoint.cxx
src/engine/ElementaryPoint.hxx
src/engine/ForkBlocPoint.cxx
src/engine/ForkBlocPoint.hxx
src/engine/HomogeneousPoolContainer.hxx
src/engine/InlineNode.cxx
src/engine/InlineNode.hxx
src/engine/LinkedBlocPoint.cxx
src/engine/LinkedBlocPoint.hxx
src/engine/Loop.cxx
src/engine/Loop.hxx
src/engine/Node.cxx
src/engine/Node.hxx
src/engine/PlayGround.cxx [new file with mode: 0644]
src/engine/PlayGround.hxx [new file with mode: 0644]
src/engine/RefCounter.cxx
src/engine/RefCounter.hxx
src/engine/Runtime.hxx
src/engine/SetOfPoints.cxx
src/engine/SetOfPoints.hxx
src/engine/Switch.cxx
src/engine/Switch.hxx
src/engine/Test/RuntimeForEngineIntegrationTest.cxx
src/engine/Test/RuntimeForEngineIntegrationTest.hxx
src/engine/Test/RuntimeForEngineTest.cxx
src/engine/Test/RuntimeForEngineTest.hxx
src/engine/VisitorSaveSchema.cxx
src/engine_swig/CMakeLists.txt
src/engine_swig/CTestTestfileInstall.cmake [new file with mode: 0644]
src/engine_swig/PlayGround.i [new file with mode: 0644]
src/engine_swig/pilot.i
src/engine_swig/testPlayGround0.py [new file with mode: 0644]
src/evalyfx_swig/CMakeLists.txt
src/genericgui/GenericGui.cxx
src/genericgui/GuiExecutor.cxx
src/genericgui/QtGuiContext.cxx
src/genericgui/QtGuiContext.hxx
src/pmml/pmml_swig/CMakeLists.txt
src/pyqt/salomefiles/threenodes.xml
src/pyqt/salomefiles/twoconnectednodes.xml
src/pyqt/salomefiles/twonodes.xml
src/runtime/CMakeLists.txt
src/runtime/CppContainer.cxx
src/runtime/CppContainer.hxx
src/runtime/DistributedPythonNode.cxx
src/runtime/PythonNode.cxx
src/runtime/RuntimeSALOME.cxx
src/runtime/RuntimeSALOME.hxx
src/runtime/SalomeContainerHelper.cxx
src/runtime/SalomeContainerHelper.hxx
src/runtime/SalomeContainerTmpForHP.cxx
src/runtime/SalomeContainerTools.cxx
src/runtime/SalomeContainerTools.hxx
src/runtime/SalomeHPContainer.cxx
src/runtime/SalomeHPContainer.hxx
src/runtime/SalomeHPContainerTools.cxx
src/runtime/SalomeHPContainerTools.hxx
src/runtime/SalomeProc.cxx
src/runtime/SalomeProc.hxx
src/runtime/StudyNodes.cxx
src/runtime/StudyPorts.cxx
src/runtime/StudyPorts.hxx
src/runtime_swig/CMakeLists.txt
src/runtime_swig/SALOMERuntime.i
src/salomegui/Yacsgui.cxx
src/salomegui/Yacsgui.hxx
src/salomegui/resources/YACSCatalog.xml.in
src/salomegui/resources/YACSSchemaCatalog.xml
src/salomegui_swig/CMakeLists.txt
src/salomeloader/samples/GeomGraph.xml
src/salomeloader/samples/GeomGraphGates.xml
src/salomeloader/samples/GeomGraphGates_py.xml
src/salomeloader/samples/GeomGraph_py.xml
src/salomeloader/samples/testvisu20.xml
src/salomewrap/SalomeWrap_Module.cxx
src/salomewrap/SalomeWrap_Module.hxx
src/salomewrap/SuitWrapper.cxx
src/salomewrap/SuitWrapper.hxx
src/wrappergen/bin/HXX2SALOME_GENERIC_CLASS_NAME_SRC/bin/runSalome.py
src/wrappergen/src/HXX2SALOME_GENERIC_CLASS_NAME_SRC/bin/runSalome.py
src/wrappergen/src/parse5.awk
src/wrappergen/src/runIDLparser
src/yacsloader/loopParsers.hxx
src/yacsloader/samples/SchemaIOFile.xml
src/yacsloader/samples/SchemaInputOutputGeom.xml
src/yacsloader/samples/calcium5.xml
src/yacsloader/samples/foreach7.xml
src/yacsloader/samples/foreach8.xml
src/yacsloader/samples/foreach_init2fin.xml
src/yacsloader/samples/foreach_init2work.xml
src/yacsloader/samples/gobj1.xml
src/yacsloader/samples/optimizer_async_cpp.xml
src/yacsloader/samples/optimizer_async_py.xml
src/yacsloader/samples/optimizer_retro.xml
src/yacsloader/samples/optimizer_sync_cpp.xml
src/yacsloader/samples/optimizer_sync_py.xml
src/yacsloader/samples/pyremote1.xml
src/yacsloader/samples/pyremote2.xml
src/yacsloader/samples/pyremote3.xml
src/yacsloader/samples/pyremote4.xml
src/yacsloader/samples/schema2.xml
src/yacsloader/samples/schemaANN2.xml
src/yacsloader/samples/schemaANNLR2.xml
src/yacsloader/samples/schemaLR2.xml
src/yacsloader/samples/schemaPmmlDoesNotExist.xml
src/yacsloader/samples/sinline1.xml
src/yacsloader/samples/sinline4.xml
src/yacsloader/samples/study1.xml
src/yacsloader/samples/switch10.xml
src/yacsloader_swig/CMakeLists.txt
src/yacsloader_swig/Test/CMakeLists.txt
src/yacsloader_swig/Test/CTestTestfileInstall.cmake
src/yacsloader_swig/Test/YacsLoaderInSessionTest.sh.in
src/yacsloader_swig/Test/testHPDecorator.py [new file with mode: 0644]
src/yacsloader_swig/Test/testSaveLoadRun.py

index 55a06dc22e1f3ac3f685f072fd0386dee4e1ec35..f23f76faf749d12fa1e8a571e4da5a800d5b41b1 100644 (file)
@@ -37,7 +37,7 @@ SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 # Common CMake macros
 # ===================
index f6c1bb9dfa7418fcbef01b9807117b90f319863a..c65aa624ce66f2255b91272ca74f0606da571893 100644 (file)
@@ -122,8 +122,8 @@ This class contains a constructor whose arguments are imposed by SALOME, a virtu
       const char *instanceName,
       const char *interfaceName);
     virtual ~HELLO();
-    HELLO_ORB::status hello  ( SALOMEDS::Study_ptr study, const char* name );
-    HELLO_ORB::status goodbye( SALOMEDS::Study_ptr study, const char* name );
+    HELLO_ORB::status hello  ( const char* name );
+    HELLO_ORB::status goodbye( const char* name );
     void              copyOrMove( const HELLO_ORB::object_list& what,
                                  SALOMEDS::SObject_ptr where,
                                  CORBA::Long row, CORBA::Boolean isCopy );
@@ -147,12 +147,12 @@ to load the HELLO component::
 The definitions of the constructor and the HELLOEngine_factory instantiation function (both normalized!),
 hello, goodbye and copyOrMove are given in the source file (HELLO.cxx)::       
 
-       HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
+       HELLO_ORB::status HELLO::hello( const char* name )
        {
        ...
        }
 
-       HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
+       HELLO_ORB::status HELLO::goodbye( const char* name )
        {
        ...
        }
@@ -237,7 +237,7 @@ Let us check that hello object is correctly typed, and we will call the hello se
 
     >>> print hello
     <HELLO_ORB._objref_HELLO_Gen instance at 0x8274e94>
-    >>> status=hello.hello(salome.myStudy, "Nicolas")
+    >>> status=hello.hello("Nicolas")
     >>> print status
     OP_OK
 
index 1aede2c762e926e208b262bfbdc94f40b555e818..d455f8146eb04154bb9e5ae95a9617b6a6beac32 100644 (file)
@@ -64,7 +64,7 @@ informed by the system about all problems detected by this operation.
 
 
 If a preliminary check is successfully done, schema run is created and then the user can start its execution in the chosen mode. Schema run 
-is exported to an XML file and passed to YACS CORBA engine and executed there. YACS CORBA engine is also given a study ID.
+is exported to an XML file and passed to YACS CORBA engine and executed there.
 
 For visual representation of execution state the following means are provided by YACS module.
 
index 6bbd81cd54339089ee7b8696db8521e68c5b099f..c873c3cd567e66c81e3f1ad0a133aae306ceb0b5 100644 (file)
@@ -318,7 +318,7 @@ A Study node is used to relate the elements of a SALOME study to the data and re
 
 StudyIn node
 ...................
-A StudyIn node has output data ports only. It is used to define data in the calculation scheme originating from a SALOME study. The associated study is given by its SALOME StudyID.
+A StudyIn node has output data ports only. It is used to define data in the calculation scheme originating from a SALOME study.
 
 A port corresponds to data stored in the associated study.  The data has a name (the port name), a type (the port type), and a reference that gives the entry into the study.  This reference is either a SALOME Entry (for example 0:1:1:2) or a path in the SALOME study tree (for example, /Geometry/box_1).
 
@@ -330,7 +330,7 @@ To create this type of node:
 
 StudyOut node
 ...................
-A StudyOut node only has input data ports.  It is used to store results in a SALOME study.  The associated study is given by its SALOME StudyID.
+A StudyOut node only has input data ports.  It is used to store results in a SALOME study.
 
 A port corresponds to a result to be stored in an associated study.  The result has a name (the port name), a type (the port type), and a reference that gives the entry into the study.  This reference is either a SALOME Entry (for example 0:1:1:2) or a path in the SALOME study tree (for example, /Geometry/box_1).
 
@@ -880,16 +880,6 @@ that is not a genuine node.  If it is said that block “b” in the previous ex
 value of 1 and a default case, then the absolute name of node “n” in the case 1 will be “c.b.p1_n” and the absolute name of the node in 
 the default case will be “c.b.default_n”.
 
-Active study
---------------
-A schema can be executed without using the SALOME study manager. But when a schema must be executed in the context
-of a SALOME study, it is possible to specify the studyId to use.
-
-The way to do that is to set the schema property **DefaultStudyID** to the study id.
-
-In the GUI, this is set automatically to the current active studyId.
-For execution in console mode, see :ref:`xml_active_study`
-
 .. _errorreport:
 
 Error report
index ccd0ada8083a0424c8e4d7f986d496686abbbc9d..fa2ded1fcef66b832cfd26c64403156fb9507366 100644 (file)
@@ -771,19 +771,17 @@ The result file will be copied into the local file myfile::
 StudyIn node
 ++++++++++++++
 A StudyIn node is defined using the runtime createInDataNode method.  It uses two arguments, the first of which must be “study” 
-and the second the node name.  The associated study is specified by adding the “StudyID” property to the node using 
-its setProperty method.  Node data are defined by adding output data ports using the edAddOutputPOrt method, transferring 
+and the second the node name.  Node data are defined by adding output data ports using the edAddOutputPOrt method, transferring 
 the name of the data and its type as arguments.  The data is initialised with the reference in the study, using the setData method 
 for the port thus created, transferring a character string to it containing either the SALOME Entry or the path in the study 
 tree structure.
 
 The following is an example of the StudyIn node that defines 2 GEOM_Object type data (a and b).  The study is assumed to be 
-loaded into memory by SALOME as StudyID 1.  Data a is referenced by one SALOME Entry.  Data b is referenced by a path in the 
+loaded into memory by SALOME.  Data a is referenced by one SALOME Entry.  Data b is referenced by a path in the 
 study tree structure::
 
   n=r.createInDataNode("study","study1")
   p.edAddChild(n)
-  n.setProperty("StudyID","1")
   pout=n.edAddOutputPort('a',tgeom)
   pout.setData("0:1:1:1")
   pout=n.edAddOutputPort('b',tgeom)
@@ -794,21 +792,19 @@ study tree structure::
 StudyOut node
 ++++++++++++++
 A StudyOut node is defined using the runtime createOutDataNode method.  It uses two arguments, the first of 
-which must be “study” and the second the node name.  The associated study is specified by adding 
-the “StudyID” property to the node using its setProperty method.  The name of the file in which the study will be 
+which must be “study” and the second the node name. The name of the file in which the study will be 
 saved is specified using the node SetRef method with the file name as an argument.  
 The node results are defined by adding input data ports to it using the edAddInputPort method, transferring the data name 
 and type as arguments.  The setData method for the port is used to associate the entry into the study to the result, transferring 
 a character string to it that contains either the SALOME Entry or the path in the study tree structure.
 
 The following contains an example of the StudyOut node that defines two GEOM_Object type results (a and b).  
-The studyId of the study used is 1.  Result a is referenced by a SALOME Entry.  The result b is referenced by a path.  
+Result a is referenced by a SALOME Entry.  The result b is referenced by a path.  
 The complete study is saved in the study1.hdf file at the end of the calculation::
 
   n=r.createOutDataNode("study","study2")
   n.setRef("study1.hdf")
   p.edAddChild(n)
-  n.setProperty("StudyID","1")
   pout=n.edAddInputPort('a',tgeom)
   pout.setData("0:1:2:1")
   pout=n.edAddInputPort('b',tgeom)
index 378d948489969aa9bb14a7430afea82a55d2352e..8a9145e67976be747c8a55ea40cb6d4cb80a1ae0 100644 (file)
@@ -794,20 +794,6 @@ In the case of a SALOME service node, the property is transmitted to the compone
 
 .. _xml_active_study:
 
-Active study
---------------
-To execute a schema in the context of a SALOME study, you have to set the **DefaultStudyID** property of the schema.
-
-Example to execute the schema in the study with studyId 5:
-
-.. code-block:: xml
-
-  <proc name="myschema">
-     <property name="DefaultStudyID" value="5"/>
-     ...
-  </proc>
-
-
 Datastream connections
 ----------------------------
 Datastream connections are only possible for SALOME service nodes, as we have seen in :ref:`principes`.  Firstly, datastream ports 
@@ -968,20 +954,19 @@ The result file will be copied into the local file myfile:
 StudyIn node
 '''''''''''''''
 This type of node is defined as a DataIn node with the datanode tag.  All that is necessary is to add the kind attribute 
-with the “study” value.  The associated study is given by a property (property tag) named StudyID (the value of which is an integer).
+with the “study” value.
 
 The parameter sub-tag will be used to define the node data.  This tag has two compulsory attributes, name and type, that give the 
 data name and type respectively.  The ref attribute gives the input into the study in the form of a SALOME Entry, or a 
 path in the study tree structure.
 
 The following is an example of a StudyIn node that defines 2 data (b and c) with types GEOM_Object and Boolean.  It is assumed 
-that SALOME has loaded the study (with StudyID 1) into memory.  Data b is referenced by a SALOME Entry.  
+that SALOME has loaded the study into memory.  Data b is referenced by a SALOME Entry.  
 The data c is referenced by a path in the study tree structure.
 
 .. code-block:: xml
 
     <datanode name="s" kind="study" >
-      <property name="StudyID" value="1" />
       <parameter name="b" type="GEOM/GEOM_Object" ref="0:1:2:2"/>
       <parameter name="c" type="bool" ref="/Geometry/Box_1"/>
     </datanode>
@@ -992,20 +977,18 @@ StudyOut node
 ''''''''''''''''''
 This type of node is defined as a DataOut node with the outnode tag and the name attribute.  
 All that is necessary is to add the kind attribute with the value “study”.  
-The optional ref attribute gives the name of the file in which the study will be saved at the end of the calculation.  
-The associated study is given by a property (property tag) with name StudyID (the value of which is an integer).
+The optional ref attribute gives the name of the file in which the study will be saved at the end of the calculation.
 
 The parameter sub-tag will be used to define the node results.  This tag has two compulsory attributes, name and type, that 
 give the data name and type respectively.  The ref attribute gives the entry into the study in the form of a SALOME Entry, or 
 a path in the study tree structure.
 
-The following gives an example of the StudyOut node that defines 2 results (a and b) of the GEOM_Object type.  The study used has 
-the studyId 1.  The complete study is saved in the study1.hdf file at the end of the calculation:
+The following gives an example of the StudyOut node that defines 2 results (a and b) of the GEOM_Object type.
+The complete study is saved in the study1.hdf file at the end of the calculation:
 
 .. code-block:: xml
 
    <outnode name="o" kind="study" ref="stud1.hdf">
-     <property name="StudyID" value="1"/>
      <parameter name="a" type="GEOM/GEOM_Object" ref="/Geometry/YacsFuse"/>
      <parameter name="b" type="GEOM/GEOM_Object" ref="0:1:1:6"/>
    </outnode>
index 41faa31463c6f2749aa6057d9fcc8517a4e5c4ac..b9ea4d296d24bd062de7826fc6a0b373edc5b017 100644 (file)
@@ -1308,10 +1308,10 @@ Here is an excerpt from pygui1 example that shows how to add a method named crea
 
   compodefs=r"""
   class A:
-    def createObject( self, study, name ):
+    def createObject( self, name ):
       "Create object.  "
-      builder = study.NewBuilder()
-      father = study.FindComponent( "pycompos" )
+      builder = salome.myStudy.NewBuilder()
+      father = salome.myStudy.FindComponent( "pycompos" )
       if father is None:
         father = builder.NewComponent( "pycompos" )
       attr = builder.FindOrCreateAttribute( father, "AttributeName" )
@@ -1342,20 +1342,15 @@ fragment that will be included in the component class to effectively redefine th
 Here is an excerpt from cppgui1 example that shows how to redefine the DumpPython method in a C++ component::
 
   compomethods=r"""
-  Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean isPublished,
+  Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
                                CORBA::Boolean& isValidScript)
   {
-    SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
-    if(CORBA::is_nil(aStudy))
-      return new Engines::TMPFile(0);
-    SALOMEDS::SObject_var aSO = aStudy->FindComponent("cppcompos");
+    SALOMEDS::SObject_var aSO = KERNEL::getStudy()->FindComponent("cppcompos");
     if(CORBA::is_nil(aSO))
        return new Engines::TMPFile(0);
     std::string Script = "import cppcompos_ORB\n";
     Script += "import salome\n";
     Script += "compo = salome.lcc.FindOrLoadComponent('FactoryServer','cppcompos')\n";
-    Script += "def RebuildData(theStudy):\n";
-    Script += "  compo.SetCurrentStudy(theStudy)\n";
     const char* aScript=Script.c_str();
     char* aBuffer = new char[strlen(aScript)+1];
     strcpy(aBuffer, aScript);
@@ -1400,10 +1395,10 @@ implementation from SALOME KERNEL) and an extra method (createObject) to a pytho
       SALOME_DriverPy.SALOME_DriverPy_i.__init__(self,"pycompos")
       return
 
-    def createObject( self, study, name ):
+    def createObject( self, name ):
       "Create object.  "
-      builder = study.NewBuilder()
-      father = study.FindComponent( "pycompos" )
+      builder = salome.myStudy.NewBuilder()
+      father = salome.myStudy.FindComponent( "pycompos" )
       if father is None:
         father = builder.NewComponent( "pycompos" )
         attr = builder.FindOrCreateAttribute( father, "AttributeName" )
@@ -1434,7 +1429,7 @@ one file (myinterface.idl) that contains the definition of interface Idl_A::
 
   interface Idl_A : SALOMEDS::Driver
   {
-    void createObject(in SALOMEDS::Study theStudy, in string name) raises (SALOME::SALOME_Exception);
+    void createObject(in string name) raises (SALOME::SALOME_Exception);
   };
 
 In this simple case, it is also possible to include directly the content of the file with the *interfacedefs* parameter.
index 4d5dd69d23bb8f32dd6035e4d06b6b43dcd488bf..6f6927794391dc500c0e1ef42b54e637fd838697 100644 (file)
@@ -29,6 +29,7 @@ SET(YACS_TEST_LIB "../lib")
 SUBDIRS(
     bases
     engine
+    engine_swig
     runtime
     pmml
     yacsloader
index 003a73e82a6d4726ee43dbbe95e55cf5eb123d9d..346f0406b4df2747aa8ef5a04467733e72531407 100644 (file)
@@ -33,6 +33,9 @@ namespace YACS
       AutoRefCnt(const AutoRefCnt& other):_ptr(0) { referPtr(other._ptr); }
       AutoRefCnt(T *ptr=0):_ptr(ptr) { }
       ~AutoRefCnt() { destroyPtr(); }
+      bool isNull() const { return _ptr==0; }
+      bool isNotNull() const { return !isNull(); }
+      void nullify() { destroyPtr(); _ptr=0; }
       bool operator==(const AutoRefCnt& other) const { return _ptr==other._ptr; }
       bool operator==(const T *other) const { return _ptr==other; }
       AutoRefCnt &operator=(const AutoRefCnt& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; }
@@ -44,6 +47,7 @@ namespace YACS
       operator T *() { return _ptr; }
       operator const T *() const { return _ptr; }
       T *retn() { if(_ptr) _ptr->incrRef(); return _ptr; }
+      void takeRef(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } }
     private:
       void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
       void destroyPtr() { if(_ptr) _ptr->decrRef(); }
@@ -51,6 +55,32 @@ namespace YACS
       T *_ptr;
     };
 
+    template<class T>
+    class AutoConstRefCnt
+    {
+    public:
+      AutoConstRefCnt(const AutoConstRefCnt& other):_ptr(0) { referPtr(other._ptr); }
+      AutoConstRefCnt(const T *ptr=0):_ptr(ptr) { }
+      ~AutoConstRefCnt() { destroyPtr(); }
+      bool isNull() const { return _ptr==0; }
+      bool isNotNull() const { return !isNull(); }
+      void nullify() { destroyPtr(); _ptr=0; }
+      bool operator==(const AutoConstRefCnt& other) const { return _ptr==other._ptr; }
+      bool operator==(const T *other) const { return _ptr==other; }
+      AutoConstRefCnt &operator=(const AutoConstRefCnt& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; }
+      AutoConstRefCnt &operator=(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; }
+      const T *operator->() const { return _ptr; }
+      const T& operator*() const { return *_ptr; }
+      operator const T *() const { return _ptr; }
+      const T *retn() { if(_ptr) _ptr->incrRef(); return _ptr; }
+      void takeRef(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } }
+    private:
+      void referPtr(const T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
+      void destroyPtr() { if(_ptr) _ptr->decrRef(); }
+    private:
+      const T *_ptr;
+    };
+
     template<class T, class U>
     typename YACS::BASES::AutoRefCnt<U> DynamicCast(typename YACS::BASES::AutoRefCnt<T>& autoSubPtr) throw()
     {
index 9a8d35afa9a783a4e040ef0ae55068c59f8b315a..3b4f5dc6409d388c7cb4d819a343a58f9b5fd82d 100644 (file)
 #define __ABSTRACTPOINT_HXX__
 
 #include "YACSlibEngineExport.hxx"
+#include "PlayGround.hxx"
+#include "AutoRefCnt.hxx"
 
+#include <map>
 #include <list>
 #include <vector>
 #include <string>
@@ -34,6 +37,7 @@ namespace YACS
     class InGate;
     class OutGate;
     class BlocPoint;
+    class ComposedNode;
     class ForkBlocPoint;
     class LinkedBlocPoint;
     
@@ -63,6 +67,8 @@ namespace YACS
       virtual bool contains(Node *node) = 0;
       virtual int getNumberOfNodes() const = 0;
       virtual int getMaxLevelOfParallelism() const = 0;
+      virtual double getWeightRegardingDPL() const = 0;
+      virtual void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const = 0;
       virtual std::string getRepr() const = 0;
       virtual ~AbstractPoint();
     public:
index 01d6dc74ca5c5cdde4b0d0c804a99fd9b23cb50a..d7727a16dae9e651006fa4e10a08b3b93b1da6a3 100644 (file)
@@ -31,28 +31,62 @@ BagPoint::BagPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *fathe
 {
 }
 
-Node *BagPoint::getFirstNode()
+AbstractPoint *BagPoint::getUnique()
 {
   if(_nodes.size()!=1)
-    throw YACS::Exception("BagPoint::getFirstNode : invalid call !");
+    throw YACS::Exception("BagPoint::getUnique : invalid call !");
   else
-    return (*_nodes.begin())->getFirstNode();
+    {
+      AbstractPoint *ret(*_nodes.begin());
+      if(!ret)
+        throw YACS::Exception("BagPoint::getUnique : Ooops !");
+      return ret;
+    }
 }
 
-Node *BagPoint::getLastNode()
+const AbstractPoint *BagPoint::getUnique() const
 {
   if(_nodes.size()!=1)
-    throw YACS::Exception("BagPoint::getLastNode : invalid call !");
+    throw YACS::Exception("BagPoint::getUnique const : invalid call !");
   else
-    return (*_nodes.begin())->getLastNode();
+    {
+      AbstractPoint *ret(*_nodes.begin());
+      if(!ret)
+        throw YACS::Exception("BagPoint::getUnique : Ooops !");
+      return ret;
+    }
+}
+
+AbstractPoint *BagPoint::getUniqueAndReleaseIt()
+{
+  AbstractPoint *ret(getUnique());
+  getOutPoint(ret);
+  return ret;
+}
+
+Node *BagPoint::getFirstNode()
+{
+  return getUnique()->getFirstNode();
+}
+
+Node *BagPoint::getLastNode()
+{
+  return getUnique()->getLastNode();
 }
 
 int BagPoint::getMaxLevelOfParallelism() const
 {
-  if(_nodes.size()!=1)
-    throw YACS::Exception("BagPoint::getMaxLevelOfParallelism : invalid call !");
-  else
-    return (*_nodes.begin())->getMaxLevelOfParallelism();
+  return getUnique()->getMaxLevelOfParallelism();
+}
+
+double BagPoint::getWeightRegardingDPL() const
+{
+  return getUnique()->getWeightRegardingDPL();
+}
+
+void BagPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
+{
+  getUnique()->partitionRegardingDPL(pd,zeMap);
 }
 
 std::string BagPoint::getRepr() const
index f08f52c7e37b31e57662380e0719804f07b3fb7f..9568deb07f4377bf31372509d5581d568e5754ba 100644 (file)
@@ -37,7 +37,10 @@ namespace YACS
       Node *getFirstNode();
       Node *getLastNode();
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const;
       std::string getRepr() const;
+      AbstractPoint *getUniqueAndReleaseIt();
     public:
       int size() const { return (int)_nodes.size(); }
       void replaceInMe(BlocPoint *aSet);
@@ -45,6 +48,9 @@ namespace YACS
       void deal2(bool& somethingDone);
       void deal2Bis(bool& somethingDone);
       void deal2Ter(bool& somethingDone);
+    private:
+      AbstractPoint *getUnique();
+      const AbstractPoint *getUnique() const;
     };
   }
 }
index 7d5e7b0450360a06e3ab9b2a15e73dd3ae827418..6fc3240abfa88716d1fb14d9d23e3654f04aaa64 100644 (file)
@@ -25,7 +25,9 @@
 #include "OutputDataStreamPort.hxx"
 #include "ElementaryNode.hxx"
 #include "Visitor.hxx"
+#include "ForkBlocPoint.hxx"
 #include "SetOfPoints.hxx"
+#include "PlayGround.hxx"
 
 #include <queue>
 #include <iostream>
@@ -452,16 +454,30 @@ void Bloc::accept(Visitor* visitor)
  * for all concurrent branches in \a this.
  */
 int Bloc::getMaxLevelOfParallelism() const
+{
+  std::list< AbstractPoint * > pts(analyzeParallelism());
+  ForkBlocPoint fbp(pts,NULL);
+  return fbp.getMaxLevelOfParallelism();
+}
+
+std::list< AbstractPoint * > Bloc::analyzeParallelism() const
 {
   std::vector< std::list<Node *> > r(splitIntoIndependantGraph());
-  int ret(0);
+  std::list< AbstractPoint * > pts;
   for(std::vector< std::list<Node *> >::const_iterator it=r.begin();it!=r.end();it++)
     {
       SetOfPoints sop(*it);
       sop.simplify();
-      ret+=sop.getMaxLevelOfParallelism();
+      pts.push_back(sop.getUniqueAndReleaseIt());
     }
-  return ret;
+  return pts;
+}
+
+double Bloc::getWeightRegardingDPL() const
+{
+  std::list< AbstractPoint * > pts(analyzeParallelism());
+  ForkBlocPoint fbp(pts,NULL);
+  return fbp.getWeightRegardingDPL();
 }
 
 void Bloc::removeRecursivelyRedundantCL()
@@ -476,6 +492,15 @@ void Bloc::removeRecursivelyRedundantCL()
   destructCFComputations(info);
 }
 
+void Bloc::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  if(!pd)
+    throw Exception("Bloc::partitionRegardingDPL : NULL pointer !");
+  std::list< AbstractPoint * > pts(analyzeParallelism());
+  ForkBlocPoint fbp(pts,NULL);
+  fbp.partitionRegardingDPL(pd,zeMap);
+}
+
 void Bloc::performCFComputationsOnlyOneLevel(LinkInfo& info) const
 {
   delete _fwLinks;//Normally useless
index 3cfec917263b5eab4445c9a4d2530a135dca5d40..3759fc0947804cfd574397f876fd8178cd6a15ed 100644 (file)
 
 #include "YACSlibEngineExport.hxx"
 #include "StaticDefinedComposedNode.hxx"
+#include "AutoRefCnt.hxx"
 
 namespace YACS
 {
   namespace ENGINE
   {
+    class PartDefinition;
+    class DynParaLoop;
+    class AbstractPoint;
+    class PlayGround;
     class YACSLIBENGINE_EXPORT Bloc : public StaticDefinedComposedNode
     {
     protected:
@@ -61,7 +66,10 @@ namespace YACS
       void findAllNodesStartingFrom(Node *start, std::set<Node *>& result, std::map<Node *, std::set<Node *> >& accelStr, LinkInfo& info) const;
       virtual std::string typeName() { return "YACS__ENGINE__Bloc"; }
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
       void removeRecursivelyRedundantCL();
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
+      void fitToPlayGround(const PlayGround *pg);
     protected:
       bool areAllSubNodesFinished() const;
       bool areAllSubNodesDone() const;
@@ -89,6 +97,7 @@ namespace YACS
       void seekOkAndUseless1(std::vector<Node *>& okAndUseless1, std::set<Node *>& allNodes) const;
       void seekUseless2(std::vector<Node *>& useless2, std::set<Node *>& allNodes) const;
     private:
+      std::list< AbstractPoint * > analyzeParallelism() const;
       static void findUselessLinksIn(const std::list< std::vector<Node *> >& res , LinkInfo& info);
       template<bool direction>
       static unsigned appendIfAlreadyFound(std::list< std::vector<Node *> >& res, const std::vector<Node *>& startRes, Node *node, std::map<Node *, std::set<Node *> >& fastFinder);
index 485bcdf2dd747388bcf2cbd10177d683eaf3629d..b351d5cdbe4391975907605b052addeadf1cb19d 100644 (file)
@@ -20,6 +20,8 @@
 #include "BlocPoint.hxx"
 #include "Node.hxx"
 
+#include <algorithm>
+
 using namespace YACS::ENGINE;
 
 BlocPoint::BlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):AbstractPoint(father),_nodes(nodes)
@@ -28,6 +30,15 @@ BlocPoint::BlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *fat
     (*it)->setFather(this);
 }
 
+void BlocPoint::getOutPoint(AbstractPoint *node)
+{
+  std::list<AbstractPoint *>::iterator it(std::find(_nodes.begin(),_nodes.end(),node));
+  if(it==_nodes.end())
+    throw YACS::Exception("BlocPoint::getOutPoint : node not in this !");
+  _nodes.erase(it);
+  node->setFather(NULL);
+}
+
 AbstractPoint *BlocPoint::findPointWithNode(Node *node)
 {
   for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
index eea6b92670664bac64ef4c2c3390db38bf218806..c75f8ef486c93ef566e31f0e878d36125341a392 100644 (file)
@@ -42,6 +42,8 @@ namespace YACS
       int getNumberOfNodes() const;
       const std::list<AbstractPoint *>& getListOfPoints() const { return _nodes; }
       virtual ~BlocPoint();
+    protected:
+      void getOutPoint(AbstractPoint *node);
     };
   }
 }
diff --git a/src/engine/Bloc_impl.cxx b/src/engine/Bloc_impl.cxx
new file mode 100644 (file)
index 0000000..d3f3c6f
--- /dev/null
@@ -0,0 +1,108 @@
+// Copyright (C) 2006-2016  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 "Bloc.hxx"
+#include "Proc.hxx"
+#include "Visitor.hxx"
+#include "ForEachLoop.hxx"
+#include "InlineNode.hxx"
+#include "HomogeneousPoolContainer.hxx"
+
+using namespace YACS::ENGINE;
+
+void Bloc::fitToPlayGround(const PlayGround *pg)
+{
+  static const char MSG[]="Bloc::fitToPlayGround : Not implemented yet for this type of node !";
+  class MyVisitor : public Visitor
+    {
+    public:
+      MyVisitor(ComposedNode *root):Visitor(root),_lev(0),_max_lev(0) { }
+      void visitBloc(Bloc *node) { node->ComposedNode::accept(this); }
+      void visitElementaryNode(ElementaryNode *node) { }
+      void visitForEachLoop(ForEachLoop *node)
+      {
+        _max_lev=std::max(_max_lev,_lev);
+        {
+          _lev++;
+          node->ComposedNode::accept(this);
+          _lev--;
+        }
+        node->edGetNbOfBranchesPort()->edInit(1);
+        if(_lev==_max_lev)
+          {
+          _fes.push_back(node);// locate all leaves ForEach
+          }
+        if(_lev==0)
+          _max_lev=0;
+        }
+      void visitOptimizerLoop(OptimizerLoop *node) { throw YACS::Exception(MSG); }
+      void visitDynParaLoop(DynParaLoop *node) { throw YACS::Exception(MSG); }
+      void visitForLoop(ForLoop *node) { throw YACS::Exception(MSG); }
+      void visitInlineNode(InlineNode *node)
+      {
+          Container *cont(node->getContainer());
+          HomogeneousPoolContainer *cont2(dynamic_cast<HomogeneousPoolContainer *>(cont));
+          if(!cont2)
+            return ;
+          _cont.push_back(cont2);
+          HomogeneousPoolContainer *cont3(cont2->getDirectFather());
+          if(cont3)
+            _cont2.insert(cont3);
+      }
+      void visitInlineFuncNode(InlineFuncNode *node) { throw YACS::Exception(MSG); }
+      void visitLoop(Loop *node) { throw YACS::Exception(MSG); }
+      void visitProc(Proc *node) { node->ComposedNode::accept(this); }
+      void visitServiceNode(ServiceNode *node) { throw YACS::Exception(MSG); }
+      void visitServerNode(ServerNode *node) { throw YACS::Exception(MSG); }
+      void visitServiceInlineNode(ServiceInlineNode *node) { throw YACS::Exception(MSG); }
+      void visitSwitch(Switch *node) { throw YACS::Exception(MSG); }
+      void visitWhileLoop(WhileLoop *node) { throw YACS::Exception(MSG); }
+      void visitPresetNode(DataNode *node) { throw YACS::Exception(MSG); }
+      void visitOutNode(DataNode *node) { throw YACS::Exception(MSG); }
+      void visitStudyInNode(DataNode *node) { throw YACS::Exception(MSG); }
+      void visitStudyOutNode(DataNode *node) { throw YACS::Exception(MSG); }
+    public:
+      std::list<ForEachLoop *> _fes;
+      std::list< HomogeneousPoolContainer *> _cont;
+      std::set< HomogeneousPoolContainer * > _cont2;
+      int _lev;
+      int _max_lev;
+  };
+  YACS::BASES::AutoRefCnt<PartDefinition> pd(new AllPartDefinition(pg,1));
+  std::map<ComposedNode *,YACS::BASES::AutoRefCnt<PartDefinition> > zeMap;
+  this->partitionRegardingDPL(pd,zeMap);
+  MyVisitor vis(this);
+  this->accept(&vis);
+  for(std::list<ForEachLoop *>::const_iterator it=vis._fes.begin();it!=vis._fes.end();it++)
+    {
+      std::map<ComposedNode *,YACS::BASES::AutoRefCnt<PartDefinition> >::iterator it2(zeMap.find(*it));
+      if(it2==zeMap.end())
+        throw YACS::Exception("Bloc::fitToPlayGround : internal error !");
+      int maxLev((*it)->getExecNode()->getMaxLevelOfParallelism());
+      int a((*it2).second->getNumberOfCoresConsumed());
+      int res(a/maxLev);
+      if(a%maxLev!=0)
+        res++;
+      (*it)->edGetNbOfBranchesPort()->edInit(res);
+    }
+  for(std::set< HomogeneousPoolContainer * >::const_iterator it=vis._cont2.begin();it!=vis._cont2.end();it++)
+    (*it)->setSizeOfPool(pg->getNumberOfWorkers((*it)->getNumberOfCoresPerWorker()));
+  for(std::list< HomogeneousPoolContainer *>::const_iterator it=vis._cont.begin();it!=vis._cont.end();it++)
+    (*it)->prepareMaskForExecution();
+}
index 9c6d3fbcfc51deb1fe46aa9f48f2519cf22216f8..b1f43ff38dbd73d31643641fb72d9fafbb3e363f 100644 (file)
@@ -106,6 +106,7 @@ SET(YACSlibEngine_HEADERS
   LinkedBlocPoint.hxx
   ElementaryPoint.hxx
   SetOfPoints.hxx
+  PlayGround.hxx
   )
 
 # --- sources ---
@@ -142,6 +143,7 @@ SET(YACSlibEngine_SOURCES
   ServiceInlineNode.cxx
   StaticDefinedComposedNode.cxx
   Bloc.cxx
+  Bloc_impl.cxx
   Proc.cxx
   Loop.cxx
   ForLoop.cxx
@@ -178,6 +180,7 @@ SET(YACSlibEngine_SOURCES
   LinkedBlocPoint.cxx
   ElementaryPoint.cxx
   SetOfPoints.cxx
+  PlayGround.cxx
   )
 SET(YACSlibEngine_HEADERS ${YACSlibEngine_HEADERS} PARENT_SCOPE)  # Make it visible to src/engine_swig to handle dependencies
 
index 73f32524e34f696184ffa3711aae3240df429b41..8f5b6edcf59a75c7f330c3b16fef106a1f578fc3 100644 (file)
@@ -72,7 +72,7 @@ namespace YACS
       virtual std::map<std::string,std::string> getProperties() const = 0;
       virtual std::map<std::string,std::string> getResourceProperties(const std::string& name) const = 0;
       virtual void setProperties(const std::map<std::string,std::string>& properties);
-      std::string getName() const { return _name; }
+      virtual std::string getName() const { return _name; }
       //! \b WARNING ! name is used in edition to identify different containers, it is not the runtime name of the container
       void setName(std::string name) { _name = name; }
       void setProc(Proc* proc) { _proc = proc; }
index cca32828ba0ac1aaf2709accbc8a631a5895b0a8..632f72478c50835cdd4f4188feb26c10e77e8a9f 100644 (file)
@@ -44,7 +44,7 @@ const char DynParaLoop::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
 DynParaLoop::DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted)
   : ComposedNode(name),_node(0),_initNode(0),_finalizeNode(0),_nbOfEltConsumed(0),
     _nbOfBranches(NAME_OF_NUMBER_OF_BRANCHES,this,Runtime::_tc_int),
-    _splittedPort(NAME_OF_SPLITTED_SEQ_OUT,this,typeOfDataSplitted),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0)
+    _splittedPort(NAME_OF_SPLITTED_SEQ_OUT,this,typeOfDataSplitted),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(1.)
 {
 }
 
@@ -58,7 +58,7 @@ DynParaLoop::~DynParaLoop()
 DynParaLoop::DynParaLoop(const DynParaLoop& other, ComposedNode *father, bool editionOnly)
   : ComposedNode(other,father), _nbOfBranches(other._nbOfBranches,this),
     _splittedPort(other._splittedPort,this), _node(0), _initNode(0), _finalizeNode(0),
-    _nbOfEltConsumed(0),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0)
+    _nbOfEltConsumed(0),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(1.)
 {
   if(other._node)
     _node=other._node->clone(this,editionOnly);
@@ -423,6 +423,13 @@ DynParaLoop::TypeOfNode DynParaLoop::getIdentityOfNotifyerNode(const Node *node,
       return FINALIZE_NODE;
 }
 
+void DynParaLoop::setWeight(double newVal)
+{
+  if(newVal<=0.)
+    throw Exception("DynParaLoop::setWeight : invalid input value !");
+  _weight=newVal;
+}
+
 bool DynParaLoop::isMultiplicitySpecified(unsigned& value) const
 {
   if(_nbOfBranches.edIsManuallyInitialized())
@@ -896,6 +903,14 @@ int DynParaLoop::getMaxLevelOfParallelism() const
   return _nbOfBranches.getIntValue() * _node->getMaxLevelOfParallelism();
 }
 
+void DynParaLoop::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  YACS::BASES::AutoRefCnt<PartDefinition> pd2(pd->copy());
+  zeMap[this]=pd2;
+  if(_node)
+    _node->partitionRegardingDPL(pd,zeMap);
+}
+
 void DynParaLoop::shutdown(int level)
 {
   if(level==0)return;
index c00a5e8c599b312701831277f9c09bbcbeafe25e..723b27e2ec43aeab81b29ccf62131d5512e9a11f 100644 (file)
@@ -57,6 +57,7 @@ namespace YACS
       int _initializingCounter;
       int _unfinishedCounter;
       int _failedCounter;
+      double _weight;
     protected:
       static const char NAME_OF_SPLITTED_SEQ_OUT[];
       static const char OLD_NAME_OF_SPLITTED_SEQ_OUT[];
@@ -97,6 +98,9 @@ namespace YACS
       Node *getChildByShortName(const std::string& name) const throw(Exception);
       Node *getChildByNameExec(const std::string& name, unsigned id) const throw(Exception);
       std::vector<Node *> getNodes() const { return _execNodes; } // need to use in GUI part for adding observers for clone nodes
+      double getWeight() const { return _weight; }
+      void setWeight(double newVal);
+      double getWeightRegardingDPL() const { return getWeight(); }
       bool isMultiplicitySpecified(unsigned& value) const;
       void forceMultiplicity(unsigned value);
       virtual void checkBasicConsistency() const throw(Exception);
@@ -106,6 +110,7 @@ namespace YACS
       Node * getExecNode();
       Node * getFinalizeNode();
       int getMaxLevelOfParallelism() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
     protected:
       void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
       void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
index 5544c86fbbac52299d09242cd22180214d46a63d..d2561e804f9335d7c5fa6a7ff8302b73f0f7e47e 100644 (file)
@@ -107,7 +107,9 @@ namespace YACS
       virtual void ensureLoading();
 
       int getMaxLevelOfParallelism() const { return 1; }
-
+      double getWeightRegardingDPL() const { return 0.; }
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) { }
+      
       //run part
       void begin();
       bool isReady();
index f476c20e4731d1cb57a29b6f45fad88a46ba53ed..aeef403b426173094037f4619f71196877483d75 100644 (file)
@@ -59,6 +59,16 @@ int ElementaryPoint::getMaxLevelOfParallelism() const
   return _node->getMaxLevelOfParallelism();
 }
 
+double ElementaryPoint::getWeightRegardingDPL() const
+{
+  return _node->getWeightRegardingDPL();
+}
+
+void ElementaryPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
+{
+  _node->partitionRegardingDPL(pd,zeMap);
+}
+
 std::string ElementaryPoint::getRepr() const
 {
   return _node->getName();
index 5228dd5e49f01849917ddbb03550cce08269755b..08897e80afcdee7b98e6a0ba89a01ac09f6ad0da 100644 (file)
@@ -43,6 +43,8 @@ namespace YACS
       Node *getLastNode();
       int getNumberOfNodes() const;
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const;
       std::string getRepr() const;
       virtual ~ElementaryPoint();
     };
index fd7271cd038d62a00e18ec5b909e36ad156120e5..79d30fe6587729443d8034aab193ff925f5de3ac 100644 (file)
@@ -54,6 +54,52 @@ int ForkBlocPoint::getMaxLevelOfParallelism() const
   return ret;
 }
 
+double ForkBlocPoint::getWeightRegardingDPL() const
+{
+  double ret(0.);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    ret+=(*it)->getWeightRegardingDPL();
+  return ret;
+}
+
+void ForkBlocPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
+{
+  std::vector< std::pair<const PartDefinition *,double> > parts,parts2;
+  std::vector<std::size_t> v,v2;
+  std::size_t ii(0);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
+    {
+      double w((*it)->getWeightRegardingDPL());
+      if(w!=0.)
+        {
+          parts.push_back(std::pair<const PartDefinition *,double >(pd,w));
+          v.push_back(ii);
+        }
+      else
+        {
+          parts2.push_back(std::pair<const PartDefinition *,double >(pd,1.));
+          v2.push_back(ii);
+        }
+    }
+  std::vector<AbstractPoint *> nodes2(_nodes.begin(),_nodes.end());
+  if(!parts.empty())
+    {
+      const PlayGround *pg(pd->getPlayGround());
+      std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > pds(pg->partition(parts));
+      ii=0;
+      for(std::vector<std::size_t>::const_iterator iter=v.begin();iter!=v.end();iter++,ii++)
+        nodes2[*iter]->partitionRegardingDPL(pds[ii],zeMap);
+    }
+  if(!parts2.empty())
+    {
+      const PlayGround *pg(pd->getPlayGround());
+      std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > pds(pg->partition(parts2));
+      ii=0;
+      for(std::vector<std::size_t>::const_iterator iter=v2.begin();iter!=v2.end();iter++,ii++)
+        nodes2[*iter]->partitionRegardingDPL(pds[ii],zeMap);
+    }
+}
+
 std::string ForkBlocPoint::getRepr() const
 {
   std::size_t sz(_nodes.size()),ii(0);
index 97afd34e7c9789a9cd2573d5177e320ae19f0acc..0aa3fbf178b05c31cf0f5dfd94ec132a77e6cd3d 100644 (file)
@@ -34,6 +34,8 @@ namespace YACS
       Node *getFirstNode();
       Node *getLastNode();
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const;
       std::string getRepr() const;
       virtual ~ForkBlocPoint();
     };
index fbc0c3fb4081b2c5161f4fc64a324e8852706d31..641a0d32014d641fe7d317c6bbd79e36e76b1aab 100644 (file)
@@ -23,6 +23,7 @@
 #include "YACSlibEngineExport.hxx"
 #include "Exception.hxx"
 #include "Container.hxx"
+#include "PlayGround.hxx"
 
 #include <vector>
 
@@ -30,6 +31,8 @@ namespace YACS
 {
   namespace ENGINE
   {
+    class ForTestOmlyHPContCls;
+    
     /*!
      * 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.
@@ -47,6 +50,12 @@ namespace YACS
       virtual std::size_t getNumberOfFreePlace() const = 0;
       virtual void allocateFor(const std::vector<const Task *>& nodes) = 0;
       virtual void release(const Task *node) = 0;
+      virtual YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd) = 0;
+      virtual HomogeneousPoolContainer *getDirectFather() = 0;
+      virtual const HomogeneousPoolContainer *getDirectFather() const = 0;
+      virtual int getNumberOfCoresPerWorker() const = 0;
+      virtual void prepareMaskForExecution() const = 0;
+      virtual void forYourTestsOnly(ForTestOmlyHPContCls *data) const = 0;
       static const char SIZE_OF_POOL_KEY[];
       static const char INITIALIZE_SCRIPT_KEY[];
     protected:
index 213d74cee69e724ad7e29afd8227df568f4741e9..ce696f61805937e7fe9fdd35fb747a4372a4ac94 100644 (file)
@@ -20,6 +20,7 @@
 #include "InlineNode.hxx"
 #include "Visitor.hxx"
 #include "Container.hxx"
+#include "HomogeneousPoolContainer.hxx"
 #include <iostream>
 
 #define _DEVDEBUG_
@@ -156,3 +157,17 @@ int InlineNode::getMaxLevelOfParallelism() const
   return ret;
 }
 
+void InlineNode::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  if(!isDeployable())
+    return ;
+  if(!_container)
+    return ;
+  HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(_container));
+  if(!contC)
+    return ;
+  YACS::BASES::AutoConstRefCnt<PartDefinition> zePd;
+  zePd.takeRef(pd);
+  YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> zeCont(contC->decorate(zePd));
+  setContainer(zeCont);
+}
index cd63a222a1fcca4625a25fc9d571a2b0b433e9b1..c97af1c0df351a9fee56566cb1280a82af75afd0 100644 (file)
@@ -68,6 +68,7 @@ namespace YACS
       void performShallowDuplicationOfPlacement(const Node& other);
       bool isDeployable() const;
       int getMaxLevelOfParallelism() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
     public:
       static const char LOCAL_STR[];
       static const char REMOTE_STR[];
index 49f97a1c2965439fa6239e16357e3f06a0adeda1..666f757e5bbdbd809662c9b1e4ef7a829f2ce4b5 100644 (file)
@@ -48,6 +48,20 @@ int LinkedBlocPoint::getMaxLevelOfParallelism() const
   return ret;
 }
 
+double LinkedBlocPoint::getWeightRegardingDPL() const
+{
+  double ret(0.);
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    ret=std::max(ret,(*it)->getWeightRegardingDPL());
+  return ret;
+}
+
+void LinkedBlocPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
+{
+  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
+    (*it)->partitionRegardingDPL(pd,zeMap);
+}
+
 std::string LinkedBlocPoint::getRepr() const
 {
   std::size_t sz(_nodes.size()),ii(0);
index c56a4b04a907e124c4fa38c0c2ac33505ec0cfae..963ca24e02fb4515792ea9baf6d932de65bee3cd 100644 (file)
@@ -36,6 +36,8 @@ namespace YACS
       Node *getFirstNode();
       Node *getLastNode();
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const;
       std::string getRepr() const;
       virtual ~LinkedBlocPoint();
     };
index 53e6ff284811fcd1244c418defcb94e6a05c7ed9..cc4f089f96cb4f26f298f8d3ec891b39feedca7b 100644 (file)
@@ -419,6 +419,19 @@ int Loop::getMaxLevelOfParallelism() const
   return _node->getMaxLevelOfParallelism();
 }
 
+double Loop::getWeightRegardingDPL() const
+{
+  if(!_node)
+    return 0.;
+  return _node->getWeightRegardingDPL();
+}
+
+void Loop::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  if(_node)
+    _node->partitionRegardingDPL(pd,zeMap);
+}
+
 Node *Loop::getChildByShortName(const std::string& name) const throw(YACS::Exception)
 {
   if (_node)
index dbe320cbe676194764f8104a7ac0a37792e74b94..a1f533af060104aa9bb84297bc7052cc9fd0a2b8 100644 (file)
@@ -173,6 +173,8 @@ namespace YACS
       std::list<InputPort *> getSetOfInputPort() const;
       int getNumberOfInputPorts() const;
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
       Node *getChildByShortName(const std::string& name) const throw(Exception);
       static TypeCode* MappingDF2DS(TypeCode* type) throw(Exception);
       static TypeCode* MappingDS2DF(TypeCode* type) throw(Exception);
index 0c633c86e549b1c87703e0362cd851d45e0eee85..aaa4ed21f164ffb3c01f89047f4bd193845918a5 100644 (file)
@@ -408,6 +408,22 @@ const Proc * Node::getProc() const
   return _father->getProc();
 }
 
+DynParaLoop *Node::getClosestDPLAmongAncestors() const
+{
+  if(!_father)
+    return NULL;
+  ComposedNode *iter(_father);
+  do
+    {
+      DynParaLoop *iter2(dynamic_cast<DynParaLoop *>(iter));
+      if(iter2)
+        return iter2;
+      iter=iter->_father;
+    }
+  while(iter);
+  return NULL;
+}
+
 ComposedNode *Node::getRootNode() const throw(YACS::Exception)
 {
   if(!_father)
index f7d4623940dc2f0449b62939f69bdb5bbde0a36a..f379204821a7677a3385eca4e2ad5619a28bc625 100644 (file)
@@ -21,6 +21,8 @@
 #define __NODE_HXX__
 
 #include "YACSlibEngineExport.hxx"
+#include "PlayGround.hxx"
+#include "AutoRefCnt.hxx"
 #include "InGate.hxx"
 #include "OutGate.hxx"
 #include "Exception.hxx"
@@ -42,8 +44,8 @@ namespace YACS
     class InputPort;
     class OutputPort;
     class InPropertyPort;
-    class DynParaLoop;
     class ForEachLoop;
+    class DynParaLoop;
     class ComposedNode;
     class Proc;
     class ElementaryNode;
@@ -161,6 +163,7 @@ namespace YACS
       bool operator>(const Node& other) const;
       bool operator<(const Node& other) const;
       std::string getImplementation() const;
+      DynParaLoop *getClosestDPLAmongAncestors() const;
       virtual ComposedNode *getRootNode() const throw(Exception);
       virtual void setProperty(const std::string& name,const std::string& value);
       virtual std::string getProperty(const std::string& name);
@@ -172,6 +175,8 @@ namespace YACS
       virtual const Proc *getProc() const;
       virtual void accept(Visitor *visitor) = 0;
       virtual int getMaxLevelOfParallelism() const = 0;
+      virtual double getWeightRegardingDPL() const = 0;
+      virtual void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) = 0;
       std::string getQualifiedName() const;
       int getNumId();
       std::vector<std::pair<std::string,int> > getDPLScopeInfo(ComposedNode *gfn);
diff --git a/src/engine/PlayGround.cxx b/src/engine/PlayGround.cxx
new file mode 100644 (file)
index 0000000..bc96d9b
--- /dev/null
@@ -0,0 +1,635 @@
+// Copyright (C) 2006-2017  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 "PlayGround.hxx"
+#include "Runtime.hxx"
+
+#include <set>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <numeric>
+#include <algorithm>
+
+using namespace YACS::ENGINE;
+
+std::string PlayGround::printSelf() const
+{
+  std::ostringstream oss;
+  std::size_t sz(0);
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+    sz=std::max(sz,(*it).first.length());
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+    {
+      oss << " - " << std::setw(10) << (*it).first << " : " << (*it).second << std::endl;
+    }
+  return oss.str();
+}
+
+void PlayGround::loadFromKernelCatalog()
+{
+  Runtime *r(getRuntime());
+  if(!r)
+    throw Exception("PlayGround::loadFromKernelCatalog : no runtime  !");
+  std::vector< std::pair<std::string,int> > data(r->getCatalogOfComputeNodes());
+  setData(data);
+}
+
+void PlayGround::setData(const std::vector< std::pair<std::string,int> >& defOfRes)
+{
+  _data=defOfRes;
+  checkCoherentInfo();
+}
+
+int PlayGround::getNumberOfCoresAvailable() const
+{
+  int ret(0);
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+    ret+=(*it).second;
+  return ret;
+}
+
+int PlayGround::getMaxNumberOfContainersCanBeHostedWithoutOverlap(int nbCoresPerCont) const
+{
+  if(nbCoresPerCont<1)
+    throw Exception("PlayGround::getMaxNumberOfContainersCanBeHostedWithoutOverlap : invalid nbCoresPerCont. Must be >=1 !");
+  int ret(0);
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+    ret+=(*it).second/nbCoresPerCont;
+  return ret;
+}
+
+std::vector<int> PlayGround::computeOffsets() const
+{
+  std::size_t sz(_data.size()),i(0);
+  std::vector<int> ret(sz+1); ret[0]=0;
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++,i++)
+    ret[i+1]=ret[i]+(*it).second;
+  return ret;
+}
+
+void PlayGround::checkCoherentInfo() const
+{
+  std::set<std::string> s;
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+    {
+      s.insert((*it).first);
+      if((*it).second<0)
+        throw Exception("Presence of negative int value !");
+    }
+  if(s.size()!=_data.size())
+    throw Exception("host names entries must be different each other !");
+}
+
+std::vector<bool> PlayGround::FromUItoVB(unsigned int sz, unsigned int v)
+{
+  std::vector<bool> ret(sz);
+  unsigned int p(1);
+  for(std::size_t i=0;i<sz;i++)
+    {
+      ret[i]=p&v;
+      p<<=1;
+    }
+  return ret;
+}
+
+unsigned int PlayGround::FromVBtoUI(const std::vector<bool>& v)
+{
+  std::size_t sz(v.size());
+  unsigned int ret(0);
+  for(std::size_t i=0;i<sz;i++)
+    {
+      if(v[i])
+        ret+=1u<<i;
+    }
+  return ret;
+}
+
+std::vector<int> PlayGround::GetIdsMatching(const std::vector<bool>& bigArr, const std::vector<bool>& pat)
+{
+  std::vector<int> ret;
+  std::size_t szp(pat.size());
+  std::size_t sz(bigArr.size()/szp);
+  for(std::size_t i=0;i<sz;i++)
+    {
+      std::vector<bool> t(bigArr.begin()+i*szp,bigArr.begin()+(i+1)*szp);
+      if(t==pat)
+        ret.push_back(i);
+    }
+  return ret;
+}
+
+std::vector<int> PlayGround::BuildVectOfIdsFromVecBool(const std::vector<bool>& v)
+{
+  std::size_t sz(std::count(v.begin(),v.end(),true)),i(0);
+  std::vector<int> ret(sz);
+  std::vector<bool>::const_iterator it(v.begin());
+  while(i<sz)
+    {
+      it=std::find(it,v.end(),true);
+      ret[i++]=std::distance(v.begin(),it);
+      it++;
+    }
+  return ret;
+}
+
+void PlayGround::highlightOnIds(const std::vector<int>& coreIds, std::vector<bool>& v) const
+{
+  if(v.size()!=getNumberOfCoresAvailable())
+    throw Exception("PlayGround::highlightOnIds : oops ! invalid size !");
+  for(std::vector<int>::const_iterator it=coreIds.begin();it!=coreIds.end();it++)
+    v[*it]=true;
+}
+
+/*! 
+ * you must garantee coherence between PlayGround::deduceMachineFrom, PlayGround::getNumberOfWorkers, and PartDefinition::computeWorkerIdsCovered
+ */
+std::vector<bool> PlayGround::getFetchedCores(int nbCoresPerWorker) const
+{
+  int nbCores(getNumberOfCoresAvailable());
+  std::vector<bool> ret(nbCores,false);
+  if(nbCoresPerWorker==1)
+    std::fill(ret.begin(),ret.end(),true);
+  else
+    {
+      std::size_t posBg(0);
+      for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+        {
+          int nbElemsToPutOn(((*it).second/nbCoresPerWorker)*nbCoresPerWorker);
+          std::fill(ret.begin()+posBg,ret.begin()+posBg+nbElemsToPutOn,true);
+          posBg+=(*it).second;
+        }
+    }
+  return ret;
+}
+/*!
+ * follow getMaxNumberOfContainersCanBeHostedWithoutOverlap method
+ */
+std::vector<std::size_t> PlayGround::getWorkerIdsFullyFetchedBy(int nbCoresPerComp, const std::vector<bool>& coreFlags) const
+{
+  std::size_t posBg(0),posWorker(0);
+  std::vector<std::size_t> ret;
+  for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+    {
+      int nbWorker((*it).second/nbCoresPerComp);
+      for(int j=0;j<nbWorker;j++,posWorker++)
+        {
+          std::vector<bool>::const_iterator it2(std::find(coreFlags.begin()+posBg+j*nbCoresPerComp,coreFlags.begin()+posBg+(j+1)*nbCoresPerComp,false));
+          if(it2==coreFlags.begin()+posBg+(j+1)*nbCoresPerComp)
+            ret.push_back(posWorker);
+        }
+      posBg+=(*it).second;
+    }
+  return ret;
+}
+
+std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > PlayGround::partition(const std::vector< std::pair<const PartDefinition *,double> >& parts) const
+{
+  std::size_t sz(parts.size()),szs(getNumberOfCoresAvailable());
+  if(sz==0)
+    return std::vector< YACS::BASES::AutoRefCnt<PartDefinition> >();
+  if(sz==1)
+    {
+      const PartDefinition *pd(parts[0].first);
+      if(!pd)
+        throw Exception("Presence of null pointer as part def  0 !");
+      YACS::BASES::AutoRefCnt<PartDefinition> ret(pd->copy());
+      std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > ret2(1,ret);
+      return ret2;
+    }
+  if(sz>31)
+    throw Exception("PlayGround::partition : not implemented yet for more than 31 ! You need to pay for it :)");
+  std::vector<bool> zeArr(szs*sz,false);
+  std::size_t i(0);
+  for(std::vector< std::pair<const PartDefinition *,double> >::const_iterator it=parts.begin();it!=parts.end();it++,i++)
+    {
+      const PartDefinition *pd((*it).first);
+      if(!pd)
+        throw Exception("Presence of null pointer as part def !");
+      if(pd->getPlayGround()!=this)
+        throw Exception("Presence of non homogeneous playground !");
+      if((*it).second<=0.)
+        throw Exception("Invalid weight !");
+      std::vector<bool> bs(pd->getCoresOn());
+      for(std::size_t j=0;j<szs;j++)
+        zeArr[j*sz+i]=bs[j];
+    }
+  std::set<unsigned int> ss;
+  for(std::size_t i=0;i<szs;i++)
+    {
+      std::vector<bool> vb(zeArr.begin()+i*sz,zeArr.begin()+(i+1)*sz);
+      ss.insert(FromVBtoUI(vb));
+    }
+  std::vector< std::vector<int> > retIds(sz);
+  for(std::set<unsigned int>::const_iterator i=ss.begin();i!=ss.end();i++)
+    {
+      std::vector<bool> code(FromUItoVB(sz,*i));// for this configuration which parts are considered
+      std::vector<int> locIds(GetIdsMatching(zeArr,code));
+      std::vector<int> partsIds(BuildVectOfIdsFromVecBool(code));
+      if(partsIds.empty())
+        continue;
+      std::vector<double> wg;
+      std::vector<int> nbCores2;
+      for(std::vector<int>::const_iterator it=partsIds.begin();it!=partsIds.end();it++)
+        {
+          wg.push_back(parts[*it].second);
+          nbCores2.push_back(parts[*it].first->getNbCoresPerCompo());
+        }
+      std::vector< std::vector<int> > ress(splitIntoParts(locIds,nbCores2,wg));
+      std::size_t k(0);
+      for(std::vector<int>::const_iterator it=partsIds.begin();it!=partsIds.end();it++,k++)
+        {
+          retIds[*it].insert(retIds[*it].end(),ress[k].begin(),ress[k].end());
+        }
+    }
+  //
+  std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > ret(sz);
+  for(std::size_t i=0;i<sz;i++)
+    {
+      std::set<int> s(retIds[i].begin(),retIds[i].end());
+      std::vector<int> v(s.begin(),s.end());
+      ret[i]=PartDefinition::BuildFrom(this,(parts[i].first)->getNbCoresPerCompo(),v);
+    }
+  return ret;
+}
+
+std::vector<int> sortArr(const std::vector<int>& v)
+{
+  std::multimap<int,int> m;
+  int i(v.size()-1);
+  for(std::vector<int>::const_reverse_iterator it=v.rbegin();it!=v.rend();it++)
+    m.insert(std::pair<int,int>(*it,i--));
+  std::vector<int> ret(m.size());
+  i=0;
+  for(std::multimap<int,int>::const_reverse_iterator it=m.rbegin();it!=m.rend();it++)// reverse -> sort from biggest to the finest
+    ret[i++]=(*it).second;
+  return ret;
+}
+
+std::vector< std::vector<int> > PlayGround::splitIntoParts(const std::vector<int>& coreIds, const std::vector<int>& nbCoresConso, const std::vector<double>& weights) const
+{
+  double wgs(std::accumulate(weights.begin(),weights.end(),0.));
+  std::size_t sz(nbCoresConso.size());
+  if(sz!=weights.size())
+    throw Exception("PlayGround::splitIntoParts : internal error !");
+  if(sz==0)
+    return std::vector< std::vector<int> >();
+  int totalSpace(coreIds.size());
+  std::vector< std::vector<int> > ret(sz);
+  std::vector<int> fromBigToTiny(sortArr(nbCoresConso));// start to treat the coarse grain to finish with fine grain
+  std::vector<bool> zeArr(getNumberOfCoresAvailable(),false);
+  highlightOnIds(coreIds,zeArr);
+  int nbOfCoresToSplit(coreIds.size());
+  std::size_t ii(fromBigToTiny.size());
+  for(std::vector<int>::const_iterator it=fromBigToTiny.begin();it!=fromBigToTiny.end();it++,ii--)
+    {
+      int maxNbOfCores((int)(totalSpace*weights[*it]/wgs));// now try to find in zeArr at most maxNbOfCores cores
+      ret[*it]=takePlace(maxNbOfCores,nbCoresConso[*it],zeArr,ii==1);
+    }
+  return ret;
+}
+
+std::vector<int> PlayGround::takePlace(int maxNbOfCoresToAlloc, int nbCoresPerShot, std::vector<bool>& distributionOfCores, bool lastOne) const
+{
+  if(maxNbOfCoresToAlloc<1)
+    throw Exception("PlayGround::takePlace : internal error ! no space to alloc !");
+  int tmpMaxNbOfCoresToAlloc(maxNbOfCoresToAlloc);
+  if(lastOne)
+    tmpMaxNbOfCoresToAlloc=std::max(tmpMaxNbOfCoresToAlloc,(int)std::count(distributionOfCores.begin(),distributionOfCores.end(),true));
+  std::vector<int> ret;
+  std::vector<int> offsets(computeOffsets());
+  int nbFullItem(0);
+  std::size_t sz(offsets.size()-1);
+  for(std::size_t i=0;i<sz && tmpMaxNbOfCoresToAlloc>=nbCoresPerShot;i++)
+    {
+      int d(offsets[i+1]-offsets[i]);
+      if(nbCoresPerShot>d)
+        continue;
+      std::vector<bool> target(nbCoresPerShot,true);
+      for(int j=0;j<=d-nbCoresPerShot && tmpMaxNbOfCoresToAlloc>=nbCoresPerShot;)
+        {
+          std::vector<bool> t(distributionOfCores.begin()+offsets[i]+j,distributionOfCores.begin()+offsets[i]+j+nbCoresPerShot);
+          if(t==target)
+            {
+              nbFullItem++;
+              tmpMaxNbOfCoresToAlloc-=nbCoresPerShot;
+              std::fill(distributionOfCores.begin()+offsets[i]+j,distributionOfCores.begin()+offsets[i]+j+nbCoresPerShot,false);
+              for(int k=offsets[i]+j;k<offsets[i]+j+nbCoresPerShot;k++)
+                ret.push_back(k);
+              j+=nbCoresPerShot;
+            }
+          else
+            j++;
+        }
+    }
+  if(nbFullItem>0)
+    return ret;
+  if(nbCoresPerShot<=1)
+    throw Exception("PlayGround::takePlace : internal error !");
+  // not enough contiguous place. Find the first wider contiguous place
+  for(int kk=std::min(nbCoresPerShot-1,tmpMaxNbOfCoresToAlloc);kk>=1;kk--)
+    {
+      for(std::size_t i=0;i<sz && tmpMaxNbOfCoresToAlloc>=kk;i++)
+        {
+          int d(offsets[i+1]-offsets[i]);
+          if(kk>d)
+            continue;
+          std::vector<bool> target(kk,true);
+          for(int j=0;j<=d-kk && tmpMaxNbOfCoresToAlloc>=kk;)
+            {
+              std::vector<bool> t(distributionOfCores.begin()+offsets[i]+j,distributionOfCores.begin()+offsets[i]+j+kk);
+              if(t==target)
+                {
+                  nbFullItem++;
+                  tmpMaxNbOfCoresToAlloc-=kk;
+                  std::fill(distributionOfCores.begin()+offsets[i]+j,distributionOfCores.begin()+offsets[i]+j+kk,false);
+                  for(int k=offsets[i]+j;k<offsets[i]+j+kk;k++)
+                    ret.push_back(k);
+                  return ret;
+                }
+              else
+                j++;
+            }
+        }
+    }
+  throw Exception("PlayGround::takePlace : internal error ! All cores are occupied !");
+}
+
+int PlayGround::fromWorkerIdToResId(int workerId, int nbProcPerNode) const
+{
+  std::size_t sz2(_data.size());
+  std::vector<int> deltas(sz2+1); deltas[0]=0;
+  for(std::size_t i=0;i<sz2;i++)
+    deltas[i+1]=deltas[i]+(_data[i].second)/nbProcPerNode;
+  int zePos(0);
+  while(zePos<sz2 && (workerId<deltas[zePos] || workerId>=deltas[zePos+1]))
+    zePos++;
+  if(zePos==sz2)
+    zePos=workerId%sz2;
+  return zePos;
+}
+
+/*! 
+ * you must garantee coherence between PlayGround::deduceMachineFrom, PlayGround::getNumberOfWorkers, and PartDefinition::computeWorkerIdsCovered
+ */
+std::string PlayGround::deduceMachineFrom(int workerId, int nbProcPerNode) const
+{
+  int zePos(fromWorkerIdToResId(workerId,nbProcPerNode));
+  return _data[zePos].first;
+}
+
+/*! 
+ * you must garantee coherence between PlayGround::deduceMachineFrom, PlayGround::getNumberOfWorkers, PlayGround::getFetchedCores and PartDefinition::computeWorkerIdsCovered
+ */
+int PlayGround::getNumberOfWorkers(int nbCoresPerWorker) const
+{
+  return getMaxNumberOfContainersCanBeHostedWithoutOverlap(nbCoresPerWorker);
+}
+
+PlayGround::~PlayGround()
+{
+}
+
+//////////////////////
+
+PartDefinition::PartDefinition(const PlayGround *pg, int nbOfCoresPerComp):_nbOfCoresPerComp(nbOfCoresPerComp)
+{
+  _pg.takeRef(pg);
+}
+
+PartDefinition::PartDefinition(const PartDefinition& other):_pg(other._pg),_nbOfCoresPerComp(other._nbOfCoresPerComp)
+{
+}
+
+PartDefinition::~PartDefinition()
+{
+}
+
+std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > PartDefinition::partition(const std::vector< double >& wgs) const
+{
+  std::size_t sz(wgs.size());
+  std::vector< std::pair<const PartDefinition *,double> > elts(sz);
+  for(std::size_t i=0;i<sz;i++)
+    elts[i]=std::pair<const PartDefinition *,double>(this,wgs[i]);
+  return getPlayGround()->partition(elts);
+}
+
+YACS::BASES::AutoRefCnt<PartDefinition> PartDefinition::BuildFrom(const PlayGround *pg, int nbOfCoresPerComp, const std::vector<int>& coreIds)
+{
+  int spaceSz(pg->getNumberOfCoresAvailable()),sz(coreIds.size());
+  if(sz>spaceSz)
+    throw Exception("PartDefinition::BuildFrom : error 1 !");
+  if(sz==0)
+    throw Exception("PartDefinition::BuildFrom : error 2 !");
+  int zeStart(coreIds.front()),zeEnd(coreIds.back());
+  if(zeStart<0 || zeEnd<zeStart)
+    throw Exception("PartDefinition::BuildFrom : error ! The content of core Ids is not OK !");
+  for(std::size_t i=0;i<sz-1;i++)
+    if(coreIds[i+1]<coreIds[i])
+      throw Exception("PartDefinition::BuildFrom : error ! The content of core Ids is not OK 2 !");
+  if(zeEnd-zeStart+1!=sz)
+    {
+      YACS::BASES::AutoRefCnt<PartDefinition> pd(new NonContigPartDefinition(pg,nbOfCoresPerComp,coreIds));
+      return pd;
+    }
+  if(sz==spaceSz)
+    {
+      YACS::BASES::AutoRefCnt<PartDefinition> pd(new AllPartDefinition(pg,nbOfCoresPerComp));
+      return pd;
+    }
+  YACS::BASES::AutoRefCnt<PartDefinition> pd(new ContigPartDefinition(pg,nbOfCoresPerComp,zeStart,zeEnd+1));
+  return pd;
+}
+
+void PartDefinition::stashPart(int nbCoresStashed, double weightOfRemain, YACS::BASES::AutoRefCnt<PartDefinition>& pdStashed, YACS::BASES::AutoRefCnt<PartDefinition>& pdRemain) const
+{
+  if(nbCoresStashed<=0)
+    throw Exception("stashPart : Invalid nbCoresStashed value !");
+  if(weightOfRemain<=0.)
+    throw Exception("stashPart : Invalid weight !");
+  std::vector<bool> coresOn(getCoresOn());
+  int nbCoresAvailable(std::count(coresOn.begin(),coresOn.end(),true));
+  std::vector<int> ids(PlayGround::BuildVectOfIdsFromVecBool(coresOn));
+  if(nbCoresAvailable==0)
+    throw Exception("PartDefinition::stashPart : no available cores !");
+  if(nbCoresAvailable<=nbCoresStashed)
+    {
+      int n0((int)(1./(1.+weightOfRemain)*nbCoresAvailable)); n0=std::max(n0,1);
+      int n1(nbCoresAvailable-n0);
+      if(n1<=0)
+        {
+          pdStashed=PartDefinition::BuildFrom(getPlayGround(),1,ids);
+          pdRemain=PartDefinition::BuildFrom(getPlayGround(),1,ids);
+        }
+      else
+        {
+          std::vector<int> ids0(ids.begin(),ids.begin()+n0),ids1(ids.begin()+n0,ids.end());
+          pdStashed=PartDefinition::BuildFrom(getPlayGround(),1,ids0);
+          pdRemain=PartDefinition::BuildFrom(getPlayGround(),1,ids1);
+        }
+    }
+  else
+    {
+      std::vector<int> ids0(ids.begin(),ids.begin()+nbCoresStashed),ids1(ids.begin()+nbCoresStashed,ids.end());
+      pdStashed=PartDefinition::BuildFrom(getPlayGround(),1,ids0);
+      pdRemain=PartDefinition::BuildFrom(getPlayGround(),1,ids1);
+    }
+}
+
+/*! 
+ * you must garantee coherence between PlayGround::deduceMachineFrom, PlayGround::getNumberOfWorkers, and PartDefinition::computeWorkerIdsCovered
+ */
+std::vector<std::size_t> PartDefinition::computeWorkerIdsCovered(int nbCoresPerComp) const
+{
+  std::vector<bool> coresOn(getCoresOn());
+  return _pg->getWorkerIdsFullyFetchedBy(nbCoresPerComp,coresOn);
+}
+
+//////////////////////
+
+ContigPartDefinition::ContigPartDefinition(const PlayGround *pg, int nbOfCoresPerComp, int zeStart, int zeStop):PartDefinition(pg,nbOfCoresPerComp),_start(zeStart),_stop(zeStop)
+{
+  if(_start<0 || _stop<_start || _stop>getSpaceSize())
+    throw Exception("ContigPartDefinition constructor : Invalid input values");
+}
+
+ContigPartDefinition::ContigPartDefinition(const ContigPartDefinition& other):PartDefinition(other),_start(other._start),_stop(other._stop)
+{
+}
+
+std::string ContigPartDefinition::printSelf() const
+{
+  std::ostringstream oss;
+  oss << "Contiguous : start=" << _start << " stop=" << _stop;
+  return oss.str();
+}
+
+std::vector<bool> ContigPartDefinition::getCoresOn() const
+{
+  std::vector<bool> ret(getSpaceSize(),false);
+  for(int i=_start;i<_stop;i++)
+    ret[i]=true;
+  return ret;
+}
+
+ContigPartDefinition *ContigPartDefinition::copy() const
+{
+  return new ContigPartDefinition(*this);
+}
+
+int ContigPartDefinition::getNumberOfCoresConsumed() const
+{
+  return _stop-_start;
+}
+
+//////////////////////
+
+NonContigPartDefinition::NonContigPartDefinition(const PlayGround *pg, int nbOfCoresPerComp, const std::vector<int>& ids):PartDefinition(pg,nbOfCoresPerComp),_ids(ids)
+{
+  checkOKIds();
+}
+
+NonContigPartDefinition::NonContigPartDefinition(const ContigPartDefinition& other):PartDefinition(other)
+{
+}
+
+std::string NonContigPartDefinition::printSelf() const
+{
+  std::ostringstream oss;
+  oss << "Non contiguous : ";
+  for(std::vector<int>::const_iterator it=_ids.begin();it!=_ids.end();it++)
+    oss << *it << ", ";
+  return oss.str();
+}
+
+std::vector<bool> NonContigPartDefinition::getCoresOn() const
+{
+  std::vector<bool> ret(getSpaceSize(),false);
+  for(std::vector<int>::const_iterator it=_ids.begin();it!=_ids.end();it++)
+    ret[*it]=true;
+  return ret;
+}
+
+NonContigPartDefinition *NonContigPartDefinition::copy() const
+{
+  return new NonContigPartDefinition(*this);
+}
+
+int NonContigPartDefinition::getNumberOfCoresConsumed() const
+{
+  return _ids.size();
+}
+
+void NonContigPartDefinition::checkOKIds() const
+{
+  int maxVal(getSpaceSize());
+  if(_ids.empty())
+    return;
+  int val(_ids.front());
+  if(val<0 || val>=maxVal)
+    throw Exception("checkOKIds : error 2 !");
+  std::size_t sz(_ids.size());
+  for(std::size_t i=0;i<sz-1;i++)
+    {
+      if(_ids[i+1]<=_ids[i])
+        throw Exception("checkOKIds : error 1 !");
+      if(_ids[i+1]>=maxVal)
+        throw Exception("checkOKIds : error 3 !");
+    }
+}
+
+//////////////////////
+
+AllPartDefinition::AllPartDefinition(const AllPartDefinition& other):PartDefinition(other)
+{
+}
+
+std::string AllPartDefinition::printSelf() const
+{
+  std::ostringstream oss;
+  oss << "All";
+  return oss.str();
+}
+
+std::vector<bool> AllPartDefinition::getCoresOn() const
+{
+  std::vector<bool> ret(getSpaceSize(),true);
+  return ret;
+}
+
+AllPartDefinition *AllPartDefinition::copy() const
+{
+  return new AllPartDefinition(*this);
+}
+
+int AllPartDefinition::getNumberOfCoresConsumed() const
+{
+  return getSpaceSize();
+}
+
+//////////////////////
+ std::vector<int> ForTestOmlyHPContCls::getIDS() const
+ {
+   std::size_t sz(_ids.size());
+   std::vector<int> ret(sz);
+   for(std::size_t i=0;i<sz;i++)
+     ret[i]=_ids[i];
+   return ret;
+ }
diff --git a/src/engine/PlayGround.hxx b/src/engine/PlayGround.hxx
new file mode 100644 (file)
index 0000000..b695e65
--- /dev/null
@@ -0,0 +1,162 @@
+// Copyright (C) 2006-2017  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 __PLAYGROUND_HXX__
+#define __PLAYGROUND_HXX__
+
+#include "YACSlibEngineExport.hxx"
+#include "RefCounter.hxx"
+#include "AutoRefCnt.hxx"
+
+#include <vector>
+#include <string>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class PartDefinition;
+    
+    class YACSLIBENGINE_EXPORT PlayGround : public RefCounter
+    {
+    public:
+      PlayGround(const std::vector< std::pair<std::string,int> >& defOfRes):_data(defOfRes) { checkCoherentInfo(); }
+      PlayGround() { }
+      std::string printSelf() const;
+      void loadFromKernelCatalog();
+      std::vector< std::pair<std::string,int> > getData() const { return _data; }
+      void setData(const std::vector< std::pair<std::string,int> >& defOfRes);
+      int getNumberOfCoresAvailable() const;
+      int getMaxNumberOfContainersCanBeHostedWithoutOverlap(int nbCoresPerCont) const;
+      std::vector<int> computeOffsets() const;
+      std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > partition(const std::vector< std::pair<const PartDefinition *,double> >& parts) const;
+      int fromWorkerIdToResId(int workerId, int nbProcPerNode) const;
+      std::string deduceMachineFrom(int workerId, int nbProcPerNode) const;
+      int getNumberOfWorkers(int nbCoresPerWorker) const;
+      void highlightOnIds(const std::vector<int>& coreIds, std::vector<bool>& v) const;
+      std::vector<bool> getFetchedCores(int nbCoresPerWorker) const;
+      std::vector<std::size_t> getWorkerIdsFullyFetchedBy(int nbCoresPerComp, const std::vector<bool>& coreFlags) const;
+      static std::vector<int> BuildVectOfIdsFromVecBool(const std::vector<bool>& v);
+      static std::vector<int> GetIdsMatching(const std::vector<bool>& bigArr, const std::vector<bool>& pat);
+      static std::vector<bool> FromUItoVB(unsigned int sz, unsigned int v);
+      static unsigned int FromVBtoUI(const std::vector<bool>& v);
+    private:
+      std::vector< std::vector<int> > splitIntoParts(const std::vector<int>& coreIds, const std::vector<int>& nbCoresConso, const std::vector<double>& weights) const;
+      std::vector<int> takePlace(int maxNbOfCoresToAlloc, int nbCoresPerShot, std::vector<bool>& distributionOfCores, bool lastOne=false) const;
+    private:
+      void checkCoherentInfo() const;
+    private:
+      ~PlayGround();
+    private:
+      std::vector< std::pair<std::string,int> > _data;
+    };
+
+    class YACSLIBENGINE_EXPORT PartDefinition : public RefCounter
+    {
+    protected:
+      PartDefinition(const PlayGround *pg, int nbOfCoresPerComp);
+      PartDefinition(const PartDefinition& other);
+      virtual ~PartDefinition();
+    public:
+      std::vector< YACS::BASES::AutoRefCnt<PartDefinition> > partition(const std::vector< double >& wgs) const;
+      static YACS::BASES::AutoRefCnt<PartDefinition> BuildFrom(const PlayGround *pg, int nbOfCoresPerComp, const std::vector<int>& coreIds);
+      const PlayGround *getPlayGround() const { return _pg; }
+      int getNbCoresPerCompo() const { return _nbOfCoresPerComp; }
+      void setNbCoresPerCompo(int newNbCores) { _nbOfCoresPerComp=newNbCores; }
+      int getSpaceSize() const { return _pg->getNumberOfCoresAvailable(); }
+      void stashPart(int nbCoresStashed, double weightOfRemain, YACS::BASES::AutoRefCnt<PartDefinition>& pdStashed, YACS::BASES::AutoRefCnt<PartDefinition>& pdRemain) const;
+      std::vector<std::size_t> computeWorkerIdsCovered(int nbCoresPerComp) const;
+      virtual std::string printSelf() const = 0;
+      virtual std::vector<bool> getCoresOn() const = 0;
+      virtual PartDefinition *copy() const = 0;
+      virtual int getNumberOfCoresConsumed() const = 0;
+    private:
+      YACS::BASES::AutoConstRefCnt<PlayGround> _pg;
+      int _nbOfCoresPerComp;
+    };
+
+    class YACSLIBENGINE_EXPORT ContigPartDefinition : public PartDefinition
+    {
+    public:
+      ContigPartDefinition(const PlayGround *pg, int nbOfCoresPerComp, int zeStart, int zeStop);
+      ContigPartDefinition(const ContigPartDefinition& other);
+      std::string printSelf() const;
+      std::vector<bool> getCoresOn() const;
+      int getStart() const { return _start; }
+      int getStop() const { return _stop; }
+      ContigPartDefinition *copy() const;
+      int getNumberOfCoresConsumed() const;
+    private:
+      ~ContigPartDefinition() { }
+    private:
+      int _start;
+      int _stop;
+    };
+
+    class YACSLIBENGINE_EXPORT NonContigPartDefinition : public PartDefinition
+    {
+    public:
+      NonContigPartDefinition(const PlayGround *pg, int nbOfCoresPerComp, const std::vector<int>& ids);
+      NonContigPartDefinition(const ContigPartDefinition& other);
+      std::string printSelf() const;
+      std::vector<bool> getCoresOn() const;
+      std::vector<int> getIDs() const { return _ids; }
+      NonContigPartDefinition *copy() const;
+      int getNumberOfCoresConsumed() const;
+    private:
+      void checkOKIds() const;
+      ~NonContigPartDefinition() { }
+    private:
+      std::vector<int> _ids;
+    };
+      
+    class AllPartDefinition : public PartDefinition
+    {
+    public:
+      AllPartDefinition(const PlayGround *pg, int nbOfCoresPerComp):PartDefinition(pg,nbOfCoresPerComp) { }
+      AllPartDefinition(const AllPartDefinition& other);
+      std::string printSelf() const;
+      std::vector<bool> getCoresOn() const;
+      AllPartDefinition *copy() const;
+      int getNumberOfCoresConsumed() const;
+    private:
+      ~AllPartDefinition() { }
+    };
+
+    class ForTestOmlyHPContCls
+    {
+    public:
+
+#ifndef SWIG
+      void setContainerType(const std::string& ct) { _container_type=ct; }
+      void setPD(YACS::BASES::AutoConstRefCnt<PartDefinition> pd) { _pd=pd; }
+      void setIDS(const std::vector<std::size_t>& ids) { _ids=ids; }
+#endif
+      std::string getContainerType() const { return _container_type; }
+      const PartDefinition *getPD() const { return _pd; }
+      std::vector<int> getIDS() const;
+    private:
+      std::string _container_type;
+      YACS::BASES::AutoConstRefCnt<PartDefinition> _pd;
+      std::vector<std::size_t> _ids;
+    };
+  }
+}
+
+#endif
index 7c4c89279a8b76254df01c2ceceb8feb3562a795..c75e473fea42bb232a33057a902509e67d7e5858 100644 (file)
@@ -45,7 +45,7 @@ void RefCounter::incrRef() const
   _globalMutexForTS.unLock();
 }
 
-bool RefCounter::decrRef()
+bool RefCounter::decrRef() const
 {
   _globalMutexForTS.lock();
 #ifdef REFCNT
index 989911561eca2ba054d7bb90411f549817bb26fe..90401e8c536ce42d9f7c8ea17bd6dd9b1718de95 100644 (file)
@@ -31,7 +31,7 @@ namespace YACS
     public:
       unsigned int getRefCnt() const { return _cnt; }
       void incrRef() const;
-      bool decrRef();
+      bool decrRef() const;
       static unsigned int _totalCnt;
     protected:
       RefCounter();
index 91745b68dfb7c06e9bd46f293fb5b6250d3d45eb..749eaf2321de06ffa86e065b7c48b37c443ee5b2 100644 (file)
@@ -70,7 +70,7 @@ namespace YACS
     public:
       virtual void init() { }
       virtual void fini() { }
-
+      virtual std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const = 0;
       virtual Catalog* loadCatalog(const std::string& sourceKind,const std::string& path);
       virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
       virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
index 148930b5dc2ecdf1a8e9fb69a3ca33fdd5ca200b..e869b88ca2ad2695635005ffceaad6cd76f7527b 100644 (file)
@@ -86,3 +86,18 @@ int SetOfPoints::getMaxLevelOfParallelism() const
 {
   return _bp->getMaxLevelOfParallelism();
 }
+
+double SetOfPoints::getWeightRegardingDPL() const
+{
+  return _bp->getWeightRegardingDPL();
+}
+
+void SetOfPoints::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
+{
+  _bp->partitionRegardingDPL(pd,zeMap);
+}
+
+AbstractPoint *SetOfPoints::getUniqueAndReleaseIt() const
+{
+  return _bp->getUniqueAndReleaseIt();
+}
index b4fd278bf1cf6ea2f295ade85b1700a2c3ecb6bd..d670ff692dc0c697f5335ad7a0e6398a3fc7cfc8 100644 (file)
 #define __SETOFPOINTS_HXX__
 
 #include "YACSlibEngineExport.hxx"
+#include "PlayGround.hxx"
+#include "AutoRefCnt.hxx"
 
+#include <map>
 #include <list>
 #include <string>
 
@@ -32,7 +35,8 @@ namespace YACS
     class Node;
     class BagPoint;
     class AbstractPoint;
-
+    class ComposedNode;
+    
     class YACSLIBENGINE_EXPORT SetOfPoints
     {
     public:
@@ -43,6 +47,9 @@ namespace YACS
       AbstractPoint *findPointWithNode(Node *node);
       const std::list<AbstractPoint *>& getListOfPoints() const;
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const;
+      AbstractPoint *getUniqueAndReleaseIt() const;
     private:
       BagPoint *_bp;
     };
index a65e8425f49ca0d0b1c540a90491ee80a84888ca..5c0b7a2d85cff08f0ad5489a6b2c4ddc82deea6a 100644 (file)
@@ -408,6 +408,20 @@ int Switch::getMaxLevelOfParallelism() const
   return ret;
 }
 
+double Switch::getWeightRegardingDPL() const
+{
+  double ret(0);
+  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+    ret=std::max(ret,((*it).second)->getWeightRegardingDPL());
+  return ret;
+}
+
+void Switch::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+    (*it).second->partitionRegardingDPL(pd,zeMap);
+}
+
 void Switch::edRemoveChild(Node *node) throw(YACS::Exception)
 {
   map< int , Node * >::iterator iter=_mapOfNode.begin();
index 1ae0a3e348ff49b614201ec25a21ba5dbcfcc953..be5b1c16fcb03f78102f8094d0c87ad8d4f555ed 100644 (file)
@@ -116,6 +116,8 @@ namespace YACS
       void writeDot(std::ostream &os) const;
       int getNumberOfInputPorts() const;
       int getMaxLevelOfParallelism() const;
+      double getWeightRegardingDPL() const;
+      void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
       void edRemoveChild(Node *node) throw(Exception);
       std::list<InputPort *> getSetOfInputPort() const;
       std::list<InputPort *> getLocalInputPorts() const;
index 89de9eb035134de094945787129c79c3bc260b02..0c822a2bf89650d48b703e450a78b0b6445c4617 100644 (file)
@@ -34,6 +34,11 @@ void RuntimeForEngineIntegrationTest::setRuntime()
     Runtime::_singleton = new RuntimeForEngineIntegrationTest;
 }
 
+std::vector< std::pair<std::string,int> > RuntimeForEngineIntegrationTest::getCatalogOfComputeNodes() const
+{
+  throw Exception("RuntimeForEngineIntegrationTest not implemented !");
+}
+
 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name) throw (YACS::Exception)
 {
   if (implementation == ToyNode::MY_IMPL_NAME)
index 77ec42bb905aa18c628d52972f2764455c0b5696..cbfdbf1e6f1c761f7d6f6554461b1c6ddf89c2d5 100644 (file)
@@ -30,6 +30,7 @@ namespace YACS
     {
     public:
       static void setRuntime();
+      std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
       ElementaryNode* createNode(const std::string& implementation, const std::string& name) throw(Exception);
       InputPort* createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
       OutputPort* createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
index 5f6bd37970ea2a8614cae030a09fe6321c1b7a29..53537a9f718c8af6b23daf5e824c358044740d2b 100644 (file)
@@ -106,6 +106,11 @@ void RuntimeForEngineTest::setRuntime()
     Runtime::_singleton = new RuntimeForEngineTest;
 }
 
+std::vector< std::pair<std::string,int> > RuntimeForEngineTest::getCatalogOfComputeNodes() const
+{
+  throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !");
+}
+
 ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name) throw(YACS::Exception)
 {
   return new TestElemNode(name);
index 0495ab60a4f95ee6a7c7212a89551718e9a81d7d..d5e5a7ea36e2bff62860bfa5ce3302f8dab2c33c 100644 (file)
@@ -66,6 +66,7 @@ namespace YACS
     {
     public:
       static void setRuntime();
+      std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
       ElementaryNode* createNode(const std::string& implementation, const std::string& name) throw(Exception);
       InputPort* createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
       OutputPort* createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
index ef6890f4fccc4ba18ee2e73b087d9398c6acc842..4e33796b94c1ecc2d5f8da76b066c73c4a50811a 100644 (file)
@@ -134,6 +134,7 @@ void VisitorSaveSchema::visitForEachLoop(ForEachLoop *node)
     _out << " state=\"disabled\"";
   if (!nbranch->isEmpty())
     _out << " nbranch=\"" << nbranch->getIntValue() << "\"";
+  _out << " weight=\"" << node->getWeight() << "\"";
   if (node->edGetSamplePort())
     _out << " type=\"" << node->edGetSamplePort()->edGetType()->name() << "\"";
   _out << ">" << endl;
@@ -159,6 +160,7 @@ void VisitorSaveSchema::visitOptimizerLoop(OptimizerLoop *node)
     _out << " state=\"disabled\"";
   if (!nbranch->isEmpty())
     _out << " nbranch=\"" << nbranch->getIntValue() << "\"";
+  _out << " weight=\"" << node->getWeight() << "\"";
   _out << " lib=\"" << node->getAlgLib() << "\"";
   _out << " entry=\"" << node->getSymbol() << "\"";
   _out << ">" << endl;
index 4e1f10a525ef103254b7dc92408df4647455be75..af9df8b3c2f84b578ab5675f109d7c374c624064 100644 (file)
@@ -110,6 +110,7 @@ SET(SWIGINCLUDES ${ENGINEINCL}
 
 SET(SWIG_MODULE_pilot_EXTRA_DEPS engtypemaps.i ${SWIGINCLUDES})
 SWIG_ADD_MODULE(pilot python pilot.i ExecutorSwig.cxx)
+SWIG_CHECK_GENERATION(pilot)
 
 SET(SWIG_MODULE_pypilot_EXTRA_DEPS pilot.i engtypemaps.i _pilot ${SWIGINCLUDES})
 SWIG_ADD_MODULE(pypilot python pypilot.i)
@@ -124,3 +125,13 @@ ENDIF(WIN32)
 INSTALL(TARGETS ${SWIG_MODULE_pilot_REAL_NAME} ${SWIG_MODULE_pypilot_REAL_NAME} DESTINATION ${SALOME_INSTALL_PYTHON})
 
 SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_PYTHON})
+
+### Test
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+ADD_TEST(NAME PlayGround0 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testPlayGround0.py)
+SET_TESTS_PROPERTIES(PlayGround0 PROPERTIES ENVIRONMENT "${tests_env}")
+SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/engine_swig)
+SET(LOCAL_TEST_FILES testPlayGround0.py)
+INSTALL(FILES ${LOCAL_TEST_FILES} DESTINATION ${LOCAL_TEST_DIR})
+INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${LOCAL_TEST_DIR} RENAME CTestTestfile.cmake)
diff --git a/src/engine_swig/CTestTestfileInstall.cmake b/src/engine_swig/CTestTestfileInstall.cmake
new file mode 100644 (file)
index 0000000..745df03
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright (C) 2015-2016  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
+#
+
+IF(NOT WIN32)
+  SET(TEST_NAME ${COMPONENT_NAME}_PlayGround0)
+  ADD_TEST(${TEST_NAME} python testPlayGround0.py)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDIF()
diff --git a/src/engine_swig/PlayGround.i b/src/engine_swig/PlayGround.i
new file mode 100644 (file)
index 0000000..859ed1f
--- /dev/null
@@ -0,0 +1,169 @@
+// Copyright (C) 2006-2016  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
+//
+
+%template()              std::pair< YACS::ENGINE::PartDefinition *, double>;
+%template(vecppdd)       std::vector< std::pair< YACS::ENGINE::PartDefinition *, double> >;
+
+%newobject YACS::ENGINE::PlayGround::copy;
+
+%{
+PyObject *convertPartDefinition(YACS::ENGINE::PartDefinition *pd)
+{
+  if(!pd)
+    return SWIG_NewPointerObj(SWIG_as_voidptr(pd),SWIGTYPE_p_YACS__ENGINE__PartDefinition, SWIG_POINTER_OWN | 0 );
+  YACS::ENGINE::ContigPartDefinition *pd1(dynamic_cast<YACS::ENGINE::ContigPartDefinition *>(pd));
+  if(pd1)
+    return SWIG_NewPointerObj(SWIG_as_voidptr(pd1),SWIGTYPE_p_YACS__ENGINE__ContigPartDefinition, SWIG_POINTER_OWN | 0 );
+  YACS::ENGINE::NonContigPartDefinition *pd2(dynamic_cast<YACS::ENGINE::NonContigPartDefinition *>(pd));
+  if(pd2)
+    return SWIG_NewPointerObj(SWIG_as_voidptr(pd2),SWIGTYPE_p_YACS__ENGINE__NonContigPartDefinition, SWIG_POINTER_OWN | 0 );
+  YACS::ENGINE::AllPartDefinition *pd3(dynamic_cast<YACS::ENGINE::AllPartDefinition *>(pd));
+  if(pd3)
+    return SWIG_NewPointerObj(SWIG_as_voidptr(pd3),SWIGTYPE_p_YACS__ENGINE__AllPartDefinition, SWIG_POINTER_OWN | 0 );
+  return SWIG_NewPointerObj(SWIG_as_voidptr(pd),SWIGTYPE_p_YACS__ENGINE__PartDefinition, SWIG_POINTER_OWN | 0 );
+  
+}
+%}
+
+%typemap(out) std::vector< YACS::BASES::AutoRefCnt<YACS::ENGINE::PartDefinition> >
+{
+  std::size_t sz($1.size());
+  std::vector< YACS::BASES::AutoRefCnt<YACS::ENGINE::PartDefinition> >::iterator it($1.begin());
+  $result = PyList_New($1.size());
+  for (std::size_t i=0; i<sz; i++,it++)
+    PyList_SetItem($result,i,convertPartDefinition((*it).retn())); 
+}
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class PartDefinition;
+
+    class PlayGround : public RefCounter
+    {
+    public:
+      PlayGround();
+      void loadFromKernelCatalog();
+      PlayGround(const std::vector< std::pair<std::string,int> >& defOfRes);
+      std::string printSelf() const;
+      std::vector< std::pair<std::string,int> > getData() const;
+      void setData(const std::vector< std::pair<std::string,int> >& defOfRes);
+      int getNumberOfCoresAvailable() const;
+      int getMaxNumberOfContainersCanBeHostedWithoutOverlap(int nbCoresPerCont) const;
+      std::string deduceMachineFrom(int workerId, int nbProcPerNode) const;
+      %extend
+         {
+           std::string __str__() const
+           {
+             return self->printSelf();
+           }
+
+           std::vector< YACS::BASES::AutoRefCnt<YACS::ENGINE::PartDefinition> > partition(const std::vector< std::pair< YACS::ENGINE::PartDefinition *,double> >& parts) const
+           {
+             std::size_t sz(parts.size());
+             std::vector< std::pair< const YACS::ENGINE::PartDefinition *,double> > partsCpp(sz);
+             for(std::size_t i=0;i<sz;i++)
+               partsCpp[i]=std::pair<const YACS::ENGINE::PartDefinition *,double >(parts[i].first,parts[i].second);
+             return self->partition(partsCpp);
+           }
+         }
+    private:
+      ~PlayGround();
+    };
+
+    class PartDefinition : public RefCounter
+    {
+    public:
+      virtual PartDefinition *copy() const;
+      virtual std::string printSelf() const;
+      virtual int getNumberOfCoresConsumed() const;
+    protected:
+      PartDefinition();
+      ~PartDefinition();
+    };
+
+    class ContigPartDefinition : public PartDefinition
+    {
+    public:
+      ContigPartDefinition(const PlayGround *pg, int nbOfCoresPerComp, int zeStart, int zeStop);
+      int getStart() const;
+      int getStop() const;
+      %extend
+         {
+           std::string __str__() const
+           {
+             return self->printSelf();
+           }
+         }
+    private:
+      ~ContigPartDefinition();
+    };
+
+    class NonContigPartDefinition : public PartDefinition
+    {
+    public:
+      NonContigPartDefinition(const PlayGround *pg, int nbOfCoresPerComp, const std::vector<int>& ids);
+      std::vector<int> getIDs() const;
+      %extend
+         {
+           std::string __str__() const
+           {
+             return self->printSelf();
+           }
+         }
+    private:
+      ~NonContigPartDefinition();
+    };
+
+    class AllPartDefinition : public PartDefinition
+    {
+    public:
+      AllPartDefinition(const PlayGround *pg, int nbOfCoresPerComp);
+      %extend
+         {
+           std::string __str__() const
+           {
+             return self->printSelf();
+           }
+         }
+    private:
+      ~AllPartDefinition();
+    };
+
+    class PartDefinition;
+    
+    class ForTestOmlyHPContCls
+    {
+    public:
+      std::string getContainerType() const;
+      std::vector<int> getIDS() const;
+    %extend
+       {
+         PyObject *getPD() const
+         {
+           const PartDefinition *ret(self->getPD());
+           if(ret)
+             ret->incrRef();
+           return convertPartDefinition(const_cast<PartDefinition *>(ret));
+         }
+       }
+    };
+  }
+}
index c8568336dc122b057b41e8524b172ebe894b0d7f..d760c97d7609b6f63a02a9c44a04c7d42eeb903b 100644 (file)
@@ -58,7 +58,8 @@
 #include "DeploymentTree.hxx"
 #include "ComponentInstance.hxx"
 #include "DataNode.hxx"
-
+#include "PlayGround.hxx"
+  
 using namespace YACS::ENGINE;
 
 %}
@@ -104,6 +105,7 @@ using namespace YACS::ENGINE;
 %template()              std::pair<std::string, YACS::ENGINE::Container *>;
 %template()              std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
 %template()              std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
+%template()              std::pair< std::string, int >;
 //%template(TCmap)         std::map<std::string, YACS::ENGINE::TypeCode *>;
 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
 %template(NODEmap)       std::map<std::string, YACS::ENGINE::Node *>;
@@ -113,11 +115,13 @@ REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
 %template(strvec)        std::vector<std::string>;
 %template(uivec)         std::vector<unsigned int>;
+%template(ivec)          std::vector<int>;
 %template(linksvec)      std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
 %template(linkvec)       std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
 %template(instreamlist)  std::list<YACS::ENGINE::InputDataStreamPort *>;
 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
-
+%template(vpsi)          std::vector< std::pair< std::string, int > >;
+          
 %template()              std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
 %template(loadermap)     std::map<std::string,YACS::ENGINE::CatalogLoader *>;
 %template()              std::pair<std::string, YACS::ENGINE::ComposedNode *>;
@@ -423,6 +427,7 @@ EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
 // OptimizerAlgASync in module SALOMERuntime
 %ignore YACS::ENGINE::OptimizerAlgASync;
 %include <OptimizerAlg.hxx>
+%include "PlayGround.i"
 
 %extend YACS::ENGINE::ConditionInputPort
 {
diff --git a/src/engine_swig/testPlayGround0.py b/src/engine_swig/testPlayGround0.py
new file mode 100644 (file)
index 0000000..3128e21
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright (C) 2006-2017  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
+#
+
+import pilot
+import unittest
+
+class TestPlayGround0(unittest.TestCase):
+    def test0(self):
+        pg=pilot.PlayGround([("a0",28),("a1",28),("a2",28)])
+        pd=pilot.ContigPartDefinition(pg,4,0,3*28)
+        res=pg.partition([(pd,1.),(pd,1.)])
+        assert(len(res)==2)
+        assert(isinstance(res[0],pilot.ContigPartDefinition))
+        assert(isinstance(res[1],pilot.ContigPartDefinition))
+        assert(res[0].getStart()==0 and res[0].getStop()==40)
+        assert(res[1].getStart()==40 and res[1].getStop()==84)
+        assert(sum([elt.getNumberOfCoresConsumed() for elt in res])==pg.getNumberOfCoresAvailable())
+        pd2=pilot.AllPartDefinition(pg,4)
+        assert(pd2.getNumberOfCoresConsumed()==84)
+        res=pg.partition([(pd2,1.),(pd2,1.),(pd2,1.)])
+        assert(len(res)==3)
+        assert(isinstance(res[0],pilot.ContigPartDefinition))
+        assert(isinstance(res[1],pilot.ContigPartDefinition))
+        assert(isinstance(res[2],pilot.ContigPartDefinition))
+        assert(res[0].getStart()==0 and res[0].getStop()==28)
+        assert(res[1].getStart()==28 and res[1].getStop()==56)
+        assert(res[2].getStart()==56 and res[2].getStop()==84)
+        #
+        pg.setData([("a0",2),("a1",8),("a2",8)])
+        res=pg.partition([(pilot.AllPartDefinition(pg,4),1.),(pilot.AllPartDefinition(pg,1),1.)])
+        assert(len(res)==2)
+        assert(isinstance(res[0],pilot.ContigPartDefinition))
+        assert(isinstance(res[1],pilot.NonContigPartDefinition))
+        assert(res[0].getStart()==2 and res[0].getStop()==10)
+        assert(res[1].getIDs()==(0,1,10,11,12,13,14,15,16,17))
+        pass
+
+    def test1(self):
+        """ test focused on complicated cut due to lack of cores"""
+        pg=pilot.PlayGround([("a0",13)])
+        pd=pilot.ContigPartDefinition(pg,4,0,13)
+        res=pg.partition([(pd,1.),(pd,1.)])
+        assert(len(res)==2)
+        assert(isinstance(res[0],pilot.ContigPartDefinition) and isinstance(res[1],pilot.ContigPartDefinition))
+        assert(res[0].getStart()==0 and res[0].getStop()==4)
+        assert(res[1].getStart()==4 and res[1].getStop()==12)# 1 core lost
+        #
+        pg=pilot.PlayGround([("a0",2),("a1",11)])
+        pd=pilot.ContigPartDefinition(pg,4,0,13)
+        res=pg.partition([(pd,1.),(pd,1.)])
+        assert(len(res)==2)
+        assert(isinstance(res[0],pilot.ContigPartDefinition) and isinstance(res[1],pilot.ContigPartDefinition))
+        assert(res[0].getStart()==2 and res[0].getStop()==6)
+        assert(res[1].getStart()==6 and res[1].getStop()==10)# 5 cores lost
+        pass
+    
+    pass
+
+if __name__ == '__main__':
+    unittest.main()
index 9aedfcdc954589e5f4e19957a23ca025d1beb501..3fd0568796b7c730b565f92d33a13077230aae97 100644 (file)
@@ -55,6 +55,7 @@ SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/evalyfx.py)
 SWIG_ADD_MODULE(evalyfx python evalyfx.i)
 
 SWIG_LINK_LIBRARIES(evalyfx ${_link_LIBRARIES})
+SWIG_CHECK_GENERATION(evalyfx)
 IF(WIN32)
   SET_TARGET_PROPERTIES(_evalyfx PROPERTIES DEBUG_OUTPUT_NAME _evalyfx_d)
 ENDIF(WIN32)
index 7f1ce70cb21cc768399f9a432faa8aa5f60ecb47..cd53c27745cee1ab47816f7c8fb2e85f97699e28 100644 (file)
@@ -969,19 +969,15 @@ bool GenericGui::closeContext(QWidget *view, bool onExit)
           break;
         }
     }
-  int studyId = _wrapper->activeStudyId();
-  if (context->getStudyId() == studyId)
+  _wrapper->deleteSchema(view);
+  DEBTRACE("delete context");
+  if (GuiExecutor* exec = context->getGuiExecutor())
     {
-      _wrapper->deleteSchema(view);
-      DEBTRACE("delete context");
-      if (GuiExecutor* exec = context->getGuiExecutor())
-        {
-          exec->closeContext();
-        }
-      delete context;
-      _mapViewContext.erase(view);
-      switchContext(newView, onExit);
+      exec->closeContext();
     }
+  delete context;
+  _mapViewContext.erase(view);
+  switchContext(newView, onExit);
   return true;
 }
 
@@ -1093,11 +1089,7 @@ void GenericGui::createContext(YACS::ENGINE::Proc* proc,
   GraphicsView* gView = new GraphicsView(viewWindow);
   gView->setScene(scene);
   gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
-  int studyId = _wrapper->AssociateViewToWindow(gView, viewWindow);
-  context->setStudyId(studyId);
-  std::ostringstream value;
-  value << studyId;
-  proc->setProperty("DefaultStudyID",value.str());
+  _wrapper->AssociateViewToWindow(gView, viewWindow);
   context->setScene(scene);
   context->setView(gView);
   context->setWindow(viewWindow);
@@ -2589,7 +2581,6 @@ void GenericGui::onShowRedo()
 void GenericGui::onCleanOnExit()
 {
   DEBTRACE("GenericGui::onCleanOnExit");
-  int studyId = _wrapper->activeStudyId();
   map<QWidget*, YACS::HMI::QtGuiContext*> mapViewContextCopy = _mapViewContext;
   map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = mapViewContextCopy.begin();
   for (; it != mapViewContextCopy.end(); ++it)
index ec06250fd6cad9b36bd769dff205d6ec638ef1ce..c758989b8b68254b583aa9556b362b8c8a8096ee 100644 (file)
@@ -92,7 +92,7 @@ void GuiExecutor::startResumeDataflow(bool initialize)
       SALOME_NamingService namingService(orb);
       SALOME_LifeCycleCORBA lcc(&namingService);
       ostringstream containerName;
-      containerName << "localhost/YACSContainer" << QtGuiContext::getQtCurrent()->getStudyId();
+      containerName << "localhost/YACSContainer";
       Engines::EngineComponent_var comp = lcc.FindOrLoad_Component(containerName.str().c_str(), "YACS" );
       _engineRef =YACS_ORB::YACS_Gen::_narrow(comp);
       YASSERT(!CORBA::is_nil(_engineRef));
index 6dd1395003d6f9438f678efb780be099a4e378b6..50aba7a339039a17e2689d81e740ea857b01ba23 100644 (file)
@@ -49,7 +49,6 @@ QtGuiContext::QtGuiContext(GenericGui *gmain) : GuiContext()
   _selectedSubject = 0;
   _isEdition = true;
   _isLoadingPresentation = false;
-  _studyId = 0;
   _fileName = QString();
   _mapOfSchemaItem.clear();
   _mapOfSceneItem.clear();
index e200849689e19fb45d7db41a863a2183eebfea2a..4e5555f19f693b1a88f324379f54b282fcc4bd96 100644 (file)
@@ -65,7 +65,6 @@ namespace YACS
       inline QString getFileName()                               {return _fileName; };
       inline YACS::HMI::GuiExecutor* getGuiExecutor()            {return _guiExecutor; };
       inline bool isEdition()                                    {return _isEdition; };
-      inline int getStudyId()                                    {return _studyId; };
       inline bool isLoadingPresentation()                        {return _isLoadingPresentation; };
 
       YACS::HMI::Subject* getSubjectToPaste(bool &isCut);
@@ -83,7 +82,6 @@ namespace YACS
       inline void setFileName(const QString& fileName)           {_fileName = fileName; };
       inline void setGuiExecutor(YACS::HMI::GuiExecutor* guiEx)  {_guiExecutor = guiEx; };
       inline void setEdition(bool isEdition)                     {_isEdition = isEdition; };
-      inline void setStudyId(int studyId)                        {_studyId = studyId; };
       inline void setLoadingPresentation(bool isLoadpres)        {_isLoadingPresentation = isLoadpres; };
 
       void setSubjectToCut(YACS::HMI::Subject* sub);
@@ -119,7 +117,6 @@ namespace YACS
       YACS::HMI::Subject* _selectedSubject;
       bool _isEdition;
       bool _isLoadingPresentation;
-      int _studyId;
       SuitWrapper* _wrapper;
     };
 
index 39b24d4bb2ede9df80d5cc3c8d891a03c820dbf0..b2c97276547e5c287618e5ce1cff37099dcbb746 100755 (executable)
@@ -49,7 +49,7 @@ SET (SWIG_MODULE_PMML_EXTRA_DEPS ${PMML_SWIG_DPYS_FILES}
 SET_SOURCE_FILES_PROPERTIES(PMMLsalome.i PROPERTIES SWIG_MODULE_NAME PMML)
 SWIG_ADD_MODULE(PMML python PMMLsalome.i)
 SWIG_LINK_LIBRARIES(PMML ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} pmmlLib)
-
+SWIG_CHECK_GENERATION(PMML)
 # _ABR_ Ensure dependency mechanism on all SWIG files and headers
 
 IF(WIN32)
index 9fa212b28ffecb89d02b7ef9d36563e681ddd239..33e6e56940c02fe97084c82ceb99ad6db794343b 100644 (file)
        <inParameter-type>string</inParameter-type>
        <inParameter-name>CreateHypothesis__anHyp</inParameter-name>
       </inParameter>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>CreateHypothesis__studyId</inParameter-name>
-      </inParameter>
      </inParameter-list>
      <outParameter-list>
       <outParameter>
        <inParameter-type>string</inParameter-type>
        <inParameter-name>anHyp</inParameter-name>
       </inParameter>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>studyId</inParameter-name>
-      </inParameter>
      </inParameter-list>
      <outParameter-list>
       <outParameter>
    </data>
    <data>
     <fromnode-name>aNewDataFlow_1</fromnode-name>
-    <fromserviceparameter-name>CreateHypothesis__studyId</fromserviceparameter-name>
     <tonode-name>CreateHypothesis</tonode-name>
-    <toserviceparameter-name>studyId</toserviceparameter-name>
     <data-value>
      <value-type>3</value-type>
      <value>1</value>
index 1f6dabd413b5467832963707e2186370d1f61328..f12168db69ff5c838e5391d923d981cf0138eca4 100644 (file)
        <inParameter-type>string</inParameter-type>
        <inParameter-name>CreateHypothesis__anHyp</inParameter-name>
       </inParameter>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>CreateHypothesis__studyId</inParameter-name>
-      </inParameter>
       <inParameter>
        <inParameter-type>GEOM_Shape</inParameter-type>
        <inParameter-name>AddHypothesis__aSubShape</inParameter-name>
        <inParameter-type>string</inParameter-type>
        <inParameter-name>anHyp</inParameter-name>
       </inParameter>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>studyId</inParameter-name>
-      </inParameter>
      </inParameter-list>
      <outParameter-list>
       <outParameter>
    </data>
    <data>
     <fromnode-name>aNewDataFlow_1</fromnode-name>
-    <fromserviceparameter-name>CreateHypothesis__studyId</fromserviceparameter-name>
     <tonode-name>CreateHypothesis</tonode-name>
-    <toserviceparameter-name>studyId</toserviceparameter-name>
     <data-value>
      <value-type>3</value-type>
      <value>1</value>
index 69627232c9db257099152583e9a0cb5c0bfdc3b0..e89bc040ea0e5b514bd1368baf8e46e2d6332e6f 100644 (file)
        <inParameter-type>string</inParameter-type>
        <inParameter-name>CreateHypothesis__anHyp</inParameter-name>
       </inParameter>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>CreateHypothesis__studyId</inParameter-name>
-      </inParameter>
      </inParameter-list>
      <outParameter-list>
       <outParameter>
        <inParameter-type>string</inParameter-type>
        <inParameter-name>anHyp</inParameter-name>
       </inParameter>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>studyId</inParameter-name>
-      </inParameter>
      </inParameter-list>
      <outParameter-list>
       <outParameter>
    </data>
    <data>
     <fromnode-name>aNewDataFlow_1</fromnode-name>
-    <fromserviceparameter-name>CreateHypothesis__studyId</fromserviceparameter-name>
     <tonode-name>CreateHypothesis</tonode-name>
-    <toserviceparameter-name>studyId</toserviceparameter-name>
     <data-value>
      <value-type>3</value-type>
      <value>1</value>
index 5fcb9c6b41412b548cb6ad180830434ec1e435ef..e71ce3a408eaafd0223936c06ff9291cdfc2f9f6 100644 (file)
@@ -29,6 +29,7 @@ IF(SALOME_YACS_USE_KERNEL)
     SalomeIDLKernel 
     SalomeNS
     SalomeContainer 
+    SalomeKernelHelpers
     SALOMEBasics 
     SalomeResourcesManager 
     OpUtil 
index d3e8b5015e58b21b5fbf217b9a793d5f1f51c9ab..0f2b8fceb9995056fa8aa85b0d0f6186490a2510 100644 (file)
@@ -126,7 +126,7 @@ bool CppContainer::loadComponentLibrary(const std::string & componentName) throw
   return false;
     }
 
-CppComponent * CppContainer::createComponentInstance(const std::string & componentName, int /* studyID */)
+CppComponent * CppContainer::createComponentInstance(const std::string & componentName)
 {
   DEBTRACE("CppContainer::createComponentInstance");
   if (_trueCont)
index 9bc3577c64b06ab5646838c5c282f4b302c5fe8f..281fa7d9e52553ab9ffbbb54cba9243e48a2f8a6 100644 (file)
@@ -120,7 +120,7 @@ namespace YACS
 
       void checkCapabilityToDealWith(const ComponentInstance *inst) const throw (YACS::Exception);
       bool loadComponentLibrary(const std::string & componentName) throw (YACS::Exception);
-      CppComponent * createComponentInstance(const std::string & componentName, int studyID = 0);
+      CppComponent * createComponentInstance(const std::string & componentName);
       void createInternalInstance(const std::string & componentName, 
                                   void *& obj, RunFunction &r, TerminateFunction &t);
       void unregisterComponentInstance(CppComponent * C);
index 60cf60543c21df25315024454288f56aa0ca61df..bf78b6d30d9f462f34ba995814133d778b86f76f 100644 (file)
@@ -113,13 +113,12 @@ void DistributedPythonNode::load()
     if(!_container)
       throw Exception("No container specified !");
     SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
-    SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
+    SalomeHPContainerBase *containerCast1(dynamic_cast<SalomeHPContainerBase *>(_container));
     if(containerCast0)
       objContainer=containerCast0->getContainerPtr(this);
     else if(containerCast1)
       {
-        YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,this));
-        objContainer=tmpCont->getContainerPtr(this);
+        objContainer=containerCast1->getContainerPtr(this);
       }
     else
       throw Exception("Unrecognized type of container ! Salome one is expected !");
index 1fa4c4dc95c88866b890b440b9446c9f95cc0233..9a604d3bd749925fbdbb5334dd67aab9e3680960 100644 (file)
@@ -127,13 +127,12 @@ Engines::Container_var PythonEntry::commonRemoteLoadPart2(InlineNode *reqNode, b
   if(!container)
     throw Exception("No container specified !");
   SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(container));
-  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(container));
+  SalomeHPContainerBase *containerCast1(dynamic_cast<SalomeHPContainerBase *>(container));
   if(containerCast0)
     objContainer=containerCast0->getContainerPtr(reqNode);
   else if(containerCast1)
     {
-      YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,reqNode));
-      objContainer=tmpCont->getContainerPtr(reqNode);
+      objContainer=containerCast1->getContainerPtr(reqNode);
     }
   else
     throw Exception("Unrecognized type of container ! Salome one is expected for PythonNode/PyFuncNode !");
index 753859e0e66071253bb4a20bdf889547b99440bd..cfabfd4796475f75022861af6347e90949dfd6df 100644 (file)
 #ifdef SALOME_KERNEL
 #include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_ResourcesManager.hxx"
+#include "SALOME_ContainerManager.hxx"
+#include "SALOMEconfig.h"
+#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+
 #endif
   
 #include <libxml/parser.h>
@@ -440,6 +446,44 @@ void RuntimeSALOME::fini()
     }
 }
 
+std::vector< std::pair<std::string,int> > RuntimeSALOME::getCatalogOfComputeNodes() const
+{
+  CORBA::ORB_ptr orb(getOrb());
+  SALOME_NamingService namingService;
+  try
+  {
+    namingService.init_orb(orb);
+  }
+  catch(SALOME_Exception& e)
+  {
+    throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Unable to contact the SALOME Naming Service");
+  }
+  CORBA::Object_var obj(namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS));
+  if(CORBA::is_nil(obj))
+    throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Unable to access to the resource manager !");
+  Engines::ResourcesManager_var resManager(Engines::ResourcesManager::_narrow(obj));
+  if(CORBA::is_nil(resManager))
+    throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! The entry attached to the res manager in NS does not have right type !");
+  std::vector< std::pair<std::string,int> > ret;
+  {
+    Engines::ResourceList *rl(0);
+    Engines::IntegerList *il(0);
+    resManager->ListAllAvailableResources(rl,il);
+    int sz(rl->length());
+    if(il->length()!=sz)
+      throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! Invalid size !");
+    ret.resize(sz);
+    for(int i=0;i<sz;i++)
+      {
+        std::string s((*rl)[i]);
+        ret[i]=std::pair<std::string,int>(s,(*il)[i]);
+      }
+    delete rl;
+    delete il;
+  }
+  return ret;
+}
+
 std::string RuntimeSALOME::getVersion() const
 {
 #ifdef YACS_DEVELOPMENT
@@ -1788,22 +1832,22 @@ InputPort* RuntimeSALOME::adapt(InputCppPort* source,
 //   return result;
 // }
 
-CORBA::ORB_ptr RuntimeSALOME::getOrb()
+CORBA::ORB_ptr RuntimeSALOME::getOrb() const
 {
   return _orb;
 }
 
-PyObject * RuntimeSALOME::getPyOrb()
+PyObject * RuntimeSALOME::getPyOrb() const
 {
   return _pyorb;
 }
 
-PyObject * RuntimeSALOME::getBuiltins()
+PyObject * RuntimeSALOME::getBuiltins() const
 {
   return _bltins;
 }
 
-DynamicAny::DynAnyFactory_ptr RuntimeSALOME::getDynFactory()
+DynamicAny::DynAnyFactory_ptr RuntimeSALOME::getDynFactory() const
 {
   return _dynFactory;
 }
index 85c98309e6225b88992e1756417ca0aaadfa2938..b777a36a33ce72d88190a41330c989ea61b56334 100644 (file)
@@ -78,7 +78,7 @@ namespace YACS
 
       virtual void init(long flags, int argc, char* argv[]);
       virtual void fini();
-
+      virtual std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
       virtual InputPort* createInputPort(const std::string& name,
                                          const std::string& impl,
                                          Node * node,
@@ -104,7 +104,9 @@ namespace YACS
       virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
       virtual ComponentInstance* createComponentInstance(const std::string& name,
                                                          const std::string& kind="");
+#ifndef SWIG
       virtual Container *createContainer(const std::string& kind="");
+#endif
       virtual WhileLoop* createWhileLoop(const std::string& name);
       virtual ForLoop* createForLoop(const std::string& name);
       virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
@@ -225,10 +227,10 @@ namespace YACS
 
       virtual ~RuntimeSALOME(); 
 
-      CORBA::ORB_ptr getOrb();
-      PyObject * getPyOrb();
-      PyObject * getBuiltins();
-      DynamicAny::DynAnyFactory_ptr getDynFactory();
+      CORBA::ORB_ptr getOrb() const;
+      PyObject * getPyOrb() const;
+      PyObject * getBuiltins() const;
+      DynamicAny::DynAnyFactory_ptr getDynFactory() const;
       omniORBpyAPI* getApi();
       PyObject * get_omnipy();
 
index f35fe882abfadb3117478533b32d6a940cf4bbf3..0e54975741eff60bbb33e6fb780d4715db1c8b9e 100644 (file)
@@ -81,8 +81,15 @@ void SalomeContainerMonoHelper::setContainer(const Task *askingNode, Engines::Co
 #endif
 }
 
+bool SalomeContainerMonoHelper::isKernelContNull() const
+{
+  return CORBA::is_nil(_trueCont);
+}
+
 void SalomeContainerMonoHelper::shutdown()
 {
+  if(CORBA::is_nil(_trueCont))
+    return ;
   try
   {
       DEBTRACE("shutdown SALOME container: " );
@@ -98,6 +105,15 @@ void SalomeContainerMonoHelper::shutdown()
   _trueCont=Engines::Container::_nil();
 }
 
+std::string SalomeContainerMonoHelper::getKernelContainerName() const
+{
+  if(CORBA::is_nil(_trueCont))
+    return std::string("NULL");
+  CORBA::String_var containerName(_trueCont->name());
+  std::string ret(containerName);
+  return ret;
+}
+
 SalomeContainerMonoHelper::~SalomeContainerMonoHelper()
 {
 }
index 08ecb7c70ab615ac1b164048939bb01084b13053..0236f81a4320579331accd3736436035583a8fab 100644 (file)
@@ -61,7 +61,9 @@ namespace YACS
       Engines::Container_var getContainer(const Task *askingNode) const;
       bool isAlreadyStarted(const Task *askingNode) const;
       void setContainer(const Task *askingNode, Engines::Container_var cont);
+      bool isKernelContNull() const;
       void shutdown();
+      std::string getKernelContainerName() const;
     private:
       ~SalomeContainerMonoHelper();
     public:
index d0f13c747f11d537130adc69af2fbfa1f91a3a7f..981ad70d9f556fd5729fa49cf3a963b917766755 100644 (file)
@@ -41,7 +41,7 @@ CORBA::Object_ptr SalomeContainerTmpForHP::loadComponent(Task *askingNode)
     YACS::BASES::AutoLocker<Container> alck(this);//To be sure
     std::string compoName(inst->getCompoName());
     Engines::Container_var container(_launchModeType->getContainer(askingNode));
-    objComponent=container->find_component_instance(compoName.c_str(),0);
+    objComponent=container->find_component_instance(compoName.c_str());
     if(CORBA::is_nil(objComponent))
       {
         char *reason;
index 48cb86646b7d2374aea15267328903df5ab103a7..6f785c8539c79b124401b1c8f56ac1f348a6e4ef 100644 (file)
@@ -30,6 +30,7 @@
 #include "ServiceNode.hxx"
 #include "ComponentInstance.hxx"
 #include "SalomeContainerHelper.hxx"
+#include "SalomeHPContainerTools.hxx"
 #include "RuntimeSALOME.hxx"
 #include "Exception.hxx"
 
 
 using namespace YACS::ENGINE;
 
-SalomeContainerTools::SalomeContainerTools()
+/*!
+ * \param [in] compoNames
+ * \param [in,out] shutdownLevel
+ */
+void SalomeContainerToolsBase::Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase& sct, int& shutdownLevel, const Container *cont, const Task *askingNode)
 {
-  /* Init ContainerParameters */
-  SALOME_LifeCycleCORBA::preSet(_params);
+  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,askingNode,isEmptyName));
+  DEBTRACE("SalomeContainer::start " << str <<";"<< sct.getHostName() <<";"<< schelp->getType());
+
+  // 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());
+  {
+    std::string dftLauchMode(schelp->getDftLaunchMode());
+    myparams.mode=CORBA::string_dup(dftLauchMode.c_str());
+  }
+
+  //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) && !isEmptyName)
+    {
+      myparams.mode=CORBA::string_dup("getorstart");
+    }
+
+  if (isEmptyName)
+    {
+      shutdownLevel=1;
+    }
+  //sct.setContainerName(str);
+  SetContainerNameOf(myparams,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(askingNode,trueCont);
+
+  CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
+  std::cerr << "SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() << std::endl;
 }
 
-SalomeContainerTools::SalomeContainerTools(const SalomeContainerTools& other):_params(other._params),_propertyMap(other._propertyMap)
+CORBA::Object_ptr SalomeContainerToolsBase::LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode)
 {
+  DEBTRACE("SalomeContainer::loadComponent ");
+  const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
+  {
+    YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
+    if(!cont->isAlreadyStarted(askingNode))
+      cont->start(askingNode);
+  }
+  if(!inst)
+    throw Exception("SalomeContainerTools::LoadComponent : no instance of component in the task requesting for a load of its component !");
+  CORBA::Object_ptr objComponent=CORBA::Object::_nil();
+  {
+    YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
+    std::string compoName(inst->getCompoName());
+    Engines::Container_var container(launchModeType->getContainer(askingNode));
+
+    char *reason;
+    bool isLoadable(container->load_component_Library(compoName.c_str(), reason));
+    if(isLoadable)
+      objComponent=CreateComponentInstance(cont,container,inst);
+  }
+  return objComponent;
 }
 
-void SalomeContainerTools::clearProperties()
+CORBA::Object_ptr SalomeContainerToolsBase::CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst)
+{
+  if(!inst)
+    throw Exception("SalomeContainerTools::CreateComponentInstance : no instance of component in the task requesting for a load of its component !");
+  char *reason(0);
+  std::string compoName(inst->getCompoName());
+  CORBA::Object_ptr objComponent=CORBA::Object::_nil();
+  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=contPtr->create_component_instance_env(compoName.c_str(), env, reason);
+  if(CORBA::is_nil(objComponent))
+    {
+      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);
+    }
+  return objComponent;
+}
+
+std::string SalomeContainerToolsBase::GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
+{
+  if(cont->isAlreadyStarted(askingNode))
+    {
+      Engines::Container_var container(launchModeType->getContainer(askingNode));
+      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 SalomeContainerToolsBase::GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
+{
+  if(cont->isAlreadyStarted(askingNode))
+    {
+      Engines::Container_var container(launchModeType->getContainer(askingNode));
+      try
+      {
+          CORBA::String_var corbaStr(container->name());
+          std::string ret(corbaStr);
+          return ret;
+      }
+      catch(...)
+      {
+          return "Unknown_placement";
+      }
+    }
+  else
+    return "Not_placed_yet";
+}
+
+void SalomeContainerToolsBase::SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name)
+{
+  params.container_name=CORBA::string_dup(name.c_str());
+}
+
+
+/////////////////////////////////
+
+SalomeContainerToolsInter::SalomeContainerToolsInter(const SalomeContainerToolsInter& other):_propertyMap(other._propertyMap)
+{
+}
+
+void SalomeContainerToolsInter::clearProperties()
 {
   _propertyMap.clear();
-  _params=Engines::ContainerParameters();
 }
 
-std::string SalomeContainerTools::getProperty(const std::string& name) const
+std::string SalomeContainerToolsInter::getProperty(const std::string& name) const
 {
   std::map<std::string,std::string>::const_iterator it(_propertyMap.find(name));
   if(it!=_propertyMap.end())
@@ -67,6 +296,69 @@ std::string SalomeContainerTools::getProperty(const std::string& name) const
     return std::string();
 }
 
+std::map<std::string,std::string> SalomeContainerToolsInter::getResourceProperties(const std::string& name) const
+{
+  std::map<std::string,std::string> properties;
+
+  YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
+  CORBA::ORB_ptr orb = runTime->getOrb();
+  if (!orb) return properties;
+  SALOME_NamingService namingService(orb);
+  SALOME_LifeCycleCORBA lcc(&namingService);
+  CORBA::Object_var obj = namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+  if (CORBA::is_nil(obj))
+    return properties;
+  Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
+  if (CORBA::is_nil(resManager))
+    return properties;
+
+  std::ostringstream value;
+  Engines::ResourceDefinition_var resource_definition = resManager->GetResourceDefinition(name.c_str());
+  properties["hostname"]=resource_definition->hostname.in();
+  properties["OS"]=resource_definition->OS.in();
+  value.str(""); value << resource_definition->mem_mb;
+  properties["mem_mb"]=value.str();
+  value.str(""); value << resource_definition->cpu_clock;
+  properties["cpu_clock"]=value.str();
+  value.str(""); value << resource_definition->nb_node;
+  properties["nb_node"]=value.str();
+  value.str(""); value << resource_definition->nb_proc_per_node;
+  properties["nb_proc_per_node"]=value.str();
+  /*
+  properties["component_list"]="";
+  for(CORBA::ULong i=0; i < resource_definition->componentList.length(); i++)
+    {
+      if(i > 0)
+        properties["component_list"]=properties["component_list"]+",";
+      properties["component_list"]=properties["component_list"]+resource_definition->componentList[i].in();
+    }
+    */
+  return properties;
+}
+
+////////////////////////
+
+SalomeContainerTools::SalomeContainerTools()
+{
+  /* Init ContainerParameters */
+  SALOME_LifeCycleCORBA::preSet(_params);
+}
+
+SalomeContainerTools::SalomeContainerTools(const SalomeContainerTools& other):SalomeContainerToolsInter(other),_params(other._params)
+{
+}
+
+int SalomeContainerTools::getNumberOfCoresPerWorker() const
+{
+  return _params.resource_params.nb_proc_per_node;
+}
+
+void SalomeContainerTools::clearProperties()
+{
+  SalomeContainerToolsInter::clearProperties();
+  _params=Engines::ContainerParameters();
+}
+
 void SalomeContainerTools::setProperty(const std::string& name, const std::string& value)
 {
   //DEBTRACE("SalomeContainer::setProperty : " << name << " ; " << value);
@@ -235,6 +527,11 @@ void SalomeContainerTools::setContainerName(const std::string& name)
   SetContainerNameOf(_params,name);
 }
 
+std::string SalomeContainerTools::getHostName() const
+{
+  return std::string(_params.resource_params.hostname);
+}
+
 std::string SalomeContainerTools::getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const
 {
   isEmpty=true;
@@ -257,279 +554,82 @@ std::string SalomeContainerTools::getNotNullContainerName(const Container *contP
     }
 }
 
-std::string SalomeContainerTools::getHostName() const
+//////////////////////////
+
+std::string SalomeContainerToolsDecoratorBase::getProperty(const std::string& name) const
 {
-  return std::string(_params.resource_params.hostname);
+  return _sct->getProperty(name);
 }
 
-void SalomeContainerTools::SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name)
+void SalomeContainerToolsDecoratorBase::setProperty(const std::string& name, const std::string& value)
 {
-  params.container_name=CORBA::string_dup(name.c_str());
+  _sct->setProperty(name,value);
 }
 
-std::map<std::string,std::string> SalomeContainerTools::getResourceProperties(const std::string& name) const
+const std::map<std::string,std::string>& SalomeContainerToolsDecoratorBase::getProperties() const
 {
-  std::map<std::string,std::string> properties;
-
-  YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
-  CORBA::ORB_ptr orb = runTime->getOrb();
-  if (!orb) return properties;
-  SALOME_NamingService namingService(orb);
-  SALOME_LifeCycleCORBA lcc(&namingService);
-  CORBA::Object_var obj = namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
-  if (CORBA::is_nil(obj))
-    return properties;
-  Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
-  if (CORBA::is_nil(resManager))
-    return properties;
-
-  std::ostringstream value;
-  Engines::ResourceDefinition_var resource_definition = resManager->GetResourceDefinition(name.c_str());
-  properties["hostname"]=resource_definition->hostname.in();
-  properties["OS"]=resource_definition->OS.in();
-  value.str(""); value << resource_definition->mem_mb;
-  properties["mem_mb"]=value.str();
-  value.str(""); value << resource_definition->cpu_clock;
-  properties["cpu_clock"]=value.str();
-  value.str(""); value << resource_definition->nb_node;
-  properties["nb_node"]=value.str();
-  value.str(""); value << resource_definition->nb_proc_per_node;
-  properties["nb_proc_per_node"]=value.str();
-  /*
-  properties["component_list"]="";
-  for(CORBA::ULong i=0; i < resource_definition->componentList.length(); i++)
-    {
-      if(i > 0)
-        properties["component_list"]=properties["component_list"]+",";
-      properties["component_list"]=properties["component_list"]+resource_definition->componentList[i].in();
-    }
-    */
-  return properties;
+  return _sct->getProperties();
 }
 
-/*!
- * \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 Task *askingNode)
+void SalomeContainerToolsDecoratorBase::clearProperties()
 {
-  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,askingNode,isEmptyName));
-  DEBTRACE("SalomeContainer::start " << str <<";"<< sct.getHostName() <<";"<<shutdownLevel);
-
-  // 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());
-  {
-    std::string dftLauchMode(schelp->getDftLaunchMode());
-    myparams.mode=CORBA::string_dup(dftLauchMode.c_str());
-  }
-
-  //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) && !isEmptyName)
-    {
-      myparams.mode=CORBA::string_dup("getorstart");
-    }
-
-  if (isEmptyName)
-    {
-      shutdownLevel=1;
-    }
-  //sct.setContainerName(str);
-  SetContainerNameOf(myparams,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(askingNode,trueCont);
+  _sct->clearProperties();
+}
 
-  CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
-  std::cerr << "SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() << std::endl;
+std::map<std::string,std::string> SalomeContainerToolsDecoratorBase::getResourceProperties(const std::string& name) const
+{
+  return _sct->getResourceProperties(name);
 }
 
-CORBA::Object_ptr SalomeContainerTools::LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode)
+void SalomeContainerToolsDecoratorBase::addToComponentList(const std::string& name)
 {
-  DEBTRACE("SalomeContainer::loadComponent ");
-  const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
-  {
-    YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
-    if(!cont->isAlreadyStarted(askingNode))
-      cont->start(askingNode);
-  }
-  if(!inst)
-    throw Exception("SalomeContainerTools::LoadComponent : no instance of component in the task requesting for a load of its component !");
-  CORBA::Object_ptr objComponent=CORBA::Object::_nil();
-  {
-    YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
-    std::string compoName(inst->getCompoName());
-    Engines::Container_var container(launchModeType->getContainer(askingNode));
+  _sct->addToComponentList(name);
+}
 
-    char *reason;
-    bool isLoadable(container->load_component_Library(compoName.c_str(), reason));
-    if(isLoadable)
-      objComponent=CreateComponentInstance(cont,container,inst);
-  }
-  return objComponent;
+void SalomeContainerToolsDecoratorBase::addToResourceList(const std::string& name)
+{
+  _sct->addToResourceList(name);
 }
 
-CORBA::Object_ptr SalomeContainerTools::CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst)
+Engines::ContainerParameters SalomeContainerToolsDecoratorBase::getParameters() const
 {
-  if(!inst)
-    throw Exception("SalomeContainerTools::CreateComponentInstance : no instance of component in the task requesting for a load of its component !");
-  char *reason(0);
-  std::string compoName(inst->getCompoName());
-  CORBA::Object_ptr objComponent=CORBA::Object::_nil();
-  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());
-    }
+  return _sct->getParameters();
+}
 
-  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();
-    }
+std::string SalomeContainerToolsDecoratorBase::getContainerName() const
+{
+  return _sct->getContainerName();
+}
 
-  objComponent=contPtr->create_component_instance_env(compoName.c_str(), studyid, env, reason);
-  if(CORBA::is_nil(objComponent))
-    {
-      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);
-    }
-  return objComponent;
+void SalomeContainerToolsDecoratorBase::setContainerName(const std::string& name)
+{
+  _sct->setContainerName(name);
 }
 
-std::string SalomeContainerTools::GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
+std::string SalomeContainerToolsDecoratorBase::getHostName() const
 {
-  if(cont->isAlreadyStarted(askingNode))
-    {
-      Engines::Container_var container(launchModeType->getContainer(askingNode));
-      const char *what="/";
-      CORBA::String_var corbaStr(container->name());
-      std::string ret(corbaStr);
+  return _sct->getHostName();
+}
 
-      //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 SalomeContainerToolsDecoratorBase::getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const
+{
+  return _sct->getNotNullContainerName(contPtr,askingNode,isEmpty);
 }
 
-std::string SalomeContainerTools::GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
+//////////////////////////////
+
+Engines::ContainerParameters SalomeContainerToolsSpreadOverTheResDecorator::getParameters() const
 {
-  if(cont->isAlreadyStarted(askingNode))
-    {
-      Engines::Container_var container(launchModeType->getContainer(askingNode));
-      try
-      {
-          CORBA::String_var corbaStr(container->name());
-          std::string ret(corbaStr);
-          return ret;
-      }
-      catch(...)
-      {
-          return "Unknown_placement";
-      }
-    }
-  else
-    return "Not_placed_yet";
+  Engines::ContainerParameters ret(getWorker()->getParameters());
+  std::string st(ret.resource_params.hostname);
+  if(!st.empty())
+    return ret;
+  int nbProcPerNode(ret.resource_params.nb_proc_per_node);
+  std::size_t iPos(_vh->locateTask(_node)),nPos(_vh->size());
+  if(_vh->size()!=_pg->getNumberOfWorkers(nbProcPerNode))
+    throw YACS::Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error !");
+  std::string zeMachine(_pg->deduceMachineFrom(iPos,nbProcPerNode));
+  ret.resource_params.hostname=CORBA::string_dup(zeMachine.c_str());
+  return ret;
 }
index 5955eee3f40f39e12c103dcb130492c42fad7a7f..793cf3488d563462b7ad3ad1d7b9430c4c9e5084 100644 (file)
@@ -37,34 +37,102 @@ namespace YACS
     class ComponentInstance;
     class SalomeContainerHelper;
 
-    class YACSRUNTIMESALOME_EXPORT SalomeContainerTools
+    class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsBase
+    {
+    public:
+      virtual ~SalomeContainerToolsBase() { }
+      virtual std::string getProperty(const std::string& name) const = 0;
+      virtual void setProperty(const std::string& name, const std::string& value) = 0;
+      virtual const std::map<std::string,std::string>& getProperties() const = 0;
+      virtual void clearProperties() = 0;
+      virtual std::map<std::string,std::string> getResourceProperties(const std::string& name) const = 0;
+      virtual void addToComponentList(const std::string& name) = 0;
+      virtual void addToResourceList(const std::string& name) = 0;
+      virtual Engines::ContainerParameters getParameters() const = 0;
+      virtual std::string getContainerName() const = 0;
+      virtual void setContainerName(const std::string& name) = 0;
+      virtual std::string getHostName() const = 0;
+      virtual std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const = 0;
+    public:
+      static void Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase& sct, int& shutdownLevel, const Container *cont, const Task *askingNode);
+      static CORBA::Object_ptr LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode);
+      static CORBA::Object_ptr CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst);
+      static std::string GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode);
+      static std::string GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode);
+      static void SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name);
+    };
+    
+    class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsInter : public SalomeContainerToolsBase
+    {
+    public:
+      SalomeContainerToolsInter() { }
+      SalomeContainerToolsInter(const SalomeContainerToolsInter& other);
+      std::string getProperty(const std::string& name) const;
+      const std::map<std::string,std::string>& getProperties() const { return _propertyMap; }
+      void clearProperties();
+      std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
+    protected:
+      std::map<std::string,std::string> _propertyMap;
+    };
+
+    class YACSRUNTIMESALOME_EXPORT SalomeContainerTools : public SalomeContainerToolsInter
     {
     public:
       SalomeContainerTools();
       SalomeContainerTools(const SalomeContainerTools& other);
+      int getNumberOfCoresPerWorker() const;
+    public:
+      Engines::ContainerParameters getParameters() const { return _params; }
+      void clearProperties();
+      void setProperty(const std::string& name, const std::string& value);
+      void addToComponentList(const std::string& name);
+      void addToResourceList(const std::string& name);
+      std::string getContainerName() const;
+      void setContainerName(const std::string& name);
+      std::string getHostName() const;
+      std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const;
+    protected:
+      Engines::ContainerParameters _params;
+    };
+
+    class PlayGround;
+    
+    class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsDecoratorBase : public SalomeContainerToolsBase
+    {
+    protected:
+      SalomeContainerToolsDecoratorBase(SalomeContainerToolsBase *sct):_sct(sct) { }
+      SalomeContainerToolsBase *getWorker() { return _sct; }
+      const SalomeContainerToolsBase *getWorker() const { return _sct; }
+    public:
       std::string getProperty(const std::string& name) const;
       void setProperty(const std::string& name, const std::string& value);
-      const std::map<std::string,std::string>& getProperties() const { return _propertyMap; }
+      const std::map<std::string,std::string>& getProperties() const;
       void clearProperties();
       std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
       void addToComponentList(const std::string& name);
       void addToResourceList(const std::string& name);
-    public:
+      Engines::ContainerParameters getParameters() const;
       std::string getContainerName() const;
       void setContainerName(const std::string& name);
-      std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const;
       std::string getHostName() const;
-      Engines::ContainerParameters getParameters() const { return _params; }
-      static void SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name);
+      std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const;
+    private:
+      SalomeContainerToolsBase *_sct;
+    };
+
+    class SalomeHPContainerVectOfHelper;
+    
+    class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsSpreadOverTheResDecorator : public SalomeContainerToolsDecoratorBase
+    {
     public:
-      static void Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerTools& sct, int& shutdownLevel, const Container *cont, const Task *askingNode);
-      static CORBA::Object_ptr LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode);
-      static CORBA::Object_ptr CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst);
-      static std::string GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode);
-      static std::string GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode);
-    protected:
-      std::map<std::string,std::string> _propertyMap;
-      Engines::ContainerParameters _params;
+      SalomeContainerToolsSpreadOverTheResDecorator(SalomeContainerToolsBase *sct, const PlayGround *pg, const SalomeHPContainerVectOfHelper *vh, const Task *node):SalomeContainerToolsDecoratorBase(sct),_pg(pg),_vh(vh),_node(node) { }
+      Engines::ContainerParameters getParameters() const;
+    private:
+      static std::string DeduceMachineFrom(const std::vector< std::pair<std::string,int> >& allResInfo, int iPos, int sz, int nbProcPerNode);
+    private:
+      const PlayGround *_pg;
+      const SalomeHPContainerVectOfHelper *_vh;
+      const Task *_node;
     };
   }
 }
index b7204fd3e69749f004f6f115b4eb6be91568f83e..b198882dbf49419b0b5d0490d258180910b618ab 100644 (file)
@@ -21,6 +21,7 @@
 #include "SalomeHPComponent.hxx"
 #include "SalomeContainerTmpForHP.hxx"
 #include "AutoLocker.hxx"
+#include "AutoRefCnt.hxx"
 
 #include <algorithm>
 
@@ -28,108 +29,238 @@ using namespace YACS::ENGINE;
 
 const char SalomeHPContainer::KIND[]="HPSalome";
 
-SalomeHPContainer::SalomeHPContainer():_shutdownLevel(999)
+SalomeHPContainerBase::SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared):_launchModeType(resShared),_shutdownLevel(999)
 {
 }
 
-SalomeHPContainer::SalomeHPContainer(const SalomeHPContainer& other):_componentNames(other._componentNames),_shutdownLevel(999),_sct(other._sct),_initScript(other._initScript)
+SalomeHPContainerBase::SalomeHPContainerBase(const SalomeHPContainerBase& other):_shutdownLevel(999),_launchModeType(new SalomeHPContainerVectOfHelper),_initScript(other._initScript)
 {
 }
 
-void SalomeHPContainer::setSizeOfPool(int sz)
+SalomeHPContainer *SalomeHPContainerBase::getTheBoss()
 {
-  _launchModeType.resize(sz);
+  HomogeneousPoolContainer *ret(this);
+  while(ret->getDirectFather())
+    ret=ret->getDirectFather();
+  SalomeHPContainer *retC(dynamic_cast<SalomeHPContainer *>(ret));
+  if(!retC)
+    throw Exception("SalomeHPContainerBase::getTheBoss : unexpected type of object !");
+  return retC;
 }
 
-int SalomeHPContainer::getSizeOfPool() const
+const SalomeHPContainer *SalomeHPContainerBase::getTheBoss() const
 {
-  return _launchModeType.size();
+  const HomogeneousPoolContainer *ret(this);
+  while(ret->getDirectFather())
+    ret=ret->getDirectFather();
+  const SalomeHPContainer *retC(dynamic_cast<const SalomeHPContainer *>(ret));
+  if(!retC)
+    throw Exception("SalomeHPContainerBase::getTheBoss : unexpected type of object !");
+  return retC;
 }
 
-std::size_t SalomeHPContainer::getNumberOfFreePlace() const
+void SalomeHPContainerBase::startInternal(const Task *askingNode, SalomeContainerToolsBase& sct, const std::vector<std::string>& compoNames)
 {
-  return _launchModeType.getNumberOfFreePlace();
+  SalomeContainerMonoHelper *helper(_launchModeType->getHelperOfTaskThreadSafe(askingNode));
+  SalomeContainerTools::Start(compoNames,helper,sct,_shutdownLevel,this,askingNode);
 }
 
-void SalomeHPContainer::allocateFor(const std::vector<const Task *>& nodes)
+void SalomeHPContainerBase::shutdown(int level)
 {
-  _launchModeType.allocateFor(nodes);
+  if(level < _shutdownLevel)
+      return;
+  _shutdownLevel=999;
+  _launchModeType->shutdown();
 }
 
-void SalomeHPContainer::release(const Task *node)
+SalomeHPContainerBase::SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared, bool isRefEaten):_launchModeType(resShared)
 {
-  _launchModeType.release(node);
+  if(!isRefEaten)
+    if(_launchModeType.isNotNull())
+      _launchModeType->incrRef();
 }
 
-SalomeHPContainer::~SalomeHPContainer()
+bool SalomeHPContainerBase::isAlreadyStarted(const Task *askingNode) const
 {
+  const SalomeContainerMonoHelper *helper(_launchModeType->getHelperOfTaskThreadSafe(askingNode));
+  return helper->isAlreadyStarted(askingNode);
 }
 
-void SalomeHPContainer::lock()
+void SalomeHPContainerBase::release(const Task *node)
 {
-  _mutex.lock();
+  _launchModeType->release(node);
 }
 
-void SalomeHPContainer::unLock()
+void SalomeHPContainerBase::lock()
 {
-  _mutex.unLock();
+  _launchModeType->lock();
 }
 
-std::string SalomeHPContainer::getKind() const
+void SalomeHPContainerBase::unLock()
 {
-  return KIND;
+  _launchModeType->unLock();
 }
 
-std::string SalomeHPContainer::getDiscreminantStrOfThis(const Task *askingNode) const
+void SalomeHPContainerBase::setSizeOfPool(int sz)
 {
-  YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(this,askingNode));
-  return tmpCont->getDiscreminantStrOfThis(askingNode);
+  _launchModeType->resize(sz);
 }
 
-bool SalomeHPContainer::isAlreadyStarted(const Task *askingNode) const
+int SalomeHPContainerBase::getSizeOfPool() const
 {
-  const SalomeContainerMonoHelper *helper(_launchModeType.getHelperOfTaskThreadSafe(this,askingNode));
-  return helper->isAlreadyStarted(askingNode);
+  return _launchModeType->size();
 }
 
-void SalomeHPContainer::start(const Task *askingNode) throw(YACS::Exception)
+void SalomeHPContainerBase::setProperty(const std::string& name,const std::string& value)
 {
-  SalomeContainerMonoHelper *helper(_launchModeType.getHelperOfTaskThreadSafe(this,askingNode));
-  SalomeContainerTools::Start(_componentNames,helper,_sct,_shutdownLevel,this,askingNode);
+  if(name==AOC_ENTRY)//no sense to set it ! It is always true ! ignore it !
+    return ;
+  else if(name==SIZE_OF_POOL_KEY)
+    {
+      std::istringstream iss(value);
+      int val(0);
+      iss >> val;
+      setSizeOfPool(val);
+    }
+  else if(name==INITIALIZE_SCRIPT_KEY)
+    {
+      _initScript=value;
+    }
+  else
+    getTheBoss()->getContainerInfo().setProperty(name,value);
 }
 
-void SalomeHPContainer::shutdown(int level)
+std::string SalomeHPContainerBase::getProperty(const std::string& name) const
 {
-  if(level < _shutdownLevel)
-      return;
-  _shutdownLevel=999;
-  for(std::size_t i=0;i<_launchModeType.size();i++)
+  if(name==AOC_ENTRY)
     {
-      SalomeContainerMonoHelper *helper(_launchModeType.at(i));
-      helper->shutdown();
+      return std::string("1");
     }
+  else if(name==SIZE_OF_POOL_KEY)
+    {
+      std::ostringstream oss; oss << getSizeOfPool();
+      return oss.str();
+    }
+  else if(name==INITIALIZE_SCRIPT_KEY)
+    {
+      return _initScript;
+    }
+  else
+    return getTheBoss()->getContainerInfo().getProperty(name);
+}
+
+std::map<std::string,std::string> SalomeHPContainerBase::getProperties() const
+{
+  std::map<std::string,std::string> ret(getTheBoss()->getContainerInfo().getProperties());
+  std::ostringstream oss; oss << getSizeOfPool();
+  ret[SIZE_OF_POOL_KEY]=oss.str();
+  if(!_initScript.empty())
+    ret[INITIALIZE_SCRIPT_KEY]=_initScript;
+  return ret;
+}
+
+void SalomeHPContainerBase::clearProperties()
+{
+  _initScript.clear();
+  getTheBoss()->getContainerInfo().clearProperties();
 }
 
-std::string SalomeHPContainer::getPlacementId(const Task *askingNode) const
+std::string SalomeHPContainerBase::getPlacementId(const Task *askingNode) const
 {
   const SalomeContainerMonoHelper *helper(0);
   {
-    YACS::BASES::AutoLocker<Container> alckCont(const_cast<SalomeHPContainer *>(this));
-    helper=_launchModeType.getHelperOfTask(askingNode);
+    YACS::BASES::AutoLocker<Container> alckCont(const_cast<SalomeHPContainerBase *>(this));
+    helper=_launchModeType->getHelperOfTask(askingNode);
   }
   return SalomeContainerTools::GetPlacementId(helper,this,askingNode);
 }
 
-std::string SalomeHPContainer::getFullPlacementId(const Task *askingNode) const
+std::string SalomeHPContainerBase::getFullPlacementId(const Task *askingNode) const
 {
   const SalomeContainerMonoHelper *helper(0);
   {
-    YACS::BASES::AutoLocker<Container> alckCont(const_cast<SalomeHPContainer *>(this));
-    helper=_launchModeType.getHelperOfTask(askingNode);
+    YACS::BASES::AutoLocker<Container> alckCont(const_cast<SalomeHPContainerBase *>(this));
+    helper=_launchModeType->getHelperOfTask(askingNode);
   }
   return SalomeContainerTools::GetFullPlacementId(helper,this,askingNode);
 }
 
+std::map<std::string,std::string> SalomeHPContainerBase::getResourceProperties(const std::string& name) const
+{
+  return getTheBoss()->getResourceProperties(name);
+}
+
+void SalomeHPContainerBase::addComponentName(const std::string& name)
+{
+  getTheBoss()->addComponentNameSpe(name);
+}
+
+void SalomeHPContainerBase::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+{
+  getTheBoss()->checkCapabilityToDealWith(inst);
+}
+
+YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> SalomeHPContainerBase::decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd)
+{
+  YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> ret(new SalomeHPContainerShared(pd,_launchModeType,this));
+  return ret;
+}
+
+Engines::Container_var SalomeHPContainerBase::getContainerPtr(const Task *askingNode) const
+{
+  const SalomeContainerMonoHelper *helper(0);
+  {
+    YACS::BASES::AutoLocker<SalomeHPContainerBase> alck(const_cast<SalomeHPContainerBase *>(this));
+    helper=_launchModeType->getHelperOfTask(askingNode);
+  }
+  return helper->getContainer(NULL);
+}
+
+std::vector<std::string> SalomeHPContainerBase::getKernelContainerNames() const
+{
+  return _launchModeType->getKernelContainerNames();
+}
+
+////////////////
+
+SalomeHPContainer::SalomeHPContainer():SalomeHPContainerBase(new SalomeHPContainerVectOfHelper)
+{
+}
+
+SalomeHPContainer::SalomeHPContainer(const SalomeHPContainer& other):SalomeHPContainerBase(other),_sct(other._sct),_componentNames(other._componentNames)
+{
+}
+
+std::size_t SalomeHPContainer::getNumberOfFreePlace() const
+{
+  return _launchModeType->getNumberOfFreePlace();
+}
+
+void SalomeHPContainer::allocateFor(const std::vector<const Task *>& nodes)
+{
+  _launchModeType->allocateFor(nodes);
+}
+
+SalomeHPContainer::~SalomeHPContainer()
+{
+}
+
+std::string SalomeHPContainer::getKind() const
+{
+  return KIND;
+}
+
+std::string SalomeHPContainer::getDiscreminantStrOfThis(const Task *askingNode) const
+{
+  YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(this,askingNode));
+  return tmpCont->getDiscreminantStrOfThis(askingNode);
+}
+
+void SalomeHPContainer::start(const Task *askingNode) throw(Exception)
+{
+  startInternal(askingNode,_sct,_componentNames);
+}
+
 /*!
  * It is not a bug here ! clone for homogeneous container is not supposed to be copied !
  */
@@ -144,72 +275,100 @@ Container *SalomeHPContainer::cloneAlways() const
   return new SalomeHPContainer(*this);
 }
 
-void SalomeHPContainer::setProperty(const std::string& name,const std::string& value)
+int SalomeHPContainer::getNumberOfCoresPerWorker() const
 {
-  if(name==AOC_ENTRY)//no sense to set it ! It is always true ! ignore it !
-    return ;
-  else if(name==SIZE_OF_POOL_KEY)
-    {
-      std::istringstream iss(value);
-      int val(0);
-      iss >> val;
-      setSizeOfPool(val);
-    }
-  else if(name==INITIALIZE_SCRIPT_KEY)
-    {
-      _initScript=value;
-    }
-  else
-    _sct.setProperty(name,value);
+  return _sct.getNumberOfCoresPerWorker();
 }
 
-std::string SalomeHPContainer::getProperty(const std::string& name) const
+std::map<std::string,std::string> SalomeHPContainer::getResourcePropertiesSpe(const std::string& name) const
 {
-  if(name==AOC_ENTRY)
-    {
-      return std::string("1");
-    }
-  else if(name==SIZE_OF_POOL_KEY)
-    {
-      std::ostringstream oss; oss << getSizeOfPool();
-      return oss.str();
-    }
-  else if(name==INITIALIZE_SCRIPT_KEY)
-    {
-      return _initScript;
-    }
-  else
-    return _sct.getProperty(name);
+  return _sct.getResourceProperties(name);
 }
 
-void SalomeHPContainer::clearProperties()
+void SalomeHPContainer::addComponentNameSpe(const std::string& name)
 {
-  _initScript.clear();
-  _sct.clearProperties();
+  _componentNames.push_back(name);
 }
 
-void SalomeHPContainer::addComponentName(const std::string& name)
+void SalomeHPContainer::checkCapabilityToDealWithSpe(const ComponentInstance *inst) const throw(YACS::Exception)
 {
-  _componentNames.push_back(name);
+  if(inst->getKind()!=SalomeHPComponent::KIND)
+    throw Exception("SalomeHPContainer::checkCapabilityToDealWithSpe : SalomeContainer is not able to deal with this type of ComponentInstance.");
 }
 
-std::map<std::string,std::string> SalomeHPContainer::getProperties() const
+void SalomeHPContainer::forYourTestsOnly(ForTestOmlyHPContCls *data) const
 {
-  std::map<std::string,std::string> ret(_sct.getProperties());
-  std::ostringstream oss; oss << getSizeOfPool();
-  ret[SIZE_OF_POOL_KEY]=oss.str();
-  if(!_initScript.empty())
-    ret[INITIALIZE_SCRIPT_KEY]=_initScript;
-  return ret;
+  data->setContainerType("HPContainer");
 }
 
-std::map<std::string,std::string> SalomeHPContainer::getResourceProperties(const std::string& name) const
+//////////////////////////////////
+
+SalomeHPContainerShared::SalomeHPContainerShared(YACS::BASES::AutoConstRefCnt<PartDefinition> pd, SalomeHPContainerVectOfHelper *resShared, SalomeHPContainerBase *directFather):SalomeHPContainerBase(resShared,false),_pd(pd)
 {
-  return _sct.getResourceProperties(name);
+  if(!directFather)
+    throw Exception("SalomeHPContainerShared : NULL pointer not allowed !");
+  _directFather.takeRef(directFather);
 }
 
-void SalomeHPContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+std::string SalomeHPContainerShared::getKind() const
 {
-  if(inst->getKind()!=SalomeHPComponent::KIND)
-    throw Exception("SalomeHPContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
+  return SalomeHPContainer::KIND;
 }
+
+void SalomeHPContainerShared::prepareMaskForExecution() const
+{
+  _idsOfKernelContainers=_pd->computeWorkerIdsCovered(getNumberOfCoresPerWorker());
+}
+
+/*!
+ * It is not a bug here ! clone for homogeneous container is not supposed to be copied !
+ */
+Container *SalomeHPContainerShared::clone() const
+{
+  incrRef();
+  return const_cast<SalomeHPContainerShared*>(this);
+}
+
+Container *SalomeHPContainerShared::cloneAlways() const
+{
+  throw Exception("SalomeHPContainerShared::cloneAlways : you are not supposed to be in this situation ! This type of container has only existence during execution !");
+}
+
+std::string SalomeHPContainerShared::getName() const
+{
+  return getTheBoss()->getName();
+}
+
+std::string SalomeHPContainerShared::getDiscreminantStrOfThis(const Task *askingNode) const
+{
+  return getTheBoss()->getDiscreminantStrOfThis(askingNode);
+}
+
+void SalomeHPContainerShared::start(const Task *askingNode) throw(Exception)
+{
+  SalomeContainerToolsSpreadOverTheResDecorator sct(&getTheBoss()->getContainerInfo(),_pd->getPlayGround(),_launchModeType,askingNode);
+  startInternal(askingNode,sct,getTheBoss()->getComponentNames());
+}
+
+void SalomeHPContainerShared::allocateFor(const std::vector<const Task *>& nodes)
+{
+  _launchModeType->allocateForAmong(_idsOfKernelContainers,nodes);
+}
+
+std::size_t SalomeHPContainerShared::getNumberOfFreePlace() const
+{
+  return _launchModeType->getNumberOfFreePlaceAmong(_idsOfKernelContainers);
+}
+
+void SalomeHPContainerShared::forYourTestsOnly(ForTestOmlyHPContCls *data) const
+{
+  data->setContainerType("HPContainerShared");
+  data->setPD(_pd);
+  data->setIDS(_idsOfKernelContainers);
+}
+
+/*
+ * SalomeHPContainerVectOfHelper is an holder of vector of SalomeContainerMonoHelper (holding itself a Kernel Container)
+ * SalomeContainerTools is a Engines::ContainerParameters holder. It is the data keeper for GiveContainer invokation.
+ * 
+ */
index f97bf8dfa76e9bc31a33e7125bff473c6cbe325a..c6fedbd3461a4914ddad0b8b6cc323191461d928 100644 (file)
 #include "SalomeContainerHelper.hxx"
 #include "SalomeContainerTools.hxx"
 #include "SalomeHPContainerTools.hxx"
+#include "PlayGround.hxx"
+
 #include "Mutex.hxx"
+#include "AutoRefCnt.hxx"
+
 #include <string>
 #include <vector>
 #include <map>
@@ -39,49 +43,83 @@ namespace YACS
   {
     class Task;
     class SalomeComponent;
-
-    class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public HomogeneousPoolContainer
+    class SalomeHPContainer;
+    
+    class YACSRUNTIMESALOME_EXPORT SalomeHPContainerBase : public HomogeneousPoolContainer
     {
+    protected:
+      SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared);
+      SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared, bool isRefEaten);
+      SalomeHPContainerBase(const SalomeHPContainerBase& other);
+      void startInternal(const Task *askingNode, SalomeContainerToolsBase& sct, const std::vector<std::string>& compoNames);
+      SalomeHPContainer *getTheBoss();
+      const SalomeHPContainer *getTheBoss() const;
     public:
-      SalomeHPContainer();
-      SalomeHPContainer(const SalomeHPContainer& other);
-      //HP specific part
-      void setSizeOfPool(int sz);
-      int getSizeOfPool() const;
-      std::size_t getNumberOfFreePlace() const;
-      void allocateFor(const std::vector<const Task *>& nodes);
       void release(const Task *node);
+      //
+      bool isAlreadyStarted(const Task *askingNode) const;
+      void shutdown(int level);
       //! For thread safety for concurrent load operation on same Container.
       void lock();
       //! For thread safety for concurrent load operation on same Container.
       void unLock();
+      void setSizeOfPool(int sz);
+      int getSizeOfPool() const;
+      void setProperty(const std::string& name,const std::string& value);
+      std::string getProperty(const std::string& name) const;
+      std::map<std::string,std::string> getProperties() const;
+      void clearProperties();
+      std::string getPlacementId(const Task *askingNode) const;
+      std::string getFullPlacementId(const Task *askingNode) const;
+      std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
+      void addComponentName(const std::string& name);
+      void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception);
+      Engines::Container_var getContainerPtr(const Task *askingNode) const;
+      std::vector<std::string> getKernelContainerNames() const;
+    public:
+      int getShutdownLev() const { return _shutdownLevel; }
+      YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd);
+#ifndef SWIG
+      const SalomeHPContainerVectOfHelper *getDirectAccessToVecOfCont() const { return _launchModeType; }
+#endif
+    protected:
+      int _shutdownLevel;
+      YACS::BASES::AutoRefCnt<SalomeHPContainerVectOfHelper> _launchModeType;
+      std::string _initScript;
+    };
+    
+    class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public SalomeHPContainerBase
+    {
+    public:
+      SalomeHPContainer();
+      SalomeHPContainer(const SalomeHPContainer& other);
+      //HP specific part
+      std::size_t getNumberOfFreePlace() const;
+      void allocateFor(const std::vector<const Task *>& nodes);
       //
       std::string getKind() const;
       std::string getDiscreminantStrOfThis(const Task *askingNode) const;
-      bool isAlreadyStarted(const Task *askingNode) const;
       void start(const Task *askingNode) throw(Exception);
-      void shutdown(int level);
-      std::string getPlacementId(const Task *askingNode) const;
-      std::string getFullPlacementId(const Task *askingNode) const;
       Container *clone() const;
       Container *cloneAlways() const;
-      void setProperty(const std::string& name,const std::string& value);
-      std::string getProperty(const std::string& name) const;
-      void clearProperties();
-      void addComponentName(const std::string& name);
-      std::map<std::string,std::string> getProperties() const;
-      std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
-      void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception);
+      int getNumberOfCoresPerWorker() const;
+      //! do nothing. because no special actions to do. Only for decorators
+      void prepareMaskForExecution() const { }
       //
 #ifndef SWIG
-      std::size_t locateTask(const Task *askingNode) const { return _launchModeType.locateTask(askingNode); }
+      void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
+      std::map<std::string,std::string> getResourcePropertiesSpe(const std::string& name) const;
+      void addComponentNameSpe(const std::string& name);
+      void checkCapabilityToDealWithSpe(const ComponentInstance *inst) const throw(YACS::Exception);
+      std::size_t locateTask(const Task *askingNode) const { return _launchModeType->locateTask(askingNode); }
       const SalomeContainerTools &getContainerInfo() const { return _sct; }
+      SalomeContainerTools &getContainerInfo() { return _sct; }
       std::vector<std::string> getComponentNames() const { return _componentNames; }
-      int getShutdownLev() const { return _shutdownLevel; }
-      SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType.getHelperOfTask(node); }
-      const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType.getHelperOfTask(node); }
+      SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType->getHelperOfTask(node); }
+      const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType->getHelperOfTask(node); }
       //
-      YACS::BASES::Mutex& getLocker() { return _mutex; }
+      HomogeneousPoolContainer *getDirectFather() { return NULL; }
+      const HomogeneousPoolContainer *getDirectFather() const { return NULL; }
 #endif
     public:
       static const char KIND[];
@@ -90,14 +128,38 @@ namespace YACS
       ~SalomeHPContainer();
 #endif
     protected:
-      int _shutdownLevel;
       SalomeContainerTools _sct;
-      YACS::BASES::Mutex _mutex;
       std::vector<std::string> _componentNames;
+    };
+
+#ifndef SWIG
+    class YACSRUNTIMESALOME_EXPORT SalomeHPContainerShared : public SalomeHPContainerBase
+    {
+    public:
+      SalomeHPContainerShared(YACS::BASES::AutoConstRefCnt<PartDefinition> pd, SalomeHPContainerVectOfHelper *resShared, SalomeHPContainerBase *directFather);
+      HomogeneousPoolContainer *getDirectFather() { return _directFather; }
+      const HomogeneousPoolContainer *getDirectFather() const { return _directFather; }
+      int getNumberOfCoresPerWorker() const { return _directFather->getNumberOfCoresPerWorker(); }
+      std::string getProperty(const std::string& name) const { return _directFather->getProperty(name); }
+      void prepareMaskForExecution() const;
+      void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
+      std::string getName() const;
+      std::string getDiscreminantStrOfThis(const Task *askingNode) const;
+    public:
+      std::string getKind() const;
+      void start(const Task *askingNode) throw(Exception);
+      Container *clone() const;
+      Container *cloneAlways() const;
       //
-      SalomeHPContainerVectOfHelper _launchModeType;
-      std::string _initScript;
+      void allocateFor(const std::vector<const Task *>& nodes);
+      std::size_t getNumberOfFreePlace() const;
+    private:
+      YACS::BASES::AutoRefCnt<SalomeHPContainerBase> _directFather;
+      YACS::BASES::AutoConstRefCnt<PartDefinition> _pd;
+      //! ids in _launchModeType covered by _pd.
+      mutable std::vector<std::size_t> _idsOfKernelContainers;
     };
+#endif
   }
 }
 
index 4e8f971e169b4c82c6396d638a1c9cafdbadaf32..59a9b1e42c983630defd77b9288b9cd52be512bf 100644 (file)
@@ -23,6 +23,7 @@
 #include "Exception.hxx"
 
 #include <algorithm>
+#include <limits>
 
 using namespace YACS::ENGINE;
 
@@ -44,6 +45,15 @@ std::size_t SalomeHPContainerVectOfHelper::getNumberOfFreePlace() const
   return std::count(_whichOccupied.begin(),_whichOccupied.end(),false);
 }
 
+std::size_t SalomeHPContainerVectOfHelper::getNumberOfFreePlaceAmong(const std::vector<std::size_t>& idsOfKernelContainers) const
+{
+  std::size_t ret;
+  for(std::vector<std::size_t>::const_iterator it=idsOfKernelContainers.begin();it!=idsOfKernelContainers.end();it++)
+    if(!_whichOccupied[*it])
+      ret++;
+  return ret;
+}
+
 void SalomeHPContainerVectOfHelper::allocateFor(const std::vector<const Task *>& nodes)
 {
   for(std::vector<const Task *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
@@ -60,6 +70,27 @@ void SalomeHPContainerVectOfHelper::allocateFor(const std::vector<const Task *>&
     }
 }
 
+void SalomeHPContainerVectOfHelper::allocateForAmong(const std::vector<std::size_t>& idsOfKernelContainers, const std::vector<const Task *>& nodes)
+{
+  for(std::vector<const Task *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
+    {
+      if(!(*it))
+        continue;
+      if(_currentlyWorking.find(*it)!=_currentlyWorking.end())
+        throw Exception("Searching 2 to allocate for a ServiceNode instance already declared as allocated !");
+      std::size_t it2(std::numeric_limits<std::size_t>::max());
+      for(std::vector<std::size_t>::const_iterator it=idsOfKernelContainers.begin();it!=idsOfKernelContainers.end();it++)
+        if(!_whichOccupied[*it])
+          {
+            it2=*it;
+            break;
+          }
+      if(it2==std::numeric_limits<std::size_t>::max())
+        throw Exception("All 2 ressources are already occupied ! You are expected to wait for released resources !");
+      _currentlyWorking[*it]=it2; _whichOccupied[it2]=true;
+    }
+}
+
 void SalomeHPContainerVectOfHelper::release(const Task *node)
 {
   if(!node)
@@ -81,9 +112,9 @@ std::size_t SalomeHPContainerVectOfHelper::locateTask(const Task *node) const
   return ret;
 }
 
-const SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(const SalomeHPContainer *cont, const Task *node) const
+const SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(const Task *node) const
 {
-  YACS::BASES::AutoLocker<Container> alck(const_cast<SalomeHPContainer *>(cont));
+  YACS::BASES::AutoLocker<SalomeHPContainerVectOfHelper> alck(const_cast<SalomeHPContainerVectOfHelper *>(this));
   return _launchModeType[locateTask(node)];
 }
 
@@ -92,9 +123,9 @@ const SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTask(
   return _launchModeType[locateTask(node)];
 }
 
-SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(SalomeHPContainer *cont, const Task *node)
+SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(const Task *node)
 {
-  YACS::BASES::AutoLocker<Container> alck(cont);
+  YACS::BASES::AutoLocker<SalomeHPContainerVectOfHelper> alck(this);
   return _launchModeType[locateTask(node)];
 }
 
@@ -118,3 +149,36 @@ void SalomeHPContainerVectOfHelper::checkPosInVec(std::size_t pos) const
   if(pos<0 || pos>=_launchModeType.size())
     throw Exception("The task has been found, but its id is not in the correct range ! resize of of container size during run ?");
 }
+
+void SalomeHPContainerVectOfHelper::shutdown()
+{
+  for(std::vector< BASES::AutoRefCnt<YACS::ENGINE::SalomeContainerMonoHelper> >::iterator it=_launchModeType.begin();it!=_launchModeType.end();it++)
+    if((*it).isNotNull())
+      if(!(*it)->isKernelContNull())
+        (*it)->shutdown();
+}
+
+std::vector<std::string> SalomeHPContainerVectOfHelper::getKernelContainerNames() const
+{
+  std::vector<std::string> ret;
+  {
+    YACS::BASES::AutoLocker<SalomeHPContainerVectOfHelper> alck(const_cast<SalomeHPContainerVectOfHelper *>(this));
+    std::size_t sz(_launchModeType.size());
+    ret.resize(sz);
+    for(std::size_t i=0;i<sz;i++)
+      {
+        ret[i]=_launchModeType[i]->getKernelContainerName();
+      }
+  }
+  return ret;
+}
+
+void SalomeHPContainerVectOfHelper::lock()
+{
+  _mutex.lock();
+}
+
+void SalomeHPContainerVectOfHelper::unLock()
+{
+  _mutex.unLock();
+}
index 895fa6405ce6ffa2f4a4c297d922375f9769732d..f3a0ccb217bc773e54d451e9b74b20c2df6c1ae7 100644 (file)
@@ -23,6 +23,9 @@
 #include "YACSRuntimeSALOMEExport.hxx"
 #include "SalomeContainerHelper.hxx"
 
+#include "RefCounter.hxx"
+
+#include "Mutex.hxx"
 #include "AutoRefCnt.hxx"
 
 #include <map>
@@ -36,25 +39,36 @@ namespace YACS
     class SalomeComponent;
     class SalomeHPContainer;
     class SalomeContainerMonoHelper;
-    class SalomeHPContainerVectOfHelper
+    class SalomeHPContainerVectOfHelper : public RefCounter
     {
     public:
       std::size_t size() const { return _launchModeType.size(); }
       void resize(std::size_t sz);
       std::size_t getNumberOfFreePlace() const;
+      std::size_t getNumberOfFreePlaceAmong(const std::vector<std::size_t>& idsOfKernelContainers) const;
       void allocateFor(const std::vector<const Task *>& nodes);
+      void allocateForAmong(const std::vector<std::size_t>& idsOfKernelContainers, const std::vector<const Task *>& nodes);
       void release(const Task *node);
       std::size_t locateTask(const Task *node) const;
       const SalomeContainerMonoHelper *at(std::size_t pos) const { checkPosInVec(pos); return _launchModeType[pos]; }
       SalomeContainerMonoHelper *at(std::size_t pos) { checkPosInVec(pos); return _launchModeType[pos]; }
-      const SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const SalomeHPContainer *cont, const Task *node) const;
+      const SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const Task *node) const;
       const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const;
-      SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(SalomeHPContainer *cont, const Task *node);
+      SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const Task *node);
       SalomeContainerMonoHelper *getHelperOfTask(const Task *node);
+      void shutdown();
+      //! For thread safety for concurrent load operation on same Container.
+      void lock();
+      //! For thread safety for concurrent load operation on same Container.
+      void unLock();
+    public:
+      std::vector<std::string> getKernelContainerNames() const;
     private:
+      ~SalomeHPContainerVectOfHelper() { }
       void checkNoCurrentWork() const;
       void checkPosInVec(std::size_t pos) const;
     private:
+      YACS::BASES::Mutex _mutex;
       std::vector<bool> _whichOccupied;
       std::vector< BASES::AutoRefCnt<YACS::ENGINE::SalomeContainerMonoHelper> > _launchModeType;
       std::map<const Task *,std::size_t > _currentlyWorking;
index 81166e9c6b220455359c8b420f49fee62476bbc1..2f8dc8d873fc21941192668f44f79930eb9549d4 100644 (file)
@@ -70,30 +70,13 @@ void SalomeProc::saveSchema(std::string xmlSchemaFile)
   vss.closeFileSchema();
 }
 
-//! Get the default study id for the proc
-/*!
- * \return the study id
- */
-int SalomeProc::getDefaultStudyId()
-{
-  std::string value=getProperty("DefaultStudyID");
-  if(value.empty())
-    return 1;
-  else
-    return atoi(value.c_str());
-}
-
 //! Initialise the proc
 void SalomeProc::init(bool start)
 {
-  std::string value=getProperty("DefaultStudyID");
-  if(!value.empty())
-    {
-      //initialise Python module salome with the study id given by value
-      std::string cmd="import salome;salome.salome_init("+value+")";
-      PyGILState_STATE gstate = PyGILState_Ensure(); // acquire the Global Interpreter Lock
-      PyRun_SimpleString(cmd.c_str());
-      PyGILState_Release(gstate); // Release the Global Interpreter Lock
-    }
+  //initialise Python module salome with the study id given by value
+  std::string cmd="import salome;salome.salome_init()";
+  PyGILState_STATE gstate = PyGILState_Ensure(); // acquire the Global Interpreter Lock
+  PyRun_SimpleString(cmd.c_str());
+  PyGILState_Release(gstate); // Release the Global Interpreter Lock
   Proc::init(start);
 }
index 46c13beefdeaaca8be1a3eaa31d8b8301106d3ce..8f45938c9d24d4c441167f9fcdc38c0ce2aa9a5a 100644 (file)
@@ -43,7 +43,6 @@ namespace YACS
        virtual TypeCode * createStructTc(const std::string& id, const std::string& name);
        virtual std::string typeName() {return "YACS__ENGINE__SalomeProc";}
        virtual void saveSchema(std::string xmlSchemaFile);
-       virtual int getDefaultStudyId();
        virtual void init(bool start=true);
     };
   }
index 42282c0eb3c09d006d52262b81053c13909abadd..0d9349030e2009b57714f0ae9268de87a99016c0 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "Basics_Utils.hxx"
 #include "SALOME_NamingService.hxx"
+#include "SALOME_KernelServices.hxx"
 #include "SALOMEDS.hh"
 #include "SALOMEDS_Attributes.hh"
 
@@ -75,47 +76,6 @@ void StudyInNode::setData(OutputPort* port, const std::string& data)
 void StudyInNode::execute()
 {
   DEBTRACE("+++++++ StudyInNode::execute +++++++++++");
-  SALOME_NamingService NS(getSALOMERuntime()->getOrb());
-  CORBA::Object_var obj=NS.Resolve("/myStudyManager");
-  if(CORBA::is_nil(obj)) 
-    {
-      _errorDetails="Execution problem: no naming service";
-      throw Exception(_errorDetails);
-    }
-
-  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(obj);
-  if(CORBA::is_nil(aStudyManager)) 
-    {
-      _errorDetails="Execution problem: no naming service";
-      throw Exception(_errorDetails);
-    }
-
-  int studyid=1;
-  if (getProperty("StudyID") != "")
-    {
-      // StudyId is specified
-      studyid=atoi(getProperty("StudyID").c_str());
-    }
-  else
-    {
-      Proc* p=getProc();
-      if(p)
-        {
-          std::string value=p->getProperty("DefaultStudyID");
-          if(!value.empty())
-            studyid= atoi(value.c_str());
-        }
-    }
-
-
-  SALOMEDS::Study_var myStudy =aStudyManager->GetStudyByID(studyid);
-  if(CORBA::is_nil(myStudy)) 
-    {
-      std::stringstream msg;
-      msg << "Execution problem: no study with id " << studyid;
-      _errorDetails=msg.str();
-      throw Exception(_errorDetails);
-    }
 
   std::list<OutputPort *>::const_iterator iter;
   for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
@@ -123,7 +83,7 @@ void StudyInNode::execute()
       OutputStudyPort *outp = dynamic_cast<OutputStudyPort *>(*iter);
       try
         {
-          outp->getDataFromStudy(myStudy);
+          outp->getDataFromStudy();
         }
       catch(Exception& e)
         {
@@ -206,10 +166,10 @@ void StudyOutNode::setData(InputPort* port, const std::string& data)
 }
 
 /*
-SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::Study_ptr study, SALOMEDS::StudyBuilder_ptr builder,
+SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::StudyBuilder_ptr builder,
                                              SALOMEDS::SObject_ptr sobj, const std::string& name)
 {
-  SALOMEDS::ChildIterator_var anIterator= study->NewChildIterator(sobj);
+  SALOMEDS::ChildIterator_var anIterator= KERNEL::getStudyServant()->NewChildIterator(sobj);
   SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::AttributeName_var namAttr ;
   SALOMEDS::SObject_var result=SALOMEDS::SObject::_nil();
@@ -243,54 +203,8 @@ SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::Study_ptr study, SALOMEDS
 void StudyOutNode::execute()
 {
   DEBTRACE("+++++++ StudyOutNode::execute +++++++++++");
-  SALOME_NamingService NS(getSALOMERuntime()->getOrb());
-  CORBA::Object_var obj=NS.Resolve("/myStudyManager");
-  if(CORBA::is_nil(obj))
-    {
-      _errorDetails="Execution problem: no naming service";
-      throw Exception(_errorDetails);
-    }
-
-  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(obj);
-  if(CORBA::is_nil(aStudyManager))
-    {
-      _errorDetails="Execution problem: no naming service";
-      throw Exception(_errorDetails);
-    }
-
-  int studyid=1;
-  if (getProperty("StudyID") != "")
-    {
-      // StudyId is specified
-      studyid=atoi(getProperty("StudyID").c_str());
-    }
-  else
-    {
-      Proc* p=getProc();
-      if(p)
-        {
-          std::string value=p->getProperty("DefaultStudyID");
-          if(!value.empty())
-            studyid= atoi(value.c_str());
-        }
-    }
-
-  SALOMEDS::Study_var myStudy =aStudyManager->GetStudyByID(studyid);
-  if(CORBA::is_nil(myStudy))
-    {
-      //open a new one
-      std::stringstream msg;
-      msg << "Study" << studyid;
-      myStudy=aStudyManager->NewStudy(Kernel_Utils::decode_s(msg.str()));
-      if(CORBA::is_nil(myStudy))
-        {
-          _errorDetails="Execution problem: can not create new study " + msg.str();
-          throw Exception(_errorDetails);
-        }
-    }
-  DEBTRACE(myStudy->StudyId());
 
-  SALOMEDS::StudyBuilder_var aBuilder =myStudy->NewBuilder() ;
+  SALOMEDS::StudyBuilder_var aBuilder =KERNEL::getStudyServant()->NewBuilder() ;
   if(CORBA::is_nil(aBuilder))
     {
       _errorDetails="Execution problem: can not create StudyBuilder";
@@ -306,13 +220,13 @@ void StudyOutNode::execute()
   for(iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
     {
       InputStudyPort *inp = dynamic_cast<InputStudyPort *>(*iter);
-      inp->putDataInStudy(myStudy,aBuilder);
+      inp->putDataInStudy(aBuilder);
     }
 
   // save in file if ref is given
   if(_ref != "")
     {
-      aStudyManager->SaveAs(Kernel_Utils::decode_s(_ref),myStudy, false);
+      KERNEL::getStudyServant()->SaveAs(Kernel_Utils::decode_s( _ref ), false, false);
     }
   DEBTRACE("+++++++ end StudyOutNode::execute +++++++++++" );
 }
index d1839b1bd96fc408f22fe1f68e569504b7abf26e..98d832b2a7c1d6c8c687dabf0c92d5b0564d86c1 100644 (file)
@@ -26,6 +26,7 @@
 #include "RuntimeSALOME.hxx"
 
 #include "SALOMEDS_Attributes.hh"
+#include "SALOME_KernelServices.hxx"
 
 #include <iostream>
 #include <iomanip>
@@ -135,25 +136,25 @@ std::string OutputStudyPort::getAsString()
   return getData();
 }
 
-void OutputStudyPort::getDataFromStudy(SALOMEDS::Study_var myStudy)
+void OutputStudyPort::getDataFromStudy()
 {
       std::string data = getData();
       DEBTRACE("data: " << data );
       //try an id
-      SALOMEDS::SObject_var aSO = myStudy->FindObjectID(data.c_str());
+      SALOMEDS::SObject_var aSO = KERNEL::getStudyServant()->FindObjectID(data.c_str());
       if(CORBA::is_nil(aSO))
         {
           //try a path
-          aSO=myStudy->FindObjectByPath(data.c_str());
+          aSO=KERNEL::getStudyServant()->FindObjectByPath(data.c_str());
           if(CORBA::is_nil(aSO))
             {
               std::stringstream msg;
-              msg << "Execution problem: no id or path: " << data << " in study " << myStudy->StudyId();
+              msg << "Execution problem: no id or path: " << data << " in study";
               throw Exception(msg.str());
             }
         }
 
-      CORBA::String_var path=myStudy->GetObjectPath(aSO);
+      CORBA::String_var path=KERNEL::getStudyServant()->GetObjectPath(aSO);
       DEBTRACE(path);
       CORBA::String_var id=aSO->GetID();
       DEBTRACE(id);
@@ -230,10 +231,10 @@ void OutputStudyPort::getDataFromStudy(SALOMEDS::Study_var myStudy)
 
 
 
-SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::Study_ptr study, SALOMEDS::StudyBuilder_ptr builder,
+SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::StudyBuilder_ptr builder,
                                              SALOMEDS::SObject_ptr sobj, const std::string& name)
 {
-  SALOMEDS::ChildIterator_var anIterator= study->NewChildIterator(sobj);
+  SALOMEDS::ChildIterator_var anIterator= KERNEL::getStudyServant()->NewChildIterator(sobj);
   SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::AttributeName_var namAttr ;
   SALOMEDS::SObject_var result=SALOMEDS::SObject::_nil();
@@ -342,7 +343,7 @@ std::string InputStudyPort::getAsString()
   return getData();
 }
 
-void InputStudyPort::putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyBuilder_var aBuilder)
+void InputStudyPort::putDataInStudy(SALOMEDS::StudyBuilder_var aBuilder)
 {
   SALOMEDS::GenericAttribute_var aGAttr;
   SALOMEDS::SObject_var aSO ;
@@ -353,11 +354,11 @@ void InputStudyPort::putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyB
   std::string data = getData();
   DEBTRACE("data: " << data );
   //try to find an existing id (i:j:k...)
-  aSO = myStudy->FindObjectID(data.c_str());
+  aSO = KERNEL::getStudyServant()->FindObjectID(data.c_str());
   if(CORBA::is_nil(aSO))
     {
       // the id does not exist. Try to create it by id
-      aSO=myStudy->CreateObjectID(data.c_str());
+      aSO=KERNEL::getStudyServant()->CreateObjectID(data.c_str());
       if(!CORBA::is_nil(aSO))
         {
           aGAttr=aBuilder->FindOrCreateAttribute(aSO,"AttributeName");
@@ -418,7 +419,7 @@ void InputStudyPort::putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyB
                           SALOMEDS::SObject_var aTmpSO; // initialized to nil
                           try 
                             {
-                              aTmpSO = aDriver->PublishInStudy(myStudy, aTmpSO, anObject,objname.c_str() );
+                              aTmpSO = aDriver->PublishInStudy(aTmpSO, anObject,objname.c_str() );
                               return;
                             }
                           catch ( ... ) 
@@ -432,7 +433,7 @@ void InputStudyPort::putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyB
         }
 
       // Does component entry exist ?
-      aSO=myStudy->FindObjectByPath(pname.c_str());
+      aSO=KERNEL::getStudyServant()->FindObjectByPath(pname.c_str());
       if(CORBA::is_nil(aSO))
         {
           // We have not been able to publish the object with Salome Driver, make it the light way
@@ -445,7 +446,7 @@ void InputStudyPort::putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyB
           aGAttr=aBuilder->FindOrCreateAttribute(aFather,"AttributeName");
           anAttr = SALOMEDS::AttributeName::_narrow( aGAttr );
           anAttr->SetValue(name.c_str());
-          aSO=myStudy->FindObjectByPath(pname.c_str());
+          aSO=KERNEL::getStudyServant()->FindObjectByPath(pname.c_str());
         }
 
       begin=data.find_first_not_of("/",pos);
@@ -456,7 +457,7 @@ void InputStudyPort::putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyB
             name=data.substr(begin,pos-begin);
           else
             name=data.substr(begin);
-          aSO=findOrCreateSoWithName(myStudy,aBuilder,aSO,name);
+          aSO=findOrCreateSoWithName(aBuilder,aSO,name);
           begin=data.find_first_not_of("/",pos);
         }
     }
index 831fd45ee6f9732af49a05beda372cbe796855b6..671e4211555e1697a8c10c06af854cfb314dcf15 100644 (file)
@@ -42,7 +42,7 @@ namespace YACS
       virtual std::string getPyObj();
       virtual std::string getAsString();
       virtual std::string typeName() {return "YACS__ENGINE__OutputStudyPort";}
-      virtual void getDataFromStudy(SALOMEDS::Study_var myStudy);
+      virtual void getDataFromStudy();
     protected:
       std::string _storeData;
     };
@@ -61,7 +61,7 @@ namespace YACS
       virtual std::string getPyObj();
       virtual std::string getAsString();
       virtual std::string typeName() {return "YACS__ENGINE__InputStudyPort";}
-      virtual void putDataInStudy(SALOMEDS::Study_var myStudy,SALOMEDS::StudyBuilder_var aBuilder);
+      virtual void putDataInStudy(SALOMEDS::StudyBuilder_var aBuilder);
     protected:
       std::string _storeData;
     };
index 2349fd6711fd87c1f1fa2e40325ec3eb62a7679e..c5d9f59cf1ad93f39cb4597552aa6204fc5ea96b 100644 (file)
@@ -102,6 +102,7 @@ SET(SWIG_MODULE_SALOMERuntime_EXTRA_DEPS
 SWIG_ADD_MODULE(SALOMERuntime python SALOMERuntime.i)
 
 SWIG_LINK_LIBRARIES(SALOMERuntime ${_link_LIBRARIES})
+SWIG_CHECK_GENERATION(SALOMERuntime)
 IF(WIN32)
   SET_TARGET_PROPERTIES(_SALOMERuntime PROPERTIES DEBUG_OUTPUT_NAME _SALOMERuntime_d)
 ENDIF(WIN32)
index 4aab32a826056ecd1b4d6aadf0cce1a19a3d62f5..95103b3a29388bbe1ae3afae97fc7eb433fc58ab 100644 (file)
   Py_DECREF(pyapi);
 %}
 
+%{
+static PyObject *convertContainer2(YACS::ENGINE::Container *cont, int owner=0)
+{
+  if(!cont)
+    return SWIG_NewPointerObj((void*)cont,SWIGTYPE_p_YACS__ENGINE__Container, owner);
+  if(dynamic_cast<YACS::ENGINE::SalomeHPContainer *>(cont))
+    {
+      return SWIG_NewPointerObj((void*)dynamic_cast<YACS::ENGINE::SalomeHPContainer *>(cont),SWIGTYPE_p_YACS__ENGINE__SalomeHPContainer, owner);
+    }
+  if(dynamic_cast<YACS::ENGINE::SalomeContainer *>(cont))
+    {
+      return SWIG_NewPointerObj((void*)dynamic_cast<YACS::ENGINE::SalomeContainer *>(cont),SWIGTYPE_p_YACS__ENGINE__SalomeContainer, owner);
+    }
+  return SWIG_NewPointerObj((void*)cont,SWIGTYPE_p_YACS__ENGINE__Container, owner);
+}
+%}
+
 // ----------------------------------------------------------------------------
 
 #ifdef SWIGPYTHON
@@ -211,3 +228,12 @@ namespace YACS
 %rename(OptimizerAlgSync) YACS::ENGINE::PyOptimizerAlgBase;
 %rename(OptimizerAlgASync) YACS::ENGINE::PyOptimizerAlgASync;
 %include "PyOptimizerAlg.hxx"
+
+%extend YACS::ENGINE::RuntimeSALOME
+{
+  PyObject *createContainer(const std::string& kind="")
+  {
+    YACS::ENGINE::Container *ret(self->createContainer(kind));
+    return convertContainer2(ret,SWIG_POINTER_OWN | 0);
+  }
+}
index 5846152511284a68aba388c9cfd5715bf7443259..c457d5da8d3fe64c0545ffb65d2402ea0bf6551a 100644 (file)
@@ -58,8 +58,6 @@
 using namespace std;
 using namespace YACS::HMI;
 
-int  Yacsgui::_oldStudyId = -1;
-
 Yacsgui::Yacsgui() :
   SalomeWrap_Module( "YACS" ) // default name
 {
@@ -67,7 +65,7 @@ Yacsgui::Yacsgui() :
   _wrapper = 0;
   _genericGui = 0;
   _selectFromTree = false;
-  _studyContextMap.clear();
+  _studyContext = 0;
 }
 
 Yacsgui::~Yacsgui()
@@ -111,7 +109,7 @@ void Yacsgui::initialize( CAM_Application* app )
   _genericGui->createActions();
   _genericGui->createMenus();
   _genericGui->createTools();
-  this->studyActivated();
+  _studyContext = QtGuiContext::getQtCurrent();
 
   // VSR 23/10/2014: note that this is not a good way to create SComponent from this point
   // as initialize() method can be potentially called when there's no yet open study;
@@ -207,8 +205,8 @@ bool Yacsgui::deactivateModule( SUIT_Study* theStudy )
   setToolShown( false );
   _genericGui->showDockWidgets(false);
   QtGuiContext *context = QtGuiContext::getQtCurrent();
-  _studyContextMap[theStudy->id()] = context;
-  DEBTRACE("_studyContextMap[theStudy] " << theStudy << " " << context);
+  _studyContext = context;
+  DEBTRACE("_studyContext " << theStudy << " " << context);
   return SalomeApp_Module::deactivateModule( theStudy );
 }
 
@@ -280,7 +278,7 @@ void Yacsgui::onWindowActivated( SUIT_ViewWindow* svw)
 
   YASSERT(_genericGui);
   _genericGui->switchContext(viewWindow);
-  _studyContextMap[getApp()->activeStudy()->id()] = QtGuiContext::getQtCurrent();
+  _studyContext = QtGuiContext::getQtCurrent();
   
   if (_selectFromTree) return;
   SalomeWrap_DataModel *model = dynamic_cast<SalomeWrap_DataModel*>(dataModel());
@@ -359,27 +357,6 @@ void Yacsgui::preferencesChanged( const QString& sect, const QString& name )
     }
 }
 
-void Yacsgui::studyActivated()
-{
-  int newStudyId = getApp()->activeStudy()->id();
-  DEBTRACE("Yacsgui::studyActivated " << _oldStudyId << " " << newStudyId);
-  
-  if (_oldStudyId != -1)
-    {
-      _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();      
-      if (_studyContextMap.count(newStudyId))
-        {
-          DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
-          QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
-        }
-      else
-        {
-          DEBTRACE("no switch to null context");
-        }
-    }
-  _oldStudyId = newStudyId;
-}
-
 void Yacsgui::loadSchema(const std::string& filename,bool edit, bool arrangeLocalNodes)
 {
   _genericGui->loadSchema(filename,edit,arrangeLocalNodes);
index 7948f1608eacff03a83fc9cf468d10a152d9e7d8..27dc99d366b34e4c64aa9c31ca80dc887e9c4dc0 100644 (file)
@@ -59,7 +59,6 @@ public:
   virtual void createPreferences();
   virtual void preferencesChanged( const QString& sect, const QString& name );
   virtual void loadSchema(const std::string& filename,bool edit=true, bool arrangeLocalNodes=false);
-  virtual void studyActivated();
   
 public slots:
   bool deactivateModule( SUIT_Study* theStudy);
@@ -81,8 +80,7 @@ protected:
   bool _selectFromTree;
   Yacsgui_Resource* _myresource;
   SUIT_ViewWindow* _currentSVW;
-  std::map<int, YACS::HMI::QtGuiContext*> _studyContextMap;
-  static int _oldStudyId;
+  YACS::HMI::QtGuiContext* _studyContext;
 };
 
 #endif
index b04b536af223ba3af5a99b105cf3ba68d31b7297..6281f8f008a59631412f966a0daffe95ad5dc6a7 100644 (file)
@@ -38,7 +38,6 @@
                 <component-author>P. RASCLE</component-author>
                 <component-version>@SALOMEYACS_VERSION@</component-version>
                 <component-comment>EDF - RD</component-comment>
-                <component-multistudy>1</component-multistudy>
                 <component-icone>ModuleYacs.png</component-icone>
                 <constraint>'linux' ~ OS</constraint>
        
index 1673967d6abda69e17b0d499097cf89e4e29829a..2b62743388ef8bf04e4f663a19187f924caf61ba 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0'?>
 <proc>
-   <property name="DefaultStudyID" value="1"/>
    <objref name="GEOM_Shape" id="IDL:GEOM/GEOM_Object:1.0"/>
    <type name="bool" kind="bool"/>
    <sequence name="boolvec" content="bool"/>
index db0ca172ac97a3601c2671cc3dcd725a85a2e2e8..9d1255437cbeba54daedb35029dab4fd236cb66c 100644 (file)
@@ -90,6 +90,7 @@ SET(SWIG_MODULE_libYACS_Swig_EXTRA_DEPS YACSGUI_Swig.hxx)
 SWIG_ADD_MODULE(libYACS_Swig python libYACS_Swig.i YACSGUI_Swig.cxx)
 
 SWIG_LINK_LIBRARIES(libYACS_Swig "${_link_LIBRARIES}")
+SWIG_CHECK_GENERATION(libYACS_Swig)
 IF(WIN32)
   SET_TARGET_PROPERTIES(_libYACS_Swig PROPERTIES DEBUG_OUTPUT_NAME _libYACS_Swig_d)
 ENDIF(WIN32)
index 35a6b168a1a231edc5e326279349e4cd8bc9913c..d4ab7aa0e9360aec1504a0a1f78929b4c90810c2 100644 (file)
@@ -31,9 +31,6 @@
     <service>
 <service-name>GeomGraph</service-name>
      <inParameter-list>
-<inParameter>
-<inParameter-type>long</inParameter-type>
-       <inParameter-name>SetStudyID__theStudyID</inParameter-name>      </inParameter>
       <inParameter>
 <inParameter-type>double</inParameter-type>
        <inParameter-name>MakeBox__theX1</inParameter-name>      </inParameter>
     <x-position>0</x-position>
     <y-position>0</y-position>   </node>  </info-list>
   <node-list>
-<node>
-<component-name>GEOM_Superv</component-name>
-    <interface-name>GEOM_Superv</interface-name>
-    <node-name>SetStudyID</node-name>
-    <kind>0</kind>
-    <coupled-node>?</coupled-node>
-    <service>
-<service-name>SetStudyID</service-name>
-     <inParameter-list>
-<inParameter>
-<inParameter-type>long</inParameter-type>
-       <inParameter-name>theStudyID</inParameter-name>      </inParameter>     </inParameter-list>
-     <outParameter-list/>    </service>
-    <DataStream-list/>
-    <PyFunction-list/>
-    <creation-date>6/6/2005 - 10:39:55</creation-date>
-    <lastmodification-date>6/6/2005 - 10:39:55</lastmodification-date>
-    <editor-release>2.0</editor-release>
-    <author>?</author>
-    <container>localhost/FactoryServer</container>
-    <comment>SetStudyID from GEOM_Superv</comment>
-    <x-position>14</x-position>
-    <y-position>241</y-position>   </node>
+
    <node>
 <component-name>GEOM_Superv</component-name>
     <interface-name>GEOM_Superv</interface-name>
     <x-position>993</x-position>
     <y-position>312</y-position>   </node>  </node-list>
   <link-list>
-<link>
-<fromnode-name>SetStudyID</fromnode-name>
-    <fromserviceparameter-name>Gate</fromserviceparameter-name>
-    <tonode-name>MakeBox</tonode-name>
-    <toserviceparameter-name>Gate</toserviceparameter-name>
-    <coord-list/>   </link>
-   <link>
-<fromnode-name>SetStudyID</fromnode-name>
-    <fromserviceparameter-name>Gate</fromserviceparameter-name>
-    <tonode-name>MakeSphere_1</tonode-name>
-    <toserviceparameter-name>Gate</toserviceparameter-name>
-    <coord-list/>   </link>
    <link>
 <fromnode-name>MakeBox</fromnode-name>
     <fromserviceparameter-name>return</fromserviceparameter-name>
     <toserviceparameter-name>theShape1</toserviceparameter-name>
     <coord-list/>   </link>  </link-list>
   <data-list>
-<data>
-<fromnode-name>GeomGraph</fromnode-name>
-    <fromserviceparameter-name>SetStudyID__theStudyID</fromserviceparameter-name>
-    <tonode-name>SetStudyID</tonode-name>
-    <toserviceparameter-name>theStudyID</toserviceparameter-name>
-    <data-value>
-<value-type>3</value-type>
-     <value>1</value>    </data-value>
-    <coord-list/>   </data>
    <data>
 <fromnode-name>GeomGraph</fromnode-name>
     <fromserviceparameter-name>MakeBox__theX1</fromserviceparameter-name>
index 392ca69495abe18ff1b2ac8e2bad23fb1f1861dd..895d26f12abc05249647ca5461b103be075cd124 100644 (file)
     <service>
      <service-name>GeomGraph</service-name>
      <inParameter-list>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>SetStudyID__theStudyID</inParameter-name>
-      </inParameter>
       <inParameter>
        <inParameter-type>double</inParameter-type>
        <inParameter-name>MakeBox__theX1</inParameter-name>
    </node>
   </info-list>
   <node-list>
-   <node>
-    <component-name>GEOM_Superv</component-name>
-    <interface-name>GEOM_Superv</interface-name>
-    <node-name>SetStudyID</node-name>
-    <kind>0</kind>
-    <coupled-node>?</coupled-node>
-    <service>
-     <service-name>SetStudyID</service-name>
-     <inParameter-list>
-      <inParameter>
-       <inParameter-type>long</inParameter-type>
-       <inParameter-name>theStudyID</inParameter-name>
-      </inParameter>
-     </inParameter-list>
-     <outParameter-list/>
-    </service>
-    <DataStream-list/>
-    <PyFunction-list/>
-    <creation-date>14/12/2005 - 14:39:18</creation-date>
-    <lastmodification-date>14/12/2005 - 14:39:18</lastmodification-date>
-    <editor-release>2.0</editor-release>
-    <author>?</author>
-    <container>localhost/FactoryServer</container>
-    <comment>SetStudyID from GEOM_Superv</comment>
-    <x-position>14</x-position>
-    <y-position>241</y-position>
-   </node>
    <node>
     <component-name>GEOM_Superv</component-name>
     <interface-name>GEOM_Superv</interface-name>
    </node>
   </node-list>
   <link-list>
-   <link>
-    <fromnode-name>SetStudyID</fromnode-name>
-    <fromserviceparameter-name>Gate</fromserviceparameter-name>
-    <tonode-name>MakeBox</tonode-name>
-    <toserviceparameter-name>Gate</toserviceparameter-name>
-    <coord-list/>
-   </link>
    <link>
     <fromnode-name>MakeBox</fromnode-name>
     <fromserviceparameter-name>return</fromserviceparameter-name>
    </link>
   </link-list>
   <data-list>
-   <data>
-    <fromnode-name>GeomGraph</fromnode-name>
-    <fromserviceparameter-name>SetStudyID__theStudyID</fromserviceparameter-name>
-    <tonode-name>SetStudyID</tonode-name>
-    <toserviceparameter-name>theStudyID</toserviceparameter-name>
-    <data-value>
-     <value-type>3</value-type>
-     <value>1</value>
-    </data-value>
-    <coord-list/>
-   </data>
    <data>
     <fromnode-name>GeomGraph</fromnode-name>
     <fromserviceparameter-name>MakeBox__theX1</fromserviceparameter-name>
index a115852150a65909173e6512c7b1baa9d44b8130..39201eaf10e8ad2c3191c3582d723f6754aaf2c7 100644 (file)
       <PyFunc><![CDATA[    shape = MakeBoolean(shape1,shape2,3) ]]></PyFunc>
       <PyFunc><![CDATA[    from SALOME_NamingServicePy import SALOME_NamingServicePy_i ]]></PyFunc>
       <PyFunc><![CDATA[    myNamingService = SALOME_NamingServicePy_i(orb) ]]></PyFunc>
-      <PyFunc><![CDATA[    aSession = myNamingService.Resolve('/Kernel/Session') ]]></PyFunc>
-      <PyFunc><![CDATA[    aStudyId = aSession.GetActiveStudyId() ]]></PyFunc>
-      <PyFunc><![CDATA[    myStudyManager = myNamingService.Resolve('/myStudyManager') ]]></PyFunc>
-      <PyFunc><![CDATA[    aStudy = myStudyManager.GetStudyByID(aStudyId) ]]></PyFunc>
+      <PyFunc><![CDATA[    aStudy = myNamingService.Resolve('/Study') ]]</PyFunc>
       <PyFunc><![CDATA[    aSObject = geom.AddInStudy(aStudy, shape, "shape", None) ]]></PyFunc>
       <PyFunc><![CDATA[    return shape ]]></PyFunc>
      </PyFunction>
index 102d8182fd73f984110add663e4dab9a7fcf5c0d..47e2d9c8308cd9c2aecdc72fb4e72c2bd866545c 100644 (file)
       <PyFunc><![CDATA[    # fuse operation 3          ]]></PyFunc>
       <PyFunc><![CDATA[    shape = MakeBoolean(shape1,shape2,3) ]]></PyFunc>
       <PyFunc><![CDATA[    myNamingService = SALOME_NamingServicePy_i(orb) ]]></PyFunc>
-      <PyFunc><![CDATA[    aSession = myNamingService.Resolve('/Kernel/Session') ]]></PyFunc>
-      <PyFunc><![CDATA[    if aSession == None : ]]></PyFunc>
-      <PyFunc><![CDATA[      aStudyId = 1 ]]></PyFunc>
-      <PyFunc><![CDATA[    else : ]]></PyFunc>
-      <PyFunc><![CDATA[      aStudyId = aSession.GetActiveStudyId() ]]></PyFunc>
-      <PyFunc><![CDATA[    myStudyManager = myNamingService.Resolve('/myStudyManager') ]]></PyFunc>
-      <PyFunc><![CDATA[    aStudy = myStudyManager.GetStudyByID(aStudyId) ]]></PyFunc>
+      <PyFunc><![CDATA[    aStudy = myNamingService.Resolve('/Study') ]]</PyFunc>
       <PyFunc><![CDATA[    aSObject = geom.AddInStudy(aStudy, shape, "shape", None) ]]></PyFunc>
       <PyFunc><![CDATA[    return shape ]]></PyFunc>     </PyFunction>    </PyFunction-list>
     <creation-date>29/10/2004 - 10:50:25</creation-date>
index 61f005ebbf931bd7adfb901dac049472f6554589..fc0d95ff63d4c7c32f1bb2a44dfab8751b41ddd4 100644 (file)
       <PyFunc><![CDATA[    lcc = LifeCycleCORBA(orb)                     ]]></PyFunc>
       <PyFunc><![CDATA[    # --- create a naming service instance              ]]></PyFunc>
       <PyFunc><![CDATA[    naming_service = SALOME_NamingServicePy_i(orb)    ]]></PyFunc>
-      <PyFunc><![CDATA[    # --- get Study Manager reference                     ]]></PyFunc>
-      <PyFunc><![CDATA[    obj = naming_service.Resolve('myStudyManager')    ]]></PyFunc>
-      <PyFunc><![CDATA[    StudyManager = obj._narrow(SALOMEDS.StudyManager)    ]]></PyFunc>
       <PyFunc><![CDATA[    # --- load visu component                          ]]></PyFunc>
       <PyFunc><![CDATA[    aVisu = lcc.FindOrLoadComponent("FactoryServer","VISU")       ]]></PyFunc>
-      <PyFunc><![CDATA[    aStudy = StudyManager.GetStudyByID(1)      ]]></PyFunc>
-      <PyFunc><![CDATA[    aVisu.SetCurrentStudy(aStudy)      ]]></PyFunc>
       <PyFunc><![CDATA[    print("InitDisplay --> aVisu ", aVisu)         ]]></PyFunc>
       <PyFunc><![CDATA[    time.sleep(2)         ]]></PyFunc>
       <PyFunc><![CDATA[    aViewManager=aVisu.GetViewManager()         ]]></PyFunc>
index f22c7a17a0dafe0c5b4f1b494ffbba1e67342aca..f98a59c79887d1b5f7fb665b0bf561e354434f38 100644 (file)
@@ -71,17 +71,11 @@ QxScene_ViewWindow* SalomeWrap_Module::getNewWindow(QGraphicsScene *scene)
   return aView;
 }
 
-int SalomeWrap_Module::AssociateViewToWindow(QGraphicsView* gView,
+void SalomeWrap_Module::AssociateViewToWindow(QGraphicsView* gView,
                                              QxScene_ViewWindow* viewWindow)
 {
   viewWindow->setSceneView(gView);
   viewWindow->setCentralWidget(gView);
-  return viewWindow->getViewManager()->study()->id();
-}
-
-int SalomeWrap_Module::activeStudyId()
-{
-  return getApp()->activeStudy()->id();
 }
 
 QDockWidget* SalomeWrap_Module::objectBrowser() {
index 811686c814972c8e4eef7abfc05d6785812c5d7f..9ad35365ab4e8b8412c00ee6d0ffba4e96ed3d15 100644 (file)
@@ -45,11 +45,9 @@ public:
 
   QxScene_ViewWindow* getNewWindow(QGraphicsScene *scene);
 
-  int AssociateViewToWindow(QGraphicsView* gView,
+  void AssociateViewToWindow(QGraphicsView* gView,
                             QxScene_ViewWindow* viewWindow);
 
-  int activeStudyId();
-
   QDockWidget* objectBrowser();
 
   QAction* wCreateAction(const int id,
index a8bda02d748b0e8aac9393b5b2c99de28c97b6c3..3d5abbcf785b04da12dd603065edc9e6bc9bfcfa 100644 (file)
@@ -60,15 +60,12 @@ QWidget* SuitWrapper::getNewWindow(QGraphicsScene *scene)
   return module->getNewWindow(scene);
 }
 
-/*!
- * return studyId used in context delete when study is closed.
- */
-int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
+void SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
 {
   SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
   YASSERT(svw);
-  int studyId = module->AssociateViewToWindow(gView, svw);
+  module->AssociateViewToWindow(gView, svw);
   WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
   YASSERT(wgv);
   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
@@ -112,13 +109,6 @@ int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow
   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
                    SIGNAL(triggered(bool)),
                    wgv, SLOT(onViewReset()));
-  return studyId;
-}
-
-int SuitWrapper::activeStudyId()
-{
-  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
-  return module->activeStudyId();
 }
 
 QDockWidget* SuitWrapper::objectBrowser()
index 5e12bc55c33ad0b6fcf563b807ca5b91ad48bfa4..5135f2b85e8bf53582a62db9184e22d76d50957e 100644 (file)
@@ -47,8 +47,8 @@ namespace YACS
       virtual ~SuitWrapper();
 
       QWidget* getNewWindow(QGraphicsScene *scene);
-      int AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow);
-      int activeStudyId();
+      void AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow);
+
       QDockWidget* objectBrowser();
 
       QAction* createAction(const int id,
index cb1d7b05e99b7fea35b0cdf472f8c2c3b9c4d709..ab53018b439d78607f049758faf7a255e22d2e44 100755 (executable)
@@ -24,19 +24,19 @@ usage="""USAGE: runSalome.py [options]
 --help                        : affichage de l'aide
 --gui                         : lancement du GUI
 --logger                      : redirection des messages dans un fichier
---xterm                       : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre
---modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue
+--xterm                       : les serveurs ouvrent une fen??tre xterm et les messages sont affich??s dans cette fen??tre
+--modules=module1,module2,... : o?? modulen est le nom d'un module Salome ?? charger dans le catalogue
 --containers=cpp,python,superv: lancement des containers cpp, python et de supervision
---killall                     : arrêt des serveurs de salome
+--killall                     : arr??t des serveurs de salome
 
- La variable d'environnement <modulen>_ROOT_DIR doit etre préalablement
- positionnée (modulen doit etre en majuscule).
+ La variable d'environnement <modulen>_ROOT_DIR doit etre pr??alablement
+ positionn??e (modulen doit etre en majuscule).
  KERNEL_ROOT_DIR est obligatoire.
 """
 
 # -----------------------------------------------------------------------------
 #
-# Fonction d'arrêt de salome
+# Fonction d'arr??t de salome
 #
 
 def killSalome():
@@ -128,7 +128,7 @@ except getopt.error as msg:
 
 # -----------------------------------------------------------------------------
 #
-# Vérification des variables d'environnement
+# V??rification des variables d'environnement
 #
 try:
     kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
@@ -148,7 +148,7 @@ for module in liste_modules :
 
 # il faut KERNEL en premier dans la liste des modules
 # - l'ordre des modules dans le catalogue sera identique
-# - la liste des modules presents dans le catalogue est exploitée pour charger les modules CORBA python,
+# - la liste des modules presents dans le catalogue est exploit??e pour charger les modules CORBA python,
 #   il faut charger les modules python du KERNEL en premier
 
 if "KERNEL" in liste_modules:liste_modules.remove("KERNEL")
@@ -162,7 +162,7 @@ if "SUPERV" in liste_modules:with_container_superv=1
 
 # -----------------------------------------------------------------------------
 #
-# Définition des classes d'objets pour le lancement des Server CORBA
+# D??finition des classes d'objets pour le lancement des Server CORBA
 #
 
 class Server:
@@ -342,7 +342,7 @@ def startSalome():
     RegistryServer().run()
 
     #
-    # Attente de la disponibilité du Registry dans le Naming Service
+    # Attente de la disponibilit?? du Registry dans le Naming Service
     #
     clt.waitNS("/Registry")
 
@@ -354,7 +354,7 @@ def startSalome():
     cataServer.run()
 
     #
-    # Attente de la disponibilité du Catalog Server dans le Naming Service
+    # Attente de la disponibilit?? du Catalog Server dans le Naming Service
     #
     import SALOME_ModuleCatalog
     clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
@@ -372,7 +372,7 @@ def startSalome():
 
 
     #
-    # Attente de la disponibilité du SalomeDS dans le Naming Service
+    # Attente de la disponibilit?? du SalomeDS dans le Naming Service
     #
     clt.waitNS("/myStudyManager")
 
@@ -382,7 +382,7 @@ def startSalome():
     SessionServer().run()
 
     #
-    # Attente de la disponibilité du Session Server dans le Naming Service
+    # Attente de la disponibilit?? du Session Server dans le Naming Service
     #
     import SALOME
     session=clt.waitNS("/Kernel/Session",SALOME.Session)
@@ -399,7 +399,7 @@ def startSalome():
     if with_container_cpp:
         ContainerCPPServer().run()
         #
-        # Attente de la disponibilité du Container C++ local
+        # Attente de la disponibilit?? du Container C++ local
         # dans le Naming Service
         #
         clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
@@ -409,7 +409,7 @@ def startSalome():
     if with_container_python:
         ContainerPYServer().run()
         #
-        # Attente de la disponibilité du Container Python local
+        # Attente de la disponibilit?? du Container Python local
         #  dans le Naming Service
         #
         clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
@@ -420,7 +420,7 @@ def startSalome():
         #
         ContainerSUPERVServer().run()
         #
-        # Attente de la disponibilité du Container Supervision local
+        # Attente de la disponibilit?? du Container Supervision local
         # dans le Naming Service
         #
         clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
@@ -463,13 +463,13 @@ if __name__ == "__main__":
  Sauvegarde du dictionnaire des process dans , %s
  Pour tuer les process SALOME, executer : python killSalome.py depuis
  une console, ou bien killSalome() depuis le present interpreteur,
- s'il n'est pas fermé.
+ s'il n'est pas ferm??.
 
  runSalome, avec l'option --killall, commence par tuer les process restants
- d'une execution précédente.
+ d'une execution pr??c??dente.
 
  Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur,
- s'il n'est pas fermé.
+ s'il n'est pas ferm??.
 
  """ % filedict)
 
index cb1d7b05e99b7fea35b0cdf472f8c2c3b9c4d709..ab53018b439d78607f049758faf7a255e22d2e44 100755 (executable)
@@ -24,19 +24,19 @@ usage="""USAGE: runSalome.py [options]
 --help                        : affichage de l'aide
 --gui                         : lancement du GUI
 --logger                      : redirection des messages dans un fichier
---xterm                       : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre
---modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue
+--xterm                       : les serveurs ouvrent une fen??tre xterm et les messages sont affich??s dans cette fen??tre
+--modules=module1,module2,... : o?? modulen est le nom d'un module Salome ?? charger dans le catalogue
 --containers=cpp,python,superv: lancement des containers cpp, python et de supervision
---killall                     : arrêt des serveurs de salome
+--killall                     : arr??t des serveurs de salome
 
- La variable d'environnement <modulen>_ROOT_DIR doit etre préalablement
- positionnée (modulen doit etre en majuscule).
+ La variable d'environnement <modulen>_ROOT_DIR doit etre pr??alablement
+ positionn??e (modulen doit etre en majuscule).
  KERNEL_ROOT_DIR est obligatoire.
 """
 
 # -----------------------------------------------------------------------------
 #
-# Fonction d'arrêt de salome
+# Fonction d'arr??t de salome
 #
 
 def killSalome():
@@ -128,7 +128,7 @@ except getopt.error as msg:
 
 # -----------------------------------------------------------------------------
 #
-# Vérification des variables d'environnement
+# V??rification des variables d'environnement
 #
 try:
     kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
@@ -148,7 +148,7 @@ for module in liste_modules :
 
 # il faut KERNEL en premier dans la liste des modules
 # - l'ordre des modules dans le catalogue sera identique
-# - la liste des modules presents dans le catalogue est exploitée pour charger les modules CORBA python,
+# - la liste des modules presents dans le catalogue est exploit??e pour charger les modules CORBA python,
 #   il faut charger les modules python du KERNEL en premier
 
 if "KERNEL" in liste_modules:liste_modules.remove("KERNEL")
@@ -162,7 +162,7 @@ if "SUPERV" in liste_modules:with_container_superv=1
 
 # -----------------------------------------------------------------------------
 #
-# Définition des classes d'objets pour le lancement des Server CORBA
+# D??finition des classes d'objets pour le lancement des Server CORBA
 #
 
 class Server:
@@ -342,7 +342,7 @@ def startSalome():
     RegistryServer().run()
 
     #
-    # Attente de la disponibilité du Registry dans le Naming Service
+    # Attente de la disponibilit?? du Registry dans le Naming Service
     #
     clt.waitNS("/Registry")
 
@@ -354,7 +354,7 @@ def startSalome():
     cataServer.run()
 
     #
-    # Attente de la disponibilité du Catalog Server dans le Naming Service
+    # Attente de la disponibilit?? du Catalog Server dans le Naming Service
     #
     import SALOME_ModuleCatalog
     clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
@@ -372,7 +372,7 @@ def startSalome():
 
 
     #
-    # Attente de la disponibilité du SalomeDS dans le Naming Service
+    # Attente de la disponibilit?? du SalomeDS dans le Naming Service
     #
     clt.waitNS("/myStudyManager")
 
@@ -382,7 +382,7 @@ def startSalome():
     SessionServer().run()
 
     #
-    # Attente de la disponibilité du Session Server dans le Naming Service
+    # Attente de la disponibilit?? du Session Server dans le Naming Service
     #
     import SALOME
     session=clt.waitNS("/Kernel/Session",SALOME.Session)
@@ -399,7 +399,7 @@ def startSalome():
     if with_container_cpp:
         ContainerCPPServer().run()
         #
-        # Attente de la disponibilité du Container C++ local
+        # Attente de la disponibilit?? du Container C++ local
         # dans le Naming Service
         #
         clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
@@ -409,7 +409,7 @@ def startSalome():
     if with_container_python:
         ContainerPYServer().run()
         #
-        # Attente de la disponibilité du Container Python local
+        # Attente de la disponibilit?? du Container Python local
         #  dans le Naming Service
         #
         clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
@@ -420,7 +420,7 @@ def startSalome():
         #
         ContainerSUPERVServer().run()
         #
-        # Attente de la disponibilité du Container Supervision local
+        # Attente de la disponibilit?? du Container Supervision local
         # dans le Naming Service
         #
         clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
@@ -463,13 +463,13 @@ if __name__ == "__main__":
  Sauvegarde du dictionnaire des process dans , %s
  Pour tuer les process SALOME, executer : python killSalome.py depuis
  une console, ou bien killSalome() depuis le present interpreteur,
- s'il n'est pas fermé.
+ s'il n'est pas ferm??.
 
  runSalome, avec l'option --killall, commence par tuer les process restants
- d'une execution précédente.
+ d'une execution pr??c??dente.
 
  Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur,
- s'il n'est pas fermé.
+ s'il n'est pas ferm??.
 
  """ % filedict)
 
index 716d97dfeea71c76b474c94ec4c270bdf6d4c2f6..8acdb68bd27ab370c56d5d3b79336ca61cca1ed1 100644 (file)
@@ -36,7 +36,6 @@ BEGIN {
         "      <component-author>""</component-author>\n"\
         "      <component-version>1.0</component-version>\n"\
         "      <component-comment></component-comment>\n"\
-        "      <component-multistudy>1</component-multistudy>\n"\
         "      <component-icone>"class_name".png</component-icone>\n"\
         "      <component-impltype>1</component-impltype>\n"\
         "      <component-interface-list>" >> catalog_file
index 8055187cd673e7ebff30586e2d33993065ec104e..3d6f705f80a3595671d2d412bf4f2cb674b0365c 100755 (executable)
@@ -40,7 +40,7 @@ if test "$hh" = "1" ; then
     echo ""
     echo "   to run IDLparser:"
     echo ""
-    echo "        $0 -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,multistudy=<component_multistudy>][,remove=component_name] <file.idl>   "
+    echo "        $0 -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,remove=component_name] <file.idl>   "
     echo ""
     echo "   to have omniidl help:"
     echo ""
index 570925302101d200a890635797c967cd90c78fe6..db84e6ff144094528ebf5116156741eb12139b72 100644 (file)
@@ -506,6 +506,7 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
           if(std::string(attr[i]) == "name")name(attr[i+1]);
           if(std::string(attr[i]) == "state")this->state(attr[i+1]);
           if(std::string(attr[i]) == "nbranch")nbranch(atoi(attr[i+1]));
+          if(std::string(attr[i]) == "weight")weight(atof(attr[i+1]));
           if(std::string(attr[i]) == "type")datatype(attr[i+1]);
         }
       postAttr();
@@ -513,6 +514,7 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
   virtual void pre ()
     {
       _nbranch=0;
+      _weight=1;
       this->looptypeParser<T>::pre();
     }
   virtual void name (const std::string& name)
@@ -526,6 +528,11 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
       DEBTRACE("foreach_nbranch: " << n )
       _nbranch=n;
     }
+  virtual void weight (const double& x)
+    {
+      DEBTRACE("foreach_weight: " << x )
+      _weight=x;
+    }
   virtual void datatype (const std::string& type)
     {
       DEBTRACE("foreach_datatype: "<< type)
@@ -552,6 +559,7 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
       this->_cnode=theRuntime->createForEachLoop(_name,currentProc->typeMap[_datatype]);
       //set number of branches
       if(_nbranch > 0)this->_cnode->edGetNbOfBranchesPort()->edInit(_nbranch);
+      this->_cnode->setWeight(_weight);
       this->_cnodes.push_back(this->_cnode);
       currentProc->names.push_back(_fullname + '.');
     }
@@ -565,6 +573,7 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
       return b;
     }
   int _nbranch;
+  double _weight;
   std::string _fullname;
   std::string _name;
   std::string _datatype;
@@ -595,6 +604,7 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
           if(std::string(attr[i]) == "name")name(attr[i+1]);
           if(std::string(attr[i]) == "state")this->state(attr[i+1]);
           if(std::string(attr[i]) == "nbranch")nbranch(atoi(attr[i+1]));
+          if(std::string(attr[i]) == "weight")weight(atof(attr[i+1]));
           if(std::string(attr[i]) == "lib")lib(attr[i+1]);
           if(std::string(attr[i]) == "entry")entry(attr[i+1]);
           if(std::string(attr[i]) == "kind")kind(attr[i+1]);
@@ -604,6 +614,7 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
   virtual void pre ()
     {
       _nbranch=0;
+      _weight=1;
       this->looptypeParser<T>::pre();
     }
   virtual void name (const std::string& name)
@@ -625,6 +636,11 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
       DEBTRACE("optimizer_nbranch: " << n )
       _nbranch=n;
     }
+  virtual void weight (const double& x)
+    {
+      DEBTRACE("foreach_weight: " << x )
+      _weight=x;
+    }
   virtual void kind (const std::string& name)
     {
       _kind=name;
@@ -634,6 +650,7 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
       this->_cnode=theRuntime->createOptimizerLoop(_name,_lib,_entry,true,_kind, currentProc);
       //set number of branches
       if(_nbranch > 0)this->_cnode->edGetNbOfBranchesPort()->edInit(_nbranch);
+      this->_cnode->setWeight(_weight);
       this->_cnodes.push_back(this->_cnode);
       currentProc->names.push_back(_fullname + '.');
     }
@@ -648,6 +665,7 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
     }
 
   int _nbranch;
+  double _weight;
   std::string _fullname;
   std::string _name;
   std::string _entry;
index c2e754c4cf14ed2b55cac0e7baf2cdab5624f915..29bff239888da1be179c5e66279b54f3fd296992 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="proc">
-   <property name="DefaultStudyID" value="1"/>
    <type name="bool" kind="bool"/>
    <type name="double" kind="double"/>
    <type name="string" kind="string"/>
index a246838ecfcf0c133adff34c9decf255967001f7..ec55a5859f142388c41ea90598f90c7942900786 100644 (file)
@@ -39,7 +39,6 @@
       <property name="workingdir" value=""/>
    </container>
    <datanode name="StudyInNode0" kind="study">
-      <property name="StudyID" value="1"/>
       <parameter name="a" type="GEOM_Object" ref="/Geometry/Box_1"/>
       <parameter name="b" type="GEOM_Object" ref="/Geometry/Sphere_1"/>
    </datanode>
@@ -61,19 +60,11 @@ y=b
       <outport name="return" type="GEOM_Object"/>
    </service>
    <outnode name="StudyOutNode0" kind="study">
-      <property name="StudyID" value="1"/>
       <parameter name="a" type="GEOM_Object" ref="/Geometry/YacsFuse"/>
    </outnode>
-   <service name="SalomeNode1">
-      <node>SalomeNode0</node>
-      <method>SetStudyID</method>
-      <inport name="theStudyID" type="Int"/>
-   </service>
    <control> <fromnode>StudyInNode0</fromnode> <tonode>PyScript0</tonode> </control>
-   <control> <fromnode>StudyInNode0</fromnode> <tonode>SalomeNode1</tonode> </control>
    <control> <fromnode>PyScript0</fromnode> <tonode>SalomeNode0</tonode> </control>
    <control> <fromnode>SalomeNode0</fromnode> <tonode>StudyOutNode0</tonode> </control>
-   <control> <fromnode>SalomeNode1</fromnode> <tonode>SalomeNode0</tonode> </control>
    <datalink control="false">
       <fromnode>StudyInNode0</fromnode> <fromport>a</fromport>
       <tonode>PyScript0</tonode> <toport>a</toport>
@@ -94,8 +85,4 @@ y=b
       <fromnode>SalomeNode0</fromnode> <fromport>return</fromport>
       <tonode>StudyOutNode0</tonode> <toport>a</toport>
    </datalink>
-   <parameter>
-      <tonode>SalomeNode1</tonode><toport>theStudyID</toport>
-      <value><int>1</int></value>
-   </parameter>
 </proc>
index d0b72c4ff5bfeafa27514ca803b4a520431777ec..01a1efbb9fff648ee8916a996725d823c54ad5cd 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="proc">
-   <property name="DefaultStudyID" value="1"/>
    <objref name="CALCIUM_integer" id="IDL:CALCIUM_integer:1.0"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
index 721f094847951fa84b1de83725df6d1bd9efefc9..edbcdb72223eca0d4a811ce5f5342d118967cca6 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 4607c61a3648ce2da39a038e7d1bc38d7fd3a63b..0b080ef0033536d521866a105e37d58fe79477ba 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="schema">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index fa3ed961c76ff2438b60dc2e63ccdd319c6840ea..1c298089005562393cf16da1035cd794d65dbb2b 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="Schema">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 2d6c3674017f1cd3c142196d478d569b58b317a3..fe9edb2af058ace9d0ef47d64cdf3ac00ce9c040 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="Schema">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 0edbd46a6436ae76ce246d0c4fb866ccec5b7114..e33fd20505fc9b19a120208ab01aa7fcf1d24d0c 100644 (file)
@@ -44,7 +44,6 @@
 
     <!--nodes -->
     <datanode name="s" kind="study" >
-      <property name="StudyID" value="1" />
       <parameter name="b" type="FIELDDOUBLE" ref="0:1:1:3:2:1"/>
     </datanode>
     <datanode name="d" >
index b47d16aee03dd711ded3989eb983c80bf4f0e16c..9a2c2d52e9d5fe823e7887b2e8549aac670746d3 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 84a4627a44c2e6787af322b6e11ced56b6cd1f8d..cf646d1a18f263e91df1d8682bed27820bc4c6f8 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 22a8255332ee2a5589f9b9832d8efda1b96275a4..d465f9e069813f951a5277a787350807233473c8 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="optim">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 85a447ccfbacb105a3c638722d6b1c8dc53fdcf2..6b9dc597cfd424ac2511b281338e7d56c010ffe9 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 0cdcb4cb7fe738f6d2ca14474ac66b95657b66d9..4a3357cb59c16427ca300c78960d3dc5a0752da8 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index dbffbf097bdc96c283563a688c6432030cd7b69e..60fda24e5c3acad80aad488eb7b04e19e1a23a77 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="TestDistPython2">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 77c10f7018c99bd9312de8bb9cf96723037db6d0..6963e8a5232e6788080b23372a2c72d48ba81082 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index dd7c99e0c8b4cd586927d525dcbbcdee44bad1b3..d068f831166578867bd3a7f67cac4884248ef4f6 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index e61f74e8d501ce5156ea6bff5c8ed8ec2dcdcc01..c9d84d182d3f25285d46d242698c64b4463ca1c3 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="TestDistPython2">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index c9115ed719e7ab23101a3a8dc61ea3a3292a5d2c..b8b83b10f8a633ee945b7cf385b216c7377ee472 100644 (file)
         <code>orb = CORBA.ORB_init([], CORBA.ORB_ID)</code>
         <code>lcc = LifeCycleCORBA(orb)</code>
         <code>naming_service = SALOME_NamingServicePy_i(orb)</code>
-        <code>StudyManager = naming_service.Resolve('myStudyManager')</code>
         <code>aVisu = lcc.FindOrLoadComponent("FactoryServer","VISU")</code>
-        <code>aStudy = StudyManager.GetStudyByID(1)</code>
-        <code>aVisu.SetCurrentStudy(aStudy)</code>
         <code>aViewManager=aVisu.GetViewManager()</code>
         <code>aView=aViewManager.Create3DView()</code>
         <code>medFile = os.getenv('DATA_DIR') + '/MedFiles/' + "TimeStamps.med" </code>
         <inport name="box" type="GEOM_Object"/>
         <outport name="box" type="GEOM_Object"/>
     </service>
-    <service name="node51" >
-        <component>GEOM_Superv</component>
-        <method>SetStudyID</method>
-        <inport name="id" type="int"/>
-    </service>
     <service name="node52" >
         <component>PYHELLO</component>
         <method>makeBanner</method>
     <control> <fromnode>node5</fromnode> <tonode>node62</tonode> </control>
     <control> <fromnode>node5</fromnode> <tonode>node63</tonode> </control>
     <control> <fromnode>node13</fromnode> <tonode>node14</tonode> </control>
-    <control> <fromnode>node44</fromnode> <tonode>node51</tonode> </control>
-    <control> <fromnode>node51</fromnode> <tonode>node49</tonode> </control>
     <control> <fromnode>node49</fromnode> <tonode>node50</tonode> </control>
     <control> <fromnode>node36</fromnode> <tonode>node37</tonode> </control>
     <!-- datalinks -->
 <parameter><tonode>node37</tonode><toport>p4</toport><value><string>vitesse</string></value></parameter>
 <parameter><tonode>node37</tonode><toport>p5</toport><value><double>0.</double></value></parameter>
 <parameter><tonode>node52</tonode><toport>nom</toport><value><string>toto</string></value></parameter>
-<parameter><tonode>node51</tonode><toport>id</toport><value><int>1</int></value></parameter>
 <parameter><tonode>node49</tonode> <toport>x1</toport><value><double>0</double></value></parameter>
 <parameter><tonode>node49</tonode> <toport>y1</toport><value><double>0</double></value></parameter>
 <parameter><tonode>node49</tonode> <toport>z1</toport><value><double>0</double></value></parameter>
index 5c44f2aecc6e1f1a5c4d825d2bd90b97f5ca05be..6d607816fe1512d6e94b48e0fcd3f7a63f50360d 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index e6cc4abfa860aa05f3b5eada00fa043a78348968..253a7b24ff9518a92ba5875c2150883941d025fc 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index d175b373baf971d9a215e125cf2e579c06a9927e..cceb188fc2cb165bf84e880fd70309ba343c10fb 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 6dae1785992f8ed37d8a4b7913f18f8ec8380b44..74dfd141f05e9613651ec325586396973066be82 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
 <proc name="newSchema_1">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index ea4ccbd5af48989905129ef7a1a3954572301063..894f1e14a7e9f88a35b8cb574922fb1208ba7a8f 100644 (file)
@@ -53,7 +53,7 @@
         <code>  param['hostname']=machine</code>
         <code>  param['container_name']=container</code>
         <code>  compo=salome.lcc.LoadComponent(param, "HELLO")</code>
-        <code>  print(compo.hello(salome.myStudy, p1))</code>
+        <code>  print(compo.hello(p1))</code>
         <code>  print(p1)</code>
       </function>
       <load container="A"/>
@@ -89,7 +89,7 @@
         <code>  param['hostname']=machine</code>
         <code>  param['container_name']=container</code>
         <code>  compo=salome.lcc.LoadComponent(param, "HELLO")</code>
-        <code>  print(compo.hello(salome.myStudy, p1))</code>
+        <code>  print(compo.hello(p1))</code>
         <code>  print(p1)</code>
       </function>
       <inport name="p1" type="string"/>
index 51a8d20414fc5c82435cdab30b45c8d1a18596ac..3a453009416f8c1ea71b569ef97f471b838f0f9b 100644 (file)
@@ -55,7 +55,7 @@
         <code>  param['hostname']=machine</code>
         <code>  param['container_name']=container</code>
         <code>  compo=salome.lcc.LoadComponent(param, "HELLO")</code>
-        <code>  print(compo.hello(salome.myStudy, p1))</code>
+        <code>  print(compo.hello(p1))</code>
         <code>  print(p1)</code>
       </function>
       <load container="A"/>
@@ -91,7 +91,7 @@
         <code>  param['hostname']=machine</code>
         <code>  param['container_name']=container</code>
         <code>  compo=salome.lcc.LoadComponent(param, "HELLO")</code>
-        <code>  print(compo.hello(salome.myStudy, p1))</code>
+        <code>  print(compo.hello(p1))</code>
         <code>  print(p1)</code>
       </function>
       <inport name="p1" type="string"/>
index 58169554944f2351308cb04e6fb81596427729d3..b2aa01aec58e1350eafe3e5d4298b523f89665ff 100644 (file)
@@ -29,7 +29,6 @@
 
     <!--nodes -->
     <datanode name="s" kind="study" >
-      <property name="StudyID" value="1" />
       <parameter name="b" type="GEOM/GEOM_Object" ref="0:1:2:2"/>
       <parameter name="c" type="bool" ref="/Geometry/Box_1"/>
     </datanode>
@@ -45,7 +44,6 @@
     </inline>
 
     <outnode name="os" kind="study" ref="stud1.hdf" >
-      <property name="StudyID" value="3" />
       <parameter name="b" type="GEOM/GEOM_Object" ref="/Save/x"/>
       <!--       <parameter name="c" type="GEOM/GEOM_Object" ref="/Geometry/Box_2"/> 
       <parameter name="b" type="GEOM/GEOM_Object" ref="0:1:1:6"/>
index e637eeece9c9d06293dd866ea36e955b36a9eef3..b9e73cb4543b8d16089a8aa28c9a539e626e7e5e 100644 (file)
@@ -20,7 +20,6 @@
 
 -->
 <proc name="proc">
-   <property name="DefaultStudyID" value="1"/>
    <type name="string" kind="string"/>
    <struct name="Engines/dataref">
       <member name="ref" type="string"/>
index 49a00815f085c839171c85056c2d57eeffaab01e..ec7048e51fe0fe9a8c218e81603b9baa52e88fd4 100644 (file)
@@ -92,6 +92,7 @@ SET(SWIG_MODULE_loader_EXTRA_DEPS
 SWIG_ADD_MODULE(loader python loader.i)
 
 SWIG_LINK_LIBRARIES(loader ${_link_LIBRARIES})
+SWIG_CHECK_GENERATION(loader)
 IF(WIN32)
   SET_TARGET_PROPERTIES(_loader PROPERTIES DEBUG_OUTPUT_NAME _loader_d)
 ENDIF(WIN32)
index f079c81d2305ecc75afde00ead21fc929dde92ce..22965a4771ba404c2329ef6a17f99dd987440260 100644 (file)
@@ -41,6 +41,7 @@ IF(NOT WIN32)
     testResume.py
     testSave.py
     testSaveLoadRun.py
+    testHPDecorator.py
     optim_plugin.py
     testValidationChecks.py
     testProgress.py
index 6c4d0699d739efba2e264162eea8f39240dace60..f673b7a83a6b5f67968148fcdfc557d884d0199e 100644 (file)
@@ -28,5 +28,6 @@ IF(NOT WIN32)
   ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} python StdAloneYacsLoaderTest1.py)
   SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
                                     LABELS "${COMPONENT_NAME}"
-                      )
+                                   )
+
 ENDIF()
index 03846640e361ba245bee07caba4acad2ff669904..29b9d06d31a4fb451409a3805ed86317f466cb0f 100644 (file)
@@ -95,7 +95,14 @@ if [ $ret7 -gt 0 ]; then
   exit $ret7
 fi
 
-let ret=$ret0+$ret1+$ret2+$ret3+$ret4+$ret5+$ret6+$ret7
+python  @CMAKE_CURRENT_SOURCE_DIR@/testHPDecorator.py
+ret8=$?
+if [ $ret8 -gt 0 ]; then
+  echo "exec status testProgress : " $ret8
+  exit $ret8
+fi
+
+let ret=$ret0+$ret1+$ret2+$ret3+$ret4+$ret5+$ret6+$ret7+$ret8
 
 # --- return unit tests status
 
diff --git a/src/yacsloader_swig/Test/testHPDecorator.py b/src/yacsloader_swig/Test/testHPDecorator.py
new file mode 100644 (file)
index 0000000..aa15b60
--- /dev/null
@@ -0,0 +1,363 @@
+# Copyright (C) 2006-2016  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
+#
+
+import pilot
+import SALOMERuntime
+import unittest
+
+class TestHPDecortator(unittest.TestCase):
+    def test0(self):
+        """ First test coming from the big boss."""
+        SALOMERuntime.RuntimeSALOME.setRuntime()
+        r=SALOMERuntime.getSALOMERuntime()
+        pg=pilot.PlayGround()
+        pg.loadFromKernelCatalog()
+        assert(len(pg.getData())!=0)
+        p=r.createProc("p0")
+        td=p.createType("double","double")
+        tdd=p.createSequenceTc("seqdouble","seqdouble",td)
+        hp1=p.createContainer("HP1","HPSalome")
+        hp4=p.createContainer("HP4","HPSalome")
+        #
+        n0=r.createScriptNode("Salome","n0")
+        n0.setExecutionMode("remote")
+        out0_0=n0.edAddOutputPort("o1",tdd)
+        n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
+        n0.setContainer(hp4)
+        p.edAddChild(n0)
+        #
+        n1_0=r.createForEachLoop("n1_0",td)
+        p.edAddChild(n1_0)
+        p.edAddCFLink(n0,n1_0)
+        p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
+        ##
+        n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
+        n1_0.edAddChild(n1_0_sc)
+        n1_0_sc.setExecutionMode("remote")
+        n1_0_sc.setScript("""2*i1""")
+        i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
+        p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
+        n1_0_sc.setContainer(hp4)
+        ##
+        #
+        n1_1=r.createForEachLoop("n1_1",td)
+        p.edAddChild(n1_1)
+        p.edAddCFLink(n0,n1_1)
+        p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
+        ##
+        n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
+        n1_1.edAddChild(n1_1_sc)
+        n1_1_sc.setExecutionMode("remote")
+        n1_1_sc.setScript("""3*i1""")
+        i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
+        p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
+        n1_1_sc.setContainer(hp1)
+        ##
+        hp1.setProperty("nb_proc_per_node","1")
+        hp4.setProperty("nb_proc_per_node","4")
+        pg.setData([("m0",8),("m1",8),("m2",8),("m3",8)]) # virtual machine with 32 cores spread over 4 nodes
+        assert(n1_0.getWeight()==1.)
+        assert(n1_1.getWeight()==1.)
+        p.fitToPlayGround(pg)########### ZE CALL
+        fyto=pilot.ForTestOmlyHPContCls()
+        assert(hp4.getSizeOfPool()==8)# 32/4
+        n1_0_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==0 and pd.getStop()==16)
+        assert(fyto.getIDS()==(0,1,2,3))
+        #
+        assert(hp1.getSizeOfPool()==32)# 32/1
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_1_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==16 and pd.getStop()==32)
+        assert(fyto.getIDS()==(16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
+        assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
+        assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
+        #
+        fyto=pilot.ForTestOmlyHPContCls()
+        n0.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.AllPartDefinition))
+        assert(list(fyto.getIDS())==range(8))
+        #############################
+        #  Change weight of ForEach #
+        #############################
+        n1_0.setWeight(2)
+        p.fitToPlayGround(pg)########### ZE CALL
+        assert(hp4.getSizeOfPool()==8)# 32/4
+        n1_0_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==0 and pd.getStop()==21)
+        assert(fyto.getIDS()==(0,1,2,3,4))
+        assert(hp1.getSizeOfPool()==32)# 32/1
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_1_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==21 and pd.getStop()==32)
+        assert(fyto.getIDS()==(21,22,23,24,25,26,27,28,29,30,31))
+        assert(n1_0.edGetNbOfBranchesPort().getPyObj()==6)
+        assert(n1_1.edGetNbOfBranchesPort().getPyObj()==11)
+        #
+        fyto=pilot.ForTestOmlyHPContCls()
+        n0.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.AllPartDefinition))
+        assert(list(fyto.getIDS())==range(8))
+        pass
+
+    def test1(self):
+        """ Second test as test0 + script node in // with 2 FE"""
+        SALOMERuntime.RuntimeSALOME.setRuntime()
+        r=SALOMERuntime.getSALOMERuntime()
+        pg=pilot.PlayGround()
+        pg.loadFromKernelCatalog()
+        assert(len(pg.getData())!=0)
+        p=r.createProc("p0")
+        td=p.createType("double","double")
+        tdd=p.createSequenceTc("seqdouble","seqdouble",td)
+        hp1=p.createContainer("HP1","HPSalome")
+        hp4=p.createContainer("HP4","HPSalome")
+        #
+        n0=r.createScriptNode("Salome","n0")
+        n0.setExecutionMode("remote")
+        out0_0=n0.edAddOutputPort("o1",tdd)
+        n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
+        n0.setContainer(hp4)
+        p.edAddChild(n0)
+        #
+        n1_0=r.createForEachLoop("n1_0",td)
+        p.edAddChild(n1_0)
+        p.edAddCFLink(n0,n1_0)
+        p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
+        ##
+        n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
+        n1_0.edAddChild(n1_0_sc)
+        n1_0_sc.setExecutionMode("remote")
+        n1_0_sc.setScript("""2*i1""")
+        i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
+        p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
+        n1_0_sc.setContainer(hp4)
+        ##
+        #
+        n1_1=r.createForEachLoop("n1_1",td)
+        p.edAddChild(n1_1)
+        p.edAddCFLink(n0,n1_1)
+        p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
+        ##
+        n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
+        n1_1.edAddChild(n1_1_sc)
+        n1_1_sc.setExecutionMode("remote")
+        n1_1_sc.setScript("""3*i1""")
+        i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
+        p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
+        n1_1_sc.setContainer(hp1)
+        #
+        n1_2=r.createScriptNode("Salome","n1_2")
+        p.edAddChild(n1_2)
+        n1_2.setExecutionMode("remote")
+        n1_2.setContainer(hp4)
+        n1_2.setScript("""my_container""")
+        p.edAddCFLink(n0,n1_2)
+        ##
+        hp1.setProperty("nb_proc_per_node","1")
+        hp4.setProperty("nb_proc_per_node","4")
+        pg.setData([("m0",8),("m1",8),("m2",8),("m3",8)]) # virtual machine with 32 cores spread over 4 nodes
+        assert(n1_0.getWeight()==1.)
+        assert(n1_1.getWeight()==1.)
+        p.fitToPlayGround(pg)########### ZE CALL
+        assert(hp4.getSizeOfPool()==8)# 32/4
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_0_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==0 and pd.getStop()==16)
+        assert(fyto.getIDS()==(0,1,2,3))
+        #
+        assert(hp1.getSizeOfPool()==32)# 32/1
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_1_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==16 and pd.getStop()==32)
+        assert(fyto.getIDS()==(16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
+        assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
+        assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
+        #
+        fyto=pilot.ForTestOmlyHPContCls()
+        n0.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.AllPartDefinition))
+        assert(list(fyto.getIDS())==range(8))
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_2.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.AllPartDefinition))
+        assert(list(fyto.getIDS())==range(8))
+        pass
+
+    @unittest.skip("requires 2 machines in catalog")
+    def test2(self):
+        """ This test is desactivated because it requires multi nodes. To be moved at the right place to support this.
+        This test is not launched here because it requires 2 machines in catalog"""
+        m1="dsp0764200"
+        m2="dsp0764412"
+        SALOMERuntime.RuntimeSALOME.setRuntime()
+        r=SALOMERuntime.getSALOMERuntime()
+        pg=pilot.PlayGround()
+        pg.loadFromKernelCatalog()
+        assert(len(pg.getData())!=0)
+        p=r.createProc("p0")
+        td=p.createType("double","double")
+        tdd=p.createSequenceTc("seqdouble","seqdouble",td)
+        hp1=p.createContainer("HP1","HPSalome")
+        #
+        n0=r.createScriptNode("Salome","n0")
+        n0.setExecutionMode("remote")
+        out0_0=n0.edAddOutputPort("o1",tdd)
+        n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
+        n0.setContainer(hp1)
+        p.edAddChild(n0)
+        ##
+        n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
+        p.edAddChild(n1_0_sc)
+        p.edAddCFLink(n0,n1_0_sc)
+        n1_0_sc.setExecutionMode("remote")
+        n1_0_sc.setScript("""assert(my_container.getHostName()=="%s")"""%m1)
+        n1_0_sc.setContainer(hp1)
+        ##
+        n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
+        p.edAddChild(n1_1_sc)
+        p.edAddCFLink(n0,n1_1_sc)
+        n1_1_sc.setExecutionMode("remote")
+        n1_1_sc.setScript("""assert(my_container.getHostName()=="%s")"""%m2)
+        n1_1_sc.setContainer(hp1)
+        ##
+        hp1.setProperty("nb_proc_per_node","1")
+        pg.setData([(m1,8),(m2,8)])
+        p.fitToPlayGround(pg)########### ZE CALL
+        assert(hp1.getSizeOfPool()==16)# 16/1
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_0_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==0 and pd.getStop()==8)
+        assert(fyto.getIDS()==(0,1,2,3,4,5,6,7))
+        #
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_1_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.ContigPartDefinition))
+        assert(pd.getStart()==8 and pd.getStop()==16)
+        assert(fyto.getIDS()==(8,9,10,11,12,13,14,15))
+        #
+        exe=pilot.ExecutorSwig()
+        assert(p.getState()==pilot.READY)
+        exe.RunW(p,0)
+        assert(p.getState()==pilot.DONE)
+        pass
+
+    def test3(self):
+        """ First test coming from the big boss."""
+        SALOMERuntime.RuntimeSALOME.setRuntime()
+        r=SALOMERuntime.getSALOMERuntime()
+        pg=pilot.PlayGround()
+        pg.loadFromKernelCatalog()
+        assert(len(pg.getData())!=0)
+        p=r.createProc("p0")
+        td=p.createType("double","double")
+        tdd=p.createSequenceTc("seqdouble","seqdouble",td)
+        hp1=r.createContainer("HPSalome") ; hp1.setName("HP1")
+        #
+        n0=r.createScriptNode("Salome","n0")
+        n0.setExecutionMode("local")
+        out0_0=n0.edAddOutputPort("o1",tdd)
+        n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
+        p.edAddChild(n0)
+        #
+        n1_0=r.createForEachLoop("n1_0",td)
+        n2_0=r.createForEachLoop("n2_0",td)
+        p.edAddChild(n1_0)
+        p.edAddChild(n2_0)
+        p.edAddCFLink(n0,n1_0)
+        p.edAddCFLink(n1_0,n2_0)
+        p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
+        p.edAddLink(out0_0,n2_0.edGetSeqOfSamplesPort())
+        ##
+        n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
+        n1_0.edAddChild(n1_0_sc)
+        n1_0_sc.setExecutionMode("remote")
+        n1_0_sc.setScript("""2*i1""")
+        i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
+        p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
+        n1_0_sc.setContainer(hp1)
+        ##
+        n2_0_sc=r.createScriptNode("Salome","n2_0_sc")
+        n2_0.edAddChild(n2_0_sc)
+        n2_0_sc.setExecutionMode("remote")
+        n2_0_sc.setScript("""2*i1""")
+        i2_0_sc=n2_0_sc.edAddInputPort("i1",td)
+        p.edAddLink(n2_0.edGetSamplePort(),i2_0_sc)
+        n2_0_sc.setContainer(hp1)
+        ##
+        hp1.setProperty("nb_proc_per_node","1")
+        pg.setData([("localhost",3)])
+        p.fitToPlayGround(pg)########### ZE CALL
+        assert(hp1.getSizeOfPool()==3)
+        fyto=pilot.ForTestOmlyHPContCls()
+        n1_0_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.AllPartDefinition))
+        assert(fyto.getIDS()==(0,1,2))
+        fyto=pilot.ForTestOmlyHPContCls()
+        n2_0_sc.getContainer().forYourTestsOnly(fyto)
+        assert(fyto.getContainerType()=="HPContainerShared")
+        pd=fyto.getPD()
+        assert(isinstance(pd,pilot.AllPartDefinition))
+        assert(fyto.getIDS()==(0,1,2))
+        assert(n1_0.edGetNbOfBranchesPort().getPyObj()==3)
+        assert(n2_0.edGetNbOfBranchesPort().getPyObj()==3)
+        #
+        exe=pilot.ExecutorSwig()
+        assert(p.getState()==pilot.READY)
+        exe.RunW(p,0)
+        assert(len(set(hp1.getKernelContainerNames()))==3)
+        pass
+    
+    pass
+
+if __name__ == '__main__':
+    unittest.main()
index 49ba4b963fc199722f7a52e0e5af90ba2deb901c..8cc06d351dd0cbfa41b68da84e0ccf0cd2817e21 100755 (executable)
@@ -1578,6 +1578,59 @@ o4=i3
     self.assertEqual(q.getState(),pilot.DONE)
     self.assertEqual(q.getChildByName("n2").getOutputPort("o4").getPyObj(),[0L,2L,10L,15L,20L,25L])
     pass
+
+  def test23(self):
+    """ test focused on weight attribut after a dump and reload from a xml file
+    """
+    fname="test23.xml"
+    xmlStateFileName="saveState23.xml"
+    from datetime import datetime
+    p=self.r.createProc("prTest23")
+    cont=p.createContainer("gg","Salome")
+    cont.setProperty("name","localhost")
+    cont.setProperty("hostname","localhost")
+    cont.setProperty("type","multi")
+    td=p.createType("double","double")
+    ti=p.createType("int","int")
+    tsi=p.createSequenceTc("seqint","seqint",ti)
+    tsd=p.createSequenceTc("seqdbl","seqdbl",td)
+    n0=self.r.createScriptNode("","n0")
+    o0=n0.edAddOutputPort("o0",tsi)
+    n0.setScript("o0=[ elt for elt in range(6) ]")
+    p.edAddChild(n0)
+    n1=self.r.createForEachLoop("n1",ti)
+    n1.setWeight(3)
+    n10=self.r.createScriptNode("","n10")
+    n10.setExecutionMode("remote")
+    n10.setContainer(cont)
+    n1.edAddChild(n10)
+    n10.setScript("""
+import time
+time.sleep(2)
+o2=2*i1
+""")
+    i1=n10.edAddInputPort("i1",ti)
+    o2=n10.edAddOutputPort("o2",ti)
+    p.edAddChild(n1)
+    p.edAddLink(o0,n1.edGetSeqOfSamplesPort())
+    p.edAddLink(n1.edGetSamplePort(),i1)
+    p.edAddCFLink(n0,n1)
+    n1.edGetNbOfBranchesPort().edInitPy(2)
+    n2=self.r.createScriptNode("","n2")
+    n2.setScript("o4=i3")
+    i3=n2.edAddInputPort("i3",tsi)
+    o4=n2.edAddOutputPort("o4",tsi)
+    n2.setScript("o4=i3")
+    p.edAddChild(n2)
+    p.edAddCFLink(n1,n2)
+    p.edAddLink(o2,i3)
+    p.saveSchema(fname)
+    #
+    l=loader.YACSLoader()
+    p=l.load(fname)
+    self.assertEqual(p.getChildByName("n1").getWeight(),3.0)
+    pass
+
   pass
 
 if __name__ == '__main__':