20 #ifndef _LOOPPARSER_HXX_
21 #define _LOOPPARSER_HXX_
47 template <
class T=ENGINE::Loop*>
82 static std::string
t3[]={
"inline",
"sinline",
"service",
"server",
"remote",
"node",
"forloop",
"foreach",
"optimizer",
"while",
"switch",
"bloc",
""};
89 this->required(
"name",attr);
90 for (
int i = 0; attr[
i];
i += 2)
92 if(std::string(attr[
i]) ==
"name")name(attr[
i+1]);
93 if(std::string(attr[
i]) ==
"state")
state(attr[
i+1]);
122 DEBTRACE(
"loop_inline" <<
n->getName() );
123 _cnode->edSetNode(
n);
131 DEBTRACE(
"loop_sinline" <<
n->getName() )
132 _cnode->edSetNode(
n);
140 DEBTRACE(
"loop_service" <<
n->getName() )
141 _cnode->edSetNode(
n);
149 DEBTRACE(
"loop_server" <<
n->getName() )
150 _cnode->edSetNode(
n);
159 DEBTRACE(
"loop_remote: " <<
n->getName() )
160 _cnode->edSetNode(
n);
170 _cnode->edSetNode(
n);
178 DEBTRACE(
"loop_forloop" <<
b->getName() )
179 _cnode->edSetNode(
b);
187 _cnode->edSetNode(
b);
190 fullname +=
".splitter";
196 DEBTRACE(
"loop_optimizer: " <<
b->getName() );
197 _cnode->edSetNode(
b);
206 DEBTRACE(
"loop_while: " <<
b->getName() )
207 _cnode->edSetNode(
b);
214 DEBTRACE(
"loop_switch: " <<
b->getName() )
215 _cnode->edSetNode(
b);
223 _cnode->edSetNode(
b);
231 DEBTRACE(
"loop_datalink: " <<
l.fromnode() <<
l.fromport() <<
l.tonode() <<
l.toport())
238 msg=
"from node " +
l.fromnode() +
" does not exist in data link: ";
239 msg=msg+
l.fromnode()+
"("+
l.fromport()+
")->"+
l.tonode()+
"("+
l.toport()+
")";
252 msg=
"to node " +
l.tonode() +
" does not exist in data link: ";
253 msg=msg+
l.fromnode()+
"("+
l.fromport()+
")->"+
l.tonode()+
"("+
l.toport()+
")";
259 DEBTRACE(fromname <<
":"<<
l.fromport()<<toname<<
":"<<
l.toport());
271 this->logError(e.
what());
283 template <
class T=ENGINE::WhileLoop*>
287 virtual void name (
const std::string&
name);
300 this->_cnodes.push_back(this->_cnode);
307 DEBTRACE(
"while_post" << this->_cnode->getName() )
311 this->_cnodes.pop_back();
313 this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
325 template <
class T=ENGINE::ForLoop*>
330 virtual void name (
const std::string&
name);
331 virtual void nsteps (
const int&
n);
343 this->required(
"name",attr);
344 for (
int i = 0; attr[
i];
i += 2)
346 if(std::string(attr[
i]) ==
"name")name(attr[
i+1]);
347 if(std::string(attr[
i]) ==
"state")this->
state(attr[
i+1]);
348 if(std::string(attr[
i]) ==
"nsteps")nsteps(atoi(attr[
i+1]));
355 DEBTRACE(
"forloop_name: " << name );
359 this->_cnodes.push_back(this->_cnode);
369 throw Exception(
"Node name must be defined before nsteps");
379 this->_cnodes.pop_back();
381 this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
405 template <
class T=PseudoComposedNode*>
427 throw YACS::Exception(
"Unexpected datalink element in DynParaLoop init or finalize node");
440 template <
class T=ENGINE::DynParaLoop*>
445 DEBTRACE(
"dynparalooptypeParser::onStart: " << el )
446 std::string element(el);
447 this->
maxcount(
"initnode",1,element);
448 this->
maxcount(
"finalizenode",1,element);
449 if (element ==
"initnode" || element ==
"finalizenode")
465 DEBTRACE(
"dynparalooptypeParser::onEnd: " << el )
466 std::string element(el);
474 DEBTRACE(
"dynparaloop_initnode: " <<
n->getNode()->getName() )
481 DEBTRACE(
"dynparaloop_finalizenode: " <<
n->getNode()->getName() )
516 for (
int i = 0; attr[
i];
i += 2)
518 if(std::string(attr[
i]) ==
"name")
name(attr[
i+1]);
519 if(std::string(attr[
i]) ==
"state")this->
state(attr[
i+1]);
520 if(std::string(attr[
i]) ==
"nbranch")
nbranch(atoi(attr[
i+1]));
521 if(std::string(attr[
i]) ==
"loopWeight")
weight(atof(attr[
i+1]));
522 if(std::string(attr[
i]) ==
"type")
datatype(attr[
i+1]);
550 DEBTRACE(
"foreach_datatype: "<< type)
561 std::stringstream msg;
562 msg <<
"Type "<<
_datatype <<
" does not exist"<<
" ("<<__FILE__<<
":"<<__LINE__<<
")";
601 template <
class T=ENGINE::OptimizerLoop*>
613 for (
int i = 0; attr[
i];
i += 2)
615 if(std::string(attr[
i]) ==
"name")
name(attr[
i+1]);
616 if(std::string(attr[
i]) ==
"state")this->
state(attr[
i+1]);
617 if(std::string(attr[
i]) ==
"nbranch")
nbranch(atoi(attr[
i+1]));
618 if(std::string(attr[
i]) ==
"loopWeight")
weight(atof(attr[
i+1]));
619 if(std::string(attr[
i]) ==
"lib")
lib(attr[
i+1]);
620 if(std::string(attr[
i]) ==
"entry")
entry(attr[
i+1]);
621 if(std::string(attr[
i]) ==
"kind")
kind(attr[
i+1]);
701 DEBTRACE(
"looptypeParser::onStart: " << el )
702 std::string element(el);
703 this->maxcount(
"inline",1,element);
704 this->maxcount(
"sinline",1,element);
705 this->maxcount(
"service",1,element);
706 this->maxcount(
"server",1,element);
707 this->maxcount(
"remote",1,element);
708 this->maxcount(
"node",1,element);
709 this->maxcount(
"forloop",1,element);
710 this->maxcount(
"foreach",1,element);
711 this->maxcount(
"foreachdyn",1,element);
712 this->maxcount(
"optimizer",1,element);
713 this->maxcount(
"while",1,element);
714 this->maxcount(
"switch",1,element);
715 this->maxcount(
"bloc",1,element);
716 this->maxchoice(
t3,1,element);
734 this->SetUserDataAndPush(pp);
743 DEBTRACE(
"looptypeParser::onEnd: " << el )
744 std::string element(el);
761 else if(element ==
"datalink") datalink(((
linktypeParser<>*)child)->post());
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
YACS::ENGINE::Runtime * theRuntime
YACS::ENGINE::Proc * currentProc
Composed node to group elementary and composed nodes.
Node * edSetFinalizeNode(Node *DISOWNnode)
Node * edSetInitNode(Node *DISOWNnode)
Loop node for parametric calculation.
Class for calculation node (script) inlined (and executed) in the schema.
Base class for all nodes.
const std::string & getName() const
class to build optimization loops
std::map< std::string, InlineNode * > inlineMap
std::map< std::string, ServiceNode * > serviceMap
std::map< std::string, Node * > nodeMap
std::map< std::string, TypeCode * > typeMap
std::vector< std::string > names
virtual OptimizerLoop * createOptimizerLoop(const std::string &name, const std::string &algLib, const std::string &factoryName, bool algInitOnFile, const std::string &kind="", Proc *procForTypes=NULL)
virtual ForLoop * createForLoop(const std::string &name)
virtual TypeCode * getTypeCode(const std::string &name)
Get a typecode by its name from runtime catalogs.
virtual ForEachLoop * createForEachLoop(const std::string &name, TypeCode *type)
virtual ForEachLoopDyn * createForEachLoopDyn(const std::string &name, TypeCode *type)
virtual WhileLoop * createWhileLoop(const std::string &name)
Class for calculation node associated with a component service.
Control node that emulates the C switch.
Base class for all type objects.
const char * what(void) const noexcept
bool edAddLink(ENGINE::OutPort *start, ENGINE::InPort *end)
void edSetNode(ENGINE::Node *node)
bool edAddDFLink(ENGINE::OutPort *start, ENGINE::InPort *end)
T buildFrom(ENGINE::Runtime *theRuntime, const std::string &name, ENGINE::TypeCode *type)
virtual void onStart(const XML_Char *el, const XML_Char **attr)
virtual void onEnd(const char *el, parser *child)
virtual void finalizenode(PseudoComposedNode *const &n)
virtual void initnode(PseudoComposedNode *const &n)
virtual void nbranch(const int &n)
virtual void weight(const double &x)
virtual void datatype(const std::string &type)
static foreachlooptypeParser< T > foreachloopParser
virtual void name(const std::string &name)
virtual void buildAttr(const XML_Char **attr)
virtual void buildAttr(const XML_Char **attr)
virtual void name(const std::string &name)
static forlooptypeParser< T > forloopParser
virtual void nsteps(const int &n)
virtual void server(ENGINE::ServerNode *const &n)
virtual void forloop(ENGINE::ForLoop *const &b)
virtual void while_(ENGINE::WhileLoop *const &b)
virtual void bloc(ENGINE::Bloc *const &b)
virtual void foreach(ENGINE::ForEachLoopGen *const &b)
virtual void datalink(const mylink &l)
virtual void service(ENGINE::ServiceNode *const &n)
virtual void property(const myprop &prop)
virtual void optimizer(ENGINE::OptimizerLoop *const &b)
virtual void remote(ENGINE::InlineNode *const &n)
virtual void node(ENGINE::InlineNode *const &n)
virtual void onStart(const XML_Char *el, const XML_Char **attr)
virtual void state(const std::string &name)
virtual void onEnd(const char *el, parser *child)
virtual void inline_(ENGINE::InlineNode *const &n)
virtual void buildAttr(const XML_Char **attr)
virtual void sinline(ENGINE::ServiceInlineNode *const &n)
virtual void switch_(ENGINE::Switch *const &b)
virtual void name(const std::string &name)
virtual void kind(const std::string &name)
virtual void name(const std::string &name)
virtual void weight(const double &x)
virtual void lib(const std::string &name)
virtual void entry(const std::string &name)
static optimizerlooptypeParser< T > optimizerloopParser
virtual void buildAttr(const XML_Char **attr)
virtual void nbranch(const int &n)
virtual void maxcount(std::string name, int max, std::string &el)
virtual void SetUserDataAndPush(parser *pp)
virtual void required(const std::string &name, const XML_Char **attr)
virtual void buildAttr(const XML_Char **attr)
static parser main_parser
Class for property parser.
static propertytypeParser propertyParser
static pseudocomposednodetypeParser< T > pseudocomposednodeParser
virtual void datalink(const mylink &l)
virtual void buildAttr(const XML_Char **attr)
Class for parsing ServiceInlineNode description.
static switchtypeParser switchParser
virtual void name(const std::string &name)
static whilelooptypeParser< T > whileloopParser