Version: 9.16.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)
 Add a child node to the bloc. More...
 
void edRemoveChild (Node *node)
 
std::list< Node * > getChildren () const
 
std::list< Node * > edGetDirectDescendants () const
 
std::vector< std::list< Node * > > splitIntoIndependantGraph () const
 
NodegetChildByShortName (const std::string &name) const
 
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 getWeightRegardingDPL (ComplexWeight *weight)
 
void removeRecursivelyRedundantCL ()
 
void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
 
void fitToPlayGround (const PlayGround *pg)
 
void propagePlayGround (const PlayGround *pg)
 
- 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
 Perform check of deployment consistency of the current graph. More...
 
std::vector< Task * > getNextTasks (bool &isMore)
 
virtual bool isPlacementPredictableB4Run () const =0
 
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)
 Add a dataflow link between two data ports. More...
 
virtual bool edAddDFLink (OutPort *start, InPort *end)
 Connect an OutPort to an InPort and add the necessary control link. More...
 
virtual bool edAddChild (Node *DISOWNnode)
 
virtual void edRemoveChild (Node *node)
 Remove a child node. More...
 
bool edAddLink (OutGate *start, InGate *end)
 Add a controlflow link between two control ports. More...
 
bool edAddCFLink (Node *nodeS, Node *nodeE)
 Add a controlflow link between two nodes. More...
 
void edRemoveCFLink (Node *nodeS, Node *nodeE)
 Remove a controlflow link. More...
 
void edRemoveLink (OutPort *start, InPort *end)
 Remove a dataflow link. More...
 
void edRemoveLink (OutGate *start, InGate *end)
 Remove a controlflow link. More...
 
virtual bool isRepeatedUnpredictablySeveralTimes () const
 
virtual bool isLoop () const
 
virtual std::list< Node * > edGetDirectDescendants () const =0
 
virtual void removeRecursivelyRedundantCL ()
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< Node * > getAllRecursiveNodes ()
 Get all children nodes elementary and composed including this node. More...
 
virtual std::list< Node * > getAllRecursiveConstituents ()
 Idem getAllRecursiveNodes, but this node is NOT included. More...
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
std::string getInPortName (const InPort *) const
 Get the input port name. More...
 
std::string getOutPortName (const OutPort *) const
 
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
 
InputPortgetInputPort (const std::string &name) const
 Get an input port given its name. More...
 
OutputPortgetOutputPort (const std::string &name) const
 Get an output port given its name. More...
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const
 
std::vector< std::pair< OutPort *, InPort * > > getSetOfInternalLinks () const
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const
 
void checkConsistency (LinkInfo &info) const
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const
 
virtual std::string typeName ()
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void checkBasicConsistency () const
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
ComposedNodegetRootNode () const
 
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
 
virtual std::string getMyQualifiedName (const Node *directSon) const
 
NodegetChildByName (const std::string &name) const
 
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
 
void setProperty (const std::string &name, const std::string &value) override
 
std::string getProperty (const std::string &name) override
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void init (bool start=true)
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getState () const
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
void writeDotInFile (const std::string &fileName) const
 
virtual void exUpdateState ()
 Update the node state. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
virtual void getReadyTasks (std::vector< Task * > &tasks)=0
 
virtual std::list< ElementaryNode * > getRecursiveConstituents () const =0
 
virtual std::list< ProgressWeightgetProgressWeight () const =0
 
virtual int getNumberOfInputPorts () const =0
 
virtual int getNumberOfOutputPorts () const =0
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::list< InputPort * > getSetOfInputPort () const =0
 
virtual std::list< OutputPort * > getSetOfOutputPort () const =0
 
virtual std::list< InputPort * > getLocalInputPorts () const =0
 
virtual std::list< OutputPort * > getLocalOutputPorts () const =0
 
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...
 
virtual std::string getInPortName (const InPort *) const =0
 
virtual std::string getOutPortName (const OutPort *) const =0
 
virtual std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const =0
 
virtual std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const =0
 
InPortgetInPort (const std::string &name) const
 
InPropertyPortgetInPropertyPort () const
 
virtual OutPortgetOutPort (const std::string &name) const
 
virtual std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const =0
 
virtual std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const =0
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const =0
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const =0
 
virtual InputPortgetInputPort (const std::string &name) const
 
virtual OutputPortgetOutputPort (const std::string &name) const =0
 
virtual InputDataStreamPortgetInputDataStreamPort (const std::string &name) const =0
 
virtual OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const =0
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
DynParaLoopgetClosestDPLAmongAncestors () const
 
virtual ComposedNodegetRootNode () 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 NodegetChildByName (const std::string &name) const =0
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
virtual void accept (Visitor *visitor)=0
 
virtual int getMaxLevelOfParallelism () const =0
 
virtual void getWeightRegardingDPL (ComplexWeight *weight)=0
 
virtual void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)=0
 
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 typeName ()
 
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 void edUpdateState ()
 update the status of the node More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error 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)
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Scheduler
virtual void init (bool start=true)=0
 
virtual bool isFinished ()=0
 
virtual void exUpdateState ()=0
 
virtual std::string getName () const =0
 
virtual std::string getTaskName (Task *task) const =0
 
virtual std::vector< Task * > getNextTasks (bool &isMore)=0
 
virtual void selectRunnableTasks (std::vector< Task * > &tasks)=0
 
virtual void notifyFrom (const Task *sender, YACS::Event event, const Executor *execInst)=0
 
virtual DeploymentTree getDeploymentTree () const =0
 
virtual bool isPlacementPredictableB4Run () const =0
 
virtual bool isMultiplicitySpecified (unsigned &value) const =0
 
virtual void forceMultiplicity (unsigned value)=0
 
virtual void setProperty (const std::string &name, const std::string &value)=0
 
virtual std::string getProperty (const std::string &name)=0
 
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)
 
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 ()
 
virtual NodegetChildByShortName (const std::string &name) const =0
 
YACS::Event updateStateFrom (Node *node, YACS::Event event, const Executor *execInst)
 Update node state on receiving event from a node. More...
 
virtual YACS::Event updateStateOnStartEventFrom (Node *node)
 Method used to notify the node that a child node has started. More...
 
virtual YACS::Event updateStateOnFinishedEventFrom (Node *node)=0
 
virtual YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
virtual void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
 
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)
 
virtual void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
virtual void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
virtual void checkNoCyclePassingThrough (Node *node)=0
 
void checkInMyDescendance (Node *nodeToTest) const
 Check if a node is in the descendance of this node. More...
 
template<class PORT >
std::string getPortName (const PORT *port) const
 
void checkNoCrossHierachyWith (Node *node) const
 
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
 
virtual 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 =0
 
void solveObviousOrDelegateCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 
virtual void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void performDuplicationOfPlacement (const Node &other)=0
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
virtual void performShallowDuplicationOfPlacement (const Node &other)=0
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
virtual NodesimpleClone (ComposedNode *father, bool editionOnly=true) const =0
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 
virtual void edDisconnectAllLinksWithMe ()
 

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)
 
- 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)
 Splits name globalName in 2 parts using separator. More...
 
- Static Protected Member Functions inherited from YACS::ENGINE::Node
static void checkValidityOfPortName (const std::string &name)
 
static ComposedNodecheckHavingCommonFather (Node *node1, Node *node2)
 

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...
 
- Protected Attributes inherited from YACS::ENGINE::Node
InGate _inGate
 
OutGate _outGate
 
InPropertyPort_inPropertyPort
 
std::string _name
 
ComposedNode_father
 
YACS::StatesForNode _state
 
int _modified
 
std::string _errorDetails
 
int _numId
 
std::string _implementation
 
std::map< std::string, std::string > _propertyMap
 
Node_eventReceiver =nullptr
 

Private Member Functions

std::list< AbstractPoint * > analyzeParallelism () const
 

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)
 Retrieves the lowest common ancestor of 2 nodes. More...
 
static std::string getLowestCommonAncestorStr (const std::string &node1, const std::string &node2)
 
- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
static void checkValidityOfNodeName (const std::string &name)
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Public Attributes inherited from YACS::ENGINE::ComposedNode
static const char SEP_CHAR_BTW_LEVEL [] ="."
 
- Static Public Attributes inherited from YACS::ENGINE::Node
static std::map< int, Node * > idMap
 
- Static Protected Attributes inherited from YACS::ENGINE::ComposedNode
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
 

Detailed Description

Composed node to group elementary and composed nodes.

Definition at line 35 of file Bloc.hxx.

Constructor & Destructor Documentation

◆ Bloc() [1/2]

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

Definition at line 48 of file Bloc.cxx.

49{
50 for(list<Node *>::const_iterator iter=other._setOfNode.begin();iter!=other._setOfNode.end();iter++)
51 _setOfNode.push_back((*iter)->simpleClone(this,editionOnly));
52
53 //CF Linking
54 vector< pair<OutGate *, InGate *> > cfLinksToReproduce=other.getSetOfInternalCFLinks();
55 vector< pair<OutGate *, InGate *> >::iterator iter1=cfLinksToReproduce.begin();
56 for(;iter1!=cfLinksToReproduce.end();iter1++)
57 edAddCFLink(getChildByName(other.getChildName((*iter1).first->getNode())),getChildByName(other.getChildName((*iter1).second->getNode())));
58
59 //Data + DataStream linking
60 vector< pair<OutPort *, InPort *> > linksToReproduce=other.getSetOfInternalLinks();
61 vector< pair<OutPort *, InPort *> >::iterator iter2=linksToReproduce.begin();
62 for(;iter2!=linksToReproduce.end();iter2++)
63 {
64 OutPort* pout = iter2->first;
65 InPort* pin = iter2->second;
66 if(&other == getLowestCommonAncestor(pout->getNode(), pin->getNode()))
67 {
68 edAddLink(getOutPort(other.getPortName(pout)),getInPort(other.getPortName(pin)));
69 }
70 }
71}
std::list< Node * > _setOfNode
Definition: Bloc.hxx:38
std::vector< std::pair< OutGate *, InGate * > > getSetOfInternalCFLinks() const
Definition: Bloc.cxx:350
std::map< Node *, std::set< Node * > > * _bwLinks
For internal calculations.
Definition: Bloc.hxx:42
std::map< Node *, std::set< Node * > > * _fwLinks
For internal calculations.
Definition: Bloc.hxx:40
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
OutPort * getOutPort(const std::string &name) const
std::vector< std::pair< OutPort *, InPort * > > getSetOfInternalLinks() const
std::string getPortName(const PORT *port) const
bool edAddCFLink(Node *nodeS, Node *nodeE)
Add a controlflow link between two nodes.
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
static ComposedNode * getLowestCommonAncestor(Node *node1, Node *node2)
Retrieves the lowest common ancestor of 2 nodes.
InPort * getInPort(const std::string &name) const
Definition: Node.cxx:239
Node * getNode() const
Definition: Port.hxx:46

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().

◆ Bloc() [2/2]

Bloc::Bloc ( const std::string &  name)

Create a Bloc node with a given name.

Parameters
name: the given name

Definition at line 77 of file Bloc.cxx.

78{
79}

◆ ~Bloc()

Bloc::~Bloc ( )
virtual

Definition at line 81 of file Bloc.cxx.

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

References _bwLinks, _fwLinks, and _setOfNode.

Member Function Documentation

◆ accept()

void Bloc::accept ( Visitor visitor)
virtual

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::Proc.

Definition at line 447 of file Bloc.cxx.

448{
449 visitor->visitBloc(this);
450}
virtual void visitBloc(Bloc *node)=0

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

Referenced by fitToPlayGround(), and propagePlayGround().

◆ analyzeParallelism()

std::list< AbstractPoint * > Bloc::analyzeParallelism ( ) const
private

Definition at line 463 of file Bloc.cxx.

464{
465 std::vector< std::list<Node *> > r(splitIntoIndependantGraph());
466 std::list< AbstractPoint * > pts;
467 for(std::vector< std::list<Node *> >::const_iterator it=r.begin();it!=r.end();it++)
468 {
469 SetOfPoints sop(*it);
470 sop.simplify();
471 pts.push_back(sop.getUniqueAndReleaseIt());
472 }
473 return pts;
474}
std::vector< std::list< Node * > > splitIntoIndependantGraph() const
Definition: Bloc.cxx:231

References YACS::ENGINE::SetOfPoints::getUniqueAndReleaseIt(), testCppPluginInvokation::r, YACS::ENGINE::SetOfPoints::simplify(), and splitIntoIndependantGraph().

Referenced by getMaxLevelOfParallelism(), getWeightRegardingDPL(), and partitionRegardingDPL().

◆ appendIfAlreadyFound()

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

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 135 of file Bloc.hxx.

136 {
137 std::map<Node *, std::set<Node *> >::iterator iter=fastFinder.find(node);
138 if(iter==fastFinder.end())
139 return 0;
140 unsigned ret=0;
141 std::vector<std::pair<std::set<Node *>::iterator, std::set<Node *>::iterator > > li;
142 std::pair<std::set<Node *>::iterator, std::set<Node *>::iterator> ipr(((*iter).second).begin(),((*iter).second).end());
143 li.push_back(ipr);
144 std::vector<Node *> work(startRes);
145 std::list< std::vector<Node *> >::iterator where=res.end(); where--;
146 std::list< std::vector<Node *> >::iterator updates=where;
147 while(!li.empty())
148 {
149 if(li.back().first!=li.back().second)
150 {
151 work.push_back(*(li.back().first));
152 if(CFDirectionVisTraits<direction>::getNexts(work.back()).empty())
153 {
154 where=res.insert(where,work);
155 ret++;
156 li.back().first++;
157 work.pop_back();
158 }
159 else
160 {
161 std::set<Node *>& s=fastFinder[*(li.back().first)];
162 std::pair<std::set<Node *>::iterator, std::set<Node *>::iterator> pr(s.begin(),s.end());
163 li.push_back(pr);
164 }
165 }
166 else
167 {
168 work.pop_back();
169 li.pop_back();
170 if(!li.empty())
171 li.back().first++;
172 }
173 }
174 updates--;
175 for(unsigned i=0;i<ret;i++,updates--)
176 updateWithNewFind(*updates,fastFinder);
177 return ret;
178 }
static void updateWithNewFind(const std::vector< Node * > &path, std::map< Node *, std::set< Node * > > &fastFinder)
Definition: Bloc.cxx:869

References yacsorb.CORBAEngineTest::i, and updateWithNewFind().

◆ areAllSubNodesDone()

bool Bloc::areAllSubNodesDone ( ) const
protected

Definition at line 288 of file Bloc.cxx.

289{
290 for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
291 {
292 if((*iter)->_state == YACS::DONE)continue;
293 if((*iter)->_state == YACS::DISABLED)continue;
294 return false;
295 }
296 return true;
297}
@ DONE
Definition: define.hxx:43
@ DISABLED
Definition: define.hxx:50

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

Referenced by updateStateOnFailedEventFrom(), and updateStateOnFinishedEventFrom().

◆ areAllSubNodesFinished()

bool Bloc::areAllSubNodesFinished ( ) const
protected

Definition at line 299 of file Bloc.cxx.

300{
301 for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
302 {
303 if((*iter)->_state == YACS::DONE)continue;
304 if((*iter)->_state == YACS::FAILED)continue;
305 if((*iter)->_state == YACS::DISABLED)continue;
306 if((*iter)->_state == YACS::ERROR)continue;
307 if((*iter)->_state == YACS::INTERNALERR)continue;
308 return false;
309 }
310 return true;
311}
@ FAILED
Definition: define.hxx:51
@ INTERNALERR
Definition: define.hxx:49
@ ERROR
Definition: define.hxx:52

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

Referenced by updateStateOnFailedEventFrom(), and updateStateOnFinishedEventFrom().

◆ areLinked()

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 650 of file Bloc.cxx.

651{
652 set<Node *>& nexts=fw ? (*_fwLinks)[start] : (*_bwLinks)[start];
653 return nexts.find(end)!=nexts.end();
654}

Referenced by checkControlDependancy().

◆ arePossiblyRunnableAtSameTime()

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 664 of file Bloc.cxx.

665{
666 set<Node *>& nexts=(*_fwLinks)[start];
667 set<Node *>& preds=(*_bwLinks)[start];
668 return nexts.find(end)==nexts.end() && preds.find(end)==preds.end();
669}

Referenced by checkControlDependancy().

◆ checkCFLinks()

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 679 of file Bloc.cxx.

680{
681 if(alreadyFed==FREE_ST || alreadyFed==FED_ST)
682 {
683 map<Node *,list <OutPort *> > classPerNodes;
684 for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
685 classPerNodes[isInMyDescendance((*iter1)->getNode())].push_back(*iter1);
686 set<Node *> allNodes;
687 for(map<Node *,list <OutPort *> >::iterator iter2=classPerNodes.begin();iter2!=classPerNodes.end();iter2++)
688 allNodes.insert((*iter2).first);
689 vector<Node *> okAndUseless1,useless2;
690 seekOkAndUseless1(okAndUseless1,allNodes);
691 seekUseless2(useless2,allNodes);//after this point allNodes contains collapses
692 verdictForOkAndUseless1(classPerNodes,end,okAndUseless1,alreadyFed,direction,info);
693 verdictForCollapses(classPerNodes,end,allNodes,alreadyFed,direction,info);
694 verdictForOkAndUseless1(classPerNodes,end,useless2,alreadyFed,direction,info);
695 }
696 else if(alreadyFed==FED_DS_ST)
697 for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
698 info.pushErrLink(*iter1,end,E_COLLAPSE_DFDS);
699}
void seekOkAndUseless1(std::vector< Node * > &okAndUseless1, std::set< Node * > &allNodes) const
Definition: Bloc.cxx:816
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)
Definition: Bloc.cxx:720
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)
Definition: Bloc.cxx:765
void seekUseless2(std::vector< Node * > &useless2, std::set< Node * > &allNodes) const
Definition: Bloc.cxx:842
static const unsigned char FREE_ST
static const unsigned char FED_ST
static const unsigned char FED_DS_ST
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
void pushErrLink(OutPort *semStart, InPort *end, ErrReason reason)
Definition: LinkInfo.cxx:86
Base class for all nodes.
Definition: Node.hxx:70

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(), and verdictForOkAndUseless1().

◆ checkControlDependancy()

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 614 of file Bloc.cxx.

619{
620 if(!cross)
621 {
622 Node *startN=isInMyDescendance(start->getNode());
623 Node *endN=isInMyDescendance(end->getNode());
624 if(startN==endN)
625 bw[(ComposedNode *)this].push_back(start);
626 else if(areLinked(startN,endN,true))
627 fw[(ComposedNode *)this].push_back(start);
628 else
629 if(areLinked(startN,endN,false))
630 bw[(ComposedNode *)this].push_back(start);
631 else
632 info.pushErrLink(start,end,E_UNPREDICTABLE_FED);
633 }
634 else//DFDS detected
636 fwCross.push_back(start);
637 else
639}
bool areLinked(Node *start, Node *end, bool fw) const
Check if two nodes are linked.
Definition: Bloc.cxx:650
bool arePossiblyRunnableAtSameTime(Node *start, Node *end) const
Check if two nodes can run in parallel.
Definition: Bloc.cxx:664
Base class for all composed nodes.
@ E_UNPREDICTABLE_FED
Definition: LinkInfo.hxx:74
@ E_DS_LINK_UNESTABLISHABLE
Definition: LinkInfo.hxx:71

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().

◆ checkNoCyclePassingThrough()

void Bloc::checkNoCyclePassingThrough ( Node node)
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 338 of file Bloc.cxx.

339{
340 set<Node *> currentNodesToTest;
341 //don't insert node to test in set.
342 //If it is present after insertion of connected nodes we have a loop
343 //collect all connected nodes
344 insertNodeChildrenInSet(node,currentNodesToTest);
345 //try to insert node
346 if(!(currentNodesToTest.insert(node)).second)
347 throw Exception("Cycle has been detected",1);
348}
bool insertNodeChildrenInSet(Node *node, std::set< Node * > &nodeSet)
Definition: Bloc.cxx:321

References insertNodeChildrenInSet().

◆ destructCFComputations()

void Bloc::destructCFComputations ( LinkInfo info) const
protectedvirtual

destroy recursively all results of initial computations.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 594 of file Bloc.cxx.

595{
597 delete _fwLinks; _fwLinks=0;
598 delete _bwLinks; _bwLinks=0;
599}
virtual void destructCFComputations(LinkInfo &info) const
destroy recursively all results of initial computations.

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

Referenced by removeRecursivelyRedundantCL().

◆ edAddChild()

bool Bloc::edAddChild ( Node node)
virtual

Add a child node to the bloc.

Parameters
nodethe 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 176 of file Bloc.cxx.

177{
179 {
180 if(node->_father==this)
181 return false;
182 else
183 {
184 string what = "Bloc::edAddChild : node "; what += node->getName();
185 what += " is already grand children of node";
186 throw Exception(what);
187 }
188 }
189
190 if(node->_father)
191 {
192 string what = "Bloc::edAddChild: node is not orphan: "; what += node->getName();
193 throw Exception(what);
194 }
195
197
198 if(isNameAlreadyUsed(node->getName()))
199 {
200 string what("Bloc::edAddChild : name "); what+=node->getName();
201 what+=" already exists in the scope of "; what+=_name;
202 throw Exception(what);
203 }
204
205 node->_father=this;
206 _setOfNode.push_back(node);
207 //should we also set _modified flag for node ??
208 ComposedNode *iter=node->_father;
209 //set the _modified flag so that latter on edUpdateState (eventually called by isValid) refresh state
210 //better call it at end
211 modified();
212 return true;
213}
bool isNameAlreadyUsed(const std::string &name) const
Definition: Bloc.cxx:313
void checkNoCrossHierachyWith(Node *node) const
bool isNodeAlreadyAggregated(const Node *node) const
Check that Node 'node' is already a direct son of this.
std::string _name
Definition: Node.hxx:89
ComposedNode * _father
Definition: Node.hxx:90
const std::string & getName() const
Definition: Node.hxx:125
virtual void modified()
Sets Node in modified state and its father if it exists.
Definition: Node.cxx:805

References YACS::ENGINE::Node::_father, YACS::ENGINE::Node::_name, _setOfNode, YACS::ENGINE::ComposedNode::checkNoCrossHierachyWith(), YACS::ENGINE::Node::getName(), isNameAlreadyUsed(), YACS::ENGINE::ComposedNode::isNodeAlreadyAggregated(), and YACS::ENGINE::Node::modified().

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

◆ edGetDirectDescendants()

std::list< Node * > YACS::ENGINE::Bloc::edGetDirectDescendants ( ) const
inlinevirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 58 of file Bloc.hxx.

58{ return _setOfNode; }

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

◆ edRemoveChild()

void Bloc::edRemoveChild ( Node node)
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 220 of file Bloc.cxx.

221{
223 list<Node *>::iterator iter=find(_setOfNode.begin(),_setOfNode.end(),node);
224 if(iter!=_setOfNode.end())
225 {
226 _setOfNode.erase(iter);
227 modified();
228 }
229}
virtual void edRemoveChild(Node *node)
Remove a child node.

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

◆ exUpdateState()

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 153 of file Bloc.cxx.

154{
155 if(_state == YACS::DISABLED)return;
156 if(_state == YACS::DONE)return;
157 if(_inGate.exIsReady())
158 {
160 for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
161 if((*iter)->exIsControlReady())
162 (*iter)->exUpdateState();
163 }
164}
bool exIsReady() const
Definition: InGate.cxx:126
InGate _inGate
Definition: Node.hxx:86
void setState(YACS::StatesForNode theState)
Sets the given state for node.
Definition: Node.cxx:652
YACS::StatesForNode _state
Definition: Node.hxx:91
@ ACTIVATED
Definition: define.hxx:41

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().

◆ findAllNodesStartingFrom()

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 181 of file Bloc.hxx.

183 {
184 std::list< std::vector<Node *> > li;
185 findAllPathsStartingFrom<direction>(start,li,accelStr);
186 for(std::list< std::vector<Node *> >::const_iterator iter=li.begin();iter!=li.end();iter++)
187 for(std::vector<Node *>::const_iterator iter2=(*iter).begin()+1;iter2!=(*iter).end();iter2++)
188 result.insert(*iter2);
189 if(direction)
190 findUselessLinksIn(li,info);
191 }
static void findUselessLinksIn(const std::list< std::vector< Node * > > &res, LinkInfo &info)
Definition: Bloc.cxx:883

References findUselessLinksIn().

Referenced by YACS::ENGINE::BagPoint::expandNonSimpleCaseOn().

◆ findAllPathsStartingFrom()

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 201 of file Bloc.hxx.

203 {
205 Node *current=start;
206 int caseId=0;
207 int idInCase=0;
208 vec.push_back(std::vector<Node *>());
209 typename CFDirectionVisTraits<direction>::Iterator iter;
210 std::list< std::vector<Node *> >::iterator curLine=vec.begin();
211 while(start->_colour!=YACS::Black)
212 {
213 (*curLine).push_back(current);
214 idInCase++;
215 //
216 if(CFDirectionVisTraits<direction>::getNexts(current).empty())
217 {
218
219 vec.push_back(std::vector<Node *>((*curLine)));
220 updateWithNewFind(*curLine,accelStr);
221 current->_colour=YACS::Black;
222 curLine++;
223 if(idInCase>1)
224 {
225 idInCase-=2;
226 current=(*curLine)[idInCase];
227 (*curLine).pop_back();
228 (*curLine).pop_back();
229 }
230 continue;
231 }
232 if(current->_colour==YACS::Black)
233 {
234 appendIfAlreadyFound<direction>(vec,(*curLine),current,accelStr);
235 curLine=vec.end(); curLine--;
236 current->_colour=YACS::Black;
237 if(idInCase>1)
238 {
239 idInCase-=2;
240 current=(*curLine)[idInCase];
241 (*curLine).pop_back();
242 (*curLine).pop_back();
243 }
244 continue;
245 }
246 for(iter=CFDirectionVisTraits<direction>::getNexts(current).begin();iter!=CFDirectionVisTraits<direction>::getNexts(current).end();iter++)
247 if(!(*iter).second)
248 break;
249 if(iter==CFDirectionVisTraits<direction>::getNexts(current).end())
250 {//Fail this branch should be forgotten go rev
251 current->_colour=YACS::Black;
252 (*curLine).pop_back();
253 if(idInCase>1)
254 {
255 idInCase-=2;
256 current=(*curLine)[idInCase];
257 (*curLine).pop_back();
258 }
259 }
260 else
261 {
262 //Nothing to signal continuing in this direction hoping to find
263 current=(*iter).first->getNode();
264 (*iter).second=true;
265 }
266 }
267 vec.pop_back();
268 }
void initComputation() const
Definition: Bloc.cxx:701
Node(const std::string &name)
Definition: Node.cxx:69
@ Black
Definition: define.hxx:30

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

◆ findUselessLinksIn()

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 883 of file Bloc.cxx.

884{
885 unsigned maxSize=0;
886 list< vector<Node *> >::const_iterator whereToPeerAt;
887 for(list< vector<Node *> >::const_iterator iter=res.begin();iter!=res.end();iter++)
888 if((*iter).size()>maxSize)
889 {
890 maxSize=(*iter).size();
891 whereToPeerAt=iter;
892 }
893 //
894 if(maxSize>1)
895 {
896 vector<Node *>::const_iterator iter2=(*whereToPeerAt).begin();
897 map<Node *,bool>::iterator iter4;
898 set<Node *> searcher(iter2+1,(*whereToPeerAt).end());//to boost research
899 for(;iter2!=((*whereToPeerAt).end()-2);iter2++)
900 {
901 list< pair<InGate *,bool> >& nexts=(*iter2)->getOutGate()->edMapInGate();
902 for(list< pair<InGate *,bool> >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++)
903 if((*iter4).first->getNode()!=*(iter2+1))
904 if(searcher.find((*iter4).first->getNode())!=searcher.end())
905 info.pushUselessCFLink(*iter2,(*iter4).first->getNode());
906 searcher.erase(*iter2);
907 }
908 }
909}
void pushUselessCFLink(Node *start, Node *end)
Definition: LinkInfo.cxx:107

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

Referenced by findAllNodesStartingFrom().

◆ fitToPlayGround()

void Bloc::fitToPlayGround ( const PlayGround pg)

Definition at line 31 of file Bloc_impl.cxx.

32{
33 static const char MSG[]="Bloc::fitToPlayGround : Not implemented yet for this type of node !";
34 class MyVisitor : public Visitor
35 {
36 public:
37 MyVisitor(ComposedNode *root):Visitor(root),_lev(0),_max_lev(0) { }
38 void visitBloc(Bloc *node) { node->ComposedNode::accept(this); }
39 void visitElementaryNode(ElementaryNode *node) { }
40 void visitForEachLoop(ForEachLoop *node)
41 {
42 _max_lev=std::max(_max_lev,_lev);
43 {
44 _lev++;
45 node->ComposedNode::accept(this);
46 _lev--;
47 }
48 node->edGetNbOfBranchesPort()->edInit(1);
49 if(_lev==_max_lev)
50 {
51 _fes.push_back(node);// locate all leaves ForEach
52 }
53 if(_lev==0)
54 _max_lev=0;
55 }
56 void visitForEachLoopDyn(ForEachLoopDyn *node) { throw YACS::Exception(MSG); }
57 void visitOptimizerLoop(OptimizerLoop *node) { throw YACS::Exception(MSG); }
58 void visitDynParaLoop(DynParaLoop *node) { throw YACS::Exception(MSG); }
59 void visitForLoop(ForLoop *node) { throw YACS::Exception(MSG); }
60 void visitInlineNode(InlineNode *node)
61 {
62 Container *cont(node->getContainer());
63 HomogeneousPoolContainer *cont2(dynamic_cast<HomogeneousPoolContainer *>(cont));
64 if(!cont2)
65 return ;
66 _cont.push_back(cont2);
67 _cont2.insert(cont2);
68 }
69 void visitInlineFuncNode(InlineFuncNode *node) { throw YACS::Exception(MSG); }
70 void visitLoop(Loop *node) { throw YACS::Exception(MSG); }
71 void visitProc(Proc *node) { node->ComposedNode::accept(this); }
72 void visitServiceNode(ServiceNode *node) { throw YACS::Exception(MSG); }
73 void visitServerNode(ServerNode *node) { throw YACS::Exception(MSG); }
74 void visitServiceInlineNode(ServiceInlineNode *node) { throw YACS::Exception(MSG); }
75 void visitSwitch(Switch *node) { throw YACS::Exception(MSG); }
76 void visitWhileLoop(WhileLoop *node) { throw YACS::Exception(MSG); }
77 void visitPresetNode(DataNode *node) { throw YACS::Exception(MSG); }
78 void visitOutNode(DataNode *node) { throw YACS::Exception(MSG); }
79 void visitStudyInNode(DataNode *node) { throw YACS::Exception(MSG); }
80 void visitStudyOutNode(DataNode *node) { throw YACS::Exception(MSG); }
81 public:
82 std::list<ForEachLoop *> _fes;
83 std::list< HomogeneousPoolContainer *> _cont;
84 std::set< HomogeneousPoolContainer * > _cont2;
85 int _lev;
86 int _max_lev;
87 };
89 std::map<ComposedNode *,YACS::BASES::AutoRefCnt<PartDefinition> > zeMap;
90 MyVisitor vis(this);
91 this->accept(&vis);
92 for(std::list<ForEachLoop *>::const_iterator it=vis._fes.begin();it!=vis._fes.end();it++)
93 (*it)->edGetNbOfBranchesPort()->edInit(1);
96 throw YACS::Exception("Bloc::fitToPlayGround : Not enough cores available to run the calculation !");
97 this->partitionRegardingDPL(pd,zeMap);
98 this->accept(&vis);
99 for(std::list<ForEachLoop *>::const_iterator it=vis._fes.begin();it!=vis._fes.end();it++)
100 {
101 std::map<ComposedNode *,YACS::BASES::AutoRefCnt<PartDefinition> >::iterator it2(zeMap.find(*it));
102 if(it2==zeMap.end())
103 throw YACS::Exception("Bloc::fitToPlayGround : internal error !");
104 int maxLev((*it)->getExecNode()->getMaxLevelOfParallelism());
105 int a((*it2).second->getNumberOfCoresConsumed());
106 int res(a/maxLev);
107 (*it)->edGetNbOfBranchesPort()->edInit(res);
108 }
109 for(std::set< HomogeneousPoolContainer * >::const_iterator it=vis._cont2.begin();it!=vis._cont2.end();it++)
110 (*it)->setSizeOfPool(pg->getNumberOfWorkers((*it)->getNumberOfCoresPerWorker()));
111 //FIXME
112}
constexpr char MSG[]
Definition: Bloc_impl.cxx:114
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36
void removeRecursivelyRedundantCL()
Definition: Bloc.cxx:483
void accept(Visitor *visitor)
Definition: Bloc.cxx:447
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
Definition: Bloc.cxx:495
int getMaxLevelOfParallelism() const
Definition: Bloc.cxx:456
Class for data parameters specification.
Definition: DataNode.hxx:38
Base class for dynamically (fully or semifully) built graphs.
Definition: DynParaLoop.hxx:41
InputPort * edGetNbOfBranchesPort()
Definition: DynParaLoop.hxx:83
Base class for all calculation nodes.
Loop node for parametric calculation.
Class for for loop node.
Definition: ForLoop.hxx:33
Class for calculation node (function) inlined (and executed) in the schema.
Definition: InlineNode.hxx:93
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
virtual Container * getContainer()
Definition: InlineNode.cxx:100
void edInit(T value)
Definition: InputPort.hxx:129
Base class for loop node.
Definition: Loop.hxx:147
class to build optimization loops
int getNumberOfCoresAvailable() const
Definition: PlayGround.cxx:130
int getNumberOfWorkers(int nbCoresPerWorker) const
Definition: PlayGround.cxx:579
Base class for all schema objects.
Definition: Proc.hxx:44
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
Control node that emulates the C switch.
Definition: Switch.hxx:85
Class for a while loop.
Definition: WhileLoop.hxx:39

References gui.CONNECTOR::a, accept(), YACS::ENGINE::DynParaLoop::edGetNbOfBranchesPort(), YACS::ENGINE::InputPort::edInit(), YACS::ENGINE::InlineNode::getContainer(), getMaxLevelOfParallelism(), YACS::ENGINE::PlayGround::getNumberOfCoresAvailable(), YACS::ENGINE::PlayGround::getNumberOfWorkers(), MSG, partitionRegardingDPL(), removeRecursivelyRedundantCL(), and YACS::ENGINE::Node::Visitor.

◆ getChildByShortName()

Node * Bloc::getChildByShortName ( const std::string &  name) const
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 279 of file Bloc.cxx.

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

References _setOfNode, and YACS::ENGINE::ComposedNode::getName().

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

◆ getChildren()

std::list< Node * > YACS::ENGINE::Bloc::getChildren ( ) const
inline

◆ getMaxLevelOfParallelism()

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 456 of file Bloc.cxx.

457{
458 std::list< AbstractPoint * > pts(analyzeParallelism());
459 ForkBlocPoint fbp(pts,NULL);
460 return fbp.getMaxLevelOfParallelism();
461}
std::list< AbstractPoint * > analyzeParallelism() const
Definition: Bloc.cxx:463

References analyzeParallelism(), and YACS::ENGINE::ForkBlocPoint::getMaxLevelOfParallelism().

Referenced by fitToPlayGround().

◆ getNumberOfCFLinks()

int Bloc::getNumberOfCFLinks ( ) const

Definition at line 116 of file Bloc.cxx.

117{
118 int ret=0;
119 for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
120 ret+=(*iter)->getOutGate()->getNbOfInGatesConnected();
121 return ret;
122}

References _setOfNode.

◆ getReadyTasks()

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 133 of file Bloc.cxx.

134{
135 /*
136 * ComposedNode state goes to ACTIVATED when one of its child has been ACTIVATED
137 * To change this uncomment the following line
138 * Then the father node will go to ACTIVATED state before its child node
139 */
142 for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
143 (*iter)->getReadyTasks(tasks);
144}
@ TOACTIVATE
Definition: define.hxx:40

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

◆ getSetOfInternalCFLinks()

std::vector< std::pair< OutGate *, InGate * > > Bloc::getSetOfInternalCFLinks ( ) const
protected

Definition at line 350 of file Bloc.cxx.

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

References _setOfNode.

Referenced by Bloc().

◆ getWeightRegardingDPL()

void Bloc::getWeightRegardingDPL ( ComplexWeight weight)
virtual

Implements YACS::ENGINE::Node.

Definition at line 476 of file Bloc.cxx.

477{
478 std::list< AbstractPoint * > pts(analyzeParallelism());
479 ForkBlocPoint fbp(pts,NULL);
480 fbp.getWeightRegardingDPL(weight);
481}

References analyzeParallelism(), and YACS::ENGINE::ForkBlocPoint::getWeightRegardingDPL().

◆ init()

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 95 of file Bloc.cxx.

96{
97 Node::init(start);
98 for(list<Node *>::iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
99 (*iter)->init(start);
100}
virtual void init(bool start=true)
Definition: Node.cxx:102

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

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

◆ initComputation()

void Bloc::initComputation ( ) const
protected

Definition at line 701 of file Bloc.cxx.

702{
703 for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
704 {
705 (*iter)->_colour=White;
706 (*iter)->getInGate()->exReset();
707 (*iter)->getOutGate()->exReset();
708 }
709}
@ White
Definition: define.hxx:28

References _setOfNode, and YACS::White.

Referenced by findAllPathsStartingFrom(), and removeRecursivelyRedundantCL().

◆ isFinished()

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 107 of file Bloc.cxx.

108{
109 if(_state==YACS::DONE)return true;
110 if(_state==YACS::ERROR)return true;
111 if(_state==YACS::FAILED)return true;
112 if(_state==YACS::DISABLED)return true;
113 return false;
114}

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

◆ isNameAlreadyUsed()

bool Bloc::isNameAlreadyUsed ( const std::string &  name) const
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 313 of file Bloc.cxx.

314{
315 for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
316 if((*iter)->getName()==name)
317 return true;
318 return false;
319}

References _setOfNode.

Referenced by edAddChild().

◆ partitionRegardingDPL()

void Bloc::partitionRegardingDPL ( const PartDefinition pd,
std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &  zeMap 
)
virtual

Implements YACS::ENGINE::Node.

Definition at line 495 of file Bloc.cxx.

496{
497 if(!pd)
498 throw Exception("Bloc::partitionRegardingDPL : NULL pointer !");
499 std::list< AbstractPoint * > pts(analyzeParallelism());
500 ForkBlocPoint fbp(pts,NULL);
501 fbp.partitionRegardingDPL(pd,zeMap);
502}

References analyzeParallelism(), and YACS::ENGINE::ForkBlocPoint::partitionRegardingDPL().

Referenced by fitToPlayGround().

◆ performCFComputations()

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 588 of file Bloc.cxx.

589{
592}
void performCFComputationsOnlyOneLevel(LinkInfo &info) const
Definition: Bloc.cxx:504
virtual void performCFComputations(LinkInfo &info) const
perform recursively all CF computations.

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

◆ performCFComputationsOnlyOneLevel()

void Bloc::performCFComputationsOnlyOneLevel ( LinkInfo info) const
protected

Definition at line 504 of file Bloc.cxx.

505{
506 delete _fwLinks;//Normally useless
507 delete _bwLinks;//Normally useless
508 _fwLinks=new map<Node *,set<Node *> >;
509 _bwLinks=new map<Node *,set<Node *> >;
510
511 //a set to store all CF links : used to find fastly if two nodes are connected
512 std::set< std::pair< Node*, Node* > > links;
513
514 for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
515 {
516 Node* n1=*iter;
517 std::list<InGate *> ingates=n1->getOutGate()->edSetInGate();
518 for(std::list<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
519 {
520 //CF link : n1 -> (*it2)->getNode()
521 Node* n2=(*it2)->getNode();
522 links.insert(std::pair< Node*, Node* >(n1,n2));
523 std::set<Node *> bwn1=(*_bwLinks)[n1];
524 std::set<Node *> fwn1=(*_fwLinks)[n1];
525 std::set<Node *> fwn2=(*_fwLinks)[n2];
526 std::set<Node *> bwn2=(*_bwLinks)[n2];
527 std::pair<std::set<Node*>::iterator,bool> ret;
528 for(std::set<Node *>::const_iterator iter2=bwn1.begin();iter2!=bwn1.end();iter2++)
529 {
530 for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
531 {
532 ret=(*_fwLinks)[*iter2].insert(*it3);
533 if(ret.second==false)
534 {
535 //dependency already exists (*iter2) -> (*it3) : if a direct link exists it's a useless one
536 if(links.find(std::pair< Node*, Node* >(*iter2,*it3)) != links.end())
537 info.pushUselessCFLink(*iter2,*it3);
538 }
539 }
540 ret=(*_fwLinks)[*iter2].insert(n2);
541 if(ret.second==false)
542 {
543 //dependency already exists (*iter2) -> n2 : if a direct link exists it's a useless one
544 if(links.find(std::pair< Node*, Node* >(*iter2,n2)) != links.end())
545 info.pushUselessCFLink(*iter2,n2);
546 }
547 }
548 for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
549 {
550 ret=(*_fwLinks)[n1].insert(*it3);
551 if(ret.second==false)
552 {
553 //dependency already exists n1 -> *it3 : if a direct link exists it's a useless one
554 if(links.find(std::pair< Node*, Node* >(n1,*it3)) != links.end())
555 info.pushUselessCFLink(n1,*it3);
556 }
557 }
558 ret=(*_fwLinks)[n1].insert(n2);
559 if(ret.second==false)
560 {
561 //dependency already exists n1 -> n2 : it's a useless link
562 info.pushUselessCFLink(n1,n2);
563 }
564
565 for(std::set<Node *>::const_iterator iter2=fwn2.begin();iter2!=fwn2.end();iter2++)
566 {
567 (*_bwLinks)[*iter2].insert(bwn1.begin(),bwn1.end());
568 (*_bwLinks)[*iter2].insert(n1);
569 }
570 (*_bwLinks)[n2].insert(bwn1.begin(),bwn1.end());
571 (*_bwLinks)[n2].insert(n1);
572 }
573 }
574}
OutGate * getOutGate()
Definition: Node.hxx:124
std::list< InGate * > edSetInGate() const
Definition: OutGate.cxx:112

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

Referenced by performCFComputations(), and removeRecursivelyRedundantCL().

◆ propagePlayGround()

void Bloc::propagePlayGround ( const PlayGround pg)

Definition at line 152 of file Bloc_impl.cxx.

153{
154 MyVisitorPropagate vis(this);
155 this->accept(&vis);
156 for(auto cont : vis._cont2)
157 cont->assignPG(pg);
158}

References MyVisitorPropagate::_cont2, and accept().

◆ removeRecursivelyRedundantCL()

void Bloc::removeRecursivelyRedundantCL ( )
virtual

This method recursively all redundant control links in this.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 483 of file Bloc.cxx.

484{
489 std::set< std::pair<Node *, Node *> > linksToKill(info.getInfoUselessLinks());
490 for(std::set< std::pair<Node *, Node *> >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++)
491 edRemoveCFLink((*it).first,(*it).second);
493}
void destructCFComputations(LinkInfo &info) const
destroy recursively all results of initial computations.
Definition: Bloc.cxx:594
void edRemoveCFLink(Node *nodeS, Node *nodeE)
Remove a controlflow link.
virtual void removeRecursivelyRedundantCL()
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83

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

Referenced by fitToPlayGround().

◆ seekOkAndUseless1()

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 816 of file Bloc.cxx.

817{
818 set<Node *>::iterator iter=allNodes.begin();
819 while(iter!=allNodes.end())
820 {
821 set<Node *>& whereToFind=(*_bwLinks)[*iter];
822 std::set<Node *>::iterator iter2;
823 for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
824 if((*iter)!=(*iter2))
825 if(whereToFind.find(*iter2)==whereToFind.end())
826 break;
827 if(iter2!=allNodes.end())
828 iter++;
829 else
830 {
831 okAndUseless1.push_back((*iter));
832 allNodes.erase(iter);
833 iter=allNodes.begin();
834 }
835 }
836}

Referenced by checkCFLinks().

◆ seekUseless2()

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 842 of file Bloc.cxx.

843{
844 set<Node *>::iterator iter=allNodes.begin();
845 while(iter!=allNodes.end())
846 {
847 set<Node *>& whereToFind=(*_fwLinks)[*iter];
848 std::set<Node *>::iterator iter2;
849 for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
850 if((*iter)!=(*iter2))
851 if(whereToFind.find(*iter2)==whereToFind.end())
852 break;
853 if(iter2!=allNodes.end())
854 {
855 iter++;
856 }
857 else
858 {
859 useless2.push_back((*iter));
860 allNodes.erase(iter);
861 iter=allNodes.begin();
862 }
863 }
864}

Referenced by checkCFLinks().

◆ simpleClone()

Node * Bloc::simpleClone ( ComposedNode father,
bool  editionOnly = true 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 124 of file Bloc.cxx.

125{
126 return new Bloc(*this,father,editionOnly);
127}

References YACS::ENGINE::ComposedNode::Bloc.

◆ splitIntoIndependantGraph()

std::vector< std::list< Node * > > Bloc::splitIntoIndependantGraph ( ) const

Definition at line 231 of file Bloc.cxx.

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

References YACS::ENGINE::Node::_colour, _setOfNode, YACS::ENGINE::OutGate::edSetInGate(), YACS::ENGINE::InGate::getBackLinks(), YACS::ENGINE::Node::getInGate(), YACS::ENGINE::Node::getOutGate(), YACS::Grey, and YACS::White.

Referenced by analyzeParallelism().

◆ typeName()

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 67 of file Bloc.hxx.

67{ return "YACS__ENGINE__Bloc"; }

◆ updateStateOnFailedEventFrom()

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 408 of file Bloc.cxx.

409{
410 node->exForwardFailed();
412 {
414 if(!areAllSubNodesDone()){
416 return YACS::ABORT;
417 }
418 return YACS::FINISH;//notify to father node that 'this' has becomed finished.
419 }
420 return YACS::NOEVENT;
421}
bool areAllSubNodesFinished() const
Definition: Bloc.cxx:299
bool areAllSubNodesDone() const
Definition: Bloc.cxx:288
virtual void exForwardFailed()
Definition: Node.cxx:378
@ ABORT
Definition: define.hxx:60
@ NOEVENT
Definition: define.hxx:57
@ FINISH
Definition: define.hxx:59

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

◆ updateStateOnFinishedEventFrom()

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 370 of file Bloc.cxx.

371{
372 DEBTRACE("Bloc::updateStateOnFinishedEventFrom: " << node->getName());
373 //ASSERT(node->_father==this)
375 {
377 if(!areAllSubNodesDone())
378 {
380 return YACS::ABORT;
381 }
382 return YACS::FINISH;//notify to father node that 'this' has becomed finished.
383 }
384 //more job to do in 'this' bloc
385 //Conversion exceptions can be thrown so catch them to control errors
386 try
387 {
388 //notify the finished node to propagate to its following nodes
389 node->exForwardFinished();
390 }
391 catch(YACS::Exception& ex)
392 {
393 //The node has failed to propagate. It must be put in error
394 DEBTRACE("Bloc::updateStateOnFinishedEventFrom: " << ex.what());
395 // notify the node it has failed
396 node->exForwardFailed();
398 return YACS::ABORT;
399 }
400 return YACS::NOEVENT;//no notification to father needed because from father point of view nothing happened.
401}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual void exForwardFinished()
Definition: Node.cxx:386

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

◆ updateWithNewFind()

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 869 of file Bloc.cxx.

870{
871 if(path.size()>=3)
872 {
873 vector<Node *>::const_iterator iter=path.begin(); iter++;
874 vector<Node *>::const_iterator iter2=path.end(); iter2-=1;
875 for(;iter!=iter2;iter++)
876 fastFinder[*iter].insert(*(iter+1));
877 }
878}

Referenced by appendIfAlreadyFound(), and findAllPathsStartingFrom().

◆ verdictForCollapses()

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 765 of file Bloc.cxx.

768{
770 for(set<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
771 {
772 const list<OutPort *>& mySet=(*pool.find(*iter)).second;
773 if(mySet.size()==1)
774 {
775 if(alreadyFed==FREE_ST)
776 info.pushWarnLink(*(mySet.begin()),end,direction ? W_COLLAPSE : W_BACK_COLLAPSE);
777 else if(alreadyFed==FED_ST)
778 info.pushWarnLink(*(mySet.begin()),end,direction ? W_COLLAPSE_AND_USELESS : W_BACK_COLLAPSE_EL_AND_USELESS);
779 }
780 else
781 {
782 if(dynamic_cast<ElementaryNode *>(*iter))
783 {
784 WarnReason reason;
785 if(alreadyFed==FREE_ST)
786 reason=direction ? W_COLLAPSE_EL : W_BACK_COLLAPSE_EL;
787 else if(alreadyFed==FED_ST)
789 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
790 info.pushWarnLink(*iter2,end,reason);
791 }
792 else
793 {
794 ((ComposedNode *)(*iter))->checkCFLinks(mySet,end,alreadyFed,direction,info);//Thanks to recursive model!
795 WarnReason reason;
796 if(alreadyFed==FREE_ST)
797 reason=direction ? W_COLLAPSE : W_BACK_COLLAPSE;
798 else if(alreadyFed==FED_ST)
800 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
801 info.pushWarnLink(*iter2,end,reason);
802 }
803 }
804 }
805 if(!candidates.empty())
806 if(alreadyFed==FREE_ST)
807 alreadyFed=FED_ST;
808 info.endCollapseTransac();
809}
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
Check control flow links.
Definition: Bloc.cxx:679
void pushWarnLink(OutPort *semStart, InPort *end, WarnReason reason)
Definition: LinkInfo.cxx:76
@ W_COLLAPSE_EL_AND_USELESS
Definition: LinkInfo.hxx:59
@ W_BACK_COLLAPSE_AND_USELESS
Definition: LinkInfo.hxx:61
@ W_BACK_COLLAPSE_EL
Definition: LinkInfo.hxx:62
@ W_BACK_COLLAPSE_EL_AND_USELESS
Definition: LinkInfo.hxx:63
@ W_COLLAPSE_AND_USELESS
Definition: LinkInfo.hxx:57

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().

◆ verdictForOkAndUseless1()

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 720 of file Bloc.cxx.

723{
724 for(vector<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
725 {
726 const list<OutPort *>& mySet=(*pool.find(*iter)).second;
727 if(mySet.size()==1)
728 {
729 if(alreadyFed==FREE_ST)
730 {
731 alreadyFed=FED_ST;//This the final choice. General case !
732 if(!direction)
733 info.pushInfoLink(*(mySet.begin()),end,I_BACK);
734 }
735 else if(alreadyFed==FED_ST)
736 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
737 }
738 else
739 {
740 if(dynamic_cast<ElementaryNode *>(*iter))
741 {
742 WarnReason reason;
743 if(alreadyFed==FREE_ST)
744 reason=direction ? W_COLLAPSE_EL : W_BACK_COLLAPSE_EL;
745 else if(alreadyFed==FED_ST)
747 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
748 info.pushWarnLink(*iter2,end,reason);
749 }
750 else
751 ((ComposedNode *)(*iter))->checkCFLinks(mySet,end,alreadyFed,direction,info);//Thanks to recursive model!
752 }
753 }
754}
void pushInfoLink(OutPort *semStart, InPort *end, InfoReason reason)
Definition: LinkInfo.cxx:71

References checkCFLinks(), 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().

◆ writeDot()

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 423 of file Bloc.cxx.

424{
425 os << " subgraph cluster_" << getId() << " {\n" ;
426 list<Node *>nodes=getChildren();
427 for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
428 {
429 (*iter)->writeDot(os);
430 string p=(*iter)->getId();
431 //not connected node
432 if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n";
433 list<Node *>outnodes = (*iter)->getOutNodes();
434 for(list<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
435 {
436 os << p << " -> " << (*itout)->getId() << ";\n";
437 }
438 }
439 os << "}\n" ;
440 os << getId() << "[fillcolor=\"" ;
442 os << getColorState(state);
443 os << "\" label=\"" << "Bloc:" ;
444 os << getQualifiedName() <<"\"];\n";
445}
std::list< Node * > getChildren() const
Definition: Bloc.hxx:57
std::string getColorState(YACS::StatesForNode state) const
Return the color associated to a state.
Definition: Node.cxx:578
std::string getQualifiedName() const
same as Node::getName() in most cases, but differs for children of switch
Definition: Node.cxx:632
std::list< Node * > getOutNodes() const
Definition: Node.cxx:185
const std::string getId() const
Definition: Node.cxx:478
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
Definition: Node.cxx:538
Proc * p
Definition: driver.cxx:216
StatesForNode
Definition: define.hxx:34

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

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

Member Data Documentation

◆ _bwLinks

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

For internal calculations.

Definition at line 42 of file Bloc.hxx.

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

◆ _fwLinks

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

For internal calculations.

Definition at line 40 of file Bloc.hxx.

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

◆ _setOfNode


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