-// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2021 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
virtual void remote (ENGINE::InlineNode* const& n);
virtual void node (ENGINE::InlineNode* const& n);
virtual void forloop (ENGINE::ForLoop* const& b);
- virtual void foreach (ENGINE::ForEachLoop* const& b);
+ virtual void foreach (ENGINE::ForEachLoopGen* const& b);
virtual void optimizer (ENGINE::OptimizerLoop* const& b);
virtual void while_ (ENGINE::WhileLoop* const& b);
virtual void switch_ (ENGINE::Switch* const& b);
currentProc->nodeMap[fullname]=b;
}
template <class T>
-void looptypeParser<T>::foreach (ENGINE::ForEachLoop* const& b)
+void looptypeParser<T>::foreach (ENGINE::ForEachLoopGen* const& b)
{
DEBTRACE("loop_foreach" << b->getName())
_cnode->edSetNode(b);
ENGINE::Node * getNode() { return _node; }
// Those two methods should never be called
- bool edAddLink(ENGINE::OutPort *start, ENGINE::InPort *end) throw(Exception) { YASSERT(false); }
- bool edAddDFLink(ENGINE::OutPort *start, ENGINE::InPort *end) throw(Exception) { YASSERT(false); }
+ bool edAddLink(ENGINE::OutPort *start, ENGINE::InPort *end) { YASSERT(false); }
+ bool edAddDFLink(ENGINE::OutPort *start, ENGINE::InPort *end) { YASSERT(false); }
protected:
ENGINE::Node * _node;
{
// Foreach loop specialization
-template <class T=ENGINE::ForEachLoop*>
+template<class T>
+T buildFrom(ENGINE::Runtime *theRuntime, const std::string& name, ENGINE::TypeCode *type);
+
+template<>
+ENGINE::ForEachLoop *buildFrom<ENGINE::ForEachLoop *>(ENGINE::Runtime *theRuntime, const std::string& name, ENGINE::TypeCode *type)
+{ return theRuntime->createForEachLoop(name,type); }
+
+template<>
+ENGINE::ForEachLoopDyn *buildFrom<ENGINE::ForEachLoopDyn *>(ENGINE::Runtime *theRuntime, const std::string& name, ENGINE::TypeCode *type)
+{ return theRuntime->createForEachLoopDyn(name,type); }
+
+
+template <class T>
struct foreachlooptypeParser:dynparalooptypeParser<T>
{
static foreachlooptypeParser<T> foreachloopParser;
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]);
}
postAttr();
virtual void pre ()
{
_nbranch=0;
+ _weight=-1.;
this->looptypeParser<T>::pre();
}
virtual void name (const std::string& name)
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)
t->incrRef();
}
}
- this->_cnode=theRuntime->createForEachLoop(_name,currentProc->typeMap[_datatype]);
+ this->_cnode=buildFrom<T>(theRuntime,_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 + '.');
}
return b;
}
int _nbranch;
+ double _weight;
std::string _fullname;
std::string _name;
std::string _datatype;
};
template <class T> foreachlooptypeParser<T> foreachlooptypeParser<T>::foreachloopParser;
-
}
namespace YACS
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]) == "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]);
virtual void pre ()
{
_nbranch=0;
+ _weight=-1.;
this->looptypeParser<T>::pre();
}
virtual void name (const std::string& name)
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;
this->_cnode=theRuntime->createOptimizerLoop(_name,_lib,_entry,true,_kind, currentProc);
//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 + '.');
}
}
int _nbranch;
+ double _weight;
std::string _fullname;
std::string _name;
std::string _entry;
this->maxcount("node",1,element);
this->maxcount("forloop",1,element);
this->maxcount("foreach",1,element);
+ this->maxcount("foreachdyn",1,element);
this->maxcount("optimizer",1,element);
this->maxcount("while",1,element);
this->maxcount("switch",1,element);
else if(element == "node")pp=&nodetypeParser<>::nodeParser;
else if(element == "forloop")pp=&forlooptypeParser<>::forloopParser;
- else if(element == "foreach")pp=&foreachlooptypeParser<>::foreachloopParser;
+ else if(element == "foreach")pp=&foreachlooptypeParser<ENGINE::ForEachLoop *>::foreachloopParser;
+ else if(element == "foreachdyn")pp=&foreachlooptypeParser<ENGINE::ForEachLoopDyn *>::foreachloopParser;
else if(element == "optimizer")pp=&optimizerlooptypeParser<>::optimizerloopParser;
else if(element == "while")pp=&whilelooptypeParser<>::whileloopParser;
else if(element == "switch")pp=&switchtypeParser::switchParser;
else if(element == "node")node(((nodetypeParser<>*)child)->post());
else if(element == "forloop")forloop(((forlooptypeParser<>*)child)->post());
- else if(element == "foreach")foreach(((foreachlooptypeParser<>*)child)->post());
+ else if(element == "foreach")foreach(((foreachlooptypeParser<ENGINE::ForEachLoop *>*)child)->post());
+ else if(element == "foreachdyn")foreach(((foreachlooptypeParser<ENGINE::ForEachLoopDyn *>*)child)->post());
else if(element == "optimizer")optimizer(((optimizerlooptypeParser<>*)child)->post());
else if(element == "while")while_(((whilelooptypeParser<>*)child)->post());
else if(element == "switch")switch_(((switchtypeParser*)child)->post());