Version: 8.3.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 () throw (Exception)
 
NodeedReleaseCase (int caseId) throw (Exception)
 
NodeedGetNode (int caseId)
 
NodeedSetNode (int caseId, Node *DISOWNnode) throw (Exception)
 
void edChangeCase (int oldCase, int newCase)
 Change the case of a node. More...
 
virtual bool edAddChild (Node *DISOWNnode) throw (Exception)
 
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 edRemoveChild (Node *node) throw (Exception)
 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 throw (Exception)
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 Get an input port given its name. More...
 
NodegetChildByShortName (const std::string &name) const throw (Exception)
 
std::string getMyQualifiedName (const Node *directSon) const
 
std::string getCaseId (const Node *node) const throw (Exception)
 
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 throw (Exception)
 Perform check of deployment consistency of the current graph. More...
 
std::vector< Task * > getNextTasks (bool &isMore)
 
void notifyFrom (const Task *sender, YACS::Event event, const Executor *execInst)
 Notify the node a task has emitted an event. More...
 
bool edAddLink (OutPort *start, InPort *end) throw (Exception)
 Add a dataflow link between two data ports. More...
 
virtual bool edAddDFLink (OutPort *start, InPort *end) throw (Exception)
 Connect an OutPort to an InPort and add the necessary control link. More...
 
bool edAddLink (OutGate *start, InGate *end) throw (Exception)
 Add a controlflow link between two control ports. More...
 
bool edAddCFLink (Node *nodeS, Node *nodeE) throw (Exception)
 Add a controlflow link between two nodes. More...
 
void edRemoveCFLink (Node *nodeS, Node *nodeE) throw (Exception)
 Remove a controlflow link. More...
 
void edRemoveLink (OutPort *start, InPort *end) throw (Exception)
 Remove a dataflow link. More...
 
void edRemoveLink (OutGate *start, InGate *end) throw (Exception)
 Remove a controlflow link. More...
 
virtual bool isRepeatedUnpredictablySeveralTimes () const
 
virtual void removeRecursivelyRedundantCL ()
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< Node * > getAllRecursiveNodes ()
 Get all children nodes elementary and composed including this node. More...
 
virtual std::list< Node * > getAllRecursiveConstituents ()
 Idem getAllRecursiveNodes, but this node is NOT included. More...
 
std::string getInPortName (const InPort *) const throw (Exception)
 Get the input port name. More...
 
std::string getOutPortName (const OutPort *) const throw (Exception)
 
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 throw (Exception)
 Get an output port given its name. More...
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const throw (Exception)
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const throw (Exception)
 
std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfInternalLinks () const
 
virtual std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfLinksLeavingCurrentScope () const
 
void checkConsistency (LinkInfo &info) const throw (Exception)
 
virtual std::vector< std::pair
< InPort *, OutPort * > > 
getSetOfLinksComingInCurrentScope () const
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void checkBasicConsistency () const throw (Exception)
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
ComposedNodegetRootNode () const throw (Exception)
 
bool isNodeAlreadyAggregated (const Node *node) const
 Check that Node 'node' is already a direct son of this. More...
 
virtual bool isNameAlreadyUsed (const std::string &name) const
 
NodeisInMyDescendance (Node *nodeToTest) const
 Returns the parent of a node that is the direct child of this node. More...
 
std::string getChildName (const Node *node) const throw (Exception)
 
NodegetChildByName (const std::string &name) const throw (Exception)
 
void loaded ()
 
void connected ()
 
virtual void cleanNodes ()
 Clean the composed node in case of not clean exit. More...
 
virtual std::string getProgress () const
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getState () const
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
InPortgetInPort (const std::string &name) const throw (Exception)
 
InPropertyPortgetInPropertyPort () const throw (Exception)
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string,
std::string > 
getProperties ()
 
std::map< std::string,
std::string > 
getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair
< std::string, int > > 
getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
- Public Member Functions inherited from YACS::ENGINE::Scheduler
virtual ~Scheduler ()
 

Static Public Attributes

static const char DEFAULT_NODE_NAME [] ="default"
 
static const char SELECTOR_INPUTPORT_NAME [] ="select"
 
static const int ID_FOR_DEFAULT_NODE =-1973012217
 

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) throw (Exception)
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void 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) throw (Exception)
 
- 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) throw (Exception)
 
virtual void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void checkInMyDescendance (Node *nodeToTest) const throw (Exception)
 Check if a node is in the descendance of this node. More...
 
template<class PORT >
std::string getPortName (const PORT *port) const throw (Exception)
 
void checkNoCrossHierachyWith (Node *node) const throw (Exception)
 
virtual void performCFComputations (LinkInfo &info) const
 perform recursively all CF computations. More...
 
virtual void destructCFComputations (LinkInfo &info) const
 destroy recursively all results of initial computations. More...
 
NodegetLowestNodeDealingAll (const std::list< OutPort * > &ports) const
 
void checkLinksCoherenceRegardingControl (const std::vector< OutPort * > &starts, InputPort *end, LinkInfo &info) const throw (Exception)
 
void solveObviousOrDelegateCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 

Protected Attributes

AnyInputPort _condition
 
std::map< int, Node * > _mapOfNode
 
FakeNodeForSwitch_undispatchableNotificationNode
 
std::map< InPort
*, CollectorSwOutPort * > 
_outPortsCollector
 
std::vector< CollectorSwOutPort * > _alreadyExistingCollectors
 

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) throw (Exception)
 Retrieves the lowest common ancestor of 2 nodes. More...
 
static std::string getLowestCommonAncestorStr (const std::string &node1, const std::string &node2)
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Protected Member Functions inherited from YACS::ENGINE::ComposedNode
static bool splitNamesBySep (const std::string &globalName, const char separator[], std::string &firstPart, std::string &lastPart, bool priority) throw (Exception)
 Splits name globalName in 2 parts using separator. More...
 
- Static Protected Attributes inherited from YACS::ENGINE::ComposedNode
static const char SEP_CHAR_BTW_LEVEL [] ="."
 
static const unsigned char FED_ST = 2
 
static const unsigned char FREE_ST = 0
 
static const unsigned char FED_DS_ST = 1
 

Detailed Description

Control node that emulates the C switch.

Definition at line 84 of file Switch.hxx.

Constructor & Destructor Documentation

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

Definition at line 281 of file Switch.cxx.

References _alreadyExistingCollectors, _mapOfNode, _outPortsCollector, and CollectorSwOutPort.

Referenced by simpleClone().

281  :StaticDefinedComposedNode(other,father),_condition(other._condition,this),
283 {
284  for(map<int,Node *>::const_iterator iter=other._mapOfNode.begin();iter!=other._mapOfNode.end();iter++)
285  _mapOfNode[(*iter).first]=(*iter).second->clone(this,editionOnly);
286  if(!editionOnly)
287  for(map<InPort *, CollectorSwOutPort * >::const_iterator iter2=other._outPortsCollector.begin();iter2!=other._outPortsCollector.end();iter2++)
288  {
289  CollectorSwOutPort *newCol=new CollectorSwOutPort(*((*iter2).second),this);
290  _alreadyExistingCollectors.push_back(newCol);
291  }
292 }
Switch::Switch ( const std::string &  name)
Switch::~Switch ( )

Definition at line 298 of file Switch.cxx.

References _alreadyExistingCollectors, _mapOfNode, _outPortsCollector, and _undispatchableNotificationNode.

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

Member Function Documentation

void Switch::accept ( Visitor visitor)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 816 of file Switch.cxx.

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

817 {
818  visitor->visitSwitch(this);
819 }
void Switch::buildDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 679 of file Switch.cxx.

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

680 {
681  map<InPort *, CollectorSwOutPort * >::iterator result=_outPortsCollector.find(finalTarget);
682  CollectorSwOutPort *newCollector;
683  if(result!=_outPortsCollector.end())
684  newCollector=(*result).second;
685  else
686  {
687  newCollector=new CollectorSwOutPort(this,finalTarget);
688  newCollector->edSetType((port.first)->edGetType());
689  _outPortsCollector[finalTarget]=newCollector;
690  }
691  newCollector->addPotentialProducerForMaster(port.first);
692  port.second=newCollector;
693  port.first=newCollector;
694 }
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 639 of file Switch.cxx.

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

640 {
641  map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.find(end);
642  if(iter!=_outPortsCollector.end())
643  {
644  set<OutPort *> represented;
645  (*iter).second->getAllRepresented(represented);
646  list<OutPort *> others;
647  for(list<OutPort *>::const_iterator iter2=starts.begin();iter2!=starts.end();iter2++)
648  if(represented.find(*iter2)==represented.end())
649  others.push_back(*iter2);
650  if(others.empty())
651  alreadyFed=FED_ST;
652  else
653  StaticDefinedComposedNode::checkCFLinks(others,end,alreadyFed,direction,info);//should never happend;
654  }
655  else
656  StaticDefinedComposedNode::checkCFLinks(starts,end,alreadyFed,direction,info);
657 }
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 659 of file Switch.cxx.

664 {
665  throw Exception("Switch::checkControlDependancy : a link was dectected between 2 cases of a switch. Impossible !");
666 }
void Switch::checkLinkPossibility ( OutPort start,
const std::list< ComposedNode * > &  pointsOfViewStart,
InPort end,
const std::list< ComposedNode * > &  pointsOfViewEnd 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 673 of file Switch.cxx.

675 {
676  throw Exception("Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible");
677 }
void Switch::checkNoCyclePassingThrough ( Node node) throw (Exception)
protectedvirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 668 of file Switch.cxx.

669 {
670  throw Exception("Switch::checkNoCyclePassingThrough : uncorrect control flow link relative to switch");
671 }
bool Switch::edAddChild ( Node DISOWNnode) throw (Exception)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 611 of file Switch.cxx.

References DEBTRACE, and PMMLBasicsTestLauncher::ret.

612 {
613  int aCase = getMaxCase() + 1;
614  DEBTRACE(aCase);
615  bool ret = edSetNode(aCase, node);
616  DEBTRACE(ret);
617  return ret;
618 }
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 553 of file Switch.cxx.

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

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

554 {
555  std::map< int , Node * >::iterator iter=_mapOfNode.find(oldCase);
556  if(iter==_mapOfNode.end())
557  {
558  //the case does not exists
559  throw Exception("Switch::edChangeCase : case does not exist");
560  }
561  iter=_mapOfNode.find(newCase);
562  if(iter != _mapOfNode.end())
563  {
564  //the new case exists
565  throw Exception("Switch::edChangeCase : new case exists");
566  }
567  Node* node=_mapOfNode[oldCase];
568  _mapOfNode.erase(oldCase);
569  _mapOfNode[newCase]=node;
570  modified();
571 }
list< Node * > Switch::edGetDirectDescendants ( ) const
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 389 of file Switch.cxx.

References _mapOfNode, and PMMLBasicsTestLauncher::ret.

Referenced by getProgressWeight().

390 {
391  list<Node *> ret;
392  for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
393  if((*iter).second)
394  ret.push_back((*iter).second);
395  return ret;
396 }
Node * Switch::edGetNode ( int  caseId)
Node * Switch::edReleaseCase ( int  caseId) throw (Exception)

Definition at line 488 of file Switch.cxx.

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

Referenced by edReleaseDefaultNode().

489 {
490  map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
491  if(iter==_mapOfNode.end())
492  {
493  string what("Switch::edReleaseCase : the case # "); what+=getRepresentationOfCase(caseId); what+=" is not set yet.";
494  throw Exception(what);
495  }
496  else
497  {
498  Node *ret=(*iter).second;
500  _mapOfNode.erase(iter);
501  modified();
502  return ret;
503  }
504 }
Node * Switch::edReleaseDefaultNode ( ) throw (Exception)

Definition at line 483 of file Switch.cxx.

References edReleaseCase(), and ID_FOR_DEFAULT_NODE.

484 {
486 }
void Switch::edRemoveChild ( Node node) throw (Exception)
virtual

Remove a child node.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 411 of file Switch.cxx.

412 {
413  map< int , Node * >::iterator iter=_mapOfNode.begin();
414  for(;iter!=_mapOfNode.end();iter++)
415  if(node==(*iter).second)
416  {
417  edReleaseCase((*iter).first);
418  return;
419  }
420  ostringstream what; what << "Switch::edRemoveChild : node with name " << node->getName() << " is not a direct child of Switch node " << _name;
421  throw Exception(what.str());
422 }
Node * Switch::edSetDefaultNode ( Node DISOWNnode)

Definition at line 478 of file Switch.cxx.

References edSetNode(), and ID_FOR_DEFAULT_NODE.

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

479 {
480  return edSetNode(ID_FOR_DEFAULT_NODE,node);
481 }
Node * Switch::edSetNode ( int  caseId,
Node node 
) throw (Exception)
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 520 of file Switch.cxx.

References PMMLBasicsTestLauncher::ret.

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

521 {
522  if(!node)
523  throw Exception("Switch::edSetNode : null node cannot be set as a case in switch node");
524  if(node->_father!=0)
525  throw Exception("Switch::edSetNode : node already held by another father");
527  node->_father=this;
528  map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
529  if(iter==_mapOfNode.end())
530  {
531  _mapOfNode[caseId]=node;
532  modified();
533  return 0;
534  }
535  else
536  {
537  if(node!=(*iter).second)
538  {
539  Node *ret=(*iter).second;
540  (*iter).second=node;
541  modified();
542  return ret;
543  }
544  }
545 }
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 315 of file Switch.cxx.

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

316 {
317  DEBTRACE("Switch::exUpdateState " << _state);
318  if(_state == YACS::DISABLED)
319  return;
320  if(_inGate.exIsReady())
321  {
323  if(_condition.isEmpty())
325  else
326  {
327  map< int , Node * >::iterator iter=_mapOfNode.find(_condition.getIntValue());
328  if(iter==_mapOfNode.end())
329  {
330  iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
331  if(iter==_mapOfNode.end())
332  {
333  bool normalFinish=getAllOutPortsLeavingCurrentScope().empty();
335  _undispatchableNotificationNode=new FakeNodeForSwitch(this,normalFinish);
336  }
337  else
338  ((*iter).second)->exUpdateState();
339  }
340  else
341  ((*iter).second)->exUpdateState();
342  }
343  }
344 }
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 626 of file Switch.cxx.

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

627 {
629  set<OutPort *> temp2=_condition.edSetOutPort();
630  for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
631  if(!isInMyDescendance((*iter3)->getNode()))
632  {
633  ret.insert((InPort *)&_condition);
634  break;
635  }
636  return ret;
637 }
std::string Switch::getCaseId ( const Node node) const throw (Exception)

Definition at line 797 of file Switch.cxx.

References gui.CONNECTOR::a.

798 {
799  const char sep='_';
800  map<int, Node*>::const_iterator iter;
801  for (iter = _mapOfNode.begin(); iter != _mapOfNode.end(); iter++)
802  if (iter->second == node)
803  {
804  stringstream a;
805  if (iter->first == Switch::ID_FOR_DEFAULT_NODE)
806  a << DEFAULT_NODE_NAME << sep;
807  else if (iter->first <0)
808  a << "m" << -iter->first << sep;
809  else a << "p" << iter->first << sep;
810  return a.str();
811  }
812  string what("node "); what+= node->getName() ; what+=" is not a child of node "; what += getName();
813  throw Exception(what);
814 }
Node * Switch::getChildByShortName ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 456 of file Switch.cxx.

457 {
458  if(name==DEFAULT_NODE_NAME)
459  {
460  map< int , Node * >::const_iterator iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
461  if(iter!=_mapOfNode.end())
462  return (Node *)((*iter).second);
463  else
464  {
465  string what("Switch::getChildByShortName : no default node defined for switch of name "); what+=getName();
466  throw Exception(what);
467  }
468  }
469  for(map< int , Node * >::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
470  {
471  if(name==((*iter).second)->getQualifiedName())
472  return (*iter).second;
473  }
474  string what("node "); what+= name ; what+=" is not a child of node switch "; what += getName();
475  throw Exception(what);
476 }
void Switch::getDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 696 of file Switch.cxx.

697 {
698  map<InPort *, CollectorSwOutPort * >::iterator iter=_outPortsCollector.find(finalTarget);
699  if(iter==_outPortsCollector.end())
700  {
701  string what("Switch::getDelegateOf : not exported OuputPort with name "); what+=(port.first)->getName(); what+=" for target inport of name ";
702  what+=finalTarget->getName();
703  throw Exception(what);
704  }
705  ((*iter).second)->checkManagementOfPort(port.first);
706  port.second=(*iter).second;
707  port.first=(*iter).second;
708 }
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 768 of file Switch.cxx.

Referenced by getProgressWeight().

769 {
770  return Node::getEffectiveState();
771 }
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
node,:the node which effective state is queried
Returns
the effective node state

Reimplemented from YACS::ENGINE::Node.

Definition at line 756 of file Switch.cxx.

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

757 {
759  if(effectiveState==YACS::READY)
760  return YACS::READY;
761  if(effectiveState==YACS::TOACTIVATE)
762  return YACS::READY;
763  if(effectiveState==YACS::DISABLED)
764  return YACS::DISABLED;
765 
766  return node->getState();
767 }
InputPort * Switch::getInputPort ( const std::string &  name) const throw (Exception)
virtual

Get an input port given its name.

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

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 449 of file Switch.cxx.

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

450 {
451  if(name==SELECTOR_INPUTPORT_NAME)
452  return (InputPort *)&_condition;
454 }
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 432 of file Switch.cxx.

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

433 {
435  ret.push_back((InputPort *)&_condition);
436  return ret;
437 }
int Switch::getMaxCase ( )

Definition at line 573 of file Switch.cxx.

References _mapOfNode.

574 {
575  int aCase = 0;
576  map<int, Node*>::const_iterator it = _mapOfNode.begin();
577  for(; it != _mapOfNode.end(); ++it)
578  if ((*it).first > aCase)
579  aCase = (*it).first;
580  return aCase;
581 }
int Switch::getMaxLevelOfParallelism ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 403 of file Switch.cxx.

References _mapOfNode, and PMMLBasicsTestLauncher::ret.

404 {
405  int ret(0);
406  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
407  ret=std::max(ret,((*it).second)->getMaxLevelOfParallelism());
408  return ret;
409 }
std::string Switch::getMyQualifiedName ( const Node directSon) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 790 of file Switch.cxx.

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

791 {
792  string id=getCaseId(directSon);
793  id+=directSon->getName();
794  return id;
795 }
int Switch::getNbOfCases ( ) const
private

Definition at line 725 of file Switch.cxx.

726 {
727  return _mapOfNode.size();
728 }
int Switch::getNumberOfInputPorts ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 398 of file Switch.cxx.

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

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

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 438 of file Switch.cxx.

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

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

439 {
440  for(map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.begin();iter!=_outPortsCollector.end();iter++)
441  if(name==(*iter).second->getName())
442  return (*iter).second;
443  for(vector<CollectorSwOutPort *>::const_iterator iter2=_alreadyExistingCollectors.begin();iter2!=_alreadyExistingCollectors.end();iter2++)
444  if(name==(*iter2)->getName())
445  return *iter2;
447 }
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 588 of file Switch.cxx.

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

589 {
590  list<ProgressWeight> ret;
591  list<Node *> setOfNode=edGetDirectDescendants();
592  if (getState() == YACS::DONE)
593  {
594  for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
595  {
596  if (getEffectiveState(*iter) == YACS::DONE)
597  ret=(*iter)->getProgressWeight();
598  }
599  }
600  else
601  {
602  for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
603  {
604  list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
605  ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
606  }
607  }
608  return ret;
609 }
int Switch::getRankOfNode ( Node node) const
void Switch::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

Implements YACS::ENGINE::Node.

Definition at line 363 of file Switch.cxx.

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.

364 {
365  /*
366  * To change the way ComposedNode state is handled, uncomment the following line
367  * see Bloc::getReadyTasks
368  */
371  {
372  map< int , Node * >::iterator iter=_mapOfNode.find(_condition.getIntValue());
373  if(iter!=_mapOfNode.end())
374  ((*iter).second)->getReadyTasks(tasks);
375  else
376  {
377  iter=_mapOfNode.find(ID_FOR_DEFAULT_NODE);
378  if(iter!=_mapOfNode.end())
379  (*iter).second->getReadyTasks(tasks);//Default Node is returned
380  else
383  else
384  throw Exception("Switch::getReadyTasks : internal error");
385  }
386  }
387 }
string Switch::getRepresentationOfCase ( int  i)
staticprivate

Definition at line 739 of file Switch.cxx.

References CORBAEngineTest::i.

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

740 {
742  {
743  ostringstream stream;
744  stream << i;
745  return stream.str();
746  }
747  else
748  return DEFAULT_NODE_NAME;
749 }
std::list< InputPort * > Switch::getSetOfInputPort ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 424 of file Switch.cxx.

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

425 {
427  ret.push_back((InputPort *)&_condition);
428  return ret;
429 }
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 346 of file Switch.cxx.

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

347 {
348  DEBTRACE("Switch::init " << start);
350  int i=0;
351  for(map< int , Node * >::iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++, i++)
352  {
353  if(!(*iter).second)
354  {
355  ostringstream stream;
356  stream << "Switch::init : initialization failed due to unitialized branch of id " << (*iter).first;
357  throw Exception(stream.str());
358  }
359  ((*iter).second)->init(start);
360  }
361 }
void Switch::releaseDelegateOf ( OutPort portDwn,
OutPort portUp,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 710 of file Switch.cxx.

References YACS::ENGINE::CollectorSwOutPort::removePotentialProducerForMaster().

711 {
712  set<OutPort *> repr;
713  portDwn->getAllRepresented(repr);
714  if(repr.size()==1)
715  {
716  CollectorSwOutPort *portCasted=dynamic_cast<CollectorSwOutPort *>(portUp);
717  if(portCasted->removePotentialProducerForMaster())//normally always true
718  {
719  delete portCasted;
720  _outPortsCollector.erase(finalTarget);
721  }
722  }
723 }
Node * Switch::simpleClone ( ComposedNode father,
bool  editionOnly = true 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 310 of file Switch.cxx.

References Switch().

311 {
312  return new Switch(*this,father,editionOnly);
313 }
virtual std::string YACS::ENGINE::Switch::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 131 of file Switch.hxx.

131 {return "YACS__ENGINE__Switch";}
YACS::Event Switch::updateStateOnFinishedEventFrom ( Node node)
protectedvirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 620 of file Switch.cxx.

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

621 {
623  return YACS::FINISH;//notify to father node that 'this' has becomed finished.
624 }
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 773 of file Switch.cxx.

References YACS::ENGINE::Node::getId(), gui.Appli::n, CORBAEngineTest::state, and YACS::ENGINE::Node::writeDot().

774 {
775  os << " subgraph cluster_" << getId() << " {\n" ;
776  for(map<int,Node*>::const_iterator iter=_mapOfNode.begin();iter!=_mapOfNode.end();iter++)
777  {
778  Node* n=(*iter).second;
779  n->writeDot(os);
780  os << getId() << " -> " << n->getId() << ";\n";
781  }
782  os << "}\n" ;
783  os << getId() << "[fillcolor=\"" ;
785  os << getColorState(state);
786  os << "\" label=\"" << "Switch:" ;
787  os << getQualifiedName() <<"\"];\n";
788 }

Friends And Related Function Documentation

friend class CollectorSwOutPort
friend

Definition at line 87 of file Switch.hxx.

Referenced by Switch().

friend class FakeNodeForSwitch
friend

Definition at line 86 of file Switch.hxx.

Referenced by exUpdateState().

Member Data Documentation

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

Definition at line 97 of file Switch.hxx.

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

AnyInputPort YACS::ENGINE::Switch::_condition
protected
std::map< int , Node * > YACS::ENGINE::Switch::_mapOfNode
protected
std::map<InPort *, CollectorSwOutPort * > YACS::ENGINE::Switch::_outPortsCollector
protected

Definition at line 96 of file Switch.hxx.

Referenced by buildDelegateOf(), checkCFLinks(), Switch(), and ~Switch().

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

Definition at line 95 of file Switch.hxx.

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

const char Switch::DEFAULT_NODE_NAME ="default"
static

Definition at line 89 of file Switch.hxx.

const char Switch::SELECTOR_INPUTPORT_NAME ="select"
static

Definition at line 90 of file Switch.hxx.


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