36 using namespace YACS::ENGINE;
49 _createDatastreamPorts(false),
50 _multi_port_node(false)
93 (*iter2)->exInit(start);
148 string what(
"ElementaryNode::exUpdateState : Invalid graph given : Node with name \"");
149 what+=
_name; what+=
"\" ready to run whereas some inputports are not set correctly\nCheck coherence DF/CF";
172 return getPort<InputPort>(name,_setOfInputPort);
177 return getPort<OutputPort>(name,_setOfOutputPort);
184 for(list<OutPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
186 set<InPort *> temp2=(*iter2)->edSetInPort();
197 for(list<InPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
199 set<OutPort *> temp2=(*iter2)->edSetOutPort();
208 vector< pair<OutPort *, InPort *> >
ret;
210 for(set<OutPort *>::iterator iter2=ports.begin();iter2!=ports.end();iter2++)
212 set<InPort *> temp2=(*iter2)->edSetInPort();
213 for(set<InPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
214 ret.push_back(pair<OutPort *, InPort *>(*iter2,*iter3));
221 vector< pair<InPort *, OutPort *> >
ret;
223 for(set<InPort *>::iterator iter2=ports.begin();iter2!=ports.end();iter2++)
225 set<OutPort *> temp2=(*iter2)->edSetOutPort();
226 for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
228 std::set<OutPort *> trueOutPorts;
229 (*iter3)->getAllRepresented(trueOutPorts);
230 for(std::set<OutPort *>::iterator iter4=trueOutPorts.begin();iter4!=trueOutPorts.end();++iter4)
231 ret.push_back(pair<InPort *, OutPort *>(*iter2,*iter4));
239 return getPort<InputDataStreamPort>(name,_setOfInputDataStreamPort);
244 return getPort<OutputDataStreamPort>(name,_setOfOutputDataStreamPort);
254 (*iter)->edRemoveAllLinksLinkedWithMe();
257 (*iter2)->edRemoveAllLinksLinkedWithMe();
261 (*iter)->edRemoveAllLinksLinkedWithMe();
264 (*iter2)->edRemoveAllLinksLinkedWithMe();
277 ret=!(*iter)->isEmpty();
296 std::string port_name = port->
getName();
297 std::map<std::string,std::string>::iterator it=
_propertyMap.find(port_name);
301 std::string multi_str = it->second;
302 std::istringstream iss(multi_str);
304 throw Exception(
"Property multi port should be set with a stringified int not an: " + multi_str);
311 port->
setName(port_name +
"_0");
312 for (
int i = 2;
i <= multi;
i++)
315 std::ostringstream number;
317 new_port->
setName(port_name +
"_" + number.str());
326 std::string port_name = port->
getName();
327 std::map<std::string,std::string>::iterator it=
_propertyMap.find(port_name);
331 std::string multi_str = it->second;
332 std::istringstream iss(multi_str);
334 throw Exception(
"Property multi port should be set with a stringified int not an: " + multi_str);
341 port->
setName(port_name +
"_0");
342 for (
int i = 2;
i <= multi;
i++)
345 std::ostringstream number;
347 new_port->
setName(port_name +
"_" + number.str());
365 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi");
368 std::string multi_str = it->second;
369 std::istringstream iss(multi_str);
371 throw Exception(
"Property multi should be set with a stringified int not an: " + multi_str);
378 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi_working_dir");
381 std::string working_dir_base = it->second;
382 std::ostringstream working_dir_stream;
383 working_dir_stream << working_dir_base;
384 working_dir_stream << 1;
387 tasks.push_back(
this);
396 if ((*it_output)->isConnected())
398 throw Exception(
"Property multi cannot be set on nodes with dataflow output ports connected");
403 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi_working_dir");
406 std::string working_dir_base = it->second;
407 std::ostringstream working_dir_stream;
408 working_dir_stream << working_dir_base;
409 working_dir_stream << 1;
412 tasks.push_back(
this);
415 for (
int i = 1;
i < multi;
i++)
423 std::stringstream inamess;
431 for(list<InputPort *>::const_iterator iter1=clone_list_inputPorts.begin(); iter1!=clone_list_inputPorts.end(); iter1++)
433 std::string input_port_name = (*iter1)->getName();
436 for (std::set<OutPort *>::const_iterator itt=master_port->
_backLinks.begin(); itt!=master_port->
_backLinks.end();itt++)
445 for(list<InputDataStreamPort *>::iterator iter = clone_list_inputDatastreamPorts.begin(); iter != clone_list_inputDatastreamPorts.end(); iter++)
447 std::string port_name = (*iter)->getName();
453 std::set<OutputDataStreamPort *>::const_iterator iter3;
454 for(iter3=connected_ports.begin();iter3!=connected_ports.end();iter3++)
459 std::string good_port_name;
460 std::stringstream temp_name;
461 std::string out_name = (*iter3)->getName();
462 out_name.erase(out_name.end()-1);
463 temp_name << out_name <<
i;
464 good_port_name = temp_name.str();
471 for(list<OutputDataStreamPort *>::iterator iter = clone_list_outputDatastreamPorts.begin(); iter != clone_list_outputDatastreamPorts.end(); iter++)
473 std::string port_name = (*iter)->getName();
476 for(set<InputDataStreamPort *>::iterator dest_port = dest_input_port.begin(); dest_port != dest_input_port.end(); dest_port++)
482 std::string good_port_name;
483 std::stringstream temp_name;
484 std::string in_name = (*dest_port)->getName();
485 in_name.erase(in_name.end()-1);
486 temp_name << in_name <<
i;
487 good_port_name = temp_name.str();
493 new_node->
init(
false);
498 for(std::list<OutGate *>::const_iterator iter=clone_cl_back.begin(); iter!=clone_cl_back.end(); iter++)
502 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi_working_dir");
505 std::string working_dir_base = it->second;
506 std::ostringstream working_dir_stream;
507 working_dir_stream << working_dir_base;
508 working_dir_stream << i+1;
511 tasks.push_back(new_node);
523 DEBTRACE(
"ElementaryNode::edRemovePort ");
524 if(port->getNode()!=
this)
525 throw Exception(
"ElementaryNode::edRemovePort : Port is not held by this node");
526 if(
InputPort *
p=dynamic_cast<InputPort *>(port))
527 edRemovePortTypedFromSet<InputPort>(
p,_setOfInputPort);
528 else if(
OutputPort *
p=dynamic_cast<OutputPort *>(port))
529 edRemovePortTypedFromSet<OutputPort>(
p,_setOfOutputPort);
531 edRemovePortTypedFromSet<InputDataStreamPort>(
p,_setOfInputDataStreamPort);
533 edRemovePortTypedFromSet<OutputDataStreamPort>(
p,_setOfOutputDataStreamPort);
535 throw Exception(
"ElementaryNode::edRemovePort : unknown port type");
546 list<ElementaryNode *>
ret;
558 list<ProgressWeight>
ret;
565 ret.push_back(myWeight);
571 string what(
"ElementaryNode does not agregate any nodes particullary node with name "); what+=name;
577 DEBTRACE(
"ElementaryNode::checkBasicConsistency");
578 list<InputPort *>::const_iterator iter;
580 (*iter)->checkBasicConsistency();
586 if(!iter->isPlacementPredictableB4Run())
605 if (inputPortName ==
"__InPropertyPort__Node__YACS_")
607 string what(
"ElementaryNode::edAddInputPort: it is forbidden to add an InputPort with the name __InPropertyPort__Node__YACS_\"");
612 if (edCheckAddPort<InputPort, TypeCode*>(inputPortName,_setOfInputPort,type))
614 ret = createInputPort(inputPortName, type);
615 _setOfInputPort.push_back(ret);
628 std::set<InputPort *> s1;
629 std::set<InputPort *> s2;
632 for(list<InputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
636 throw Exception(
"ElementaryNode::edOrderInputPorts : port list must contain same ports as existing ones");
639 for(list<InputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
645 std::set<OutputPort *> s1;
646 std::set<OutputPort *> s2;
649 for(list<OutputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
653 throw Exception(
"ElementaryNode::edOrderOutputPorts : port list must contain same ports as existing ones");
656 for(list<OutputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
673 if (edCheckAddPort<OutputPort, TypeCode*>(outputPortName,_setOfOutputPort,type))
675 ret = createOutputPort(outputPortName, type);
676 _setOfOutputPort.push_back(ret);
695 if (edCheckAddPort<InputDataStreamPort, TypeCode*>(inputPortDSName,_setOfInputDataStreamPort,type))
697 ret = createInputDataStreamPort(inputPortDSName, type);
698 _setOfInputDataStreamPort.push_back(ret);
712 if (edCheckAddPort<OutputDataStreamPort, TypeCode*>(outputPortDSName,_setOfOutputDataStreamPort,type))
714 ret = createOutputDataStreamPort(outputPortDSName, type);
715 _setOfOutputDataStreamPort.push_back(ret);
727 Node *node = inPort->getNode();
730 string what(
"InputPort "); what += inPort->getName(); what +=
" does not belong to node "; what += node->
getName();
733 return inPort->getName();
738 Node *node = outPort->getNode();
741 string what(
"OutputPort "); what += outPort->getName(); what +=
" does not belong to node "; what += node->
getName();
744 return outPort->getName();
842 std::list<OutputDataStreamPort *>::iterator iterout;
847 std::set<InPort *>::iterator iter;
848 for(iter=ports.begin();iter != ports.end(); iter++)
850 Node* node= (*iter)->getNode();
854 std::list<InputDataStreamPort *>::iterator iterin;
859 std::set<OutPort *>::iterator iter;
860 for(iter=ports.begin();iter != ports.end(); iter++)
862 Node* node= (*iter)->getNode();
877 if(coupledSet.find(
this) != coupledSet.end())
return;
879 coupledSet.insert(
this);
881 std::list<OutputDataStreamPort *>::iterator iterout;
886 std::set<InPort *>::iterator iter;
887 for(iter=ports.begin();iter != ports.end(); iter++)
889 Node* node= (*iter)->getNode();