]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 16 Mar 2020 16:26:14 +0000 (17:26 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 16 Mar 2020 16:26:14 +0000 (17:26 +0100)
src/engine/DynParaLoop.cxx
src/engine/DynParaLoop.hxx
src/engine/ForEachLoop.cxx
src/engine/NbBranches.cxx
src/engine/OptimizerLoop.cxx

index 2a84e19beaf5375d62b0059492cf2a01cc225c19..ea2e40072d03b8220d95637a85a27fca37fd0d7f 100644 (file)
@@ -39,11 +39,9 @@ using namespace YACS::ENGINE;
 const char DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT[] = "evalSamples";
 const char DynParaLoop::OLD_NAME_OF_SPLITTED_SEQ_OUT[] = "SmplPrt"; // For backward compatibility with 5.1.4
 
-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),
+    _nbOfBranches(this),
     _splittedPort(NAME_OF_SPLITTED_SEQ_OUT,this,typeOfDataSplitted),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(), _loopWeight(0)
 {
   _weight.setDefaultLoop();
@@ -276,21 +274,21 @@ std::list<Node *> DynParaLoop::edGetDirectDescendants() const
 std::list<InputPort *> DynParaLoop::getSetOfInputPort() const
 {
   list<InputPort *> ret=ComposedNode::getSetOfInputPort();
-  ret.push_back((InputPort *)&_nbOfBranches);
+  ret.push_back(_nbOfBranches.getPort());
   return ret;
 }
 
 InputPort *DynParaLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
 {
-  if(name==NAME_OF_NUMBER_OF_BRANCHES)
-    return (InputPort *)&_nbOfBranches;
+  if(NbBranches::IsBranchPortName(name))
+    return _nbOfBranches.getPort();
   return ComposedNode::getInputPort(name);
 }
 
 std::list<InputPort *> DynParaLoop::getLocalInputPorts() const
 {
   list<InputPort *> ret=ComposedNode::getLocalInputPorts();
-  ret.push_back((InputPort *)&_nbOfBranches);
+  ret.push_back(_nbOfBranches.getPort());
   return ret;
 }
 
@@ -441,19 +439,12 @@ ComplexWeight* DynParaLoop::getWeight()
 
 bool DynParaLoop::isMultiplicitySpecified(unsigned& value) const
 {
-  if(_nbOfBranches.edIsManuallyInitialized())
-    if(_nbOfBranches.edGetNumberOfLinks()==0)
-      {
-        value=_nbOfBranches.getIntValue();
-        return true;
-      }
-  return false;
+  return _nbOfBranches.isMultiplicitySpecified(value);
 }
 
 void DynParaLoop::forceMultiplicity(unsigned value)
 {
-  _nbOfBranches.edRemoveAllLinksLinkedWithMe();
-  _nbOfBranches.edInit((int)value);
+  _nbOfBranches.forceMultiplicity(value);
 }
 
 void DynParaLoop::buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
index d2849265df04e1aa6039de48cec1e1afb7f4f135..1ff196e95676b7ea3337702ff185fd82172751a3 100644 (file)
@@ -25,6 +25,7 @@
 #include "AnyInputPort.hxx"
 #include "AnyOutputPort.hxx"
 #include "OutputPort.hxx"
+#include "NbBranches.hxx"
 
 namespace YACS
 {
@@ -49,7 +50,7 @@ namespace YACS
       Node *_finalizeNode;
       unsigned _nbOfEltConsumed;
       std::vector<int> _execIds;
-      AnyInputPort _nbOfBranches;
+      NbBranches _nbOfBranches;
       AnyOutputPort _splittedPort;
       std::vector<Node *> _execNodes;
       std::vector<Node *> _execInitNodes;
@@ -62,7 +63,6 @@ namespace YACS
     protected:
       static const char NAME_OF_SPLITTED_SEQ_OUT[];
       static const char OLD_NAME_OF_SPLITTED_SEQ_OUT[];
-      static const char NAME_OF_NUMBER_OF_BRANCHES[];
     protected:
       DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted);
       virtual ~DynParaLoop();
@@ -77,7 +77,7 @@ namespace YACS
       Node *edSetFinalizeNode(Node *DISOWNnode);
       virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception);
       void init(bool start=true);
-      InputPort *edGetNbOfBranchesPort() { return &_nbOfBranches; }
+      InputPort *edGetNbOfBranchesPort() { return _nbOfBranches.getPort(); }
       int getNumberOfInputPorts() const;
       int getNumberOfOutputPorts() const;
       unsigned getNumberOfEltsConsumed() const { return _nbOfEltConsumed; }
index 33faee131cdf0e5c8d1b13eaff2b9a680c739f7b..34f231b9b5f5595ac0b4adcd0cac7f9c3a1d1d87 100644 (file)
@@ -1084,7 +1084,7 @@ void ForEachLoop::checkLinkPossibility(OutPort *start, const std::list<ComposedN
   if(end->getNode() == &_splitterNode)
     throw Exception("Illegal link within a foreach loop: \
 the 'SmplsCollection' port cannot be linked within the scope of the loop.");
-  if(end == &_nbOfBranches)
+  if(end == _nbOfBranches.getPort())
     throw Exception("Illegal link within a foreach loop: \
 the 'nbBranches' port cannot be linked within the scope of the loop.");
 }
index b9528aeb7c14f66aa2191c70c6cc6812ce198cf7..b39e4ce62119acb7469d21f3db6a60aa30ce8776 100644 (file)
@@ -25,12 +25,12 @@ const char NbBranches::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
 
 void NbBranches::exInit(bool start)
 {
-    _nbOfBranches.exInit(start);
+  _nbOfBranches.exInit(start);
 }
 
 InputPort *NbBranches::getPort() const
 {
-    return const_cast<AnyInputPort *>(&_nbOfBranches);
+  return const_cast<AnyInputPort *>(&_nbOfBranches);
 }
 
 bool NbBranches::isMultiplicitySpecified(unsigned& value) const
index 37101e057ddb3b4e6900064b75c786cc0a00e7d2..39c45ffd0a5a0c1e635fe9fa4257052624d45d43 100644 (file)
@@ -530,7 +530,7 @@ void OptimizerLoop::checkLinkPossibility(OutPort *start, const std::list<Compose
   linkName += start->getName()+" to "+end->getName()+")";
 
   // Yes, it should be possible to link back the result port to any input port of the loop.
-  if(end == &_nbOfBranches || end == &_algoInitPort)
+  if(end == _nbOfBranches.getPort() || end == &_algoInitPort)
     if(start != &_algoResultPort)
       throw Exception(std::string("Illegal OptimizerLoop link.") + linkName);
     else