From 27530cea88069c0cb2321b83c42b33062bddb288 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 16 Mar 2020 17:26:14 +0100 Subject: [PATCH] WIP --- src/engine/DynParaLoop.cxx | 23 +++++++---------------- src/engine/DynParaLoop.hxx | 6 +++--- src/engine/ForEachLoop.cxx | 2 +- src/engine/NbBranches.cxx | 4 ++-- src/engine/OptimizerLoop.cxx | 2 +- 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/engine/DynParaLoop.cxx b/src/engine/DynParaLoop.cxx index 2a84e19be..ea2e40072 100644 --- a/src/engine/DynParaLoop.cxx +++ b/src/engine/DynParaLoop.cxx @@ -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 DynParaLoop::edGetDirectDescendants() const std::list DynParaLoop::getSetOfInputPort() const { list 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 DynParaLoop::getLocalInputPorts() const { list 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& pointsOfView) diff --git a/src/engine/DynParaLoop.hxx b/src/engine/DynParaLoop.hxx index d2849265d..1ff196e95 100644 --- a/src/engine/DynParaLoop.hxx +++ b/src/engine/DynParaLoop.hxx @@ -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 _execIds; - AnyInputPort _nbOfBranches; + NbBranches _nbOfBranches; AnyOutputPort _splittedPort; std::vector _execNodes; std::vector _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; } diff --git a/src/engine/ForEachLoop.cxx b/src/engine/ForEachLoop.cxx index 33faee131..34f231b9b 100644 --- a/src/engine/ForEachLoop.cxx +++ b/src/engine/ForEachLoop.cxx @@ -1084,7 +1084,7 @@ void ForEachLoop::checkLinkPossibility(OutPort *start, const std::listgetNode() == &_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."); } diff --git a/src/engine/NbBranches.cxx b/src/engine/NbBranches.cxx index b9528aeb7..b39e4ce62 100644 --- a/src/engine/NbBranches.cxx +++ b/src/engine/NbBranches.cxx @@ -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(&_nbOfBranches); + return const_cast(&_nbOfBranches); } bool NbBranches::isMultiplicitySpecified(unsigned& value) const diff --git a/src/engine/OptimizerLoop.cxx b/src/engine/OptimizerLoop.cxx index 37101e057..39c45ffd0 100644 --- a/src/engine/OptimizerLoop.cxx +++ b/src/engine/OptimizerLoop.cxx @@ -530,7 +530,7 @@ void OptimizerLoop::checkLinkPossibility(OutPort *start, const std::listgetName()+" 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 -- 2.39.2