Version: 8.3.0
YACS::ENGINE::Bloc Class Reference

Composed node to group elementary and composed nodes. More...

#include <Bloc.hxx>

Inheritance diagram for YACS::ENGINE::Bloc:
Collaboration diagram for YACS::ENGINE::Bloc:

Public Member Functions

 Bloc (const Bloc &other, ComposedNode *father, bool editionOnly)
 
 Bloc (const std::string &name)
 Create a Bloc node with a given name. More...
 
virtual ~Bloc ()
 
bool isFinished ()
 Indicate if the bloc execution is finished. More...
 
int getNumberOfCFLinks () const
 
void init (bool start=true)
 Initialize the bloc. More...
 
void getReadyTasks (std::vector< Task * > &tasks)
 Collect all nodes that are ready to execute. More...
 
void exUpdateState ()
 Update the bloc state. More...
 
bool edAddChild (Node *DISOWNnode) throw (Exception)
 Add a child node to the bloc. More...
 
void edRemoveChild (Node *node) throw (Exception)
 
std::list< Node * > getChildren () const
 
std::list< Node * > edGetDirectDescendants () const
 
std::vector< std::list< Node * > > splitIntoIndependantGraph () const
 
NodegetChildByShortName (const std::string &name) const throw (Exception)
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
void accept (Visitor *visitor)
 
template<bool direction>
void findAllPathsStartingFrom (Node *start, std::list< std::vector< Node * > > &vec, std::map< Node *, std::set< Node * > > &accelStr) const
 
template<bool direction>
void findAllNodesStartingFrom (Node *start, std::set< Node * > &result, std::map< Node *, std::set< Node * > > &accelStr, LinkInfo &info) const
 
virtual std::string typeName ()
 
int getMaxLevelOfParallelism () const
 
void removeRecursivelyRedundantCL ()
 
template<bool direction>
unsigned appendIfAlreadyFound (std::list< std::vector< Node * > > &res, const std::vector< Node * > &startRes, Node *node, std::map< Node *, std::set< Node * > > &fastFinder)
 
- Public Member Functions inherited from YACS::ENGINE::StaticDefinedComposedNode
bool isPlacementPredictableB4Run () const
 
bool isMultiplicitySpecified (unsigned &value) const
 
void forceMultiplicity (unsigned value)
 
void selectRunnableTasks (std::vector< Task * > &tasks)
 
- Public Member Functions inherited from YACS::ENGINE::ComposedNode
virtual ~ComposedNode ()
 
bool isFinished ()
 
void init (bool start=true)
 
virtual void shutdown (int level)
 Stop all pending activities of the composed node. More...
 
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...
 
virtual bool edAddDFLink (OutPort *start, InPort *end) throw (Exception)
 Connect an OutPort to an InPort and add the necessary control link. 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
 
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)
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
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
 
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...
 
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...
 
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...
 
ComposedNodegetRootNode () const throw (Exception)
 
bool isNodeAlreadyAggregated (const Node *node) const
 Check that Node 'node' is already a direct son of this. More...
 
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 ()
 
void accept (Visitor *visitor)
 
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 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 ()
 

Protected Member Functions

NodesimpleClone (ComposedNode *father, bool editionOnly=true) const
 
bool areAllSubNodesFinished () const
 
bool areAllSubNodesDone () const
 
bool isNameAlreadyUsed (const std::string &name) const
 
void checkNoCyclePassingThrough (Node *node) throw (Exception)
 
std::vector< std::pair
< OutGate *, InGate * > > 
getSetOfInternalCFLinks () const
 
YACS::Event updateStateOnFinishedEventFrom (Node *node)
 
YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Notify this bloc that a node has failed. More...
 
void initComputation () const
 
void performCFComputationsOnlyOneLevel (LinkInfo &info) const
 
void performCFComputations (LinkInfo &info) const
 
void destructCFComputations (LinkInfo &info) const
 destroy recursively all results of initial computations. 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
 
bool areLinked (Node *start, Node *end, bool fw) const
 Check if two nodes are linked. More...
 
bool arePossiblyRunnableAtSameTime (Node *start, Node *end) const
 Check if two nodes can run in parallel. More...
 
void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 Check control flow links. More...
 
void seekOkAndUseless1 (std::vector< Node * > &okAndUseless1, std::set< Node * > &allNodes) const
 
void seekUseless2 (std::vector< Node * > &useless2, std::set< Node * > &allNodes) const
 
- Protected Member Functions inherited from YACS::ENGINE::StaticDefinedComposedNode
 StaticDefinedComposedNode (const std::string &name)
 
 StaticDefinedComposedNode (const StaticDefinedComposedNode &other, ComposedNode *father)
 
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
 
- 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 checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd) throw (Exception)
 
virtual void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
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)
 
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)
 
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 ()
 

Static Protected Member Functions

static void verdictForOkAndUseless1 (const std::map< Node *, std::list< OutPort * > > &pool, InputPort *end, const std::vector< Node * > &candidates, unsigned char &alreadyFed, bool direction, LinkInfo &info)
 
static void verdictForCollapses (const std::map< Node *, std::list< OutPort * > > &pool, InputPort *end, const std::set< Node * > &candidates, unsigned char &alreadyFed, bool direction, LinkInfo &info)
 

Protected Attributes

std::list< Node * > _setOfNode
 
std::map< Node *, std::set
< Node * > > * 
_fwLinks
 For internal calculations. More...
 
std::map< Node *, std::set
< Node * > > * 
_bwLinks
 For internal calculations. More...
 

Static Private Member Functions

static void findUselessLinksIn (const std::list< std::vector< Node * > > &res, LinkInfo &info)
 
template<bool direction>
static unsigned appendIfAlreadyFound (std::list< std::vector< Node * > > &res, const std::vector< Node * > &startRes, Node *node, std::map< Node *, std::set< Node * > > &fastFinder)
 
static void updateWithNewFind (const std::vector< Node * > &path, std::map< Node *, std::set< Node * > > &fastFinder)
 

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 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
 

Detailed Description

Composed node to group elementary and composed nodes.

Definition at line 30 of file Bloc.hxx.

Constructor & Destructor Documentation

Bloc::Bloc ( const Bloc other,
ComposedNode father,
bool  editionOnly 
)

Definition at line 46 of file Bloc.cxx.

References _setOfNode, YACS::ENGINE::ComposedNode::edAddCFLink(), YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Node::getInPort(), YACS::ENGINE::ComposedNode::getLowestCommonAncestor(), YACS::ENGINE::Port::getNode(), YACS::ENGINE::ComposedNode::getOutPort(), YACS::ENGINE::ComposedNode::getPortName(), getSetOfInternalCFLinks(), and YACS::ENGINE::ComposedNode::getSetOfInternalLinks().

Referenced by simpleClone().

46  :StaticDefinedComposedNode(other,father),_fwLinks(0),_bwLinks(0)
47 {
48  for(list<Node *>::const_iterator iter=other._setOfNode.begin();iter!=other._setOfNode.end();iter++)
49  _setOfNode.push_back((*iter)->simpleClone(this,editionOnly));
50 
51  //CF Linking
52  vector< pair<OutGate *, InGate *> > cfLinksToReproduce=other.getSetOfInternalCFLinks();
53  vector< pair<OutGate *, InGate *> >::iterator iter1=cfLinksToReproduce.begin();
54  for(;iter1!=cfLinksToReproduce.end();iter1++)
55  edAddCFLink(getChildByName(other.getChildName((*iter1).first->getNode())),getChildByName(other.getChildName((*iter1).second->getNode())));
56 
57  //Data + DataStream linking
58  vector< pair<OutPort *, InPort *> > linksToReproduce=other.getSetOfInternalLinks();
59  vector< pair<OutPort *, InPort *> >::iterator iter2=linksToReproduce.begin();
60  for(;iter2!=linksToReproduce.end();iter2++)
61  {
62  OutPort* pout = iter2->first;
63  InPort* pin = iter2->second;
64  if(&other == getLowestCommonAncestor(pout->getNode(), pin->getNode()))
65  {
66  edAddLink(getOutPort(other.getPortName(pout)),getInPort(other.getPortName(pin)));
67  }
68  }
69 }
Bloc::Bloc ( const std::string &  name)

Create a Bloc node with a given name.

Parameters
name: the given name

Definition at line 75 of file Bloc.cxx.

76 {
77 }
Bloc::~Bloc ( )
virtual

Definition at line 79 of file Bloc.cxx.

References _bwLinks, _fwLinks, and _setOfNode.

80 {
81  for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
82  delete *iter;
83  delete _fwLinks;
84  delete _bwLinks;
85 }

Member Function Documentation

void Bloc::accept ( Visitor visitor)
virtual

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::Proc.

Definition at line 445 of file Bloc.cxx.

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

446 {
447  visitor->visitBloc(this);
448 }
template<bool direction>
static unsigned YACS::ENGINE::Bloc::appendIfAlreadyFound ( std::list< std::vector< Node * > > &  res,
const std::vector< Node * > &  startRes,
Node node,
std::map< Node *, std::set< Node * > > &  fastFinder 
)
staticprivate
template<bool direction>
unsigned YACS::ENGINE::Bloc::appendIfAlreadyFound ( std::list< std::vector< Node * > > &  res,
const std::vector< Node * > &  startRes,
Node node,
std::map< Node *, std::set< Node * > > &  fastFinder 
)

Internal method for CF computation. Given 'fastFinder' it searched 'node' to see if an already found path in 'res' go through 'node'. If true all paths are deduced and append to res and 'fastFinder' is updated for next turn.

Definition at line 125 of file Bloc.hxx.

References CORBAEngineTest::i, PMMLBasicsTestLauncher::ret, and updateWithNewFind().

126  {
127  std::map<Node *, std::set<Node *> >::iterator iter=fastFinder.find(node);
128  if(iter==fastFinder.end())
129  return 0;
130  unsigned ret=0;
131  std::vector<std::pair<std::set<Node *>::iterator, std::set<Node *>::iterator > > li;
132  std::pair<std::set<Node *>::iterator, std::set<Node *>::iterator> ipr(((*iter).second).begin(),((*iter).second).end());
133  li.push_back(ipr);
134  std::vector<Node *> work(startRes);
135  std::list< std::vector<Node *> >::iterator where=res.end(); where--;
136  std::list< std::vector<Node *> >::iterator updates=where;
137  while(!li.empty())
138  {
139  if(li.back().first!=li.back().second)
140  {
141  work.push_back(*(li.back().first));
142  if(CFDirectionVisTraits<direction>::getNexts(work.back()).empty())
143  {
144  where=res.insert(where,work);
145  ret++;
146  li.back().first++;
147  work.pop_back();
148  }
149  else
150  {
151  std::set<Node *>& s=fastFinder[*(li.back().first)];
152  std::pair<std::set<Node *>::iterator, std::set<Node *>::iterator> pr(s.begin(),s.end());
153  li.push_back(pr);
154  }
155  }
156  else
157  {
158  work.pop_back();
159  li.pop_back();
160  if(!li.empty())
161  li.back().first++;
162  }
163  }
164  updates--;
165  for(unsigned i=0;i<ret;i++,updates--)
166  updateWithNewFind(*updates,fastFinder);
167  return ret;
168  }
bool Bloc::areAllSubNodesDone ( ) const
protected

Definition at line 286 of file Bloc.cxx.

References _setOfNode, YACS::DISABLED, and YACS::DONE.

Referenced by updateStateOnFailedEventFrom(), and updateStateOnFinishedEventFrom().

287 {
288  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
289  {
290  if((*iter)->_state == YACS::DONE)continue;
291  if((*iter)->_state == YACS::DISABLED)continue;
292  return false;
293  }
294  return true;
295 }
bool Bloc::areAllSubNodesFinished ( ) const
protected

Definition at line 297 of file Bloc.cxx.

References _setOfNode, YACS::DISABLED, YACS::DONE, YACS::ERROR, YACS::FAILED, and YACS::INTERNALERR.

Referenced by updateStateOnFailedEventFrom(), and updateStateOnFinishedEventFrom().

298 {
299  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
300  {
301  if((*iter)->_state == YACS::DONE)continue;
302  if((*iter)->_state == YACS::FAILED)continue;
303  if((*iter)->_state == YACS::DISABLED)continue;
304  if((*iter)->_state == YACS::ERROR)continue;
305  if((*iter)->_state == YACS::INTERNALERR)continue;
306  return false;
307  }
308  return true;
309 }
bool Bloc::areLinked ( Node start,
Node end,
bool  fw 
) const
protected

Check if two nodes are linked.

'start' and 'end' must be direct son of 'this'. Typically used for data link.

Parameters
start: start node
end: end node
fwindicates if it is a forward link searched (true : default value) or a backward link serach.
Returns
if true or false

Definition at line 625 of file Bloc.cxx.

Referenced by checkControlDependancy().

626 {
627  set<Node *>& nexts=fw ? (*_fwLinks)[start] : (*_bwLinks)[start];
628  return nexts.find(end)!=nexts.end();
629 }
bool Bloc::arePossiblyRunnableAtSameTime ( Node start,
Node end 
) const
protected

Check if two nodes can run in parallel.

Typically used for stream link. 'start' and 'end' must be direct son of 'this'.

Parameters
start: start node
end: end node
Returns
true or false

Definition at line 639 of file Bloc.cxx.

Referenced by checkControlDependancy().

640 {
641  set<Node *>& nexts=(*_fwLinks)[start];
642  set<Node *>& preds=(*_bwLinks)[start];
643  return nexts.find(end)==nexts.end() && preds.find(end)==preds.end();
644 }
void Bloc::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: end port
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: collected information

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 654 of file Bloc.cxx.

References YACS::ENGINE::E_COLLAPSE_DFDS, YACS::ENGINE::ComposedNode::FED_DS_ST, YACS::ENGINE::ComposedNode::FED_ST, YACS::ENGINE::ComposedNode::FREE_ST, YACS::ENGINE::ComposedNode::isInMyDescendance(), YACS::ENGINE::LinkInfo::pushErrLink(), seekOkAndUseless1(), seekUseless2(), verdictForCollapses(), and verdictForOkAndUseless1().

Referenced by verdictForCollapses().

655 {
656  if(alreadyFed==FREE_ST || alreadyFed==FED_ST)
657  {
658  map<Node *,list <OutPort *> > classPerNodes;
659  for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
660  classPerNodes[isInMyDescendance((*iter1)->getNode())].push_back(*iter1);
661  set<Node *> allNodes;
662  for(map<Node *,list <OutPort *> >::iterator iter2=classPerNodes.begin();iter2!=classPerNodes.end();iter2++)
663  allNodes.insert((*iter2).first);
664  vector<Node *> okAndUseless1,useless2;
665  seekOkAndUseless1(okAndUseless1,allNodes);
666  seekUseless2(useless2,allNodes);//after this point allNodes contains collapses
667  verdictForOkAndUseless1(classPerNodes,end,okAndUseless1,alreadyFed,direction,info);
668  verdictForCollapses(classPerNodes,end,allNodes,alreadyFed,direction,info);
669  verdictForOkAndUseless1(classPerNodes,end,useless2,alreadyFed,direction,info);
670  }
671  else if(alreadyFed==FED_DS_ST)
672  for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
673  info.pushErrLink(*iter1,end,E_COLLAPSE_DFDS);
674 }
void Bloc::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

WARNING Needs call of performCFComputations before beeing called. Perform updates of containers regarding attributes of link 'start' -> 'end' and check the correct linking. The output is in info struct.

Parameters
start: start port
end: end port
cross:
fwout parameter being append if start -> end link is a forward link without cross type DF/DS.
fwCrossout parameter being append if start -> end link is a forward link with cross type DF/DS.
bwout parameter being append if start -> end link is a backward link.
infoout parameter being informed about eventual errors.

Implements YACS::ENGINE::ComposedNode.

Definition at line 589 of file Bloc.cxx.

References areLinked(), arePossiblyRunnableAtSameTime(), YACS::ENGINE::E_DS_LINK_UNESTABLISHABLE, YACS::ENGINE::E_UNPREDICTABLE_FED, YACS::ENGINE::Port::getNode(), YACS::ENGINE::ComposedNode::isInMyDescendance(), and YACS::ENGINE::LinkInfo::pushErrLink().

594 {
595  if(!cross)
596  {
597  Node *startN=isInMyDescendance(start->getNode());
598  Node *endN=isInMyDescendance(end->getNode());
599  if(startN==endN)
600  bw[(ComposedNode *)this].push_back(start);
601  else if(areLinked(startN,endN,true))
602  fw[(ComposedNode *)this].push_back(start);
603  else
604  if(areLinked(startN,endN,false))
605  bw[(ComposedNode *)this].push_back(start);
606  else
607  info.pushErrLink(start,end,E_UNPREDICTABLE_FED);
608  }
609  else//DFDS detected
611  fwCross.push_back(start);
612  else
613  info.pushErrLink(start,end,E_DS_LINK_UNESTABLISHABLE);
614 }
void Bloc::checkNoCyclePassingThrough ( Node node) throw (Exception)
protectedvirtual
Note
Checks that in the forest from 'node' there are NO back-edges. WARNING : When using this method 'node' has to be checked in order to be part of direct children of 'this'.

Implements YACS::ENGINE::ComposedNode.

Definition at line 336 of file Bloc.cxx.

References insertNodeChildrenInSet().

337 {
338  set<Node *> currentNodesToTest;
339  //don't insert node to test in set.
340  //If it is present after insertion of connected nodes we have a loop
341  //collect all connected nodes
342  insertNodeChildrenInSet(node,currentNodesToTest);
343  //try to insert node
344  if(!(currentNodesToTest.insert(node)).second)
345  throw Exception("Cycle has been detected",1);
346 }
void Bloc::destructCFComputations ( LinkInfo info) const
protectedvirtual

destroy recursively all results of initial computations.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 569 of file Bloc.cxx.

References _bwLinks, _fwLinks, and YACS::ENGINE::ComposedNode::destructCFComputations().

Referenced by removeRecursivelyRedundantCL().

570 {
572  delete _fwLinks; _fwLinks=0;
573  delete _bwLinks; _bwLinks=0;
574 }
bool Bloc::edAddChild ( Node node) throw (Exception)
virtual

Add a child node to the bloc.

Parameters
node,:the node to add to the bloc
Returns
a boolean flag indicating if the node has been added

If node is already a direct child of current bloc, do nothing. If node is a child of another bloc, throw exception. If node name already used in bloc, throw exception. Publish inputPorts in current bloc and ancestors.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 174 of file Bloc.cxx.

References YACS::ENGINE::Node::_father.

Referenced by YACS::HMI::SubjectNode::registerUndoDestroy().

175 {
176  if(isNodeAlreadyAggregated(node))
177  {
178  if(node->_father==this)
179  return false;
180  else
181  {
182  string what = "Bloc::edAddChild : node "; what += node->getName();
183  what += " is already grand children of node";
184  throw Exception(what);
185  }
186  }
187 
188  if(node->_father)
189  {
190  string what = "Bloc::edAddChild: node is not orphan: "; what += node->getName();
191  throw Exception(what);
192  }
193 
195 
196  if(isNameAlreadyUsed(node->getName()))
197  {
198  string what("Bloc::edAddChild : name "); what+=node->getName();
199  what+=" already exists in the scope of "; what+=_name;
200  throw Exception(what);
201  }
202 
203  node->_father=this;
204  _setOfNode.push_back(node);
205  //should we also set _modified flag for node ??
206  ComposedNode *iter=node->_father;
207  //set the _modified flag so that latter on edUpdateState (eventually called by isValid) refresh state
208  //better call it at end
209  modified();
210  return true;
211 }
std::list<Node *> YACS::ENGINE::Bloc::edGetDirectDescendants ( ) const
inlinevirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 53 of file Bloc.hxx.

Referenced by YACS::HMI::GuiEditor::PutGraphInBloc().

53 { return _setOfNode; }
void Bloc::edRemoveChild ( Node node) throw (Exception)
virtual

Remove 'node' from the set of direct children.

Exceptions
If'node' is NOT the son of 'this'.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 218 of file Bloc.cxx.

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

219 {
221  list<Node *>::iterator iter=find(_setOfNode.begin(),_setOfNode.end(),node);
222  if(iter!=_setOfNode.end())
223  {
224  _setOfNode.erase(iter);
225  modified();
226  }
227 }
void Bloc::exUpdateState ( )
virtual

Update the bloc state.

Update the '_state' attribute. Typically called by 'this->_inGate' when 'this->_inGate' is ready. Contrary to Node::exUpdateState no check done on inputs because internal linked DF inputports are not valid yet.

Reimplemented from YACS::ENGINE::Node.

Definition at line 151 of file Bloc.cxx.

References YACS::ENGINE::Node::_inGate, _setOfNode, YACS::ENGINE::Node::_state, YACS::ACTIVATED, YACS::DISABLED, YACS::DONE, YACS::ENGINE::InGate::exIsReady(), and YACS::ENGINE::Node::setState().

Referenced by YACS::ENGINE::loadState(), and main().

152 {
153  if(_state == YACS::DISABLED)return;
154  if(_state == YACS::DONE)return;
155  if(_inGate.exIsReady())
156  {
158  for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
159  if((*iter)->exIsControlReady())
160  (*iter)->exUpdateState();
161  }
162 }
template<bool direction>
void YACS::ENGINE::Bloc::findAllNodesStartingFrom ( Node start,
std::set< Node * > &  result,
std::map< Node *, std::set< Node * > > &  accelStr,
LinkInfo info 
) const

Definition at line 171 of file Bloc.hxx.

References findUselessLinksIn().

173  {
174  std::list< std::vector<Node *> > li;
175  findAllPathsStartingFrom<direction>(start,li,accelStr);
176  for(std::list< std::vector<Node *> >::const_iterator iter=li.begin();iter!=li.end();iter++)
177  for(std::vector<Node *>::const_iterator iter2=(*iter).begin()+1;iter2!=(*iter).end();iter2++)
178  result.insert(*iter2);
179  if(direction)
180  findUselessLinksIn(li,info);
181  }
template<bool direction>
void YACS::ENGINE::Bloc::findAllPathsStartingFrom ( Node start,
std::list< std::vector< Node * > > &  vec,
std::map< Node *, std::set< Node * > > &  accelStr 
) const

Method for CF computation.DFS visitor is used. if direction is true forward visiting is performed, if false backward is performed.

Parameters
startmust be a direct descendant of 'this'.
vec:
accelStr

Definition at line 191 of file Bloc.hxx.

References YACS::ENGINE::Node::_colour, YACS::Black, initComputation(), and updateWithNewFind().

193  {
194  initComputation();
195  Node *current=start;
196  int caseId=0;
197  int idInCase=0;
198  vec.push_back(std::vector<Node *>());
199  typename CFDirectionVisTraits<direction>::Iterator iter;
200  std::list< std::vector<Node *> >::iterator curLine=vec.begin();
201  while(start->_colour!=YACS::Black)
202  {
203  (*curLine).push_back(current);
204  idInCase++;
205  //
206  if(CFDirectionVisTraits<direction>::getNexts(current).empty())
207  {
208 
209  vec.push_back(std::vector<Node *>((*curLine)));
210  updateWithNewFind(*curLine,accelStr);
211  current->_colour=YACS::Black;
212  curLine++;
213  if(idInCase>1)
214  {
215  idInCase-=2;
216  current=(*curLine)[idInCase];
217  (*curLine).pop_back();
218  (*curLine).pop_back();
219  }
220  continue;
221  }
222  if(current->_colour==YACS::Black)
223  {
224  appendIfAlreadyFound<direction>(vec,(*curLine),current,accelStr);
225  curLine=vec.end(); curLine--;
226  current->_colour=YACS::Black;
227  if(idInCase>1)
228  {
229  idInCase-=2;
230  current=(*curLine)[idInCase];
231  (*curLine).pop_back();
232  (*curLine).pop_back();
233  }
234  continue;
235  }
236  for(iter=CFDirectionVisTraits<direction>::getNexts(current).begin();iter!=CFDirectionVisTraits<direction>::getNexts(current).end();iter++)
237  if(!(*iter).second)
238  break;
239  if(iter==CFDirectionVisTraits<direction>::getNexts(current).end())
240  {//Fail this branch should be forgotten go rev
241  current->_colour=YACS::Black;
242  (*curLine).pop_back();
243  if(idInCase>1)
244  {
245  idInCase-=2;
246  current=(*curLine)[idInCase];
247  (*curLine).pop_back();
248  }
249  }
250  else
251  {
252  //Nothing to signal continuing in this direction hoping to find
253  current=(*iter).first->getNode();
254  (*iter).second=true;
255  }
256  }
257  vec.pop_back();
258  }
void Bloc::findUselessLinksIn ( const std::list< std::vector< Node * > > &  res,
LinkInfo info 
)
staticprivate

Internal method : After all paths have been found, useless CF links are searched

Definition at line 858 of file Bloc.cxx.

References YACS::ENGINE::LinkInfo::pushUselessCFLink().

Referenced by findAllNodesStartingFrom().

859 {
860  unsigned maxSize=0;
861  list< vector<Node *> >::const_iterator whereToPeerAt;
862  for(list< vector<Node *> >::const_iterator iter=res.begin();iter!=res.end();iter++)
863  if((*iter).size()>maxSize)
864  {
865  maxSize=(*iter).size();
866  whereToPeerAt=iter;
867  }
868  //
869  if(maxSize>1)
870  {
871  vector<Node *>::const_iterator iter2=(*whereToPeerAt).begin();
872  map<Node *,bool>::iterator iter4;
873  set<Node *> searcher(iter2+1,(*whereToPeerAt).end());//to boost research
874  for(;iter2!=((*whereToPeerAt).end()-2);iter2++)
875  {
876  list< pair<InGate *,bool> >& nexts=(*iter2)->getOutGate()->edMapInGate();
877  for(list< pair<InGate *,bool> >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++)
878  if((*iter4).first->getNode()!=*(iter2+1))
879  if(searcher.find((*iter4).first->getNode())!=searcher.end())
880  info.pushUselessCFLink(*iter2,(*iter4).first->getNode());
881  searcher.erase(*iter2);
882  }
883  }
884 }
Node * Bloc::getChildByShortName ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 277 of file Bloc.cxx.

Referenced by YACS::HMI::GuiEditor::PutGraphInBloc(), and YACS::HMI::GuiEditor::PutGraphInNode().

278 {
279  for (list<Node *>::const_iterator iter = _setOfNode.begin(); iter != _setOfNode.end(); iter++)
280  if ((*iter)->getName() == name)
281  return (*iter);
282  string what("node "); what+= name ; what+=" is not a child of Bloc "; what += getName();
283  throw Exception(what);
284 }
std::list<Node *> YACS::ENGINE::Bloc::getChildren ( ) const
inline
int Bloc::getMaxLevelOfParallelism ( ) const
virtual

Returns the max level of parallelism is this. The max of parallelism is equal to the sum of the max parallelism level for all concurrent branches in this.

Implements YACS::ENGINE::Node.

Definition at line 454 of file Bloc.cxx.

References YACS::ENGINE::SetOfPoints::getMaxLevelOfParallelism(), PMMLBasicsTestLauncher::ret, YACS::ENGINE::SetOfPoints::simplify(), and splitIntoIndependantGraph().

455 {
456  std::vector< std::list<Node *> > r(splitIntoIndependantGraph());
457  int ret(0);
458  for(std::vector< std::list<Node *> >::const_iterator it=r.begin();it!=r.end();it++)
459  {
460  SetOfPoints sop(*it);
461  sop.simplify();
462  ret+=sop.getMaxLevelOfParallelism();
463  }
464  return ret;
465 }
int Bloc::getNumberOfCFLinks ( ) const

Definition at line 114 of file Bloc.cxx.

References _setOfNode, and PMMLBasicsTestLauncher::ret.

115 {
116  int ret=0;
117  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
118  ret+=(*iter)->getOutGate()->getNbOfInGatesConnected();
119  return ret;
120 }
void Bloc::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

Collect all nodes that are ready to execute.

Parameters
tasks: vector of tasks to collect ready nodes

Implements YACS::ENGINE::Node.

Definition at line 131 of file Bloc.cxx.

References _setOfNode, YACS::ENGINE::Node::_state, YACS::ACTIVATED, YACS::ENGINE::Node::setState(), and YACS::TOACTIVATE.

132 {
133  /*
134  * ComposedNode state goes to ACTIVATED when one of its child has been ACTIVATED
135  * To change this uncomment the following line
136  * Then the father node will go to ACTIVATED state before its child node
137  */
140  for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
141  (*iter)->getReadyTasks(tasks);
142 }
std::vector< std::pair< OutGate *, InGate * > > Bloc::getSetOfInternalCFLinks ( ) const
protected

Definition at line 348 of file Bloc.cxx.

References _setOfNode, and PMMLBasicsTestLauncher::ret.

Referenced by Bloc().

349 {
350  vector< pair<OutGate *, InGate *> > ret;
351  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
352  {
353  list<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
354  for(list<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
355  ret.push_back(pair<OutGate *, InGate *>(&(*iter)->_outGate,*iter2));
356  }
357  return ret;
358 }
void Bloc::init ( bool  start = true)
virtual

Initialize the bloc.

Parameters
start: a boolean flag indicating the kind of initialization If start is true, it's a complete initialization with reinitialization of port values If start is false, there is no initialization of port values

Reimplemented from YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::SalomeProc.

Definition at line 93 of file Bloc.cxx.

References _setOfNode, and YACS::ENGINE::Node::init().

Referenced by YACS::ENGINE::SalomeProc::init(), YACS::ENGINE::loadState(), and main().

94 {
95  Node::init(start);
96  for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
97  (*iter)->init(start);
98 }
void Bloc::initComputation ( ) const
protected

Definition at line 676 of file Bloc.cxx.

References _setOfNode, and YACS::White.

Referenced by findAllPathsStartingFrom(), and removeRecursivelyRedundantCL().

677 {
678  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
679  {
680  (*iter)->_colour=White;
681  (*iter)->getInGate()->exReset();
682  (*iter)->getOutGate()->exReset();
683  }
684 }
bool Bloc::isFinished ( )
virtual

Indicate if the bloc execution is finished.

The execution bloc is finished if all its child nodes are finished with or without error or if it is disabled (not to execute)

Implements YACS::ENGINE::Scheduler.

Definition at line 105 of file Bloc.cxx.

References YACS::ENGINE::Node::_state, YACS::DISABLED, YACS::DONE, YACS::ERROR, and YACS::FAILED.

106 {
107  if(_state==YACS::DONE)return true;
108  if(_state==YACS::ERROR)return true;
109  if(_state==YACS::FAILED)return true;
110  if(_state==YACS::DISABLED)return true;
111  return false;
112 }
bool Bloc::isNameAlreadyUsed ( const std::string &  name) const
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 311 of file Bloc.cxx.

References _setOfNode.

312 {
313  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
314  if((*iter)->getName()==name)
315  return true;
316  return false;
317 }
void Bloc::performCFComputations ( LinkInfo info) const
protectedvirtual

Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method). _fwLinks is a map with a Node* as key and a set<Node*> as value. The set gives all nodes that are forwardly connected to the key node _bwLinks is a map for backward dependencies The method is : for all CF link (n1->n2) add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1] add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2] For useless links If a node is already in a forward dependency when adding and the direct link already exists so it's a useless link (see the code !)

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 563 of file Bloc.cxx.

References YACS::ENGINE::ComposedNode::performCFComputations(), and performCFComputationsOnlyOneLevel().

void Bloc::performCFComputationsOnlyOneLevel ( LinkInfo info) const
protected

Definition at line 479 of file Bloc.cxx.

References _bwLinks, _fwLinks, _setOfNode, YACS::ENGINE::OutGate::edSetInGate(), YACS::ENGINE::Node::getOutGate(), YACS::ENGINE::LinkInfo::pushUselessCFLink(), and PMMLBasicsTestLauncher::ret.

Referenced by performCFComputations(), and removeRecursivelyRedundantCL().

480 {
481  delete _fwLinks;//Normally useless
482  delete _bwLinks;//Normally useless
483  _fwLinks=new map<Node *,set<Node *> >;
484  _bwLinks=new map<Node *,set<Node *> >;
485 
486  //a set to store all CF links : used to find fastly if two nodes are connected
487  std::set< std::pair< Node*, Node* > > links;
488 
489  for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
490  {
491  Node* n1=*iter;
492  std::list<InGate *> ingates=n1->getOutGate()->edSetInGate();
493  for(std::list<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
494  {
495  //CF link : n1 -> (*it2)->getNode()
496  Node* n2=(*it2)->getNode();
497  links.insert(std::pair< Node*, Node* >(n1,n2));
498  std::set<Node *> bwn1=(*_bwLinks)[n1];
499  std::set<Node *> fwn1=(*_fwLinks)[n1];
500  std::set<Node *> fwn2=(*_fwLinks)[n2];
501  std::set<Node *> bwn2=(*_bwLinks)[n2];
502  std::pair<std::set<Node*>::iterator,bool> ret;
503  for(std::set<Node *>::const_iterator iter2=bwn1.begin();iter2!=bwn1.end();iter2++)
504  {
505  for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
506  {
507  ret=(*_fwLinks)[*iter2].insert(*it3);
508  if(ret.second==false)
509  {
510  //dependency already exists (*iter2) -> (*it3) : if a direct link exists it's a useless one
511  if(links.find(std::pair< Node*, Node* >(*iter2,*it3)) != links.end())
512  info.pushUselessCFLink(*iter2,*it3);
513  }
514  }
515  ret=(*_fwLinks)[*iter2].insert(n2);
516  if(ret.second==false)
517  {
518  //dependency already exists (*iter2) -> n2 : if a direct link exists it's a useless one
519  if(links.find(std::pair< Node*, Node* >(*iter2,n2)) != links.end())
520  info.pushUselessCFLink(*iter2,n2);
521  }
522  }
523  for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
524  {
525  ret=(*_fwLinks)[n1].insert(*it3);
526  if(ret.second==false)
527  {
528  //dependency already exists n1 -> *it3 : if a direct link exists it's a useless one
529  if(links.find(std::pair< Node*, Node* >(n1,*it3)) != links.end())
530  info.pushUselessCFLink(n1,*it3);
531  }
532  }
533  ret=(*_fwLinks)[n1].insert(n2);
534  if(ret.second==false)
535  {
536  //dependency already exists n1 -> n2 : it's a useless link
537  info.pushUselessCFLink(n1,n2);
538  }
539 
540  for(std::set<Node *>::const_iterator iter2=fwn2.begin();iter2!=fwn2.end();iter2++)
541  {
542  (*_bwLinks)[*iter2].insert(bwn1.begin(),bwn1.end());
543  (*_bwLinks)[*iter2].insert(n1);
544  }
545  (*_bwLinks)[n2].insert(bwn1.begin(),bwn1.end());
546  (*_bwLinks)[n2].insert(n1);
547  }
548  }
549 }
void Bloc::removeRecursivelyRedundantCL ( )
virtual

This method recursively all redundant control links in this.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 467 of file Bloc.cxx.

References destructCFComputations(), YACS::ENGINE::ComposedNode::edRemoveCFLink(), YACS::ENGINE::LinkInfo::getInfoUselessLinks(), YACS::ENGINE::I_CF_USELESS, initComputation(), performCFComputationsOnlyOneLevel(), and YACS::ENGINE::ComposedNode::removeRecursivelyRedundantCL().

468 {
470  LinkInfo info(I_CF_USELESS);
471  initComputation();
473  std::set< std::pair<Node *, Node *> > linksToKill(info.getInfoUselessLinks());
474  for(std::set< std::pair<Node *, Node *> >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++)
475  edRemoveCFLink((*it).first,(*it).second);
477 }
void Bloc::seekOkAndUseless1 ( std::vector< Node * > &  okAndUseless1,
std::set< Node * > &  allNodes 
) const
protected

WARNING use this method only after having called Bloc::performCFComputations method.

Parameters
okAndUseless1out param contains at the end, the nodes without any collapse.
allNodesin/out param. At the end, all the nodes in 'okAndUseless1' are deleted from 'allNodes'.

Definition at line 791 of file Bloc.cxx.

Referenced by checkCFLinks().

792 {
793  set<Node *>::iterator iter=allNodes.begin();
794  while(iter!=allNodes.end())
795  {
796  set<Node *>& whereToFind=(*_bwLinks)[*iter];
797  std::set<Node *>::iterator iter2;
798  for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
799  if((*iter)!=(*iter2))
800  if(whereToFind.find(*iter2)==whereToFind.end())
801  break;
802  if(iter2!=allNodes.end())
803  iter++;
804  else
805  {
806  okAndUseless1.push_back((*iter));
807  allNodes.erase(iter);
808  iter=allNodes.begin();
809  }
810  }
811 }
void Bloc::seekUseless2 ( std::vector< Node * > &  useless2,
std::set< Node * > &  allNodes 
) const
protected

WARNING use this method only after having called Bloc::performCFComputations method. For params see Bloc::seekOkAndUseless1.

Definition at line 817 of file Bloc.cxx.

Referenced by checkCFLinks().

818 {
819  set<Node *>::iterator iter=allNodes.begin();
820  while(iter!=allNodes.end())
821  {
822  set<Node *>& whereToFind=(*_fwLinks)[*iter];
823  std::set<Node *>::iterator iter2;
824  for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
825  if((*iter)!=(*iter2))
826  if(whereToFind.find(*iter2)==whereToFind.end())
827  break;
828  if(iter2!=allNodes.end())
829  {
830  iter++;
831  }
832  else
833  {
834  useless2.push_back((*iter));
835  allNodes.erase(iter);
836  iter=allNodes.begin();
837  }
838  }
839 }
Node * Bloc::simpleClone ( ComposedNode father,
bool  editionOnly = true 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 122 of file Bloc.cxx.

References Bloc().

123 {
124  return new Bloc(*this,father,editionOnly);
125 }
std::vector< std::list< Node * > > Bloc::splitIntoIndependantGraph ( ) const

Definition at line 229 of file Bloc.cxx.

References YACS::ENGINE::Node::_colour, _setOfNode, YACS::Grey, PMMLBasicsTestLauncher::ret, and YACS::White.

Referenced by getMaxLevelOfParallelism().

230 {
231  std::size_t sz(_setOfNode.size());
232  list<Node *>::const_iterator it=_setOfNode.begin();
233  for(;it!=_setOfNode.end();it++)
234  (*it)->_colour=White;
235  it=_setOfNode.begin();
236  std::vector< list<Node *> > ret;
237  while(it!=_setOfNode.end())
238  {
239  Node *start(*it); start->_colour=Grey;
240  ret.push_back(list<Node *>());
241  list<Node *>& ll(ret.back());
242  std::queue<Node *> fifo; fifo.push(start);
243  while(!fifo.empty())
244  {
245  Node *cur(fifo.front()); fifo.pop();
246  ll.push_back(cur);
247  //
248  OutGate *og(cur->getOutGate());
249  list<InGate *> og2(og->edSetInGate());
250  for(list<InGate *>::const_iterator it2=og2.begin();it2!=og2.end();it2++)
251  {
252  Node *cur2((*it2)->getNode());
253  if(cur2->_colour==White)
254  {
255  cur2->_colour=Grey;
256  fifo.push(cur2);
257  }
258  }
259  //
260  InGate *ig(cur->getInGate());
261  list<OutGate *> bl(ig->getBackLinks());
262  for(list<OutGate *>::const_iterator it3=bl.begin();it3!=bl.end();it3++)
263  {
264  Node *cur3((*it3)->getNode());
265  if(cur3->_colour==White)
266  {
267  cur3->_colour=Grey;
268  fifo.push(cur3);
269  }
270  }
271  }
272  for(it=_setOfNode.begin();it!=_setOfNode.end() && (*it)->_colour!=White;it++);
273  }
274  return ret;
275 }
virtual std::string YACS::ENGINE::Bloc::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::Proc, and YACS::ENGINE::SalomeProc.

Definition at line 62 of file Bloc.hxx.

62 { return "YACS__ENGINE__Bloc"; }
YACS::Event Bloc::updateStateOnFailedEventFrom ( Node node,
const Executor execInst 
)
protectedvirtual

Notify this bloc that a node has failed.

Parameters
node: node that has emitted the event
Returns
the event to notify to bloc's father

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 406 of file Bloc.cxx.

References YACS::ABORT, areAllSubNodesDone(), areAllSubNodesFinished(), YACS::DONE, YACS::ENGINE::Node::exForwardFailed(), YACS::FAILED, YACS::FINISH, YACS::NOEVENT, and YACS::ENGINE::Node::setState().

407 {
408  node->exForwardFailed();
410  {
412  if(!areAllSubNodesDone()){
414  return YACS::ABORT;
415  }
416  return YACS::FINISH;//notify to father node that 'this' has becomed finished.
417  }
418  return YACS::NOEVENT;
419 }
YACS::Event Bloc::updateStateOnFinishedEventFrom ( Node node)
protectedvirtual
Note
: Runtime called method. Indirectly called by StaticDefinedComposedNode::updateStateFrom which has dispatch to this method 'when event == FINISH'. WARNING Precondition : '_state == Running' and 'node->_father==this'(garanteed by StaticDefinedComposedNode::notifyFrom)

Calls the node's outgate OutGate::exNotifyDone if all nodes are not finished

Implements YACS::ENGINE::ComposedNode.

Definition at line 368 of file Bloc.cxx.

References YACS::ABORT, areAllSubNodesDone(), areAllSubNodesFinished(), DEBTRACE, YACS::DONE, YACS::ENGINE::Node::exForwardFailed(), YACS::ENGINE::Node::exForwardFinished(), YACS::FAILED, YACS::FINISH, YACS::ENGINE::Node::getName(), YACS::NOEVENT, YACS::ENGINE::Node::setState(), and YACS::Exception::what().

369 {
370  DEBTRACE("Bloc::updateStateOnFinishedEventFrom: " << node->getName());
371  //ASSERT(node->_father==this)
373  {
375  if(!areAllSubNodesDone())
376  {
378  return YACS::ABORT;
379  }
380  return YACS::FINISH;//notify to father node that 'this' has becomed finished.
381  }
382  //more job to do in 'this' bloc
383  //Conversion exceptions can be thrown so catch them to control errors
384  try
385  {
386  //notify the finished node to propagate to its following nodes
387  node->exForwardFinished();
388  }
389  catch(YACS::Exception& ex)
390  {
391  //The node has failed to propagate. It must be put in error
392  DEBTRACE("Bloc::updateStateOnFinishedEventFrom: " << ex.what());
393  // notify the node it has failed
394  node->exForwardFailed();
396  return YACS::ABORT;
397  }
398  return YACS::NOEVENT;//no notification to father needed because from father point of view nothing happened.
399 }
void Bloc::updateWithNewFind ( const std::vector< Node * > &  path,
std::map< Node *, std::set< Node * > > &  fastFinder 
)
staticprivate

Internal method : Given a succeful path : updates 'fastFinder'

Definition at line 844 of file Bloc.cxx.

Referenced by appendIfAlreadyFound(), and findAllPathsStartingFrom().

845 {
846  if(path.size()>=3)
847  {
848  vector<Node *>::const_iterator iter=path.begin(); iter++;
849  vector<Node *>::const_iterator iter2=path.end(); iter2-=1;
850  for(;iter!=iter2;iter++)
851  fastFinder[*iter].insert(*(iter+1));
852  }
853 }
void Bloc::verdictForCollapses ( const std::map< Node *, std::list< OutPort * > > &  pool,
InputPort end,
const std::set< Node * > &  candidates,
unsigned char &  alreadyFed,
bool  direction,
LinkInfo info 
)
staticprotected

Part of final step for CF graph anylizing. This is the part of collapses nodes.

Parameters
pool:
end:
candidates:
alreadyFedin/out parameter. Indicates if 'end' ports is already and surely set or fed by an another port.
direction
info: collected information

Definition at line 740 of file Bloc.cxx.

References checkCFLinks(), YACS::ENGINE::LinkInfo::endCollapseTransac(), YACS::ENGINE::ComposedNode::FED_ST, YACS::ENGINE::ComposedNode::FREE_ST, YACS::ENGINE::LinkInfo::pushWarnLink(), YACS::ENGINE::LinkInfo::startCollapseTransac(), YACS::ENGINE::W_BACK_COLLAPSE, YACS::ENGINE::W_BACK_COLLAPSE_AND_USELESS, YACS::ENGINE::W_BACK_COLLAPSE_EL, YACS::ENGINE::W_BACK_COLLAPSE_EL_AND_USELESS, YACS::ENGINE::W_COLLAPSE, YACS::ENGINE::W_COLLAPSE_AND_USELESS, YACS::ENGINE::W_COLLAPSE_EL, and YACS::ENGINE::W_COLLAPSE_EL_AND_USELESS.

Referenced by checkCFLinks().

743 {
744  info.startCollapseTransac();
745  for(set<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
746  {
747  const list<OutPort *>& mySet=(*pool.find(*iter)).second;
748  if(mySet.size()==1)
749  {
750  if(alreadyFed==FREE_ST)
751  info.pushWarnLink(*(mySet.begin()),end,direction ? W_COLLAPSE : W_BACK_COLLAPSE);
752  else if(alreadyFed==FED_ST)
753  info.pushWarnLink(*(mySet.begin()),end,direction ? W_COLLAPSE_AND_USELESS : W_BACK_COLLAPSE_EL_AND_USELESS);
754  }
755  else
756  {
757  if(dynamic_cast<ElementaryNode *>(*iter))
758  {
759  WarnReason reason;
760  if(alreadyFed==FREE_ST)
761  reason=direction ? W_COLLAPSE_EL : W_BACK_COLLAPSE_EL;
762  else if(alreadyFed==FED_ST)
764  for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
765  info.pushWarnLink(*iter2,end,reason);
766  }
767  else
768  {
769  ((ComposedNode *)(*iter))->checkCFLinks(mySet,end,alreadyFed,direction,info);//Thanks to recursive model!
770  WarnReason reason;
771  if(alreadyFed==FREE_ST)
772  reason=direction ? W_COLLAPSE : W_BACK_COLLAPSE;
773  else if(alreadyFed==FED_ST)
775  for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
776  info.pushWarnLink(*iter2,end,reason);
777  }
778  }
779  }
780  if(!candidates.empty())
781  if(alreadyFed==FREE_ST)
782  alreadyFed=FED_ST;
783  info.endCollapseTransac();
784 }
void Bloc::verdictForOkAndUseless1 ( const std::map< Node *, std::list< OutPort * > > &  pool,
InputPort end,
const std::vector< Node * > &  candidates,
unsigned char &  alreadyFed,
bool  direction,
LinkInfo info 
)
staticprotected

Part of final step for CF graph anylizing. This is the part of non collapse nodes.

Parameters
pool:
end:
candidates:
alreadyFedin/out parameter. Indicates if 'end' ports is already and surely set or fed by an another port.
direction
info: collected information

Definition at line 695 of file Bloc.cxx.

References YACS::ENGINE::ComposedNode::FED_ST, YACS::ENGINE::ComposedNode::FREE_ST, YACS::ENGINE::I_BACK, YACS::ENGINE::I_BACK_USELESS, YACS::ENGINE::I_USELESS, YACS::ENGINE::LinkInfo::pushInfoLink(), YACS::ENGINE::LinkInfo::pushWarnLink(), YACS::ENGINE::W_BACK_COLLAPSE_EL, YACS::ENGINE::W_BACK_COLLAPSE_EL_AND_USELESS, YACS::ENGINE::W_COLLAPSE_EL, and YACS::ENGINE::W_COLLAPSE_EL_AND_USELESS.

Referenced by checkCFLinks().

698 {
699  for(vector<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
700  {
701  const list<OutPort *>& mySet=(*pool.find(*iter)).second;
702  if(mySet.size()==1)
703  {
704  if(alreadyFed==FREE_ST)
705  {
706  alreadyFed=FED_ST;//This the final choice. General case !
707  if(!direction)
708  info.pushInfoLink(*(mySet.begin()),end,I_BACK);
709  }
710  else if(alreadyFed==FED_ST)
711  info.pushInfoLink(*(mySet.begin()),end,direction ? I_USELESS : I_BACK_USELESS);//Second or more turn in case of alreadyFed==FREE_ST before call of this method
712  }
713  else
714  {
715  if(dynamic_cast<ElementaryNode *>(*iter))
716  {
717  WarnReason reason;
718  if(alreadyFed==FREE_ST)
719  reason=direction ? W_COLLAPSE_EL : W_BACK_COLLAPSE_EL;
720  else if(alreadyFed==FED_ST)
722  for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
723  info.pushWarnLink(*iter2,end,reason);
724  }
725  else
726  ((ComposedNode *)(*iter))->checkCFLinks(mySet,end,alreadyFed,direction,info);//Thanks to recursive model!
727  }
728  }
729 }
void Bloc::writeDot ( std::ostream &  os) const
virtual

Dump to the input stream a dot representation of the node.

Parameters
os: the input stream

Reimplemented from YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::Proc.

Definition at line 421 of file Bloc.cxx.

References getChildren(), YACS::ENGINE::Node::getColorState(), YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::Node::getId(), YACS::ENGINE::Node::getQualifiedName(), p, and CORBAEngineTest::state.

Referenced by YACS::ENGINE::Proc::writeDot().

422 {
423  os << " subgraph cluster_" << getId() << " {\n" ;
424  list<Node *>nodes=getChildren();
425  for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
426  {
427  (*iter)->writeDot(os);
428  string p=(*iter)->getId();
429  //not connected node
430  if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n";
431  list<Node *>outnodes = (*iter)->getOutNodes();
432  for(list<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
433  {
434  os << p << " -> " << (*itout)->getId() << ";\n";
435  }
436  }
437  os << "}\n" ;
438  os << getId() << "[fillcolor=\"" ;
440  os << getColorState(state);
441  os << "\" label=\"" << "Bloc:" ;
442  os << getQualifiedName() <<"\"];\n";
443 }

Member Data Documentation

std::map<Node *,std::set<Node *> >* YACS::ENGINE::Bloc::_bwLinks
mutableprotected

For internal calculations.

Definition at line 37 of file Bloc.hxx.

Referenced by destructCFComputations(), performCFComputationsOnlyOneLevel(), and ~Bloc().

std::map<Node *,std::set<Node *> >* YACS::ENGINE::Bloc::_fwLinks
mutableprotected

For internal calculations.

Definition at line 35 of file Bloc.hxx.

Referenced by destructCFComputations(), performCFComputationsOnlyOneLevel(), and ~Bloc().


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