49 _createDatastreamPorts(false),
50 _multi_port_node(false),
95 (*iter2)->exInit(start);
150 string what(
"ElementaryNode::exUpdateState : Invalid graph given : Node with name \"");
151 what+=
_name; what+=
"\" ready to run whereas some inputports are not set correctly\nCheck coherence DF/CF";
186 for(list<OutPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
188 set<InPort *> temp2=(*iter2)->edSetInPort();
199 for(list<InPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
201 set<OutPort *> temp2=(*iter2)->edSetOutPort();
210 vector< pair<OutPort *, InPort *> > ret;
212 for(set<OutPort *>::iterator iter2=ports.begin();iter2!=ports.end();iter2++)
214 set<InPort *> temp2=(*iter2)->edSetInPort();
215 for(set<InPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
216 ret.push_back(pair<OutPort *, InPort *>(*iter2,*iter3));
223 vector< pair<InPort *, OutPort *> > ret;
225 for(set<InPort *>::iterator iter2=ports.begin();iter2!=ports.end();iter2++)
227 set<OutPort *> temp2=(*iter2)->edSetOutPort();
228 for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
230 std::set<OutPort *> trueOutPorts;
231 (*iter3)->getAllRepresented(trueOutPorts);
232 for(std::set<OutPort *>::iterator iter4=trueOutPorts.begin();iter4!=trueOutPorts.end();++iter4)
233 ret.push_back(pair<InPort *, OutPort *>(*iter2,*iter4));
256 (*iter)->edRemoveAllLinksLinkedWithMe();
259 (*iter2)->edRemoveAllLinksLinkedWithMe();
263 (*iter)->edRemoveAllLinksLinkedWithMe();
266 (*iter2)->edRemoveAllLinksLinkedWithMe();
279 ret=!(*iter)->isEmpty();
298 std::string port_name = port->
getName();
299 std::map<std::string,std::string>::iterator it=
_propertyMap.find(port_name);
303 std::string multi_str = it->second;
304 std::istringstream iss(multi_str);
306 throw Exception(
"Property multi port should be set with a stringified int not an: " + multi_str);
313 port->
setName(port_name +
"_0");
314 for (
int i = 2;
i <= multi;
i++)
317 std::ostringstream number;
319 new_port->
setName(port_name +
"_" + number.str());
328 std::string port_name = port->
getName();
329 std::map<std::string,std::string>::iterator it=
_propertyMap.find(port_name);
333 std::string multi_str = it->second;
334 std::istringstream iss(multi_str);
336 throw Exception(
"Property multi port should be set with a stringified int not an: " + multi_str);
343 port->
setName(port_name +
"_0");
344 for (
int i = 2;
i <= multi;
i++)
347 std::ostringstream number;
349 new_port->
setName(port_name +
"_" + number.str());
367 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi");
370 std::string multi_str = it->second;
371 std::istringstream iss(multi_str);
373 throw Exception(
"Property multi should be set with a stringified int not an: " + multi_str);
380 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi_working_dir");
383 std::string working_dir_base = it->second;
384 std::ostringstream working_dir_stream;
385 working_dir_stream << working_dir_base;
386 working_dir_stream << 1;
389 tasks.push_back(
this);
398 if ((*it_output)->isConnected())
400 throw Exception(
"Property multi cannot be set on nodes with dataflow output ports connected");
405 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi_working_dir");
408 std::string working_dir_base = it->second;
409 std::ostringstream working_dir_stream;
410 working_dir_stream << working_dir_base;
411 working_dir_stream << 1;
414 tasks.push_back(
this);
417 for (
int i = 1;
i < multi;
i++)
425 std::stringstream inamess;
433 for(list<InputPort *>::const_iterator iter1=clone_list_inputPorts.begin(); iter1!=clone_list_inputPorts.end(); iter1++)
435 std::string input_port_name = (*iter1)->getName();
447 for(list<InputDataStreamPort *>::iterator iter = clone_list_inputDatastreamPorts.begin(); iter != clone_list_inputDatastreamPorts.end(); iter++)
449 std::string port_name = (*iter)->getName();
455 std::set<OutputDataStreamPort *>::const_iterator iter3;
456 for(iter3=connected_ports.begin();iter3!=connected_ports.end();iter3++)
461 std::string good_port_name;
462 std::stringstream temp_name;
463 std::string out_name = (*iter3)->getName();
464 out_name.erase(out_name.end()-1);
465 temp_name << out_name <<
i;
466 good_port_name = temp_name.str();
473 for(list<OutputDataStreamPort *>::iterator iter = clone_list_outputDatastreamPorts.begin(); iter != clone_list_outputDatastreamPorts.end(); iter++)
475 std::string port_name = (*iter)->getName();
478 for(set<InputDataStreamPort *>::iterator dest_port = dest_input_port.begin(); dest_port != dest_input_port.end(); dest_port++)
484 std::string good_port_name;
485 std::stringstream temp_name;
486 std::string in_name = (*dest_port)->getName();
487 in_name.erase(in_name.end()-1);
488 temp_name << in_name <<
i;
489 good_port_name = temp_name.str();
495 new_node->
init(
false);
500 for(std::list<OutGate *>::const_iterator iter=clone_cl_back.begin(); iter!=clone_cl_back.end(); iter++)
504 std::map<std::string,std::string>::iterator it=
_propertyMap.find(
"multi_working_dir");
507 std::string working_dir_base = it->second;
508 std::ostringstream working_dir_stream;
509 working_dir_stream << working_dir_base;
510 working_dir_stream <<
i+1;
513 tasks.push_back(new_node);
525 DEBTRACE(
"ElementaryNode::edRemovePort ");
527 throw Exception(
"ElementaryNode::edRemovePort : Port is not held by this node");
537 throw Exception(
"ElementaryNode::edRemovePort : unknown port type");
548 list<ElementaryNode *> ret;
560 list<ProgressWeight> ret;
567 ret.push_back(myWeight);
573 string what(
"ElementaryNode does not agregate any nodes particullary node with name "); what+=name;
579 DEBTRACE(
"ElementaryNode::checkBasicConsistency");
580 list<InputPort *>::const_iterator iter;
582 (*iter)->checkBasicConsistency();
588 if(!iter->isPlacementPredictableB4Run())
607 if (inputPortName ==
"__InPropertyPort__Node__YACS_")
609 string what(
"ElementaryNode::edAddInputPort: it is forbidden to add an InputPort with the name __InPropertyPort__Node__YACS_\"");
614 if (edCheckAddPort<InputPort, TypeCode*>(inputPortName,
_setOfInputPort,type))
630 std::set<InputPort *> s1;
631 std::set<InputPort *> s2;
634 for(list<InputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
638 throw Exception(
"ElementaryNode::edOrderInputPorts : port list must contain same ports as existing ones");
641 for(list<InputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
647 std::set<OutputPort *> s1;
648 std::set<OutputPort *> s2;
651 for(list<OutputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
655 throw Exception(
"ElementaryNode::edOrderOutputPorts : port list must contain same ports as existing ones");
658 for(list<OutputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
675 if (edCheckAddPort<OutputPort, TypeCode*>(outputPortName,
_setOfOutputPort,type))
732 string what(
"InputPort "); what += inPort->
getName(); what +=
" does not belong to node "; what += node->
getName();
743 string what(
"OutputPort "); what += outPort->
getName(); what +=
" does not belong to node "; what += node->
getName();
844 std::list<OutputDataStreamPort *>::iterator iterout;
849 std::set<InPort *>::iterator iter;
850 for(iter=ports.begin();iter != ports.end(); iter++)
852 Node* node= (*iter)->getNode();
856 std::list<InputDataStreamPort *>::iterator iterin;
861 std::set<OutPort *>::iterator iter;
862 for(iter=ports.begin();iter != ports.end(); iter++)
864 Node* node= (*iter)->getNode();
879 if(coupledSet.find(
this) != coupledSet.end())
return;
881 coupledSet.insert(
this);
883 std::list<OutputDataStreamPort *>::iterator iterout;
888 std::set<InPort *>::iterator iter;
889 for(iter=ports.begin();iter != ports.end(); iter++)
891 Node* node= (*iter)->getNode();
899 if(elementaryWeight<=0.)
900 throw Exception(
"ElementaryNode::setWeight : invalid input value !");
void setElementaryWeight(double elementaryWeight)
void setDefaultElementary()
Base class for all component instances.
Base class for all composed nodes.
virtual bool edAddDFLink(OutPort *start, InPort *end)
Connect an OutPort to an InPort and add the necessary control link.
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
virtual void setProperty(const std::string &name, const std::string &value)=0
void setName(std::string theName)
std::string getName() const
Base class for all calculation nodes.
void performDuplicationOfPlacement(const Node &other)
performs a duplication of placement using clone method of containers and components....
Container * getContainer()
int getNumberOfOutputPorts() const
std::set< OutPort * > getAllOutPortsLeavingCurrentScope() const
virtual OutputDataStreamPort * edAddOutputDataStreamPort(const std::string &outputPortDSName, TypeCode *type)
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope() const
void loaded()
Notify this node that it is loaded.
bool isDeployable() const
int getNumberOfInputPorts() const
InputPort * getInputPort(const std::string &name) const
ComposedNode * getDynClonerIfExists(const ComposedNode *levelToStop) const
virtual InputDataStreamPort * createInputDataStreamPort(const std::string &inputPortDSName, TypeCode *type)
virtual void ensureLoading()
Put this node into TOLOAD state when possible.
std::list< ElementaryNode * > getRecursiveConstituents() const
virtual void getCoupledNodes(std::set< Task * > &coupledSet)
Put all nodes that are coupled to this node in coupledSet.
void connected()
Notify this node that it is connected.
OutputDataStreamPort * getOutputDataStreamPort(const std::string &name) const
OutputPort * getOutputPort(const std::string &name) const
std::list< InputPort * > _setOfInputPort
std::list< ProgressWeight > getProgressWeight() const
Get the progress weight for all elementary nodes.
void initCommonPartWithoutStateManagement(bool start)
virtual std::string getErrorDetails()
Give a description of error when node status is ERROR.
void accept(Visitor *visitor)
std::list< OutputDataStreamPort * > _setOfOutputDataStreamPort
bool _createDatastreamPorts
virtual void addDatastreamPortToInitMultiService(const std::string &port_name, int number)
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope() const
std::string getOutPortName(const OutPort *) const
virtual OutputPort * createOutputPort(const std::string &outputPortName, TypeCode *type)
virtual ~ElementaryNode()
virtual InputPort * edAddInputPort(const std::string &inputPortName, TypeCode *type)
std::list< InputDataStreamPort * > _setOfInputDataStreamPort
std::list< InputPort * > getSetOfInputPort() const
std::list< OutputPort * > _setOfOutputPort
virtual InputDataStreamPort * edAddInputDataStreamPort(const std::string &inputPortDSName, TypeCode *type)
YACS::StatesForNode getState() const
virtual OutputDataStreamPort * createOutputDataStreamPort(const std::string &outputPortDSName, TypeCode *type)
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort() const
void init(bool start=true)
void setWeight(double elementaryWeight)
void edRemovePort(Port *port)
virtual InputPort * createInputPort(const std::string &inputPortName, TypeCode *type)
InputDataStreamPort * getInputDataStreamPort(const std::string &name) const
virtual void edUpdateState()
update the status of the node
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const
virtual void createMultiDatastreamPorts()
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort() const
bool areAllInputPortsValid() const
void edDisconnectAllLinksWithMe()
void performShallowDuplicationOfPlacement(const Node &other)
performs a also duplication of placement but here containers and components are not copied at all wha...
virtual void edOrderInputPorts(const std::list< InputPort * > &ports)
Node * getChildByName(const std::string &name) const
void getReadyTasks(std::vector< Task * > &tasks)
void exUpdateState()
Update the node state.
virtual void edOrderOutputPorts(const std::list< OutputPort * > &ports)
virtual void checkBasicConsistency() const
std::string getInPortName(const InPort *) const
ComponentInstance * getComponent()
virtual void getCoupledTasks(std::set< Task * > &coupledSet)
Calls getCoupledNodes for Task interface.
virtual OutputPort * edAddOutputPort(const std::string &outputPortName, TypeCode *type)
std::list< OutGate * > getBackLinks()
void exNotifyFromPrecursor(OutGate *fromgate)
Notify this port that an upstream node connected by a control flow link is finished.
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
std::set< std::pair< OutPort *, bool > > _backLinks
Base class for all nodes.
friend class ElementaryNode
virtual void getCoupledNodes(std::set< Task * > &coupledNodes)
virtual void modified()
Sets Node in modified state and its father if it exists.
void setName(const std::string &name)
Change the name of the node.
Node * clone(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
std::map< std::string, std::string > _propertyMap
std::list< OutPort * > getSetOfOutPort() const
std::list< InPort * > getSetOfInPort() const
void setState(YACS::StatesForNode theState)
Sets the given state for node.
std::string _implementation
virtual void exDisabledState()
Notify this node that it has been disabled.
virtual YACS::StatesForNode getState() const
const std::string & getName() const
virtual InputPort * getInputPort(const std::string &name) const
virtual void ensureLoading()
Put this node into TOLOAD state when possible.
std::string _errorDetails
YACS::StatesForNode _state
virtual void edDisconnectAllLinksWithMe()
std::set< InputDataStreamPort * > _setOfInputDataStreamPort
virtual OutputDataStreamPort * clone(Node *newHelder) const
std::set< InPort * > edSetInPort() const
Base class for all ports.
virtual InputPort * createInputPort(const std::string &name, const std::string &impl, Node *node, TypeCode *type)=0
virtual OutputPort * createOutputPort(const std::string &name, const std::string &impl, Node *node, TypeCode *type)=0
virtual InputDataStreamPort * createInputDataStreamPort(const std::string &name, Node *node, TypeCode *type)
virtual OutputDataStreamPort * createOutputDataStreamPort(const std::string &name, Node *node, TypeCode *type)
Base class for all type objects.
virtual void visitElementaryNode(ElementaryNode *node)=0
const char * what(void) const noexcept
YACSLIBENGINE_EXPORT Runtime * getRuntime()