Version: 9.15.0
YACS::ENGINE::Switch Class Reference

Control node that emulates the C switch. More...

#include <Switch.hxx>

Inheritance diagram for YACS::ENGINE::Switch:
Collaboration diagram for YACS::ENGINE::Switch:

Public Member Functions

 Switch (const Switch &other, ComposedNode *father, bool editionOnly)
 
 Switch (const std::string &name)
 
 ~Switch ()
 
void exUpdateState ()
 Update the node state. More...
 
void init (bool start=true)
 
NodeedSetDefaultNode (Node *DISOWNnode)
 
NodeedReleaseDefaultNode ()
 
NodeedReleaseCase (int caseId)
 
NodeedGetNode (int caseId)
 
NodeedSetNode (int caseId, Node *DISOWNnode)
 
void edChangeCase (int oldCase, int newCase)
 Change the case of a node. More...
 
virtual bool edAddChild (Node *DISOWNnode)
 
int getMaxCase ()
 
void getReadyTasks (std::vector< Task * > &tasks)
 
std::list< Node * > edGetDirectDescendants () const
 
InputPortedGetConditionPort ()
 
void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
int getNumberOfInputPorts () const
 
int getMaxLevelOfParallelism () const
 
void getWeightRegardingDPL (ComplexWeight *weight)
 
void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
 
void edRemoveChild (Node *node)
 Remove a child node. More...
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
YACS::StatesForNode getEffectiveState (const Node *node) const
 Return the effective state of a node in the context of this switch (its father) More...
 
OutPortgetOutPort (const std::string &name) const
 
InputPortgetInputPort (const std::string &name) const
 Get an input port given its name. More...
 
NodegetChildByShortName (const std::string &name) const
 
std::string getMyQualifiedName (const Node *directSon) const
 
std::string getCaseId (const Node *node) const
 
virtual void accept (Visitor *visitor)
 
int getRankOfNode (Node *node) const
 
virtual std::string typeName ()
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight of the graph. More...
 
- 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 ()
 
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)
 
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...
 
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 void removeRecursivelyRedundantCL ()
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< Node * > getAllRecursiveNodes ()
 Get all children nodes elementary and composed including this node. More...
 
virtual std::list< Node * > getAllRecursiveConstituents ()
 Idem getAllRecursiveNodes, but this node is NOT included. More...
 
std::string getInPortName (const InPort *) const
 Get the input port name. More...
 
std::string getOutPortName (const OutPort *) const
 
int getNumberOfOutputPorts () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 List all output ports of children nodes that are linked to out of scope input ports. More...
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
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 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
 
NodegetChildByName (const std::string &name) const
 
void loaded ()
 
void connected ()
 
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 ()
 
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
 
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
 
void writeDotInFile (const std::string &fileName) 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
 
InPropertyPortgetInPropertyPort () const
 
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
 
std::map< std::string, std::string > getProperties ()
 
std::map< std::string, std::string > getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair< std::string, int > > getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
- Public Member Functions inherited from YACS::ENGINE::Scheduler
virtual ~Scheduler ()
 

Static Public Attributes

static const char DEFAULT_NODE_NAME [] ="default"
 
static const char SELECTOR_INPUTPORT_NAME [] ="select"
 
static const int ID_FOR_DEFAULT_NODE =-1973012217
 
- 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
 

Protected Member Functions

YACS::Event updateStateOnFinishedEventFrom (Node *node)
 
NodesimpleClone (ComposedNode *father, bool editionOnly=true) const
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 List all input ports that are linked to out of scope ports. More...
 
void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * > > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * > > &bw, LinkInfo &info) const
 
void checkNoCyclePassingThrough (Node *node)
 
- 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 YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
virtual void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void getDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
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
 
void solveObviousOrDelegateCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 

Protected Attributes

AnyInputPort _condition
 
std::map< int, Node * > _mapOfNode
 
FakeNodeForSwitch_undispatchableNotificationNode
 
std::map< InPort *, CollectorSwOutPort * > _outPortsCollector
 
std::vector< CollectorSwOutPort * > _alreadyExistingCollectors
 
- 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

int getNbOfCases () const
 

Static Private Member Functions

static std::string getRepresentationOfCase (int i)
 

Friends

class FakeNodeForSwitch
 
class CollectorSwOutPort
 

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

Control node that emulates the C switch.

Definition at line 84 of file Switch.hxx.

Constructor & Destructor Documentation

◆ Switch() [1/2]

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

Definition at line 285 of file Switch.cxx.

285  :StaticDefinedComposedNode(other,father),_condition(other._condition,this),
287 {
288  for(map<int,Node *>::const_iterator iter=other._mapOfNode.begin();iter!=other._mapOfNode.end();iter++)
289  _mapOfNode[(*iter).first]=(*iter).second->clone(this,editionOnly);
290  if(!editionOnly)
291  for(map<InPort *, CollectorSwOutPort * >::const_iterator iter2=other._outPortsCollector.begin();iter2!=other._outPortsCollector.end();iter2++)
292  {
293  CollectorSwOutPort *newCol=new CollectorSwOutPort(*((*iter2).second),this);
294  _alreadyExistingCollectors.push_back(newCol);
295  }
296 }
std::vector< CollectorSwOutPort * > _alreadyExistingCollectors
Definition: Switch.hxx:97
std::map< int, Node * > _mapOfNode
Definition: Switch.hxx:94
friend class CollectorSwOutPort
Definition: Switch.hxx:87
std::map< InPort *, CollectorSwOutPort * > _outPortsCollector
Definition: Switch.hxx:96
AnyInputPort _condition
Definition: Switch.hxx:93
FakeNodeForSwitch * _undispatchableNotificationNode
Definition: Switch.hxx:95

References _alreadyExistingCollectors, _mapOfNode, _outPortsCollector, and CollectorSwOutPort.

◆ Switch() [2/2]

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

Definition at line 298 of file Switch.cxx.

299 {
300 }
static YACS::ENGINE::TypeCode * _tc_int
Definition: Runtime.hxx:137
static const char SELECTOR_INPUTPORT_NAME[]
Definition: Switch.hxx:90

◆ ~Switch()

Switch::~Switch ( )

Definition at line 302 of file Switch.cxx.

303 {
305 
306  for(map< int , Node * >::iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
307  delete (*iter).second;
308  for(map<InPort *, CollectorSwOutPort * >::iterator iter2=_outPortsCollector.begin();iter2!=_outPortsCollector.end();iter2++)
309  delete (*iter2).second;
310  for(vector<CollectorSwOutPort *>::iterator iter3=_alreadyExistingCollectors.begin();iter3!=_alreadyExistingCollectors.end();iter3++)
311  delete (*iter3);
312 }

References _alreadyExistingCollectors, _mapOfNode, _outPortsCollector, and _undispatchableNotificationNode.

Member Function Documentation

◆ accept()

void Switch::accept ( Visitor visitor)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 838 of file Switch.cxx.

839 {
840  visitor->visitSwitch(this);
841 }
virtual void visitSwitch(Switch *node)=0

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

◆ buildDelegateOf()

void Switch::buildDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 701 of file Switch.cxx.

702 {
703  map<InPort *, CollectorSwOutPort * >::iterator result=_outPortsCollector.find(finalTarget);
704  CollectorSwOutPort *newCollector;
705  if(result!=_outPortsCollector.end())
706  newCollector=(*result).second;
707  else
708  {
709  newCollector=new CollectorSwOutPort(this,finalTarget);
710  newCollector->edSetType((port.first)->edGetType());
711  _outPortsCollector[finalTarget]=newCollector;
712  }
713  newCollector->addPotentialProducerForMaster(port.first);
714  port.second=newCollector;
715  port.first=newCollector;
716 }
void addPotentialProducerForMaster(OutPort *port)
Definition: Switch.cxx:137
void edSetType(TypeCode *type)
Definition: DataPort.cxx:47

References _outPortsCollector, YACS::ENGINE::CollectorSwOutPort::addPotentialProducerForMaster(), CollectorSwOutPort, and YACS::ENGINE::DataPort::edSetType().

◆ checkCFLinks()

void Switch::checkCFLinks ( const std::list< OutPort * > &  starts,
InputPort end,
unsigned char &  alreadyFed,
bool  direction,
LinkInfo info 
) const
protectedvirtual

check control flow links

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

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 661 of file Switch.cxx.

662 {
663  map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.find(end);
664  if(iter!=_outPortsCollector.end())
665  {
666  set<OutPort *> represented;
667  (*iter).second->getAllRepresented(represented);
668  list<OutPort *> others;
669  for(list<OutPort *>::const_iterator iter2=starts.begin();iter2!=starts.end();iter2++)
670  if(represented.find(*iter2)==represented.end())
671  others.push_back(*iter2);
672  if(others.empty())
673  alreadyFed=FED_ST;
674  else
675  StaticDefinedComposedNode::checkCFLinks(others,end,alreadyFed,direction,info);//should never happend;
676  }
677  else
678  StaticDefinedComposedNode::checkCFLinks(starts,end,alreadyFed,direction,info);
679 }
static const unsigned char FED_ST
virtual void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links

References _outPortsCollector, YACS::ENGINE::ComposedNode::checkCFLinks(), and YACS::ENGINE::ComposedNode::FED_ST.

◆ checkControlDependancy()

void Switch::checkControlDependancy ( OutPort start,
InPort end,
bool  cross,
std::map< ComposedNode *, std::list< OutPort * > > &  fw,
std::vector< OutPort * > &  fwCross,
std::map< ComposedNode *, std::list< OutPort * > > &  bw,
LinkInfo info 
) const
protected

Definition at line 681 of file Switch.cxx.

686 {
687  throw Exception("Switch::checkControlDependancy : a link was dectected between 2 cases of a switch. Impossible !");
688 }

◆ checkLinkPossibility()

void Switch::checkLinkPossibility ( OutPort start,
const std::list< ComposedNode * > &  pointsOfViewStart,
InPort end,
const std::list< ComposedNode * > &  pointsOfViewEnd 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 695 of file Switch.cxx.

697 {
698  throw Exception("Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible");
699 }

◆ checkNoCyclePassingThrough()

void Switch::checkNoCyclePassingThrough ( Node node)
protectedvirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 690 of file Switch.cxx.

691 {
692  throw Exception("Switch::checkNoCyclePassingThrough : uncorrect control flow link relative to switch");
693 }

◆ edAddChild()

bool Switch::edAddChild ( Node DISOWNnode)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 633 of file Switch.cxx.

634 {
635  int aCase = getMaxCase() + 1;
636  DEBTRACE(aCase);
637  bool ret = edSetNode(aCase, node);
638  DEBTRACE(ret);
639  return ret;
640 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Node * edSetNode(int caseId, Node *DISOWNnode)
Definition: Switch.cxx:541

References DEBTRACE, edSetNode(), and getMaxCase().

◆ edChangeCase()

void Switch::edChangeCase ( int  oldCase,
int  newCase 
)

Change the case of a node.

Parameters
oldCase: the case value to change
newCase: the new value to set raise an exception if the old case does not exist or if the new case already exists

Definition at line 575 of file Switch.cxx.

576 {
577  std::map< int , Node * >::iterator iter=_mapOfNode.find(oldCase);
578  if(iter==_mapOfNode.end())
579  {
580  //the case does not exists
581  throw Exception("Switch::edChangeCase : case does not exist");
582  }
583  iter=_mapOfNode.find(newCase);
584  if(iter != _mapOfNode.end())
585  {
586  //the new case exists
587  throw Exception("Switch::edChangeCase : new case exists");
588  }
589  Node* node=_mapOfNode[oldCase];
590  _mapOfNode.erase(oldCase);
591  _mapOfNode[newCase]=node;
592  modified();
593 }
Base class for all nodes.
Definition: Node.hxx:70
virtual void modified()
Sets Node in modified state and its father if it exists.
Definition: Node.cxx:805

References _mapOfNode, and YACS::ENGINE::Node::modified().

Referenced by YACS::HMI::CommandSetSwitchCase::localExecute(), and YACS::HMI::CommandSetSwitchCase::localReverse().

◆ edGetConditionPort()

◆ edGetDirectDescendants()

list< Node * > Switch::edGetDirectDescendants ( ) const
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 393 of file Switch.cxx.

394 {
395  list<Node *> ret;
396  for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
397  if((*iter).second)
398  ret.push_back((*iter).second);
399  return ret;
400 }

References _mapOfNode.

Referenced by getProgressWeight().

◆ edGetNode()

Node * Switch::edGetNode ( int  caseId)

◆ edReleaseCase()

Node * Switch::edReleaseCase ( int  caseId)

Definition at line 509 of file Switch.cxx.

510 {
511  map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
512  if(iter==_mapOfNode.end())
513  {
514  string what("Switch::edReleaseCase : the case # "); what+=getRepresentationOfCase(caseId); what+=" is not set yet.";
515  throw Exception(what);
516  }
517  else
518  {
519  Node *ret=(*iter).second;
521  _mapOfNode.erase(iter);
522  modified();
523  return ret;
524  }
525 }
virtual void edRemoveChild(Node *node)
Remove a child node.
static std::string getRepresentationOfCase(int i)
Definition: Switch.cxx:761

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

Referenced by edReleaseDefaultNode(), and edRemoveChild().

◆ edReleaseDefaultNode()

Node * Switch::edReleaseDefaultNode ( )

Definition at line 504 of file Switch.cxx.

505 {
507 }
Node * edReleaseCase(int caseId)
Definition: Switch.cxx:509
static const int ID_FOR_DEFAULT_NODE
Definition: Switch.hxx:91

References edReleaseCase(), and ID_FOR_DEFAULT_NODE.

◆ edRemoveChild()

void Switch::edRemoveChild ( Node node)
virtual

Remove a child node.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 432 of file Switch.cxx.

433 {
434  map< int , Node * >::iterator iter=_mapOfNode.begin();
435  for(;iter!=_mapOfNode.end();iter++)
436  if(node==(*iter).second)
437  {
438  edReleaseCase((*iter).first);
439  return;
440  }
441  ostringstream what; what << "Switch::edRemoveChild : node with name " << node->getName() << " is not a direct child of Switch node " << _name;
442  throw Exception(what.str());
443 }
std::string _name
Definition: Node.hxx:89
const std::string & getName() const
Definition: Node.hxx:125

References _mapOfNode, YACS::ENGINE::Node::_name, edReleaseCase(), and YACS::ENGINE::Node::getName().

◆ edSetDefaultNode()

Node * Switch::edSetDefaultNode ( Node DISOWNnode)

Definition at line 499 of file Switch.cxx.

500 {
501  return edSetNode(ID_FOR_DEFAULT_NODE,node);
502 }

References edSetNode(), and ID_FOR_DEFAULT_NODE.

Referenced by YACS::switchtypeParser::default_().

◆ edSetNode()

Node * Switch::edSetNode ( int  caseId,
Node node 
)
Parameters
caseId: the case ID chosen to place 'node'
node: the node for the specified 'caseId'
Returns
: If an old node with id equal to 'caseId' exists before, this old node is returned so that to be deallocated. 0 is returned if caseId is a new ID. WARNING : 'node' is held by 'this' after call, whereas returned node is no more held.

Definition at line 541 of file Switch.cxx.

542 {
543  if(!node)
544  throw Exception("Switch::edSetNode : null node cannot be set as a case in switch node");
545  if(node->_father!=0)
546  throw Exception("Switch::edSetNode : node already held by another father");
548  node->_father=this;
549  map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
550  if(iter==_mapOfNode.end())
551  {
552  _mapOfNode[caseId]=node;
553  modified();
554  return 0;
555  }
556  else
557  {
558  if(node!=(*iter).second)
559  {
560  Node *ret=(*iter).second;
561  (*iter).second=node;
562  modified();
563  return ret;
564  }
565  }
566  return 0;
567 }
void checkNoCrossHierachyWith(Node *node) const
ComposedNode * _father
Definition: Node.hxx:90

References YACS::ENGINE::Node::_father, _mapOfNode, YACS::ENGINE::ComposedNode::checkNoCrossHierachyWith(), and YACS::ENGINE::Node::modified().

Referenced by YACS::switchtypeParser::case_(), edAddChild(), and edSetDefaultNode().

◆ exUpdateState()

void Switch::exUpdateState ( )
virtual

Update the node state.

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

Called by InGate::exNotifyFromPrecursor

Reimplemented from YACS::ENGINE::Node.

Definition at line 319 of file Switch.cxx.

320 {
321  DEBTRACE("Switch::exUpdateState " << _state);
322  if(_state == YACS::DISABLED)
323  return;
324  if(_inGate.exIsReady())
325  {
327  if(_condition.isEmpty())
329  else
330  {
331  map< int , Node * >::iterator iter=_mapOfNode.find(_condition.getIntValue());
332  if(iter==_mapOfNode.end())
333  {
334  iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
335  if(iter==_mapOfNode.end())
336  {
337  bool normalFinish=getAllOutPortsLeavingCurrentScope().empty();
339  _undispatchableNotificationNode=new FakeNodeForSwitch(this,normalFinish);
340  }
341  else
342  ((*iter).second)->exUpdateState();
343  }
344  else
345  ((*iter).second)->exUpdateState();
346  }
347  }
348 }
std::set< OutPort * > getAllOutPortsLeavingCurrentScope() const
List all output ports of children nodes that are linked to out of scope input ports.
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
friend class FakeNodeForSwitch
Definition: Switch.hxx:86
@ ACTIVATED
Definition: define.hxx:41
@ DISABLED
Definition: define.hxx:50

References _condition, YACS::ENGINE::Node::_inGate, _mapOfNode, YACS::ENGINE::Node::_state, _undispatchableNotificationNode, YACS::ACTIVATED, DEBTRACE, YACS::DISABLED, YACS::ENGINE::InGate::exIsReady(), FakeNodeForSwitch, YACS::ENGINE::ComposedNode::getAllOutPortsLeavingCurrentScope(), YACS::ENGINE::AnyInputPort::getIntValue(), ID_FOR_DEFAULT_NODE, YACS::ENGINE::AnyInputPort::isEmpty(), and YACS::ENGINE::Node::setState().

◆ getAllInPortsComingFromOutsideOfCurrentScope()

std::set< InPort * > Switch::getAllInPortsComingFromOutsideOfCurrentScope ( ) const
protectedvirtual

List all input ports that are linked to out of scope ports.

List all input ports of 'this' so that, for each it exists at least 1 link coming from outside to it.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 648 of file Switch.cxx.

649 {
651  set<OutPort *> temp2=_condition.edSetOutPort();
652  for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
653  if(!isInMyDescendance((*iter3)->getNode()))
654  {
655  ret.insert((InPort *)&_condition);
656  break;
657  }
658  return ret;
659 }
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const
List all input ports that are linked to out of scope ports.
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
Definition: InPort.cxx:65

References _condition, YACS::ENGINE::InPort::edSetOutPort(), YACS::ENGINE::ComposedNode::getAllInPortsComingFromOutsideOfCurrentScope(), and YACS::ENGINE::ComposedNode::isInMyDescendance().

◆ getCaseId()

std::string Switch::getCaseId ( const Node node) const

Definition at line 819 of file Switch.cxx.

820 {
821  const char sep='_';
822  map<int, Node*>::const_iterator iter;
823  for (iter = _mapOfNode.begin(); iter != _mapOfNode.end(); iter++)
824  if (iter->second == node)
825  {
826  stringstream a;
827  if (iter->first == Switch::ID_FOR_DEFAULT_NODE)
828  a << DEFAULT_NODE_NAME << sep;
829  else if (iter->first <0)
830  a << "m" << -iter->first << sep;
831  else a << "p" << iter->first << sep;
832  return a.str();
833  }
834  string what("node "); what+= node->getName() ; what+=" is not a child of node "; what += getName();
835  throw Exception(what);
836 }
std::string getName() const
static const char DEFAULT_NODE_NAME[]
Definition: Switch.hxx:89

References _mapOfNode, gui.CONNECTOR::a, DEFAULT_NODE_NAME, YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), and ID_FOR_DEFAULT_NODE.

Referenced by getMyQualifiedName().

◆ getChildByShortName()

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

Implements YACS::ENGINE::ComposedNode.

Definition at line 477 of file Switch.cxx.

478 {
479  if(name==DEFAULT_NODE_NAME)
480  {
481  map< int , Node * >::const_iterator iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
482  if(iter!=_mapOfNode.end())
483  return (Node *)((*iter).second);
484  else
485  {
486  string what("Switch::getChildByShortName : no default node defined for switch of name "); what+=getName();
487  throw Exception(what);
488  }
489  }
490  for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
491  {
492  if(name==((*iter).second)->getQualifiedName())
493  return (*iter).second;
494  }
495  string what("node "); what+= name ; what+=" is not a child of node switch "; what += getName();
496  throw Exception(what);
497 }

References _mapOfNode, DEFAULT_NODE_NAME, YACS::ENGINE::ComposedNode::getName(), and ID_FOR_DEFAULT_NODE.

◆ getDelegateOf()

void Switch::getDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 718 of file Switch.cxx.

719 {
720  map<InPort *, CollectorSwOutPort * >::iterator iter=_outPortsCollector.find(finalTarget);
721  if(iter==_outPortsCollector.end())
722  {
723  string what("Switch::getDelegateOf : not exported OuputPort with name "); what+=(port.first)->getName(); what+=" for target inport of name ";
724  what+=finalTarget->getName();
725  throw Exception(what);
726  }
727  ((*iter).second)->checkManagementOfPort(port.first);
728  port.second=(*iter).second;
729  port.first=(*iter).second;
730 }
std::string getName() const
Definition: DataPort.hxx:55

References _outPortsCollector, YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::DataPort::getName().

◆ getEffectiveState() [1/2]

YACS::StatesForNode Switch::getEffectiveState ( ) const
virtual

Return the node state in the context of its father.

Returns
the effective node state

The node state is stored in a private attribute _state. This state is relative to its father state : a node with a TOACTIVATE state with a father node in a READY state is not to activate. Its effective state is only READY. This method returns the effective state of the node taking into account that of its father.

Reimplemented from YACS::ENGINE::Node.

Definition at line 790 of file Switch.cxx.

791 {
792  return Node::getEffectiveState();
793 }
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
Definition: Node.cxx:538

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

Referenced by getProgressWeight().

◆ getEffectiveState() [2/2]

YACS::StatesForNode Switch::getEffectiveState ( const Node node) const
virtual

Return the effective state of a node in the context of this switch (its father)

Parameters
nodethe node which effective state is queried
Returns
the effective node state

Reimplemented from YACS::ENGINE::Node.

Definition at line 778 of file Switch.cxx.

779 {
781  if(effectiveState==YACS::READY)
782  return YACS::READY;
783  if(effectiveState==YACS::TOACTIVATE)
784  return YACS::READY;
785  if(effectiveState==YACS::DISABLED)
786  return YACS::DISABLED;
787 
788  return node->getState();
789 }
virtual YACS::StatesForNode getState() const
Definition: Node.hxx:118
StatesForNode
Definition: define.hxx:34
@ READY
Definition: define.hxx:37
@ TOACTIVATE
Definition: define.hxx:40

References YACS::DISABLED, YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::Node::getState(), YACS::READY, and YACS::TOACTIVATE.

◆ getInputPort()

InputPort * Switch::getInputPort ( const std::string &  name) const
virtual

Get an input port given its name.

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

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 470 of file Switch.cxx.

471 {
472  if(name==SELECTOR_INPUTPORT_NAME)
473  return (InputPort *)&_condition;
475 }
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
Base class for Input Ports.
Definition: InputPort.hxx:44

References _condition, YACS::ENGINE::ComposedNode::getInputPort(), and SELECTOR_INPUTPORT_NAME.

◆ getLocalInputPorts()

std::list< InputPort * > Switch::getLocalInputPorts ( ) const
virtual

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

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 453 of file Switch.cxx.

454 {
455  list<InputPort *> ret=StaticDefinedComposedNode::getLocalInputPorts();
456  ret.push_back((InputPort *)&_condition);
457  return ret;
458 }
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

References _condition, and YACS::ENGINE::ComposedNode::getLocalInputPorts().

◆ getMaxCase()

int Switch::getMaxCase ( )

Definition at line 595 of file Switch.cxx.

596 {
597  int aCase = 0;
598  map<int, Node*>::const_iterator it = _mapOfNode.begin();
599  for(; it != _mapOfNode.end(); ++it)
600  if ((*it).first > aCase)
601  aCase = (*it).first;
602  return aCase;
603 }

References _mapOfNode.

Referenced by edAddChild().

◆ getMaxLevelOfParallelism()

int Switch::getMaxLevelOfParallelism ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 407 of file Switch.cxx.

408 {
409  int ret(0);
410  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
411  ret=std::max(ret,((*it).second)->getMaxLevelOfParallelism());
412  return ret;
413 }

References _mapOfNode.

◆ getMyQualifiedName()

std::string Switch::getMyQualifiedName ( const Node directSon) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 812 of file Switch.cxx.

813 {
814  string id=getCaseId(directSon);
815  id+=directSon->getName();
816  return id;
817 }
std::string getCaseId(const Node *node) const
Definition: Switch.cxx:819

References getCaseId(), and YACS::ENGINE::Node::getName().

◆ getNbOfCases()

int Switch::getNbOfCases ( ) const
private

Definition at line 747 of file Switch.cxx.

748 {
749  return _mapOfNode.size();
750 }

References _mapOfNode.

◆ getNumberOfInputPorts()

int Switch::getNumberOfInputPorts ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 402 of file Switch.cxx.

403 {
405 }

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

◆ getOutPort()

OutPort * Switch::getOutPort ( const std::string &  name) const
virtual
Note
: Contrary to getOutputPort method, this method returns the output port at highest level, possible. That is to say in some ComposedNode, like ForEachLoop or Switch, an outport inside 'this' is seen differently than the true outport.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 459 of file Switch.cxx.

460 {
461  for(map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.begin();iter!=_outPortsCollector.end();iter++)
462  if(name==(*iter).second->getName())
463  return (*iter).second;
464  for(vector<CollectorSwOutPort *>::const_iterator iter2=_alreadyExistingCollectors.begin();iter2!=_alreadyExistingCollectors.end();iter2++)
465  if(name==(*iter2)->getName())
466  return *iter2;
468 }
OutPort * getOutPort(const std::string &name) const

References _alreadyExistingCollectors, _outPortsCollector, and YACS::ENGINE::ComposedNode::getOutPort().

Referenced by YACS::ENGINE::CollectorSwOutPort::CollectorSwOutPort().

◆ getProgressWeight()

list< ProgressWeight > Switch::getProgressWeight ( ) const
virtual

Get the progress weight of the graph.

Only elementary nodes have weight. If the switch node is not done, we add the weight of all his descendants, otherwise only the weight of the used case count.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 610 of file Switch.cxx.

611 {
612  list<ProgressWeight> ret;
613  list<Node *> setOfNode=edGetDirectDescendants();
614  if (getState() == YACS::DONE)
615  {
616  for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
617  {
618  if (getEffectiveState(*iter) == YACS::DONE)
619  ret=(*iter)->getProgressWeight();
620  }
621  }
622  else
623  {
624  for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
625  {
626  list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
627  ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
628  }
629  }
630  return ret;
631 }
YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
Definition: Switch.cxx:790
std::list< Node * > edGetDirectDescendants() const
Definition: Switch.cxx:393
@ DONE
Definition: define.hxx:43

References YACS::DONE, edGetDirectDescendants(), getEffectiveState(), and YACS::ENGINE::Node::getState().

◆ getRankOfNode()

◆ getReadyTasks()

void Switch::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

Implements YACS::ENGINE::Node.

Definition at line 367 of file Switch.cxx.

368 {
369  /*
370  * To change the way ComposedNode state is handled, uncomment the following line
371  * see Bloc::getReadyTasks
372  */
375  {
376  map< int , Node * >::iterator iter=_mapOfNode.find(_condition.getIntValue());
377  if(iter!=_mapOfNode.end())
378  ((*iter).second)->getReadyTasks(tasks);
379  else
380  {
381  iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
382  if(iter!=_mapOfNode.end())
383  (*iter).second->getReadyTasks(tasks);//Default Node is returned
384  else
387  else
388  throw Exception("Switch::getReadyTasks : internal error");
389  }
390  }
391 }
void getReadyTasks(std::vector< Task * > &tasks)
void getReadyTasks(std::vector< Task * > &tasks)
Definition: Switch.cxx:367

References _condition, _mapOfNode, YACS::ENGINE::Node::_state, _undispatchableNotificationNode, YACS::ACTIVATED, YACS::ENGINE::AnyInputPort::getIntValue(), YACS::ENGINE::ElementaryNode::getReadyTasks(), ID_FOR_DEFAULT_NODE, YACS::ENGINE::Node::setState(), and YACS::TOACTIVATE.

◆ getRepresentationOfCase()

string Switch::getRepresentationOfCase ( int  i)
staticprivate

Definition at line 761 of file Switch.cxx.

762 {
764  {
765  ostringstream stream;
766  stream << i;
767  return stream.str();
768  }
769  else
770  return DEFAULT_NODE_NAME;
771 }

References DEFAULT_NODE_NAME, yacsorb.CORBAEngineTest::i, and ID_FOR_DEFAULT_NODE.

Referenced by YACS::ENGINE::CollectorSwOutPort::addPotentialProducerForMaster(), edReleaseCase(), and YACS::ENGINE::CollectorSwOutPort::getHumanReprOfIncompleteCases().

◆ getSetOfInputPort()

std::list< InputPort * > Switch::getSetOfInputPort ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 445 of file Switch.cxx.

446 {
447  list<InputPort *> ret=StaticDefinedComposedNode::getSetOfInputPort();
448  ret.push_back((InputPort *)&_condition);
449  return ret;
450 }
std::list< InputPort * > getSetOfInputPort() const

References _condition, and YACS::ENGINE::ComposedNode::getSetOfInputPort().

◆ getWeightRegardingDPL()

void Switch::getWeightRegardingDPL ( ComplexWeight weight)
virtual

Implements YACS::ENGINE::Node.

Definition at line 415 of file Switch.cxx.

416 {
417  ComplexWeight localWeight;
418  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
419  {
420  ((*it).second)->getWeightRegardingDPL(&localWeight);
421  weight->max(localWeight);
422  localWeight.setToZero();
423  }
424 }
void max(ComplexWeight &other)
void getWeightRegardingDPL(ComplexWeight *weight)
Definition: Switch.cxx:415

References _mapOfNode, YACS::ENGINE::ComplexWeight::max(), and YACS::ENGINE::ComplexWeight::setToZero().

◆ init()

void Switch::init ( bool  start = true)
virtual

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

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 350 of file Switch.cxx.

351 {
352  DEBTRACE("Switch::init " << start);
354  int i=0;
355  for(map< int , Node * >::iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++, i++)
356  {
357  if(!(*iter).second)
358  {
359  ostringstream stream;
360  stream << "Switch::init : initialization failed due to unitialized branch of id " << (*iter).first;
361  throw Exception(stream.str());
362  }
363  ((*iter).second)->init(start);
364  }
365 }
void init(bool start=true)
void init(bool start=true)
Definition: Switch.cxx:350

References _mapOfNode, DEBTRACE, yacsorb.CORBAEngineTest::i, and YACS::ENGINE::ComposedNode::init().

◆ partitionRegardingDPL()

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

Implements YACS::ENGINE::Node.

Definition at line 426 of file Switch.cxx.

427 {
428  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
429  (*it).second->partitionRegardingDPL(pd,zeMap);
430 }

References _mapOfNode.

◆ releaseDelegateOf()

void Switch::releaseDelegateOf ( OutPort portDwn,
OutPort portUp,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 732 of file Switch.cxx.

733 {
734  set<OutPort *> repr;
735  portDwn->getAllRepresented(repr);
736  if(repr.size()==1)
737  {
738  CollectorSwOutPort *portCasted=dynamic_cast<CollectorSwOutPort *>(portUp);
739  if(portCasted->removePotentialProducerForMaster())//normally always true
740  {
741  delete portCasted;
742  _outPortsCollector.erase(finalTarget);
743  }
744  }
745 }
virtual void getAllRepresented(std::set< OutPort * > &represented) const
Definition: OutPort.cxx:45

References _outPortsCollector, YACS::ENGINE::OutPort::getAllRepresented(), and YACS::ENGINE::CollectorSwOutPort::removePotentialProducerForMaster().

◆ simpleClone()

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

Implements YACS::ENGINE::Node.

Definition at line 314 of file Switch.cxx.

315 {
316  return new Switch(*this,father,editionOnly);
317 }
friend class Switch
Definition: Node.hxx:73

References YACS::ENGINE::Node::Switch.

◆ typeName()

virtual std::string YACS::ENGINE::Switch::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 133 of file Switch.hxx.

133 {return "YACS__ENGINE__Switch";}

◆ updateStateOnFinishedEventFrom()

YACS::Event Switch::updateStateOnFinishedEventFrom ( Node node)
protectedvirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 642 of file Switch.cxx.

643 {
645  return YACS::FINISH;//notify to father node that 'this' has becomed finished.
646 }
@ FINISH
Definition: define.hxx:59

References YACS::DONE, YACS::FINISH, and YACS::ENGINE::Node::setState().

◆ writeDot()

void Switch::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.

Definition at line 795 of file Switch.cxx.

796 {
797  os << " subgraph cluster_" << getId() << " {\n" ;
798  for(map<int,Node*>::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
799  {
800  Node* n=(*iter).second;
801  n->writeDot(os);
802  os << getId() << " -> " << n->getId() << ";\n";
803  }
804  os << "}\n" ;
805  os << getId() << "[fillcolor=\"" ;
807  os << getColorState(state);
808  os << "\" label=\"" << "Switch:" ;
809  os << getQualifiedName() <<"\"];\n";
810 }
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
const std::string getId() const
Definition: Node.cxx:478

References _mapOfNode, YACS::ENGINE::Node::getColorState(), YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::Node::getId(), YACS::ENGINE::Node::getQualifiedName(), gui.Appli::n, and yacsorb.CORBAEngineTest::state.

Friends And Related Function Documentation

◆ CollectorSwOutPort

friend class CollectorSwOutPort
friend

Definition at line 87 of file Switch.hxx.

Referenced by buildDelegateOf(), and Switch().

◆ FakeNodeForSwitch

friend class FakeNodeForSwitch
friend

Definition at line 86 of file Switch.hxx.

Referenced by exUpdateState().

Member Data Documentation

◆ _alreadyExistingCollectors

std::vector<CollectorSwOutPort *> YACS::ENGINE::Switch::_alreadyExistingCollectors
mutableprotected

Definition at line 97 of file Switch.hxx.

Referenced by getOutPort(), Switch(), and ~Switch().

◆ _condition

AnyInputPort YACS::ENGINE::Switch::_condition
protected

◆ _mapOfNode

◆ _outPortsCollector

std::map<InPort *, CollectorSwOutPort * > YACS::ENGINE::Switch::_outPortsCollector
protected

◆ _undispatchableNotificationNode

FakeNodeForSwitch* YACS::ENGINE::Switch::_undispatchableNotificationNode
protected

Definition at line 95 of file Switch.hxx.

Referenced by exUpdateState(), getReadyTasks(), and ~Switch().

◆ DEFAULT_NODE_NAME

const char Switch::DEFAULT_NODE_NAME ="default"
static

Definition at line 89 of file Switch.hxx.

Referenced by getCaseId(), getChildByShortName(), and getRepresentationOfCase().

◆ ID_FOR_DEFAULT_NODE

◆ SELECTOR_INPUTPORT_NAME

const char Switch::SELECTOR_INPUTPORT_NAME ="select"
static

Definition at line 90 of file Switch.hxx.

Referenced by getInputPort().


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