From 2e24c282a088b16c569bc5c22f7412f382cd8906 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 19 Mar 2020 21:41:37 +0100 Subject: [PATCH] XML load of ForEachLoopDyn is now OK --- src/yacsloader/blocParsers.hxx | 2 +- src/yacsloader/loopParsers.hxx | 9 --------- src/yacsloader/procParsers.hxx | 2 ++ src/yacsloader_swig/Test/testFEDyn.py | 8 ++++---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/yacsloader/blocParsers.hxx b/src/yacsloader/blocParsers.hxx index 61b6b9a85..dcaadc12d 100644 --- a/src/yacsloader/blocParsers.hxx +++ b/src/yacsloader/blocParsers.hxx @@ -178,7 +178,7 @@ struct bloctypeParser:parser //fullname += ".splitter"; //currentProc->nodeMap[fullname]=b->getChildByShortName("splitter"); } - virtual void foreach (YACS::ENGINE::ForEachLoop* const& b) + virtual void foreach (YACS::ENGINE::ForEachLoopGen* const& b) { DEBTRACE( "bloc_foreach_set: " << b->getName() ) _bloc->edAddChild(b); diff --git a/src/yacsloader/loopParsers.hxx b/src/yacsloader/loopParsers.hxx index ee42b9ab3..a7a6d6ce1 100644 --- a/src/yacsloader/loopParsers.hxx +++ b/src/yacsloader/loopParsers.hxx @@ -608,7 +608,6 @@ struct foreachloopdyntypeParser:dynparalooptypeParser { 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]) == "loopWeight")weight(atof(attr[i+1])); if(std::string(attr[i]) == "type")datatype(attr[i+1]); } @@ -616,7 +615,6 @@ struct foreachloopdyntypeParser:dynparalooptypeParser } virtual void pre () { - _nbranch=0; _weight=-1.; this->looptypeParser::pre(); } @@ -626,11 +624,6 @@ struct foreachloopdyntypeParser:dynparalooptypeParser _name=name; _fullname=currentProc->names.back()+name; } - virtual void nbranch (const int& n) - { - DEBTRACE("foreach_nbranch: " << n ) - _nbranch=n; - } virtual void weight (const double& x) { DEBTRACE("foreach_weight: " << x ) @@ -661,7 +654,6 @@ struct foreachloopdyntypeParser:dynparalooptypeParser } this->_cnode=theRuntime->createForEachLoopDyn(_name,currentProc->typeMap[_datatype]); //set number of branches - if(_nbranch > 0)this->_cnode->edGetNbOfBranchesPort()->edInit(_nbranch); if(_weight > 0)this->_cnode->setWeight(_weight); this->_cnodes.push_back(this->_cnode); currentProc->names.push_back(_fullname + '.'); @@ -675,7 +667,6 @@ struct foreachloopdyntypeParser:dynparalooptypeParser this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back(); return b; } - int _nbranch; double _weight; std::string _fullname; std::string _name; diff --git a/src/yacsloader/procParsers.hxx b/src/yacsloader/procParsers.hxx index c2c112cbb..46884614f 100644 --- a/src/yacsloader/procParsers.hxx +++ b/src/yacsloader/procParsers.hxx @@ -196,6 +196,7 @@ void proctypeParser::onStart(const XML_Char* el, const XML_Char** attr) else if(element == "bloc")pp=&bloctypeParser<>::blocParser; else if(element == "forloop")pp=&forlooptypeParser<>::forloopParser; else if(element == "foreach")pp=&foreachlooptypeParser<>::foreachloopParser; + else if(element == "foreachdyn")pp=&foreachloopdyntypeParser<>::foreachloopdynParser; else if(element == "optimizer")pp=&optimizerlooptypeParser<>::optimizerloopParser; else if(element == "while")pp=&whilelooptypeParser<>::whileloopParser; else if(element == "switch")pp=&switchtypeParser::switchParser; @@ -252,6 +253,7 @@ void proctypeParser::onEnd(const char *el,parser* child) else if(element == "bloc")this->bloc(((bloctypeParser<>*)child)->post()); else if(element == "forloop")this->forloop(((forlooptypeParser<>*)child)->post()); else if(element == "foreach")this->foreach(((foreachlooptypeParser<>*)child)->post()); + else if(element == "foreachdyn")this->foreach(((foreachloopdyntypeParser<>*)child)->post()); else if(element == "optimizer")this->optimizer(((optimizerlooptypeParser<>*)child)->post()); else if(element == "while")this->while_(((whilelooptypeParser<>*)child)->post()); else if(element == "switch")this->switch_(((switchtypeParser*)child)->post()); diff --git a/src/yacsloader_swig/Test/testFEDyn.py b/src/yacsloader_swig/Test/testFEDyn.py index 86027a12d..d31e26c7e 100644 --- a/src/yacsloader_swig/Test/testFEDyn.py +++ b/src/yacsloader_swig/Test/testFEDyn.py @@ -22,8 +22,8 @@ n0=r.createScriptNode("","n0") o0=n0.edAddOutputPort("o0",tsi) n0.setScript("o0=[ elt for elt in range(8) ]") p.edAddChild(n0) -n1=r.createForEachLoop("n1",ti)#Dyn -n1.getInputPort("nbBranches").edInitPy(2) +n1=r.createForEachLoopDyn("n1",ti)#Dyn +#n1.getInputPort("nbBranches").edInitPy(2) n10=r.createScriptNode("","n10") n10.setExecutionMode("remote") n10.setContainer(cont) @@ -49,8 +49,8 @@ p.edAddChild(n2) p.edAddCFLink(n1,n2) p.edAddLink(o2,i3) # Second parallel foreach -n11=r.createForEachLoop("n11",ti)#Dyn -n11.getInputPort("nbBranches").edInitPy(2) +n11=r.createForEachLoopDyn("n11",ti) +#n11.getInputPort("nbBranches").edInitPy(2) n110=r.createScriptNode("","n110") n110.setExecutionMode("remote") n110.setContainer(cont) -- 2.39.2