Version: 8.3.0
YACS::ENGINE::DynParaLoop Class Reference

Base class for dynamically (fully or semifully) built graphs. More...

#include <DynParaLoop.hxx>

Inheritance diagram for YACS::ENGINE::DynParaLoop:
Collaboration diagram for YACS::ENGINE::DynParaLoop:

Public Member Functions

NodeedRemoveNode ()
 
NodeedRemoveInitNode ()
 
NodeedRemoveFinalizeNode ()
 
NodeedSetNode (Node *DISOWNnode)
 
NodeedSetInitNode (Node *DISOWNnode)
 
NodeedSetFinalizeNode (Node *DISOWNnode)
 
virtual bool edAddDFLink (OutPort *start, InPort *end) throw (Exception)
 Connect an OutPort to an InPort and add control link if necessary. More...
 
void init (bool start=true)
 
InputPortedGetNbOfBranchesPort ()
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
unsigned getNumberOfEltsConsumed () const
 
int getBranchIDOfNode (Node *node) const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
OutputPortedGetSamplePort ()
 
OutPortgetOutPort (const std::string &name) const throw (Exception)
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 Get an input port given its name. More...
 
OutputPortgetOutputPort (const std::string &name) const throw (Exception)
 Get an output port given its name. More...
 
bool isPlacementPredictableB4Run () const
 For the moment false is returned : impovement about it coming soon. More...
 
void edRemoveChild (Node *node) throw (Exception)
 Remove a child node. More...
 
virtual bool edAddChild (Node *DISOWNnode) throw (Exception)
 
std::list< Node * > edGetDirectDescendants () const
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
unsigned getNumberOfBranchesCreatedDyn () const throw (Exception)
 
NodegetChildByShortName (const std::string &name) const throw (Exception)
 
NodegetChildByNameExec (const std::string &name, unsigned id) const throw (Exception)
 
std::vector< Node * > getNodes () const
 
bool isMultiplicitySpecified (unsigned &value) const
 
void forceMultiplicity (unsigned value)
 
virtual void checkBasicConsistency () const throw (Exception)
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
void accept (Visitor *visitor)
 
NodegetInitNode ()
 
NodegetExecNode ()
 
NodegetFinalizeNode ()
 
int getMaxLevelOfParallelism () const
 
- Public Member Functions inherited from YACS::ENGINE::ComposedNode
virtual ~ComposedNode ()
 
bool isFinished ()
 
virtual void resetState (int level)
 Reset the state of the node and its children depending on the parameter level. More...
 
std::string getName () const
 
std::string getTaskName (Task *task) const
 
DeploymentTree getDeploymentTree () const
 Essentially for test. Use checkDeploymentTree instead to be sure that returned DeploymentTree is consistent. More...
 
DeploymentTree checkDeploymentTree (bool deep) const throw (Exception)
 Perform check of deployment consistency of the current graph. More...
 
std::vector< Task * > getNextTasks (bool &isMore)
 
void notifyFrom (const Task *sender, YACS::Event event, const Executor *execInst)
 Notify the node a task has emitted an event. More...
 
bool edAddLink (OutPort *start, InPort *end) throw (Exception)
 Add a dataflow link between two data ports. More...
 
bool edAddLink (OutGate *start, InGate *end) throw (Exception)
 Add a controlflow link between two control ports. More...
 
bool edAddCFLink (Node *nodeS, Node *nodeE) throw (Exception)
 Add a controlflow link between two nodes. More...
 
void edRemoveCFLink (Node *nodeS, Node *nodeE) throw (Exception)
 Remove a controlflow link. More...
 
void edRemoveLink (OutPort *start, InPort *end) throw (Exception)
 Remove a dataflow link. More...
 
void edRemoveLink (OutGate *start, InGate *end) throw (Exception)
 Remove a controlflow link. More...
 
virtual bool isRepeatedUnpredictablySeveralTimes () const
 
virtual void removeRecursivelyRedundantCL ()
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< Node * > getAllRecursiveNodes ()
 Get all children nodes elementary and composed including this node. More...
 
virtual std::list< Node * > getAllRecursiveConstituents ()
 Idem getAllRecursiveNodes, but this node is NOT included. More...
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
std::string getInPortName (const InPort *) const throw (Exception)
 Get the input port name. More...
 
std::string getOutPortName (const OutPort *) const throw (Exception)
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 List all output ports of children nodes that are linked to out of scope input ports. More...
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 List all input ports that are linked to out of scope ports. More...
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const throw (Exception)
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const throw (Exception)
 
std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfInternalLinks () const
 
virtual std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfLinksLeavingCurrentScope () const
 
void checkConsistency (LinkInfo &info) const throw (Exception)
 
virtual std::vector< std::pair
< InPort *, OutPort * > > 
getSetOfLinksComingInCurrentScope () const
 
virtual std::string typeName ()
 
virtual void edUpdateState ()
 update the status of the node More...
 
ComposedNodegetRootNode () const throw (Exception)
 
bool isNodeAlreadyAggregated (const Node *node) const
 Check that Node 'node' is already a direct son of this. More...
 
virtual bool isNameAlreadyUsed (const std::string &name) const
 
NodeisInMyDescendance (Node *nodeToTest) const
 Returns the parent of a node that is the direct child of this node. More...
 
std::string getChildName (const Node *node) const throw (Exception)
 
virtual std::string getMyQualifiedName (const Node *directSon) const
 
NodegetChildByName (const std::string &name) const throw (Exception)
 
void loaded ()
 
void connected ()
 
virtual void cleanNodes ()
 Clean the composed node in case of not clean exit. More...
 
virtual std::string getProgress () const
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getState () const
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
virtual void exUpdateState ()
 Update the node state. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
virtual void getReadyTasks (std::vector< Task * > &tasks)=0
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
InPortgetInPort (const std::string &name) const throw (Exception)
 
InPropertyPortgetInPropertyPort () const throw (Exception)
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string,
std::string > 
getProperties ()
 
std::map< std::string,
std::string > 
getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair
< std::string, int > > 
getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
- Public Member Functions inherited from YACS::ENGINE::Scheduler
virtual void exUpdateState ()=0
 
virtual void selectRunnableTasks (std::vector< Task * > &tasks)=0
 
virtual ~Scheduler ()
 

Protected Types

enum  TypeOfNode { INIT_NODE = 5, WORK_NODE = 6, FINALIZE_NODE = 7 }
 

Protected Member Functions

 DynParaLoop (const std::string &name, TypeCode *typeOfDataSplitted)
 
virtual ~DynParaLoop ()
 
 DynParaLoop (const DynParaLoop &other, ComposedNode *father, bool editionOnly)
 
void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const
 
virtual void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd) throw (Exception)
 
void cleanDynGraph ()
 
void prepareInputsFromOutOfScope (int branchNb)
 
void putValueOnBranch (Any *val, unsigned branchId, bool first)
 
TypeOfNode getIdentityOfNotifyerNode (const Node *node, unsigned &id)
 
InputPortgetDynInputPortByAbsName (int branchNb, const std::string &name, bool initNodeAdmitted)
 
virtual void forwardExecStateToOriginalBody (Node *execNode)
 
virtual YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
std::vector< Node * > cloneAndPlaceNodesCoherently (const std::vector< Node * > &origNodes)
 Clone nodes and make their placement consistent with the placement of the original ones. More...
 
NodecheckConsistencyAndSetNode (Node *&nodeToReplace, Node *DISOWNnode)
 This method is used to factorize methods edSetNode, edSetInitNode and edSetFinalizeNode. More...
 
NoderemoveNode (Node *&nodeToRemove)
 This method is used to factorize methods edRemoveNode, edRemoveInitNode and edRemoveFinalizeNode. More...
 
virtual void shutdown (int level)
 Stop all pending activities of the composed node. More...
 
- Protected Member Functions inherited from YACS::ENGINE::ComposedNode
 ComposedNode (const std::string &name)
 
 ComposedNode (const ComposedNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
void edDisconnectAllLinksWithMe ()
 
YACS::Event updateStateFrom (Node *node, YACS::Event event, const Executor *execInst)
 Update node state on receiving event from a node. More...
 
virtual YACS::Event updateStateOnStartEventFrom (Node *node)
 Method used to notify the node that a child node has started. More...
 
virtual YACS::Event updateStateOnFinishedEventFrom (Node *node)=0
 
virtual void getDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
virtual void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
virtual void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
virtual void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
virtual void checkNoCyclePassingThrough (Node *node)=0 throw (Exception)
 
void checkInMyDescendance (Node *nodeToTest) const throw (Exception)
 Check if a node is in the descendance of this node. More...
 
template<class PORT >
std::string getPortName (const PORT *port) const throw (Exception)
 
void checkNoCrossHierachyWith (Node *node) const throw (Exception)
 
virtual void performCFComputations (LinkInfo &info) const
 perform recursively all CF computations. More...
 
virtual void destructCFComputations (LinkInfo &info) const
 destroy recursively all results of initial computations. More...
 
NodegetLowestNodeDealingAll (const std::list< OutPort * > &ports) const
 
void checkLinksCoherenceRegardingControl (const std::vector< OutPort * > &starts, InputPort *end, LinkInfo &info) const throw (Exception)
 
void solveObviousOrDelegateCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual NodesimpleClone (ComposedNode *father, bool editionOnly=true) const =0
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 

Protected Attributes

Node_node
 
Node_initNode
 
Node_finalizeNode
 
unsigned _nbOfEltConsumed
 
std::vector< int > _execIds
 
AnyInputPort _nbOfBranches
 
AnyOutputPort _splittedPort
 
std::vector< Node * > _execNodes
 
std::vector< Node * > _execInitNodes
 
std::vector< Node * > _execFinalizeNodes
 
int _initializingCounter
 
int _unfinishedCounter
 
int _failedCounter
 

Static Protected Attributes

static const char NAME_OF_SPLITTED_SEQ_OUT [] = "evalSamples"
 
static const char OLD_NAME_OF_SPLITTED_SEQ_OUT [] = "SmplPrt"
 
static const char NAME_OF_NUMBER_OF_BRANCHES [] ="nbBranches"
 
- Static Protected Attributes inherited from YACS::ENGINE::ComposedNode
static const char SEP_CHAR_BTW_LEVEL [] ="."
 
static const unsigned char FED_ST = 2
 
static const unsigned char FREE_ST = 0
 
static const unsigned char FED_DS_ST = 1
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::ComposedNode
static ComposedNodegetLowestCommonAncestor (Node *node1, Node *node2) throw (Exception)
 Retrieves the lowest common ancestor of 2 nodes. More...
 
static std::string getLowestCommonAncestorStr (const std::string &node1, const std::string &node2)
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Public Attributes inherited from YACS::ENGINE::Node
static std::map< int, Node * > idMap
 
- Static Protected Member Functions inherited from YACS::ENGINE::ComposedNode
static bool splitNamesBySep (const std::string &globalName, const char separator[], std::string &firstPart, std::string &lastPart, bool priority) throw (Exception)
 Splits name globalName in 2 parts using separator. More...
 

Detailed Description

Base class for dynamically (fully or semifully) built graphs.

Definition at line 37 of file DynParaLoop.hxx.

Member Enumeration Documentation

Enumerator
INIT_NODE 
WORK_NODE 
FINALIZE_NODE 

Definition at line 40 of file DynParaLoop.hxx.

41  {
42  INIT_NODE = 5,
43  WORK_NODE = 6,
44  FINALIZE_NODE = 7
45  } TypeOfNode;

Constructor & Destructor Documentation

DynParaLoop::DynParaLoop ( const std::string &  name,
TypeCode typeOfDataSplitted 
)
protected
DynParaLoop::~DynParaLoop ( )
protectedvirtual

Definition at line 51 of file DynParaLoop.cxx.

References _finalizeNode, _initNode, and _node.

52 {
53  delete _node;
54  delete _initNode;
55  delete _finalizeNode;
56 }
DynParaLoop::DynParaLoop ( const DynParaLoop other,
ComposedNode father,
bool  editionOnly 
)
protected

Definition at line 58 of file DynParaLoop.cxx.

References _finalizeNode, _initNode, _node, _splittedPort, YACS::ENGINE::Node::clone(), YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::OutputPort::edSetInPort(), YACS::ENGINE::Node::getInPort(), and YACS::ENGINE::ComposedNode::getPortName().

59  : ComposedNode(other,father), _nbOfBranches(other._nbOfBranches,this),
62 {
63  if(other._node)
64  _node=other._node->clone(this,editionOnly);
65  if(other._initNode)
66  _initNode=other._initNode->clone(this,editionOnly);
67  if(other._finalizeNode)
68  _finalizeNode = other._finalizeNode->clone(this,editionOnly);
69  const AnyOutputPort& startOfLinksToReproduce=other._splittedPort;
70  set<InPort *> endsOfLinksToReproduce=startOfLinksToReproduce.edSetInPort();
71  for(set<InPort *>::iterator iter=endsOfLinksToReproduce.begin();iter!=endsOfLinksToReproduce.end();iter++)
73 }

Member Function Documentation

void DynParaLoop::accept ( Visitor visitor)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 874 of file DynParaLoop.cxx.

References YACS::ENGINE::Visitor::visitDynParaLoop().

875 {
876  visitor->visitDynParaLoop(this);
877 }
void DynParaLoop::buildDelegateOf ( InPort *&  port,
OutPort initialStart,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::OptimizerLoop.

Definition at line 443 of file DynParaLoop.cxx.

References YACS::ENGINE::DataPort::getNameOfTypeOfCurrentInstance(), and YACS::ENGINE::InputPort::NAME.

Referenced by YACS::ENGINE::OptimizerLoop::buildDelegateOf(), and YACS::ENGINE::ForEachLoop::buildDelegateOf().

444 {
445  string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
446  if(typeOfPortInstance!=InputPort::NAME)
447  throw Exception("DynParaLoop::buildDelegateOf : A link with datastream end inside DynParaLoop is not possible");
448 }
void DynParaLoop::buildDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 450 of file DynParaLoop.cxx.

References _finalizeNode, _initNode, _splittedPort, YACS::ENGINE::DataPort::getName(), and YACS::ENGINE::ComposedNode::isInMyDescendance().

451 {
452  std::string linkName("(");
453  linkName += port.first->getName()+" to "+finalTarget->getName()+")";
454  if(_initNode)
455  if(isInMyDescendance(port.first->getNode())==_initNode)
456  throw Exception(std::string("Illegal link within a parallel loop: \
457 a link starting from the init node can't leave the scope of the loop.")
458  + linkName);
459 
460  if(_finalizeNode)
461  if(isInMyDescendance(port.first->getNode())==_finalizeNode)
462  throw Exception(std::string("Illegal link within a parallel loop: \
463 an output port of the finalize node can't be linked.")
464  + linkName);
465 
466  if(port.first==&_splittedPort)
467  throw Exception(std::string("Illegal link within a parallel loop: \
468 the 'evalSamples' port must be linked within the scope of the loop.")
469  + linkName);
470 }
void DynParaLoop::checkBasicConsistency ( ) const throw (Exception)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::OptimizerLoop.

Definition at line 567 of file DynParaLoop.cxx.

References _node, YACS::ENGINE::ComposedNode::checkBasicConsistency(), and DEBTRACE.

Referenced by YACS::ENGINE::OptimizerLoop::checkBasicConsistency().

568 {
569  DEBTRACE("DynParaLoop::checkBasicConsistency");
571  if(!_node)
572  throw Exception("For a dynamic loop, internal node is mandatory");
573 }
void DynParaLoop::checkCFLinks ( const std::list< OutPort * > &  starts,
InputPort end,
unsigned char &  alreadyFed,
bool  direction,
LinkInfo info 
) const
protectedvirtual

check control flow links

Parameters
startsIf different of 0, must aggregate at leat 1 element.
end:
alreadyFedin/out parameter. Indicates if 'end' ports is already and surely set or fed by an another port.
directionIf true : forward direction else backward direction.
info: informations collectedduring the check

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::OptimizerLoop.

Definition at line 472 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::FED_ST, YACS::ENGINE::ComposedNode::FREE_ST, YACS::ENGINE::Port::getNode(), YACS::ENGINE::I_USELESS, YACS::ENGINE::ComposedNode::isInMyDescendance(), YACS::ENGINE::LinkInfo::pushInfoLink(), and YACS::ENGINE::ComposedNode::solveObviousOrDelegateCFLinks().

Referenced by YACS::ENGINE::OptimizerLoop::checkCFLinks().

473 {
474  const char what[]="DynParaLoop::checkCFLinks : internal error.";
475  //First dealing checkCFLinks forwarding...
476  if(isInMyDescendance(end->getNode())==0)//no chance that _splittedPort is in starts due to buildDelegate.
477  solveObviousOrDelegateCFLinks(starts,end,alreadyFed,direction,info);
478  else
479  {//no forwarding here.
480  if(starts.size()!=1)
481  throw Exception(what);
482  //ASSERT(direction) : see DynParaLoop::checkControlDependancy only 'fw' filled.
483  if(alreadyFed==FREE_ST)
484  alreadyFed=FED_ST;
485  else if(alreadyFed==FED_ST)
486  {//Shame ! splittedPort fills a port already fed...
487  info.pushInfoLink(*(starts.begin()),end,I_USELESS);
488  }
489  }
490 }
Node * DynParaLoop::checkConsistencyAndSetNode ( Node *&  nodeToReplace,
Node DISOWNnode 
)
protected

This method is used to factorize methods edSetNode, edSetInitNode and edSetFinalizeNode.

Definition at line 81 of file DynParaLoop.cxx.

References YACS::ENGINE::Node::_father, _finalizeNode, _initNode, YACS::ENGINE::Node::_name, _node, YACS::ENGINE::ComposedNode::checkNoCrossHierachyWith(), YACS::ENGINE::ComposedNode::edRemoveChild(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Node::modified(), and PMMLBasicsTestLauncher::ret.

Referenced by edSetFinalizeNode(), edSetInitNode(), and edSetNode().

82 {
83  if (node == NULL || nodeToReplace == node)
84  return 0;
85  if (node->_father)
86  throw Exception(string("Can't set node: node ") + node->getName() + " is not orphan.");
87  if (_node && _node != nodeToReplace && _node->getName() == node->getName())
88  throw Exception(string("Can't set node: node ") + node->getName() +
89  " has the same name than exec node already in " + _name + ".");
90  if (_initNode && _initNode != nodeToReplace && _initNode->getName() == node->getName())
91  throw Exception(string("Can't set node: node ") + node->getName() +
92  " has the same name than init node already in " + _name + ".");
93  if (_finalizeNode && _finalizeNode != nodeToReplace && _finalizeNode->getName() == node->getName())
94  throw Exception(string("Can't set node: node ") + node->getName() +
95  " has the same name than finalize node already in " + _name + ".");
97  ComposedNode::edRemoveChild(nodeToReplace);
98  Node * ret = nodeToReplace;
99  nodeToReplace = node;
100  nodeToReplace->_father = this;
101  // set _modified flag so that edUpdateState can refresh state
102  modified();
103  return ret;
104 }
void DynParaLoop::checkControlDependancy ( OutPort start,
InPort end,
bool  cross,
std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &  fw,
std::vector< OutPort * > &  fwCross,
std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &  bw,
LinkInfo info 
) const
protectedvirtual
Parameters
start: start port
end: end port
crossindicates if start -> end link is a DS link behind.
fwout parameter.
fwCrossout parameter storing links where a cross has been detected.
bwout parameter where backward links are stored.
info: collected information

Implements YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::OptimizerLoop.

Definition at line 501 of file DynParaLoop.cxx.

Referenced by YACS::ENGINE::OptimizerLoop::checkControlDependancy().

506 {
507  fw[(ComposedNode *)this].push_back(start);
508 }
void DynParaLoop::checkLinkPossibility ( OutPort start,
const std::list< ComposedNode * > &  pointsOfViewStart,
InPort end,
const std::list< ComposedNode * > &  pointsOfViewEnd 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 510 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::checkLinkPossibility().

Referenced by YACS::ENGINE::OptimizerLoop::checkLinkPossibility(), and YACS::ENGINE::ForEachLoop::checkLinkPossibility().

512 {
513  ComposedNode::checkLinkPossibility(start, pointsOfViewStart, end, pointsOfViewEnd);
514  Node * startNode = isInMyDescendance(start->getNode());
515  Node * endNode = isInMyDescendance(end->getNode());
516  std::string linkName("(");
517  linkName += start->getName()+" to "+end->getName()+")";
518 
519  if(start == &_splittedPort && endNode != _node)
520  throw Exception(std::string("Illegal link within a parallel loop: \
521 the 'evalSamples' port can only be connected to the working node of the loop.")
522  + linkName);
523 
524  if(_finalizeNode && _finalizeNode == startNode)
525  throw Exception(std::string("Illegal link within a parallel loop: \
526 the finalize node can't be the origin of a link.")
527  + linkName);
528 
529  if(_initNode && _node == startNode && _initNode == endNode)
530  throw Exception(std::string("Illegal link within a parallel loop: \
531 can't make a link from the working node to the init node.")
532  + linkName);
533 
534  if(_finalizeNode && _node == startNode && _finalizeNode == endNode)
535  throw Exception(std::string("Illegal link within a parallel loop: \
536 can't make a link from the working node to the finalize node.")
537  + linkName);
538 }
void DynParaLoop::cleanDynGraph ( )
protected

Definition at line 330 of file DynParaLoop.cxx.

References _execFinalizeNodes, _execInitNodes, and _execNodes.

Referenced by YACS::ENGINE::ForEachLoop::cleanDynGraph(), YACS::ENGINE::OptimizerLoop::init(), and YACS::ENGINE::OptimizerLoop::~OptimizerLoop().

331 {
332  vector<Node *>::iterator iter;
333  for(iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++)
334  delete *iter;
335  _execNodes.clear();
336  for(iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++)
337  delete *iter;
338  _execInitNodes.clear();
339  for(iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++)
340  delete *iter;
341  _execFinalizeNodes.clear();
342 }
vector< Node * > DynParaLoop::cloneAndPlaceNodesCoherently ( const std::vector< Node * > &  origNodes)
protected

Clone nodes and make their placement consistent with the placement of the original ones.

For instance, if two original nodes are placed on a component comp1 in a container cont1 and a third one is placed on a component comp2 in the container cont1, the clones of the two first nodes will be placed on a component comp3 in a container cont2 and the third clone will be placed on a component comp4 in the container cont2.

Definition at line 729 of file DynParaLoop.cxx.

References _finalizeNode, _initNode, _node, YACS::ENGINE::DeploymentTree::appendTask(), YACS::ENGINE::Container::clone(), YACS::ENGINE::ComponentInstance::clone(), DEBTRACE, YACS::ENGINE::RefCounter::decrRef(), YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::DeploymentTree::getAllContainers(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::DeploymentTree::getComponentsLinkedToContainer(), YACS::ENGINE::Node::getInPort(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Container::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Port::getNode(), getOutPort(), YACS::ENGINE::Node::getSetOfLinksLeavingCurrentScope(), YACS::ENGINE::DeploymentTree::getTasksLinkedToComponent(), YACS::ENGINE::DeploymentTree::getTasksLinkedToContainer(), CORBAEngineTest::i, YACS::ENGINE::ComposedNode::isInMyDescendance(), YACS::ENGINE::ServiceNode::setComponent(), YACS::ENGINE::ComponentInstance::setContainer(), YACS::ENGINE::InlineNode::setContainer(), YACS::ENGINE::Node::simpleClone(), and YASSERT.

Referenced by YACS::ENGINE::OptimizerLoop::exUpdateState(), and YACS::ENGINE::ForEachLoop::exUpdateState().

730 {
731  DEBTRACE("Begin cloneAndPlaceNodesCoherently")
732  vector<Node *> clones;
733  DeploymentTree treeToDup;
734  vector<list<ElementaryNode *> > origElemNodeList;
735  for (int i=0 ; i<origNodes.size() ; i++)
736  {
737  DEBTRACE("Cloning node " << i)
738  if (origNodes[i] == NULL)
739  {
740  DEBTRACE("Cloning node " << i << ", NULL" )
741  clones.push_back(NULL);
742  origElemNodeList.push_back(list<ElementaryNode *>());
743  }
744  else
745  {
746  DEBTRACE("Cloning node " << i << "," << origNodes[i]->getName())
747  clones.push_back(origNodes[i]->simpleClone(this, false));
748  list<ElementaryNode *> tasks = origNodes[i]->getRecursiveConstituents();
749  origElemNodeList.push_back(tasks);
750  for (list< ElementaryNode *>::iterator iter=tasks.begin() ; iter!=tasks.end() ; iter++)
751  treeToDup.appendTask(*iter, (*iter)->getDynClonerIfExists(this));
752  }
753  }
754 
755  // Build the links between clones.
756  // Only the links starting from initNode are possible.
757  if(_initNode)
758  {
759  std::vector< std::pair<OutPort *, InPort *> > outLinks = _initNode->getSetOfLinksLeavingCurrentScope();
760  std::vector< std::pair<OutPort *, InPort *> >::const_iterator it;
761  for(it=outLinks.begin(); it!=outLinks.end(); it++)
762  {
763  OutPort *startPort = it->first;
764  InPort *endPort = it->second;
765  Node* destNode = isInMyDescendance(endPort->getNode());
766  if(destNode == _node)
767  edAddLink(clones[0]->getOutPort(startPort->getName()),
768  clones[1]->getInPort(endPort->getName()));
769  if(destNode == _finalizeNode)
770  edAddLink(clones[0]->getOutPort(startPort->getName()),
771  clones[2]->getInPort(endPort->getName()));
772  }
773  }
774 
775  DEBTRACE("Placing nodes...")
776  vector<Container *> conts=treeToDup.getAllContainers();
777 
778  //iterate on all containers
779  for(vector<Container *>::iterator iterCt=conts.begin();iterCt!=conts.end();iterCt++)
780  {
781  DEBTRACE("Container " << ((*iterCt)?(*iterCt)->getName():"NULL"))
782  vector<ComponentInstance *> comps=treeToDup.getComponentsLinkedToContainer(*iterCt);
783  Container *contCloned=0;
784  if((*iterCt))
785  contCloned=(*iterCt)->clone();
786 
787  //iterate on all component instances linked to the container
788  for(vector<ComponentInstance *>::iterator iterCp=comps.begin();iterCp!=comps.end();iterCp++)
789  {
790  DEBTRACE("Component " << (*iterCp)->getCompoName())
791  vector<Task *> tasks=treeToDup.getTasksLinkedToComponent(*iterCp);
792  ComponentInstance *curCloned=(*iterCp)->clone();
793  DEBTRACE("Assign container " << (*iterCp)->getCompoName())
794  curCloned->setContainer(contCloned);
795  for(vector<Task *>::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++)
796  {
797  DEBTRACE("Task " << ((ElementaryNode *)(*iterT))->getName())
798  int i = 0;
799  ElementaryNode * origElemNode = NULL;
800  for (i=0 ; i<origNodes.size() ; i++)
801  if (origNodes[i] != NULL)
802  {
803  DEBTRACE("Looking in original node " << i)
804  list<ElementaryNode *>::iterator res=find(origElemNodeList[i].begin(),
805  origElemNodeList[i].end(),
806  (ElementaryNode *)(*iterT));
807  if (res != origElemNodeList[i].end()) {
808  origElemNode = *res;
809  break;
810  }
811  }
812 
813  YASSERT(origElemNode != NULL)
814  DEBTRACE("Found task in node " << i)
815  ServiceNode * nodeC = NULL;
816  if (origNodes[i] == origElemNode)
817  nodeC = (ServiceNode *)clones[i];
818  else
819  {
820  string childName = ((ComposedNode *)origNodes[i])->getChildName(origElemNode);
821  nodeC = (ServiceNode *)clones[i]->getChildByName(childName);
822  }
823  DEBTRACE("Assign component: " << (*iterCp)->getCompoName() << "," << nodeC->getName())
824  nodeC->setComponent(curCloned);
825  }
826  curCloned->decrRef();
827  }
828 
829  // iterate on all tasks linked to the container
830  vector<Task *> tasks=treeToDup.getTasksLinkedToContainer(*iterCt);
831  for(vector<Task *>::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++)
832  {
833  DEBTRACE("Task " << ((ElementaryNode *)(*iterT))->getName())
834  int i = 0;
835  ElementaryNode * origElemNode = NULL;
836  for (i=0 ; i<origNodes.size() ; i++)
837  if (origNodes[i] != NULL)
838  {
839  DEBTRACE("Looking in original node " << i)
840  list<ElementaryNode *>::iterator res=find(origElemNodeList[i].begin(),
841  origElemNodeList[i].end(),
842  (ElementaryNode *)(*iterT));
843  if (res != origElemNodeList[i].end())
844  {
845  origElemNode = *res;
846  break;
847  }
848  }
849  YASSERT(origElemNode != NULL)
850  DEBTRACE("Found task in node " << i)
851  InlineFuncNode * nodeC = NULL;
852  if (origNodes[i] == origElemNode)
853  {
854  nodeC = (InlineFuncNode *)clones[i];
855  }
856  else
857  {
858  string childName = ((ComposedNode *)origNodes[i])->getChildName(origElemNode);
859  nodeC = (InlineFuncNode *)clones[i]->getChildByName(childName);
860  }
861  DEBTRACE("Assign container " << nodeC->getName() << "," << contCloned->getName())
862  nodeC->setContainer(contCloned);
863  }
864 
865  // ended with current container
866  if(contCloned)
867  contCloned->decrRef();
868  }
869 
870  DEBTRACE("End cloneAndPlaceNodesCoherently")
871  return clones;
872 }
bool DynParaLoop::edAddChild ( Node DISOWNnode) throw (Exception)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 258 of file DynParaLoop.cxx.

259 {
260  return edSetNode(DISOWNnode);
261 }
bool DynParaLoop::edAddDFLink ( OutPort start,
InPort end 
) throw (Exception)
virtual

Connect an OutPort to an InPort and add control link if necessary.

Connect the ports with a data link (edAddLink) In a Loop don't add control flow link : use this only to add data back links

Parameters
start: the OutPort to connect
end: the InPort to connect
Returns
true if a new link has been created, false otherwise.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 142 of file DynParaLoop.cxx.

143 {
144  return edAddLink(start,end);
145 }
std::list< Node * > DynParaLoop::edGetDirectDescendants ( ) const
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 263 of file DynParaLoop.cxx.

References _finalizeNode, _initNode, _node, and PMMLBasicsTestLauncher::ret.

Referenced by getErrorReport(), and YACS::ENGINE::ForEachLoop::getProgressWeight().

264 {
265  list<Node *> ret;
266  if(_node)
267  ret.push_back(_node);
268  if(_initNode)
269  ret.push_back(_initNode);
270  if(_finalizeNode)
271  ret.push_back(_finalizeNode);
272  return ret;
273 }
void DynParaLoop::edRemoveChild ( Node node) throw (Exception)
virtual

Remove a child node.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 246 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::edRemoveChild().

Referenced by YACS::HMI::SubjectForEachLoop::clean().

247 {
249  if(node==_node)
250  _node=0;
251  if(node==_initNode)
252  _initNode=0;
253  if(node==_finalizeNode)
254  _finalizeNode=0;
255  modified();
256 }
Node * DynParaLoop::edRemoveFinalizeNode ( )

Definition at line 241 of file DynParaLoop.cxx.

References _finalizeNode, and removeNode().

242 {
243  return removeNode(_finalizeNode);
244 }
Node * DynParaLoop::edRemoveInitNode ( )

Definition at line 236 of file DynParaLoop.cxx.

References _initNode, and removeNode().

237 {
238  return removeNode(_initNode);
239 }
Node * DynParaLoop::edRemoveNode ( )

Definition at line 219 of file DynParaLoop.cxx.

References _node, and removeNode().

220 {
221  return removeNode(_node);
222 }
Node * DynParaLoop::edSetFinalizeNode ( Node DISOWNnode)

Definition at line 128 of file DynParaLoop.cxx.

References _finalizeNode, and checkConsistencyAndSetNode().

129 {
131 }
Node * DynParaLoop::edSetInitNode ( Node DISOWNnode)

Definition at line 123 of file DynParaLoop.cxx.

References _initNode, and checkConsistencyAndSetNode().

124 {
126 }
Node * DynParaLoop::edSetNode ( Node DISOWNnode)

Definition at line 75 of file DynParaLoop.cxx.

References _node, and checkConsistencyAndSetNode().

76 {
77  return checkConsistencyAndSetNode(_node, node);
78 }
void DynParaLoop::forceMultiplicity ( unsigned  value)
virtual
void DynParaLoop::forwardExecStateToOriginalBody ( Node execNode)
protectedvirtual

Definition at line 648 of file DynParaLoop.cxx.

References _finalizeNode, _initNode, _node, FINALIZE_NODE, YACS::ENGINE::ComposedNode::getAllRecursiveConstituents(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Node::getErrorDetails(), getIdentityOfNotifyerNode(), YACS::ENGINE::Node::getState(), INIT_NODE, YACS::ENGINE::Node::setErrorDetails(), YACS::ENGINE::Node::setState(), WORK_NODE, and YASSERT.

Referenced by YACS::ENGINE::ForEachLoop::exUpdateState(), YACS::ENGINE::ForEachLoop::updateStateForWorkNodeOnFinishedEventFrom(), and updateStateOnFailedEventFrom().

649 {
650  unsigned int id;
651  Node * origNode = NULL;
652  switch (getIdentityOfNotifyerNode(execNode,id))
653  {
654  case INIT_NODE:
655  {
656  origNode = _initNode;
657  break;
658  }
659  case WORK_NODE:
660  {
661  origNode = _node;
662  break;
663  }
664  case FINALIZE_NODE:
665  {
666  origNode = _finalizeNode;
667  break;
668  }
669  default:
670  YASSERT(false)
671  }
672 
673  YASSERT(origNode != NULL)
674  origNode->setState(execNode->getState());
675  origNode->setErrorDetails(execNode->getErrorDetails());
676 
677  ComposedNode* compNode = dynamic_cast<ComposedNode*>(origNode);
678  ComposedNode* compNodeExe = dynamic_cast<ComposedNode*>(execNode);
679  if (compNode && compNodeExe)
680  {
681  list<Node *> aChldn = compNodeExe->getAllRecursiveConstituents();
682  list<Node *>::iterator iter=aChldn.begin();
683  for(;iter!=aChldn.end();iter++)
684  {
685  Node* node=compNode->getChildByName(compNodeExe->getChildName(*iter));
686  node->setState((*iter)->getState());
687  node->setErrorDetails((*iter)->getErrorDetails());
688  }
689  }
690 }
int DynParaLoop::getBranchIDOfNode ( Node node) const

DynParaLoop creates at runtime (exupdateState) clone of nodes. One clone per branch. This method returns the id of the branch given the node node. If node is not a dynamically created node in this -1 is returned.

Definition at line 162 of file DynParaLoop.cxx.

References _execFinalizeNodes, _execInitNodes, _execNodes, _finalizeNode, _initNode, _node, and gui.graph::distance().

Referenced by YACS::ENGINE::Node::getDPLScopeInfo().

163 {
164  if(_node)
165  {
166  for(std::vector<Node *>::const_iterator it=_execNodes.begin();it!=_execNodes.end();it++)
167  if(node==*it)
168  return std::distance(_execNodes.begin(),it);
169  }
170  if(_finalizeNode)
171  {
172  for(std::vector<Node *>::const_iterator it=_execFinalizeNodes.begin();it!=_execFinalizeNodes.end();it++)
173  if(node==*it)
174  return std::distance(_execFinalizeNodes.begin(),it);
175  }
176  if(_initNode)
177  {
178  for(std::vector<Node *>::const_iterator it=_execInitNodes.begin();it!=_execInitNodes.end();it++)
179  if(node==*it)
180  return std::distance(_execInitNodes.begin(),it);
181  }
182  return -1;
183 }
Node * DynParaLoop::getChildByNameExec ( const std::string &  name,
unsigned  id 
) const throw (Exception)

Definition at line 316 of file DynParaLoop.cxx.

317 {
319  throw Exception("ForEachLoop::getChildByNameExec : invalid id - too large compared with dynamically created branches.");
320  if (_node && name == _node->getName())
321  return _execNodes[id];
322  if (_initNode && name == _initNode->getName())
323  return _execInitNodes[id];
324  if (_finalizeNode && name == _finalizeNode->getName())
325  return _execFinalizeNodes[id];
326  std::string what("node "); what+= name ; what+=" is not a child of DynParaLoop node "; what += getName();
327  throw Exception(what);
328 }
Node * DynParaLoop::getChildByShortName ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop.

Definition at line 304 of file DynParaLoop.cxx.

Referenced by YACS::ENGINE::ForEachLoop::getChildByShortName().

305 {
306  if (_node && name == _node->getName())
307  return _node;
308  if (_initNode && name == _initNode->getName())
309  return _initNode;
310  if (_finalizeNode && name == _finalizeNode->getName())
311  return _finalizeNode;
312  std::string what("node "); what+= name ; what+=" is not a child of DynParaLoop node "; what += getName();
313  throw Exception(what);
314 }
InputPort * DynParaLoop::getDynInputPortByAbsName ( int  branchNb,
const std::string &  name,
bool  initNodeAdmitted 
)
protected
Note
: For a given name 'name' of port in absolute form from this, returns the corresponding InputPort instance of the port for the branch # 'branchNb'. The port can be part of _node or _initNode if it exists (if 'initNodeAdmitted' is true). WARNING : no check performed on 'branchNb' value to see if it is compatible with size of '_execNodes'. This method is called to dispatch value on each InputPort linked to this->._splitterNode._splittedPort

Definition at line 547 of file DynParaLoop.cxx.

References _execInitNodes, _execNodes, _initNode, _node, YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ComposedNode::isInMyDescendance(), YACS::ENGINE::Node::SEP_CHAR_IN_PORT, and YACS::ENGINE::ComposedNode::splitNamesBySep().

Referenced by prepareInputsFromOutOfScope(), and putValueOnBranch().

548 {
549  string portName, nodeName;
550  splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,true);
551  Node *staticChild = getChildByName(nodeName);
552  Node *desc=isInMyDescendance(staticChild);
553  if(desc==_node)
554  {
555  splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false);
556  return _execNodes[branchNb]->getInputPort(portName);
557  }
558  else if(desc==_initNode)
559  if(initNodeAdmitted)
560  {
561  splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false);
562  return _execInitNodes[branchNb]->getInputPort(portName);
563  }
564  return 0;
565 }
std::string DynParaLoop::getErrorReport ( )
virtual

returns a string that contains an error report if the node is in error

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 575 of file DynParaLoop.cxx.

References YACS::ENGINE::Node::_errorDetails, _execFinalizeNodes, _execInitNodes, _execNodes, YACS::ENGINE::Node::_state, DEBTRACE, edGetDirectDescendants(), YACS::ERROR, YACS::FAILED, YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::ComposedNode::getName(), and YACS::INVALID.

576 {
577  DEBTRACE("DynParaLoop::getErrorReport: " << getName() << " " << _state);
578  YACS::StatesForNode effectiveState=getEffectiveState();
579 
580  if(effectiveState != YACS::INVALID && effectiveState != YACS::ERROR && effectiveState != YACS::FAILED)
581  return "";
582 
583  std::string report="<error node= " + getName();
584  switch(effectiveState)
585  {
586  case YACS::INVALID:
587  report=report+" state= INVALID";
588  break;
589  case YACS::ERROR:
590  report=report+" state= ERROR";
591  break;
592  case YACS::FAILED:
593  report=report+" state= FAILED";
594  break;
595  default:
596  break;
597  }
598  report=report + ">\n" ;
599  if(_errorDetails != "")
600  report=report+_errorDetails+"\n";
601 
602  if(_execNodes.empty())
603  {
604  // edition node
605  list<Node *> constituents=edGetDirectDescendants();
606  for(list<Node *>::iterator iter=constituents.begin(); iter!=constituents.end(); iter++)
607  {
608  std::string rep=(*iter)->getErrorReport();
609  if(rep != "")
610  {
611  report=report+rep+"\n";
612  }
613  }
614  }
615  else
616  {
617  // execution nodes
618  for(vector<Node *>::iterator iter=_execInitNodes.begin();iter!=_execInitNodes.end();iter++)
619  {
620  std::string rep=(*iter)->getErrorReport();
621  if(rep != "")
622  {
623  report=report+rep+"\n";
624  }
625  }
626  for(vector<Node *>::iterator iter=_execNodes.begin();iter!=_execNodes.end();iter++)
627  {
628  std::string rep=(*iter)->getErrorReport();
629  if(rep != "")
630  {
631  report=report+rep+"\n";
632  }
633  }
634  for(vector<Node *>::iterator iter=_execFinalizeNodes.begin();iter!=_execFinalizeNodes.end();iter++)
635  {
636  std::string rep=(*iter)->getErrorReport();
637  if(rep != "")
638  {
639  report=report+rep+"\n";
640  }
641  }
642  }
643 
644  report=report+"</error>";
645  return report;
646 }
Node * DynParaLoop::getExecNode ( )

Definition at line 884 of file DynParaLoop.cxx.

References _node.

Referenced by YACS::HMI::SubjectDynParaLoop::completeChildrenSubjectList(), and YACS::ENGINE::VisitorSaveSchema::visitDynParaLoop().

885 {
886  return _node;
887 }
Node * DynParaLoop::getFinalizeNode ( )
DynParaLoop::TypeOfNode DynParaLoop::getIdentityOfNotifyerNode ( const Node node,
unsigned &  id 
)
protected

Definition at line 409 of file DynParaLoop.cxx.

References _execFinalizeNodes, _execInitNodes, _execNodes, FINALIZE_NODE, INIT_NODE, and WORK_NODE.

Referenced by forwardExecStateToOriginalBody(), updateStateOnFailedEventFrom(), YACS::ENGINE::ForEachLoop::updateStateOnFailedEventFrom(), YACS::ENGINE::OptimizerLoop::updateStateOnFinishedEventFrom(), and YACS::ENGINE::ForEachLoop::updateStateOnFinishedEventFrom().

410 {
411  vector<Node *>::iterator iter;
412  id=0;
413  for (iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++,id++)
414  if (*iter==node)
415  return WORK_NODE;
416  id=0;
417  for (iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++,id++)
418  if (*iter==node)
419  return INIT_NODE;
420  id=0;
421  for (iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++,id++)
422  if (*iter==node)
423  return FINALIZE_NODE;
424 }
Node * DynParaLoop::getInitNode ( )
InputPort * DynParaLoop::getInputPort ( const std::string &  name) const throw (Exception)
virtual

Get an input port given its name.

Contrary to YACS::ENGINE::ComposedNode::getOutputPort, this method is NOT recursive and so the leaf of type ElementaryNode aggregating this InputPort is directly invoked.

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 282 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::getInputPort().

Referenced by YACS::ENGINE::OptimizerLoop::getInputPort(), and YACS::ENGINE::ForEachLoop::getInputPort().

283 {
285  return (InputPort *)&_nbOfBranches;
286  return ComposedNode::getInputPort(name);
287 }
std::list< InputPort * > DynParaLoop::getLocalInputPorts ( ) const
virtual

redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 289 of file DynParaLoop.cxx.

References _nbOfBranches, YACS::ENGINE::ComposedNode::getLocalInputPorts(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::OptimizerLoop::getLocalInputPorts(), YACS::ENGINE::ForEachLoop::getLocalInputPorts(), and prepareInputsFromOutOfScope().

290 {
291  list<InputPort *> ret=ComposedNode::getLocalInputPorts();
292  ret.push_back((InputPort *)&_nbOfBranches);
293  return ret;
294 }
std::list< OutputPort * > DynParaLoop::getLocalOutputPorts ( ) const
virtual

redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 192 of file DynParaLoop.cxx.

References _splittedPort, YACS::ENGINE::ComposedNode::getLocalOutputPorts(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::OptimizerLoop::getLocalOutputPorts().

193 {
194  list<OutputPort *> ret=ComposedNode::getLocalOutputPorts();
195  ret.push_back((OutputPort *)&_splittedPort);
196  return ret;
197 }
int DynParaLoop::getMaxLevelOfParallelism ( ) const
virtual
std::vector<Node *> YACS::ENGINE::DynParaLoop::getNodes ( ) const
inline

Definition at line 99 of file DynParaLoop.hxx.

99 { return _execNodes; } // need to use in GUI part for adding observers for clone nodes
unsigned DynParaLoop::getNumberOfBranchesCreatedDyn ( ) const throw (Exception)

Definition at line 296 of file DynParaLoop.cxx.

References _execNodes.

297 {
298  if(_execNodes.empty())
299  throw Exception("ForEachLoop::getNumberOfBranches : No branches created dynamically ! - ForEachLoop needs to run or to be runned to call getNumberOfBranches");
300  else
301  return _execNodes.size();
302 }
unsigned YACS::ENGINE::DynParaLoop::getNumberOfEltsConsumed ( ) const
inline

Definition at line 81 of file DynParaLoop.hxx.

81 { return _nbOfEltConsumed; }
int DynParaLoop::getNumberOfInputPorts ( ) const
virtual
int DynParaLoop::getNumberOfOutputPorts ( ) const
virtual
OutPort * DynParaLoop::getOutPort ( const std::string &  name) const throw (Exception)
virtual
Note
: Contrary to getOutputPort method, this method returns the output port at highest level, possible. That is to say in some ComposedNode, like ForEachLoop or Switch, an outport inside 'this' is seen differently than the true outport.

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 199 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::getOutPort().

Referenced by cloneAndPlaceNodesCoherently(), YACS::ENGINE::OptimizerLoop::getOutPort(), and YACS::ENGINE::ForEachLoop::getOutPort().

200 {
202  return (OutPort *)&_splittedPort;
203  return ComposedNode::getOutPort(name);
204 }
OutputPort * DynParaLoop::getOutputPort ( const std::string &  name) const throw (Exception)
virtual

Get an output port given its name.

Contrary to YACS::ENGINE::ComposedNode::getInputPort, this method is recursive and go down hierarchy step by step to complete its work.

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 207 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::getOutputPort().

Referenced by YACS::ENGINE::OptimizerLoop::getOutputPort(), and YACS::ENGINE::ForEachLoop::getOutputPort().

208 {
210  return (OutputPort *)&_splittedPort;
211  return ComposedNode::getOutputPort(name);
212 }
std::list< InputPort * > DynParaLoop::getSetOfInputPort ( ) const
virtual
std::list< OutputPort * > DynParaLoop::getSetOfOutputPort ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::OptimizerLoop.

Definition at line 185 of file DynParaLoop.cxx.

References _splittedPort, YACS::ENGINE::ComposedNode::getSetOfOutputPort(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::OptimizerLoop::getSetOfOutputPort().

186 {
187  list<OutputPort *> ret=ComposedNode::getSetOfOutputPort();
188  ret.push_back((OutputPort *)&_splittedPort);
189  return ret;
190 }
void DynParaLoop::init ( bool  start = true)
virtual

initialisation of all input and output ports and gates, for execution

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 106 of file DynParaLoop.cxx.

References _failedCounter, _finalizeNode, _initNode, YACS::ENGINE::Node::_name, _nbOfBranches, _nbOfEltConsumed, _node, _splittedPort, YACS::ENGINE::OutputPort::exInit(), YACS::ENGINE::InputPort::exInit(), YACS::ENGINE::ComposedNode::init(), and YACS::ENGINE::Node::init().

Referenced by YACS::ENGINE::OptimizerLoop::init(), and YACS::ENGINE::ForEachLoop::init().

107 {
108  ComposedNode::init(start);
109  if(!_node)
110  {
111  string what("DynParaLoop::init : no node specified for ForEachLoop with name "); what +=_name;
112  throw Exception(what);
113  }
114  _node->init(start);
115  if (_initNode) _initNode->init(start);
116  if (_finalizeNode) _finalizeNode->init(start);
117  _nbOfBranches.exInit(start);
120  _failedCounter=0;
121 }
bool DynParaLoop::isMultiplicitySpecified ( unsigned &  value) const
virtual
bool DynParaLoop::isPlacementPredictableB4Run ( ) const
virtual

For the moment false is returned : impovement about it coming soon.

Implements YACS::ENGINE::ComposedNode.

Definition at line 214 of file DynParaLoop.cxx.

215 {
216  return false;
217 }
void DynParaLoop::prepareInputsFromOutOfScope ( int  branchNb)
protected

This method applies on newly cloned on exec nodes (_execNodes/_execInitNodes) the setting of input ports coming from outside of 'this'

Definition at line 348 of file DynParaLoop.cxx.

References YACS::ENGINE::InPort::edNotifyReferencedBy(), YACS::ENGINE::InputPort::get(), YACS::ENGINE::ComposedNode::getAllInPortsComingFromOutsideOfCurrentScope(), getDynInputPortByAbsName(), YACS::ENGINE::ComposedNode::getInPortName(), getLocalInputPorts(), YACS::ENGINE::Node::getSetOfInPort(), and YACS::ENGINE::InputPort::put().

Referenced by YACS::ENGINE::OptimizerLoop::exUpdateState(), and YACS::ENGINE::ForEachLoop::exUpdateState().

349 {
350  set< InPort * > portsToSetVals=getAllInPortsComingFromOutsideOfCurrentScope();
351 
352  // This tweak is to fix problems with nested dynamic loops where links are not cloned properly
353  list<InPort *> temp = getSetOfInPort();
354  for(list<InPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
355  {
356  if ((*iter2)->edSetOutPort().size() == 1 && *(*iter2)->edSetOutPort().begin() == NULL)
357  {
358  portsToSetVals.insert(*iter2);
359  }
360  }
361 
362  // local input ports are not candidates for dynamically duplicated inport.
363  list<InputPort *> localPorts = getLocalInputPorts();
364  for(list<InputPort *>::iterator iter = localPorts.begin() ; iter != localPorts.end() ; iter++)
365  portsToSetVals.erase(*iter);
366  for(set< InPort * >::iterator iter=portsToSetVals.begin();iter!=portsToSetVals.end();iter++)
367  {
368  InputPort *curPortCasted=(InputPort *) *iter;//Cast granted by ForEachLoop::buildDelegateOf(InPort)
369  void *val=curPortCasted->get();
370  InputPort *portToSet=getDynInputPortByAbsName(branchNb,getInPortName(*iter),true);
371  if(portToSet)//portToSet==0 in case of portToSet==_splitterNode._dataPortToDispatch of ForEach
372  {
373  portToSet->put((const void *)val);
374  portToSet->edNotifyReferencedBy(0);//This is to indicate that somewhere somebody deals with this inputport
375  //even if no direct physical link exists. This exclusively for _execNodes[branchNb]::init on the next turn of loop.
376  }
377  }
378 }
void DynParaLoop::putValueOnBranch ( Any val,
unsigned  branchId,
bool  first 
)
protected

Definition at line 380 of file DynParaLoop.cxx.

References _splittedPort, YACS::ENGINE::Runtime::adapt(), YACS::ENGINE::Any::clone(), YACS::ENGINE::RefCounter::decrRef(), YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::InPort::edNotifyReferencedBy(), YACS::ENGINE::OutputPort::edSetInPort(), getDynInputPortByAbsName(), YACS::ENGINE::ComposedNode::getPortName(), YACS::ENGINE::getRuntime(), YACS::ENGINE::InputPort::put(), YACS::ENGINE::Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME, and YACS::ENGINE::AnyOutputPort::setValue().

Referenced by YACS::ENGINE::OptimizerLoop::launchMaxOfSamples(), and YACS::ENGINE::SplitterNode::putSplittedValueOnRankTo().

381 {
382  bool isDispatched = false;
383  set<InPort *> inPrtLkdWthSplttdPrt=_splittedPort.edSetInPort();
384  for(set<InPort *>::iterator iter=inPrtLkdWthSplttdPrt.begin();iter!=inPrtLkdWthSplttdPrt.end();iter++)
385  {
386  std::string portNameOnCurPrt=getPortName(*iter);
387  InputPort *portOnGivenBranch=getDynInputPortByAbsName(branchId,portNameOnCurPrt,first);//Cast granted because impossible to have cross protocol with _splittedPort
388  //see OptimizerLoop::buildDelegateOf
389  if(portOnGivenBranch)
390  {
391  if(first)
392  portOnGivenBranch->edNotifyReferencedBy(0);
393  InputPort *traducer=getRuntime()->adapt(portOnGivenBranch,
395  traducer->put((const void *)val);
396  isDispatched = true;
397  if(traducer!=portOnGivenBranch)
398  delete traducer;
399  }
400  }
401  if ( isDispatched )
402  {
403  Any *tmp=val->clone();
404  _splittedPort.setValue(tmp);
405  tmp->decrRef();
406  }
407 }
Node * DynParaLoop::removeNode ( Node *&  nodeToRemove)
protected

This method is used to factorize methods edRemoveNode, edRemoveInitNode and edRemoveFinalizeNode.

Definition at line 225 of file DynParaLoop.cxx.

References YACS::ENGINE::ComposedNode::edRemoveChild(), YACS::ENGINE::Node::modified(), and PMMLBasicsTestLauncher::ret.

Referenced by edRemoveFinalizeNode(), edRemoveInitNode(), and edRemoveNode().

226 {
227  if (!nodeToRemove)
228  return NULL;
229  ComposedNode::edRemoveChild(nodeToRemove);
230  Node * ret = nodeToRemove;
231  nodeToRemove = NULL;
232  modified();
233  return ret;
234 }
void DynParaLoop::shutdown ( int  level)
protectedvirtual

Stop all pending activities of the composed node.

This method should be called when a Proc is finished and must be deleted from the YACS server

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 899 of file DynParaLoop.cxx.

References _execFinalizeNodes, _execInitNodes, _execNodes, and _node.

900 {
901  if(level==0)return;
902  if(!_node) return;
903 
904  std::vector<Node *>::iterator iter;
905  for (iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++)
906  (*iter)->shutdown(level);
907  for (iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++)
908  (*iter)->shutdown(level);
909  for (iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++)
910  (*iter)->shutdown(level);
911 }
YACS::Event DynParaLoop::updateStateOnFailedEventFrom ( Node node,
const Executor execInst 
)
protectedvirtual

Method used to notify the node that a child node has failed.

Update the current state and return the change state

Parameters
node: the child node that has failed
Returns
the state change

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForEachLoop, and YACS::ENGINE::OptimizerLoop.

Definition at line 699 of file DynParaLoop.cxx.

References _finalizeNode, _node, YACS::ABORT, DEBTRACE, YACS::FAILED, forwardExecStateToOriginalBody(), getIdentityOfNotifyerNode(), YACS::ENGINE::Node::getName(), INIT_NODE, YACS::ENGINE::Node::setState(), and WORK_NODE.

Referenced by YACS::ENGINE::OptimizerLoop::updateStateOnFailedEventFrom(), and YACS::ENGINE::ForEachLoop::updateStateOnFailedEventFrom().

700 {
701  DEBTRACE("DynParaLoop::updateStateOnFailedEventFrom " << node->getName());
704  unsigned int id;
705  switch (getIdentityOfNotifyerNode(node,id))
706  {
707  case INIT_NODE:
708  {
711  break;
712  }
713  case WORK_NODE:
714  {
716  break;
717  }
718  }
719  return YACS::ABORT;
720 }

Member Data Documentation

AnyOutputPort YACS::ENGINE::DynParaLoop::_splittedPort
protected
const char DynParaLoop::NAME_OF_NUMBER_OF_BRANCHES ="nbBranches"
staticprotected

Definition at line 63 of file DynParaLoop.hxx.

const char DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT = "evalSamples"
staticprotected
const char DynParaLoop::OLD_NAME_OF_SPLITTED_SEQ_OUT = "SmplPrt"
staticprotected

Definition at line 62 of file DynParaLoop.hxx.


The documentation for this class was generated from the following files: