Version: 8.3.0
YACS::ENGINE::ForEachLoop Class Reference

Loop node for parametric calculation. More...

#include <ForEachLoop.hxx>

Inheritance diagram for YACS::ENGINE::ForEachLoop:
Collaboration diagram for YACS::ENGINE::ForEachLoop:

Public Member Functions

 ForEachLoop (const std::string &name, TypeCode *typeOfDataSplitted)
 
 ForEachLoop (const ForEachLoop &other, ComposedNode *father, bool editionOnly)
 
 ~ForEachLoop ()
 
void init (bool start=true)
 
void exUpdateState ()
 Update the node state. More...
 
void exUpdateProgress ()
 
void getReadyTasks (std::vector< Task * > &tasks)
 
int getNumberOfInputPorts () const
 
void checkNoCyclePassingThrough (Node *node) throw (Exception)
 
void selectRunnableTasks (std::vector< Task * > &tasks)
 
unsigned getExecCurrentId () 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...
 
InputPortedGetSeqOfSamplesPort ()
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 Get an input port given its name. More...
 
OutPortgetOutPort (const std::string &name) const throw (Exception)
 
OutputPortgetOutputPort (const std::string &name) const throw (Exception)
 Get an output port given its name. More...
 
NodegetChildByShortName (const std::string &name) const throw (Exception)
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
void accept (Visitor *visitor)
 
void writeDot (std::ostream &os) const
 Dump the node state to a stream. More...
 
virtual std::string typeName ()
 
virtual void resetState (int level)
 Reset the state of the node and its children depending on the parameter level. More...
 
std::string getProgress () const
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
int getCurrentIndex () const
 
int getNbOfElementsToBeProcessed () const
 
ForEachLoopPassedDatagetProcessedData () const
 
void setProcessedData (ForEachLoopPassedData *processedData)
 
std::vector< unsigned int > getPassedResults (Executor *execut, std::vector< SequenceAny * > &outputs, std::vector< std::string > &nameOfOutputs) const
 
void assignPassedResults (const std::vector< unsigned int > &passedIds, const std::vector< SequenceAny * > &passedOutputs, const std::vector< std::string > &nameOfOutputs)
 
const TypeCodegetOutputPortType (const std::string &portName) const
 
- Public Member Functions inherited from YACS::ENGINE::DynParaLoop
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...
 
InputPortedGetNbOfBranchesPort ()
 
int getNumberOfOutputPorts () const
 
unsigned getNumberOfEltsConsumed () const
 
int getBranchIDOfNode (Node *node) const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
OutputPortedGetSamplePort ()
 
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
 
unsigned getNumberOfBranchesCreatedDyn () 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...
 
NodegetInitNode ()
 
NodegetExecNode ()
 
NodegetFinalizeNode ()
 
int getMaxLevelOfParallelism () const
 
- Public Member Functions inherited from YACS::ENGINE::ComposedNode
virtual ~ComposedNode ()
 
bool isFinished ()
 
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::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 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...
 
- 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 exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
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 ~Scheduler ()
 

Static Public Member Functions

static int getFEDeltaBetween (OutPort *start, InPort *end)
 
static void InterceptorizeNameOfPort (std::string &portName)
 

Static Public Attributes

static const char NAME_OF_SPLITTERNODE [] ="splitter"
 
static const char INTERCEPTOR_STR [] ="_interceptor"
 

Protected Member Functions

NodesimpleClone (ComposedNode *father, bool editionOnly=true) const
 
void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd) throw (Exception)
 
YACS::Event updateStateOnFinishedEventFrom (Node *node)
 Method used to notify the node that a child node has finished. More...
 
YACS::Event updateStateForInitNodeOnFinishedEventFrom (Node *node, unsigned int id)
 
YACS::Event updateStateForWorkNodeOnFinishedEventFrom (Node *node, unsigned int id, bool isNormalFinish)
 
YACS::Event updateStateForFinalizeNodeOnFinishedEventFrom (Node *node, unsigned int id)
 
YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void cleanDynGraph ()
 
void pushAllSequenceValues ()
 
void createOutputOutOfScopeInterceptors (int branchNb)
 
void prepareSequenceValues (int sizeOfSamples)
 
OutPortgetDynOutPortByAbsName (int branchNb, const std::string &name)
 
void storeOutValsInSeqForOutOfScopeUse (int rank, int branchNb)
 
- Protected Member Functions inherited from YACS::ENGINE::DynParaLoop
 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 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
 
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)
 
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 void getDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
virtual void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) 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 void exForwardFailed ()
 
virtual void exForwardFinished ()
 

Protected Attributes

int _currentIndex
 
SplitterNode _splitterNode
 
FakeNodeForForEachLoop_nodeForSpecialCases
 
std::vector< AnySplitOutputPort * > _outGoingPorts
 
std::vector
< InterceptorInputPort * > 
_intecptrsForOutGoingPorts
 ports linked to node outside the current scope More...
 
unsigned _execCurrentId
 ports created for TypeCodes correctness More...
 
std::vector< SequenceAny * > _execVals
 
std::vector< std::vector
< AnyInputPort * > > 
_execOutGoingPorts
 
ForEachLoopPassedData_passedData
 
- Protected Attributes inherited from YACS::ENGINE::DynParaLoop
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 int NOT_RUNNING_BRANCH_ID =-1
 
- Static Protected Attributes inherited from YACS::ENGINE::DynParaLoop
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
 

Private Member Functions

int getFinishedId ()
 

Friends

class SplitterNode
 
class FakeNodeForForEachLoop
 

Additional Inherited Members

- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Protected Types inherited from YACS::ENGINE::DynParaLoop
enum  TypeOfNode { INIT_NODE = 5, WORK_NODE = 6, FINALIZE_NODE = 7 }
 
- 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

Loop node for parametric calculation.

Definition at line 153 of file ForEachLoop.hxx.

Constructor & Destructor Documentation

ForEachLoop::ForEachLoop ( const std::string &  name,
TypeCode typeOfDataSplitted 
)

Definition at line 464 of file ForEachLoop.cxx.

Referenced by simpleClone().

464  :DynParaLoop(name,typeOfDataSplitted),
465  _splitterNode(NAME_OF_SPLITTERNODE,typeOfDataSplitted,this),
467 {
468 }
ForEachLoop::ForEachLoop ( const ForEachLoop other,
ComposedNode father,
bool  editionOnly 
)

Definition at line 470 of file ForEachLoop.cxx.

References _intecptrsForOutGoingPorts, _outGoingPorts, YACS::ENGINE::AnySplitOutputPort::addRepr(), getOutPort(), YACS::ENGINE::ComposedNode::getOutPortName(), CORBAEngineTest::i, and YACS::ENGINE::InterceptorInputPort::setRepr().

470  :DynParaLoop(other,father,editionOnly),
471  _splitterNode(other._splitterNode,this),
473 {
474  int i=0;
475  if(!editionOnly)
476  for(vector<AnySplitOutputPort *>::const_iterator iter2=other._outGoingPorts.begin();iter2!=other._outGoingPorts.end();iter2++,i++)
477  {
478  AnySplitOutputPort *temp=new AnySplitOutputPort(*(*iter2),this);
480  temp->addRepr(getOutPort(other.getOutPortName((*iter2)->getRepr())),interc);
481  interc->setRepr(temp);
482  _outGoingPorts.push_back(temp);
483  _intecptrsForOutGoingPorts.push_back(interc);
484  }
485 }
ForEachLoop::~ForEachLoop ( )

Definition at line 492 of file ForEachLoop.cxx.

References _intecptrsForOutGoingPorts, _outGoingPorts, _passedData, and cleanDynGraph().

493 {
494  cleanDynGraph();
495  for(vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();iter!=_outGoingPorts.end();iter++)
496  delete *iter;
497  for(vector<InterceptorInputPort *>::iterator iter2=_intecptrsForOutGoingPorts.begin();iter2!=_intecptrsForOutGoingPorts.end();iter2++)
498  delete *iter2;
499  delete _passedData;
500 }

Member Function Documentation

void ForEachLoop::accept ( Visitor visitor)
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 1085 of file ForEachLoop.cxx.

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

1086 {
1087  visitor->visitForEachLoop(this);
1088 }
void ForEachLoop::assignPassedResults ( const std::vector< unsigned int > &  passedIds,
const std::vector< SequenceAny * > &  passedOutputs,
const std::vector< std::string > &  nameOfOutputs 
)

This method is typically useful for post-mortem relaunch to avoid to recompute already passed cases. This method takes in input exactly the parameters retrieved by getPassedResults method.

Definition at line 1201 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::_failedCounter, and _passedData.

Referenced by YACS::ENGINE::nodeParser::onEnd().

1202 {
1203  delete _passedData;
1204  _failedCounter=0;
1205  _passedData=new ForEachLoopPassedData(passedIds,passedOutputs,nameOfOutputs);
1206 }
void ForEachLoop::buildDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 905 of file ForEachLoop.cxx.

References _intecptrsForOutGoingPorts, _outGoingPorts, YACS::ENGINE::AnySplitOutputPort::addRepr(), YACS::ENGINE::DynParaLoop::buildDelegateOf(), YACS::ENGINE::DataPort::edGetType(), getFEDeltaBetween(), YACS::ENGINE::ComposedNode::getPortName(), CORBAEngineTest::i, InterceptorizeNameOfPort(), YACS::ENGINE::OutputPort::NAME, YACS::ENGINE::TypeCode::sequenceTc(), YACS::ENGINE::InterceptorInputPort::setRepr(), and YACS::ENGINE::TypeCode::subContentType().

906 {
907  DynParaLoop::buildDelegateOf(port,finalTarget,pointsOfView);
908  string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
909  if(typeOfPortInstance==OutputPort::NAME)
910  {
911  vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
912  int i=0;
913  for(;iter!=_outGoingPorts.end();iter++,i++)
914  if((*iter)->getRepr()==port.first || *iter==port.first)
915  break;
916  if(iter!=_outGoingPorts.end())
917  {
918  if(*iter!=port.first)
919  {
920  (*iter)->incrRef();
921  (*iter)->addRepr(port.first,_intecptrsForOutGoingPorts[i]);
922  }
923  port.first=*iter;
924  }
925  else
926  {
927  TypeCode *tcTrad((YACS::ENGINE::TypeCode*)finalTarget->edGetType()->subContentType(getFEDeltaBetween(port.first,finalTarget)));
928  TypeCodeSeq *newTc=(TypeCodeSeq *)TypeCode::sequenceTc("","",tcTrad);
929  // The out going ports belong to the ForEachLoop, whereas
930  // the delegated port belongs to a node child of the ForEachLoop.
931  // The name of the delegated port contains dots (bloc.node.outport),
932  // whereas the name of the out going port shouldn't do.
933  std::string outputPortName(getPortName(port.first));
934  InterceptorizeNameOfPort(outputPortName);
935  AnySplitOutputPort *newPort(new AnySplitOutputPort(outputPortName,this,newTc));
936  InterceptorInputPort *intercptor(new InterceptorInputPort(outputPortName + "_in",this,tcTrad));
937  intercptor->setRepr(newPort);
938  newTc->decrRef();
939  newPort->addRepr(port.first,intercptor);
940  _outGoingPorts.push_back(newPort);
941  _intecptrsForOutGoingPorts.push_back(intercptor);
942  port.first=newPort;
943  }
944  }
945  else
946  throw Exception("ForEachLoop::buildDelegateOf : not implemented for DS because not specified");
947 }
void ForEachLoop::checkLinkPossibility ( OutPort start,
const std::list< ComposedNode * > &  pointsOfViewStart,
InPort end,
const std::list< ComposedNode * > &  pointsOfViewEnd 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 1066 of file ForEachLoop.cxx.

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

1068 {
1069  DynParaLoop::checkLinkPossibility(start, pointsOfViewStart, end, pointsOfViewEnd);
1070  if(end->getNode() == &_splitterNode)
1071  throw Exception("Illegal link within a foreach loop: \
1072 the 'SmplsCollection' port cannot be linked within the scope of the loop.");
1073  if(end == &_nbOfBranches)
1074  throw Exception("Illegal link within a foreach loop: \
1075 the 'nbBranches' port cannot be linked within the scope of the loop.");
1076 }
void ForEachLoop::checkNoCyclePassingThrough ( Node node) throw (Exception)
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 665 of file ForEachLoop.cxx.

666 {
667  //TO DO
668 }
void ForEachLoop::cleanDynGraph ( )
protected

Definition at line 1002 of file ForEachLoop.cxx.

References _execOutGoingPorts, _execVals, and YACS::ENGINE::DynParaLoop::cleanDynGraph().

Referenced by init(), resetState(), and ~ForEachLoop().

1003 {
1005  for(vector< SequenceAny *>::iterator iter3=_execVals.begin();iter3!=_execVals.end();iter3++)
1006  (*iter3)->decrRef();
1007  _execVals.clear();
1008  for(vector< vector<AnyInputPort *> >::iterator iter4=_execOutGoingPorts.begin();iter4!=_execOutGoingPorts.end();iter4++)
1009  for(vector<AnyInputPort *>::iterator iter5=(*iter4).begin();iter5!=(*iter4).end();iter5++)
1010  delete *iter5;
1011  _execOutGoingPorts.clear();
1012 }
void ForEachLoop::createOutputOutOfScopeInterceptors ( int  branchNb)
protected

Definition at line 1049 of file ForEachLoop.cxx.

References _execOutGoingPorts, _outGoingPorts, DEBTRACE, getDynOutPortByAbsName(), YACS::ENGINE::ComposedNode::getOutPortName(), and CORBAEngineTest::i.

Referenced by exUpdateState().

1050 {
1051  vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
1052  int i=0;
1053  for(;iter!=_outGoingPorts.end();iter++,i++)
1054  {
1055  DEBTRACE( (*iter)->getName() << " " << (*iter)->edGetType()->kind() );
1056  //AnyInputPort *interceptor=new AnyInputPort((*iter)->getName(),this,(*iter)->edGetType());
1057  OutPort *portOut=getDynOutPortByAbsName(branchNb,getOutPortName(((*iter)->getRepr())));
1058  DEBTRACE( portOut->getName() );
1059  TypeCode *tc((TypeCode *)(*iter)->edGetType()->contentType());
1060  AnyInputPort *interceptor=new AnyInputPort((*iter)->getName(),this,tc);
1061  portOut->addInPort(interceptor);
1062  _execOutGoingPorts[branchNb].push_back(interceptor);
1063  }
1064 }
InputPort* YACS::ENGINE::ForEachLoop::edGetSeqOfSamplesPort ( )
inline
void ForEachLoop::exUpdateProgress ( )

Definition at line 632 of file ForEachLoop.cxx.

References YACS::ENGINE::Node::sendEvent().

Referenced by init(), updateStateForFinalizeNodeOnFinishedEventFrom(), and updateStateForWorkNodeOnFinishedEventFrom().

633 {
634  // emit notification to all observers registered with the dispatcher on any change of the node's state
635  sendEvent("progress");
636 }
void ForEachLoop::exUpdateState ( )
virtual

Update the node state.

Note
: Update the '_state' attribute. Typically called by 'this->_inGate' when 'this->_inGate' is ready.

Called by InGate::exNotifyFromPrecursor

Reimplemented from YACS::ENGINE::Node.

Definition at line 514 of file ForEachLoop.cxx.

References _execCurrentId, YACS::ENGINE::DynParaLoop::_execFinalizeNodes, YACS::ENGINE::DynParaLoop::_execIds, YACS::ENGINE::DynParaLoop::_execInitNodes, YACS::ENGINE::DynParaLoop::_execNodes, _execOutGoingPorts, _execVals, YACS::ENGINE::DynParaLoop::_finalizeNode, YACS::ENGINE::Node::_inGate, YACS::ENGINE::DynParaLoop::_initializingCounter, YACS::ENGINE::DynParaLoop::_initNode, YACS::ENGINE::DynParaLoop::_nbOfBranches, YACS::ENGINE::DynParaLoop::_nbOfEltConsumed, YACS::ENGINE::DynParaLoop::_node, _nodeForSpecialCases, _passedData, _splitterNode, YACS::ENGINE::Node::_state, YACS::ACTIVATED, YACS::ENGINE::ForEachLoopPassedData::assignAlreadyDone(), YACS::ENGINE::ForEachLoopPassedData::checkCompatibilyWithNb(), YACS::ENGINE::ForEachLoopPassedData::checkLevel2(), YACS::ENGINE::DynParaLoop::cloneAndPlaceNodesCoherently(), createOutputOutOfScopeInterceptors(), DEBTRACE, YACS::DISABLED, YACS::DONE, YACS::ERROR, YACS::ENGINE::Node::exForwardFailed(), YACS::ENGINE::InGate::exIsReady(), FakeNodeForForEachLoop, YACS::ENGINE::DynParaLoop::forwardExecStateToOriginalBody(), YACS::ENGINE::ComposedNode::getAllOutPortsLeavingCurrentScope(), YACS::ENGINE::AnyInputPort::getIntValue(), YACS::ENGINE::SplitterNode::getNumberOfElements(), YACS::ENGINE::ForEachLoopPassedData::getNumberOfEltsAlreadyDone(), CORBAEngineTest::i, YACS::ENGINE::DynParaLoop::prepareInputsFromOutOfScope(), prepareSequenceValues(), YACS::ENGINE::SplitterNode::putSplittedValueOnRankTo(), YACS::ENGINE::Node::setState(), YACS::ENGINE::ForEachLoopPassedData::toAbsId(), and YACS::Exception::what().

515 {
516  DEBTRACE("ForEachLoop::exUpdateState");
517  if(_state == YACS::DISABLED)
518  return;
519  if(_state == YACS::DONE)
520  return;
521  if(_inGate.exIsReady())
522  {
523  //internal graph update
524  int i;
525  int nbOfBr(_nbOfBranches.getIntValue()),nbOfElts(_splitterNode.getNumberOfElements()),nbOfEltsDone(0);
526  if(_passedData)
527  {
529  nbOfEltsDone=_passedData->getNumberOfEltsAlreadyDone();
530  }
531  int nbOfEltsToDo(nbOfElts-nbOfEltsDone);
532 
533  DEBTRACE("nbOfElts=" << nbOfElts);
534  DEBTRACE("nbOfBr=" << nbOfBr);
535 
536  if(nbOfEltsToDo==0)
537  {
539  delete _nodeForSpecialCases;
542  return ;
543  }
544  if(nbOfBr<=0)
545  {
546  delete _nodeForSpecialCases;
549  return ;
550  }
551  if(nbOfBr>nbOfEltsToDo)
552  nbOfBr=nbOfEltsToDo;
553  _execNodes.resize(nbOfBr);
554  _execIds.resize(nbOfBr);
555  _execOutGoingPorts.resize(nbOfBr);
556  prepareSequenceValues(nbOfElts);
557  if(_initNode)
558  _execInitNodes.resize(nbOfBr);
560  if (_finalizeNode)
561  _execFinalizeNodes.resize(nbOfBr);
562 
563  vector<Node *> origNodes;
564  origNodes.push_back(_initNode);
565  origNodes.push_back(_node);
566  origNodes.push_back(_finalizeNode);
567 
568  //Conversion exceptions can be thrown by createOutputOutOfScopeInterceptors
569  //so catch them to control errors
570  try
571  {
572  for(i=0;i<nbOfBr;i++)
573  {
574  DEBTRACE( "-------------- 2" );
575  vector<Node *> clonedNodes = cloneAndPlaceNodesCoherently(origNodes);
576  if(_initNode)
577  _execInitNodes[i] = clonedNodes[0];
578  _execNodes[i] = clonedNodes[1];
579  if(_finalizeNode)
580  _execFinalizeNodes[i] = clonedNodes[2];
581  DEBTRACE( "-------------- 4" );
583  DEBTRACE( "-------------- 5" );
585  DEBTRACE( "-------------- 6" );
586  }
587  for(i=0;i<nbOfBr;i++)
588  {
589  DEBTRACE( "-------------- 1 " << i << " " << _execCurrentId);
591  int posInAbs(_execCurrentId);
592  if(_passedData)
594  _splitterNode.putSplittedValueOnRankTo(posInAbs,i,true);
595  _execCurrentId++;
596  DEBTRACE( "-------------- 7" );
597  }
598  if(_passedData)
599  {
602  }
603  }
604  catch(YACS::Exception& ex)
605  {
606  //ForEachLoop must be put in error and the exception rethrown to notify the caller
607  DEBTRACE( "ForEachLoop::exUpdateState: " << ex.what() );
609  exForwardFailed();
610  throw;
611  }
612 
613  setState(YACS::ACTIVATED); // move the calling of setState method there for adding observers for clone nodes in GUI part
614 
615  //let's go
616  for(i=0;i<nbOfBr;i++)
617  if(_initNode)
618  {
619  _execInitNodes[i]->exUpdateState();
621  }
622  else
623  {
625  _execNodes[i]->exUpdateState();
626  }
627 
629  }
630 }
Node * ForEachLoop::getChildByShortName ( const std::string &  name) const throw (Exception)
virtual
int YACS::ENGINE::ForEachLoop::getCurrentIndex ( ) const
inline

Definition at line 201 of file ForEachLoop.hxx.

Referenced by getProgressWeight().

201 { return _currentIndex; }
void ForEachLoop::getDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 949 of file ForEachLoop.cxx.

References YACS::ENGINE::OutputPort::NAME.

950 {
951  string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
952  if(typeOfPortInstance==OutputPort::NAME)
953  {
954  vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
955  for(;iter!=_outGoingPorts.end();iter++)
956  if((*iter)->getRepr()==port.first)
957  break;
958  if(iter==_outGoingPorts.end())
959  {
960  string what("ForEachLoop::getDelegateOf : Port with name "); what+=port.first->getName(); what+=" not exported by ForEachLoop "; what+=_name;
961  throw Exception(what);
962  }
963  else
964  port.first=(*iter);
965  }
966  else
967  throw Exception("ForEachLoop::getDelegateOf : not implemented because not specified");
968 }
OutPort * ForEachLoop::getDynOutPortByAbsName ( int  branchNb,
const std::string &  name 
)
protected

Definition at line 993 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::Node::SEP_CHAR_IN_PORT, and YACS::ENGINE::ComposedNode::splitNamesBySep().

Referenced by createOutputOutOfScopeInterceptors().

994 {
995  string portName, nodeName;
996  splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false);
997  Node *staticChild = getChildByName(nodeName);
998  return _execNodes[branchNb]->getOutPort(portName);//It's impossible(garanteed by YACS::ENGINE::ForEachLoop::buildDelegateOf)
999  //that a link starting from _initNode goes out of scope of 'this'.
1000 }
unsigned YACS::ENGINE::ForEachLoop::getExecCurrentId ( ) const
inline

Definition at line 186 of file ForEachLoop.hxx.

186 { return _execCurrentId; } // for update progress bar on GUI part
int ForEachLoop::getFEDeltaBetween ( OutPort start,
InPort end 
)
static

Definition at line 1208 of file ForEachLoop.cxx.

References YACS::ENGINE::Node::getFather(), YACS::ENGINE::ComposedNode::getLowestCommonAncestor(), YACS::ENGINE::Port::getNode(), and PMMLBasicsTestLauncher::ret.

Referenced by buildDelegateOf().

1209 {
1210  Node *ns(start->getNode()),*ne(end->getNode());
1212  int ret(0);
1213  Node *work(ns);
1214  while(work!=co)
1215  {
1216  ForEachLoop *isFE(dynamic_cast<ForEachLoop *>(work));
1217  if(isFE)
1218  ret++;
1219  work=work->getFather();
1220  }
1221  if(dynamic_cast<AnySplitOutputPort *>(start))
1222  ret--;
1223  return ret;
1224 }
int ForEachLoop::getFinishedId ( )
private
InputPort * ForEachLoop::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::DynParaLoop.

Definition at line 688 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::getInputPort(), and YACS::ENGINE::SplitterNode::NAME_OF_SEQUENCE_INPUT.

Referenced by YACS::ENGINE::portParser::onEnd().

689 {
692  else
693  return DynParaLoop::getInputPort(name);
694 }
std::list< InputPort * > ForEachLoop::getLocalInputPorts ( ) const
virtual

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

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 681 of file ForEachLoop.cxx.

References YACS::ENGINE::SplitterNode::_dataPortToDispatch, _splitterNode, YACS::ENGINE::DynParaLoop::getLocalInputPorts(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::VisitorSalomeSaveState::visitForEachLoop().

682 {
683  list<InputPort *> ret=DynParaLoop::getLocalInputPorts();
684  ret.push_back((InputPort *)&_splitterNode._dataPortToDispatch);
685  return ret;
686 }
std::list< OutputPort * > ForEachLoop::getLocalOutputPorts ( ) const
virtual

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

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 1078 of file ForEachLoop.cxx.

References getOutputPort(), YACS::ENGINE::DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT, and PMMLBasicsTestLauncher::ret.

1079 {
1080  list<OutputPort *> ret;
1081  ret.push_back(getOutputPort(NAME_OF_SPLITTED_SEQ_OUT));
1082  return ret;
1083 }
int ForEachLoop::getNbOfElementsToBeProcessed ( ) const
int ForEachLoop::getNumberOfInputPorts ( ) const
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 660 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::getNumberOfInputPorts().

661 {
663 }
OutPort * ForEachLoop::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::DynParaLoop.

Definition at line 706 of file ForEachLoop.cxx.

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

Referenced by ForEachLoop().

707 {
708  for(vector<AnySplitOutputPort *>::const_iterator iter=_outGoingPorts.begin();iter!=_outGoingPorts.end();iter++)
709  {
710  if(name==(*iter)->getName())
711  return (OutPort *)(*iter);
712  }
713  return DynParaLoop::getOutPort(name);
714 }
OutputPort * ForEachLoop::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::DynParaLoop.

Definition at line 696 of file ForEachLoop.cxx.

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

Referenced by getLocalOutputPorts().

697 {
698  for(vector<AnySplitOutputPort *>::const_iterator iter=_outGoingPorts.begin();iter!=_outGoingPorts.end();iter++)
699  {
700  if(name==(*iter)->getName())
701  return (OutputPort *)(*iter);
702  }
703  return DynParaLoop::getOutputPort(name);
704 }
const YACS::ENGINE::TypeCode * ForEachLoop::getOutputPortType ( const std::string &  portName) const
Parameters
portName: "interceptorized" name of port.

Definition at line 1258 of file ForEachLoop.cxx.

References _outGoingPorts, YACS::ENGINE::TypeCode::contentType(), DEBTRACE, YACS::ENGINE::ComposedNode::getPortName(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::nodeParser::onEnd().

1259 {
1260  const YACS::ENGINE::TypeCode* ret=NULL;
1261  vector<AnySplitOutputPort *>::const_iterator it;
1262  for(it=_outGoingPorts.begin();it!=_outGoingPorts.end() && ret==NULL;it++)
1263  {
1264  std::string originalPortName(getPortName(*it));
1265  //InterceptorizeNameOfPort(originalPortName);
1266  DEBTRACE("ForEachLoop::getOutputPortType compare " << portName << " == " << originalPortName);
1267  if(originalPortName == portName)
1268  {
1269  ret = (*it)->edGetType()->contentType();
1270  }
1271  }
1272  return ret;
1273 }
std::vector< unsigned int > ForEachLoop::getPassedResults ( Executor execut,
std::vector< SequenceAny * > &  outputs,
std::vector< std::string > &  nameOfOutputs 
) const

This method allows to retrieve the state of this during execution or after. This method works even if this is NOT complete, or during execution or after a failure in this. The typical usage of this method is to retrieve the results of items that passed successfully to avoid to lose all of them if only one fails. This method has one input execut and 3 outputs.

Parameters
[in]execut- The single input is for threadsafety reasons because this method can be called safely during the execution of this.
[out]outputs- For each output ports in this linked with nodes sharing the same father than this the passed results are stored. All of the items in outputs have the same size.
[out]nameOfOutputs- The array with same size than outputs, that tells for each item in outputs the output port it refers to.
Returns
the list of ids among this->edGetSeqOfSamplesPort() that run successfully. The length of this returned array will be the length of all SequenceAny objects contained in outputs.
See Also
edGetSeqOfSamplesPort

Definition at line 1178 of file ForEachLoop.cxx.

References _execOutGoingPorts, _execVals, YACS::ENGINE::Executor::getTheMutexForSchedulerUpdate(), and CORBAEngineTest::i.

1179 {
1181  if(_execVals.empty())
1182  return std::vector<unsigned int>();
1183  if(_execOutGoingPorts.empty())
1184  return std::vector<unsigned int>();
1185  std::size_t sz(_execVals.size());
1186  outputs.resize(sz);
1187  nameOfOutputs.resize(sz);
1188  const std::vector<AnyInputPort *>& ports(_execOutGoingPorts[0]);
1189  for(std::size_t i=0;i<sz;i++)
1190  {
1191  outputs[i]=_execVals[i]->removeUnsetItemsFromThis();
1192  nameOfOutputs[i]=ports[i]->getName();
1193  }
1194  return _execVals[0]->getSetItems();
1195 }
ForEachLoopPassedData * ForEachLoop::getProcessedData ( ) const

This method is used to obtain the values already processed by the ForEachLoop. A new ForEachLoopPassedData object is returned. You have to delete it.

Definition at line 1230 of file ForEachLoop.cxx.

References _execOutGoingPorts, _execVals, and CORBAEngineTest::i.

Referenced by YACS::ENGINE::VisitorSalomeSaveState::visitForEachLoop().

1231 {
1232  std::vector<SequenceAny *> outputs;
1233  std::vector<std::string> nameOfOutputs;
1234  if(_execVals.empty() || _execOutGoingPorts.empty())
1235  return new ForEachLoopPassedData(std::vector<unsigned int>(), outputs, nameOfOutputs);
1236  std::size_t sz(_execVals.size());
1237  outputs.resize(sz);
1238  nameOfOutputs.resize(sz);
1239  const std::vector<AnyInputPort *>& ports(_execOutGoingPorts[0]);
1240  for(std::size_t i=0;i<sz;i++)
1241  {
1242  outputs[i]=_execVals[i]->removeUnsetItemsFromThis();
1243  nameOfOutputs[i]=ports[i]->getName();
1244  }
1245  return new ForEachLoopPassedData(_execVals[0]->getSetItems(), outputs, nameOfOutputs);
1246 }
std::string ForEachLoop::getProgress ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 1121 of file ForEachLoop.cxx.

References _currentIndex, and getNbOfElementsToBeProcessed().

1122 {
1123  int nbElems(getNbOfElementsToBeProcessed());
1124  std::stringstream aProgress;
1125  if (nbElems > 0)
1126  aProgress << _currentIndex << "/" << nbElems;
1127  else
1128  aProgress << "0";
1129  return aProgress.str();
1130 }
list< ProgressWeight > ForEachLoop::getProgressWeight ( ) const
virtual

Get the progress weight for all elementary nodes.

Only elementary nodes have weight. For each node in the loop, the weight done is multiplied by the number of elements done and the weight total by the number total of elements

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 1137 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::edGetDirectDescendants(), getCurrentIndex(), getNbOfElementsToBeProcessed(), and PMMLBasicsTestLauncher::ret.

1138 {
1139  list<ProgressWeight> ret;
1140  list<Node *> setOfNode=edGetDirectDescendants();
1141  int elemDone=getCurrentIndex();
1142  int elemTotal=getNbOfElementsToBeProcessed();
1143  for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
1144  {
1145  list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
1146  for(list<ProgressWeight>::iterator iter=myCurrentSet.begin();iter!=myCurrentSet.end();iter++)
1147  {
1148  (*iter).weightDone=((*iter).weightTotal) * elemDone;
1149  (*iter).weightTotal*=elemTotal;
1150  }
1151  ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
1152  }
1153  return ret;
1154 }
void ForEachLoop::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

Implements YACS::ENGINE::Node.

Definition at line 638 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::_execFinalizeNodes, YACS::ENGINE::DynParaLoop::_execInitNodes, YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::DynParaLoop::_node, _nodeForSpecialCases, YACS::ENGINE::Node::_state, YACS::ACTIVATED, YACS::ENGINE::ElementaryNode::getReadyTasks(), YACS::ENGINE::Node::setState(), and YACS::TOACTIVATE.

639 {
640  if(!_node)
641  return;
644  {
646  {
648  return ;
649  }
650  vector<Node *>::iterator iter;
651  for (iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++)
652  (*iter)->getReadyTasks(tasks);
653  for (iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++)
654  (*iter)->getReadyTasks(tasks);
655  for (iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++)
656  (*iter)->getReadyTasks(tasks);
657  }
658 }
std::list< InputPort * > ForEachLoop::getSetOfInputPort ( ) const
virtual
void ForEachLoop::init ( bool  start = true)
virtual

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

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 502 of file ForEachLoop.cxx.

References _currentIndex, _execCurrentId, _passedData, _splitterNode, cleanDynGraph(), exUpdateProgress(), YACS::ENGINE::DynParaLoop::init(), YACS::ENGINE::SplitterNode::init(), and YACS::ENGINE::ForEachLoopPassedData::init().

503 {
504  DynParaLoop::init(start);
505  _splitterNode.init(start);
506  _execCurrentId=0;
507  cleanDynGraph();
508  _currentIndex = 0;
510  if(_passedData)
511  _passedData->init();
512 }
void ForEachLoop::InterceptorizeNameOfPort ( std::string &  portName)
static

Definition at line 899 of file ForEachLoop.cxx.

References INTERCEPTOR_STR.

Referenced by buildDelegateOf().

900 {
901  std::replace_if(portName.begin(), portName.end(), std::bind1st(std::equal_to<char>(), '.'), '_');
902  portName += INTERCEPTOR_STR;
903 }
void ForEachLoop::prepareSequenceValues ( int  sizeOfSamples)
protected

Definition at line 1033 of file ForEachLoop.cxx.

References _execVals, _outGoingPorts, CORBAEngineTest::i, and YACS::ENGINE::SequenceAny::New().

Referenced by exUpdateState().

1034 {
1035  _execVals.resize(_outGoingPorts.size());
1036  vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
1037  for(int i=0;iter!=_outGoingPorts.end();iter++,i++)
1038  _execVals[i]=SequenceAny::New((*iter)->edGetType()->contentType(),sizeOfSamples);
1039 }
void ForEachLoop::pushAllSequenceValues ( )
protected

Definition at line 1041 of file ForEachLoop.cxx.

References _execVals, _outGoingPorts, and CORBAEngineTest::i.

Referenced by YACS::ENGINE::FakeNodeForForEachLoop::execute(), and updateStateForWorkNodeOnFinishedEventFrom().

1042 {
1043  vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
1044  int i=0;
1045  for(;iter!=_outGoingPorts.end();iter++,i++)
1046  (*iter)->put((const void *)_execVals[i]);
1047 }
void ForEachLoop::releaseDelegateOf ( OutPort portDwn,
OutPort portUp,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 970 of file ForEachLoop.cxx.

References YACS::ENGINE::OutputPort::NAME, and p.

971 {
972  string typeOfPortInstance=portDwn->getNameOfTypeOfCurrentInstance();
973  if(typeOfPortInstance==OutputPort::NAME)
974  {
975  vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
976  vector<InterceptorInputPort *>::iterator iter2=_intecptrsForOutGoingPorts.begin();
977  for(;iter!=_outGoingPorts.end();iter++,iter2++)
978  if((*iter)->getRepr()==portDwn)
979  break;
980  //ASSERT(portUp==*iter.second)
981  if((*iter)->decrRef())
982  {
983  AnySplitOutputPort *p=*iter;
984  _outGoingPorts.erase(iter);
985  delete p;
986  InterceptorInputPort *ip=*iter2;
987  _intecptrsForOutGoingPorts.erase(iter2);
988  delete ip;
989  }
990  }
991 }
void ForEachLoop::resetState ( int  level)
virtual

Reset the state of the node and its children depending on the parameter level.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 1112 of file ForEachLoop.cxx.

References _execCurrentId, cleanDynGraph(), and YACS::ENGINE::ComposedNode::resetState().

1113 {
1114  if(level==0)return;
1115  DynParaLoop::resetState(level);
1116  _execCurrentId=0;
1117  //Note: cleanDynGraph is not a virtual method (must be called from ForEachLoop object)
1118  cleanDynGraph();
1119 }
void ForEachLoop::selectRunnableTasks ( std::vector< Task * > &  tasks)
virtual

Implements YACS::ENGINE::Scheduler.

Definition at line 670 of file ForEachLoop.cxx.

671 {
672 }
void ForEachLoop::setProcessedData ( ForEachLoopPassedData processedData)

Definition at line 1248 of file ForEachLoop.cxx.

References _passedData.

1249 {
1250  if(_passedData)
1251  delete _passedData;
1252  _passedData = processedData;
1253 }
Node * ForEachLoop::simpleClone ( ComposedNode father,
bool  editionOnly = true 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 487 of file ForEachLoop.cxx.

References ForEachLoop().

488 {
489  return new ForEachLoop(*this,father,editionOnly);
490 }
void ForEachLoop::storeOutValsInSeqForOutOfScopeUse ( int  rank,
int  branchNb 
)
protected

Definition at line 1014 of file ForEachLoop.cxx.

References _execOutGoingPorts, _execVals, and CORBAEngineTest::i.

Referenced by updateStateForWorkNodeOnFinishedEventFrom().

1015 {
1016  vector<AnyInputPort *>::iterator iter;
1017  int i=0;
1018  for(iter=_execOutGoingPorts[branchNb].begin();iter!=_execOutGoingPorts[branchNb].end();iter++,i++)
1019  {
1020  Any *val=(Any *)(*iter)->getValue();
1021  _execVals[i]->setEltAtRank(rank,val);
1022  }
1023 }
virtual std::string YACS::ENGINE::ForEachLoop::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 197 of file ForEachLoop.hxx.

197 {return "YACS__ENGINE__ForEachLoop";}
YACS::Event ForEachLoop::updateStateForFinalizeNodeOnFinishedEventFrom ( Node node,
unsigned int  id 
)
protected

Definition at line 868 of file ForEachLoop.cxx.

References _currentIndex, YACS::ENGINE::DynParaLoop::_finalizeNode, YACS::ENGINE::DynParaLoop::_unfinishedCounter, DEBTRACE, YACS::DONE, exUpdateProgress(), YACS::FINISH, YACS::NOEVENT, and YACS::ENGINE::Node::setState().

Referenced by updateStateOnFinishedEventFrom().

869 {
870  DEBTRACE("Finalize node finished on branch " << id);
872  _currentIndex++;
874  DEBTRACE(_unfinishedCounter << " finalize nodes still running");
875  if (_unfinishedCounter == 0)
876  {
879  return YACS::FINISH;
880  }
881  else
882  return YACS::NOEVENT;
883 }
YACS::Event ForEachLoop::updateStateForInitNodeOnFinishedEventFrom ( Node node,
unsigned int  id 
)
protected
YACS::Event ForEachLoop::updateStateForWorkNodeOnFinishedEventFrom ( Node node,
unsigned int  id,
bool  isNormalFinish 
)
protected
Parameters
[in]isNormalFinish- if true

Definition at line 763 of file ForEachLoop.cxx.

References _currentIndex, _execCurrentId, YACS::ENGINE::DynParaLoop::_execFinalizeNodes, YACS::ENGINE::DynParaLoop::_execIds, YACS::ENGINE::DynParaLoop::_failedCounter, YACS::ENGINE::DynParaLoop::_finalizeNode, YACS::ENGINE::DynParaLoop::_nbOfEltConsumed, YACS::ENGINE::DynParaLoop::_node, _passedData, _splitterNode, YACS::ENGINE::Node::_state, YACS::ENGINE::DynParaLoop::_unfinishedCounter, YACS::ABORT, YACS::ACTIVATED, DEBTRACE, YACS::DONE, YACS::ERROR, YACS::ENGINE::Node::exForwardFailed(), exUpdateProgress(), YACS::ENGINE::Node::exUpdateState(), YACS::FAILED, YACS::FINISH, YACS::ENGINE::DynParaLoop::forwardExecStateToOriginalBody(), YACS::ENGINE::ComposedNode::getAllRecursiveConstituents(), getFinishedId(), CORBAEngineTest::i, YACS::ENGINE::Node::init(), YACS::ENGINE::ComposedNode::isFinished(), YACS::NOEVENT, NOT_RUNNING_BRANCH_ID, pushAllSequenceValues(), YACS::ENGINE::SplitterNode::putSplittedValueOnRankTo(), YACS::ENGINE::Node::sendEvent2(), YACS::ENGINE::Node::setState(), storeOutValsInSeqForOutOfScopeUse(), YACS::ENGINE::ForEachLoopPassedData::toAbsId(), YACS::Exception::what(), and YASSERT.

Referenced by updateStateOnFailedEventFrom(), and updateStateOnFinishedEventFrom().

764 {
765  _currentIndex++;
767  if(isNormalFinish)
768  {
769  int globalId(_execIds[id]);
770  if(_passedData)
771  globalId=_passedData->toAbsId(globalId);
772  sendEvent2("progress_ok",&globalId);
774  }
775  else
776  {
777  int globalId(_execIds[id]);
778  if(_passedData)
779  globalId=_passedData->toAbsId(globalId);
780  sendEvent2("progress_ko",&globalId);
781  }
782  //
784  {//No more elements of _dataPortToDispatch to treat
786  //analyzing if some samples are still on treatment on other branches.
787  bool isFinished(true);
788  for(int i=0;i<_execIds.size() && isFinished;i++)
790  if(isFinished)
791  {
792  try
793  {
794  if(_failedCounter!=0)
795  {// case of keepgoing mode + a failed
796  std::ostringstream oss; oss << "Keep Going mode activated and some errors (" << _failedCounter << ")reported !";
797  DEBTRACE("ForEachLoop::updateStateOnFinishedEventFrom : "<< oss.str());
799  return YACS::ABORT;
800  }
802 
803  if (_node)
804  {
806 
807  ComposedNode* compNode = dynamic_cast<ComposedNode*>(_node);
808  if (compNode)
809  {
810  std::list<Node *> aChldn = compNode->getAllRecursiveConstituents();
811  std::list<Node *>::iterator iter=aChldn.begin();
812  for(;iter!=aChldn.end();iter++)
813  (*iter)->setState(YACS::DONE);
814  }
815  }
816 
817  if (_finalizeNode == NULL)
818  {
819  // No finalize node, we just finish the loop at the end of exec nodes execution
821  return YACS::FINISH;
822  }
823  else
824  {
825  // Run the finalize nodes, the loop will be done only when they all finish
826  _unfinishedCounter = 0; // This counter indicates how many branches are not finished
827  for (int i=0 ; i<_execIds.size() ; i++)
828  {
830  DEBTRACE("Launching finalize node for branch " << i);
831  _execFinalizeNodes[i]->exUpdateState();
833  }
834  return YACS::NOEVENT;
835  }
836  }
837  catch(YACS::Exception& ex)
838  {
839  DEBTRACE("ForEachLoop::updateStateOnFinishedEventFrom: "<<ex.what());
840  //no way to push results : put following nodes in FAILED state
841  //TODO could be more fine grain : put only concerned nodes in FAILED state
842  exForwardFailed();
844  return YACS::ABORT;
845  }
846  }
847  }
848  else if(_state == YACS::ACTIVATED)
849  {//more elements to do and loop still activated
851  node->init(false);
852  int posInAbs(_execCurrentId);
853  if(_passedData)
855  _splitterNode.putSplittedValueOnRankTo(posInAbs,id,false);
856  _execCurrentId++;
857  node->exUpdateState();
860  }
861  else
862  {//elements to process and loop no more activated
863  DEBTRACE("foreach loop state " << _state);
864  }
865  return YACS::NOEVENT;
866 }
YACS::Event ForEachLoop::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::DynParaLoop.

Definition at line 885 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::_failedCounter, YACS::ENGINE::DynParaLoop::getIdentityOfNotifyerNode(), YACS::ENGINE::Executor::getKeepGoingProperty(), updateStateForWorkNodeOnFinishedEventFrom(), YACS::ENGINE::DynParaLoop::updateStateOnFailedEventFrom(), and YACS::ENGINE::DynParaLoop::WORK_NODE.

886 {
887  unsigned int id;
889  // TODO: deal with keepgoing without the dependency to Executor
890  if(ton!=WORK_NODE || !execInst->getKeepGoingProperty())
891  return DynParaLoop::updateStateOnFailedEventFrom(node,execInst);
892  else
893  {
894  _failedCounter++;
895  return updateStateForWorkNodeOnFinishedEventFrom(node,id,false);
896  }
897 }
YACS::Event ForEachLoop::updateStateOnFinishedEventFrom ( Node node)
protectedvirtual

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

Update the current state and return the change state

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

Implements YACS::ENGINE::ComposedNode.

Definition at line 731 of file ForEachLoop.cxx.

References DEBTRACE, YACS::ENGINE::DynParaLoop::FINALIZE_NODE, YACS::ENGINE::DynParaLoop::getIdentityOfNotifyerNode(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Node::getState(), YACS::ENGINE::DynParaLoop::INIT_NODE, YACS::NOEVENT, updateStateForFinalizeNodeOnFinishedEventFrom(), updateStateForInitNodeOnFinishedEventFrom(), updateStateForWorkNodeOnFinishedEventFrom(), YACS::ENGINE::DynParaLoop::WORK_NODE, and YASSERT.

732 {
733  DEBTRACE("updateStateOnFinishedEventFrom " << node->getName() << " " << node->getState());
734  unsigned int id;
735  switch(getIdentityOfNotifyerNode(node,id))
736  {
737  case INIT_NODE:
739  case WORK_NODE:
740  return updateStateForWorkNodeOnFinishedEventFrom(node,id,true);
741  case FINALIZE_NODE:
743  default:
744  YASSERT(false);
745  }
746  return YACS::NOEVENT;
747 }
void ForEachLoop::writeDot ( std::ostream &  os) const
virtual

Dump the node state to a stream.

Parameters
os: the output stream

Reimplemented from YACS::ENGINE::Node.

Definition at line 1094 of file ForEachLoop.cxx.

References YACS::ENGINE::DynParaLoop::_node, YACS::ENGINE::Node::getColorState(), YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::Node::getId(), YACS::ENGINE::ComposedNode::getName(), CORBAEngineTest::state, and YACS::ENGINE::Node::writeDot().

1095 {
1096  os << " subgraph cluster_" << getId() << " {\n" ;
1097  //only one node in a loop
1098  if(_node)
1099  {
1100  _node->writeDot(os);
1101  os << getId() << " -> " << _node->getId() << ";\n";
1102  }
1103  os << "}\n" ;
1104  os << getId() << "[fillcolor=\"" ;
1106  os << getColorState(state);
1107  os << "\" label=\"" << "Loop:" ;
1108  os << getName() <<"\"];\n";
1109 }

Friends And Related Function Documentation

friend class FakeNodeForForEachLoop
friend

Definition at line 156 of file ForEachLoop.hxx.

Referenced by exUpdateState().

friend class SplitterNode
friend

Definition at line 155 of file ForEachLoop.hxx.

Member Data Documentation

int YACS::ENGINE::ForEachLoop::_currentIndex
protected
unsigned YACS::ENGINE::ForEachLoop::_execCurrentId
protected

ports created for TypeCodes correctness

Definition at line 169 of file ForEachLoop.hxx.

Referenced by exUpdateState(), init(), resetState(), and updateStateForWorkNodeOnFinishedEventFrom().

std::vector< std::vector<AnyInputPort *> > YACS::ENGINE::ForEachLoop::_execOutGoingPorts
protected
std::vector<SequenceAny *> YACS::ENGINE::ForEachLoop::_execVals
protected
std::vector<InterceptorInputPort *> YACS::ENGINE::ForEachLoop::_intecptrsForOutGoingPorts
protected

ports linked to node outside the current scope

Definition at line 167 of file ForEachLoop.hxx.

Referenced by buildDelegateOf(), ForEachLoop(), and ~ForEachLoop().

FakeNodeForForEachLoop* YACS::ENGINE::ForEachLoop::_nodeForSpecialCases
protected

Definition at line 165 of file ForEachLoop.hxx.

Referenced by exUpdateState(), and getReadyTasks().

std::vector<AnySplitOutputPort *> YACS::ENGINE::ForEachLoop::_outGoingPorts
protected
ForEachLoopPassedData* YACS::ENGINE::ForEachLoop::_passedData
protected
const char ForEachLoop::INTERCEPTOR_STR ="_interceptor"
static

Definition at line 234 of file ForEachLoop.hxx.

Referenced by InterceptorizeNameOfPort().

const char ForEachLoop::NAME_OF_SPLITTERNODE ="splitter"
static
const int ForEachLoop::NOT_RUNNING_BRANCH_ID =-1
staticprotected

Definition at line 161 of file ForEachLoop.hxx.

Referenced by updateStateForWorkNodeOnFinishedEventFrom().


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