4 #include "StaticDefinedComposedNode.hxx"
5 #include "ElementaryNode.hxx"
6 #include "AnyInputPort.hxx"
17 class CollectorSwOutPort : public OutPort
21 int edGetNumberOfOutLinks() const;
22 std::set<InPort *> edSetInPort() const;
23 bool isAlreadyLinkedWith(InPort *with) const;
24 std::string getNameOfTypeOfCurrentInstance() const;
25 void edRemoveAllLinksLinkedWithMe() throw(Exception);
26 bool isDifferentTypeOf(const DataPort *other) const;
27 void getAllRepresented(std::set<OutPort *>& represented) const;
28 bool addInPort(InPort *inPort) throw(Exception);
29 int removeInPort(InPort *inPort, bool forward) throw(Exception);
30 private://Specific part
31 bool removePotentialProducerForMaster();
32 void checkCompletenessOfCases() const throw(Exception);
33 CollectorSwOutPort(Switch *master, InPort *port);
34 CollectorSwOutPort(const CollectorSwOutPort& other, Switch *master);
35 void addPotentialProducerForMaster(OutPort *port);
36 bool checkManagementOfPort(OutPort *port) throw(Exception);
39 std::string _className;
40 OutPort *_currentProducer;
41 std::map<int, OutPort *> _potentialProducers;
44 class FakeNodeForSwitch : public ElementaryNode
52 FakeNodeForSwitch(Switch *sw, bool normalFinish, bool internalError=false);
53 FakeNodeForSwitch(const FakeNodeForSwitch& other);
54 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
55 void exForwardFailed();
56 void exForwardFinished();
62 class Switch : public StaticDefinedComposedNode
64 friend class FakeNodeForSwitch;
65 friend class CollectorSwOutPort;
67 static const char DEFAULT_NODE_NAME[];
68 static const char SELECTOR_INPUTPORT_NAME[];
69 static const int ID_FOR_DEFAULT_NODE;
71 AnyInputPort _condition;
72 std::map< int , Node * > _mapOfNode;//Nodes ownered
73 FakeNodeForSwitch *_undispatchableNotificationNode;
74 std::map<InPort *, CollectorSwOutPort * > _outPortsCollector;
75 mutable std::vector<CollectorSwOutPort *> _alreadyExistingCollectors;
77 Switch(const Switch& other, ComposedNode *father, bool editionOnly);
78 Switch(const std::string& name);
81 void init(bool start=true);
82 Node *edSetDefaultNode(Node *node);
83 Node *edReleaseDefaultNode() throw(Exception);
84 Node *edReleaseCase(int caseId) throw(Exception);
85 Node *edSetNode(int caseId, Node *node) throw(Exception);
86 void getReadyTasks(std::vector<Task *>& tasks);
87 void selectRunnableTasks(std::vector<Task *>& tasks);
88 std::set<Node *> edGetDirectDescendants() const;
89 InputPort *edGetConditionPort() { return &_condition; }
90 void writeDot(std::ostream &os);
91 int getNumberOfInputPorts() const;
92 void edRemoveChild(Node *node) throw(Exception);
93 std::list<InputPort *> getSetOfInputPort() const;
94 YACS::StatesForNode getEffectiveState(Node* node);
95 OutPort *getOutPort(const std::string& name) const throw(Exception);
96 InputPort* getInputPort(const std::string& name) const throw(Exception);
97 void checkConsistency(ComposedNode *pointOfView=0) const throw(Exception);
98 Node *getChildByShortName(const std::string& name) const throw(Exception);
99 std::string getMyQualifiedName(const Node *directSon) const;
100 std::string getCaseId(const Node *node) const throw(Exception);
101 virtual void accept(Visitor *visitor);
102 int getRankOfNode(Node *node) const;
104 YACS::Event updateStateOnFinishedEventFrom(Node *node);
105 Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
106 std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const;
107 std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const;
108 void checkLinkPossibility(OutPort *start, const std::set<ComposedNode *>& pointsOfViewStart,
109 InPort *end, const std::set<ComposedNode *>& pointsOfViewEnd) throw(Exception);
110 void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::set<ComposedNode *>& pointsOfView);
111 void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
112 void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::set<ComposedNode *>& pointsOfView) throw(Exception);
113 void checkNoCyclePassingThrough(Node *node) throw(Exception);
115 int getNbOfCases() const;
116 static std::string getRepresentationOfCase(int i);