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 TypeOfChannel getTypeOfChannel() 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);
31 void getHumanReprOfIncompleteCases(std::ostream& stream) const;
32 private://Specific part
33 bool removePotentialProducerForMaster();
34 void checkConsistency(LinkInfo& info) const;
35 CollectorSwOutPort(Switch *master, InPort *port);
36 CollectorSwOutPort(const CollectorSwOutPort& other, Switch *master);
37 void addPotentialProducerForMaster(OutPort *port);
38 bool checkManagementOfPort(OutPort *port) throw(Exception);
41 std::string _className;
42 OutPort *_currentProducer;
43 std::map<int, OutPort *> _potentialProducers;
46 class FakeNodeForSwitch : public ElementaryNode
54 FakeNodeForSwitch(Switch *sw, bool normalFinish, bool internalError=false);
55 FakeNodeForSwitch(const FakeNodeForSwitch& other);
56 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
57 void exForwardFailed();
58 void exForwardFinished();
64 class Switch : public StaticDefinedComposedNode
66 friend class FakeNodeForSwitch;
67 friend class CollectorSwOutPort;
69 static const char DEFAULT_NODE_NAME[];
70 static const char SELECTOR_INPUTPORT_NAME[];
71 static const int ID_FOR_DEFAULT_NODE;
73 AnyInputPort _condition;
74 std::map< int , Node * > _mapOfNode;//Nodes ownered
75 FakeNodeForSwitch *_undispatchableNotificationNode;
76 std::map<InPort *, CollectorSwOutPort * > _outPortsCollector;
77 mutable std::vector<CollectorSwOutPort *> _alreadyExistingCollectors;
79 Switch(const Switch& other, ComposedNode *father, bool editionOnly);
80 Switch(const std::string& name);
83 void init(bool start=true);
84 //Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
85 Node *edSetDefaultNode(Node *DISOWNnode);
86 Node *edReleaseDefaultNode() throw(Exception);
87 Node *edReleaseCase(int caseId) throw(Exception);
88 Node *edSetNode(int caseId, Node *DISOWNnode) throw(Exception);
89 void getReadyTasks(std::vector<Task *>& tasks);
90 void selectRunnableTasks(std::vector<Task *>& tasks);
91 std::list<Node *> edGetDirectDescendants() const;
92 InputPort *edGetConditionPort() { return &_condition; }
93 void writeDot(std::ostream &os) const;
94 int getNumberOfInputPorts() const;
95 void edRemoveChild(Node *node) throw(Exception);
96 std::list<InputPort *> getSetOfInputPort() const;
97 std::list<InputPort *> getLocalInputPorts() const;
98 YACS::StatesForNode getEffectiveState() const;
99 YACS::StatesForNode getEffectiveState(const Node* node) const;
100 OutPort *getOutPort(const std::string& name) const throw(Exception);
101 InputPort* getInputPort(const std::string& name) const throw(Exception);
102 Node *getChildByShortName(const std::string& name) const throw(Exception);
103 std::string getMyQualifiedName(const Node *directSon) const;
104 std::string getCaseId(const Node *node) const throw(Exception);
105 virtual void accept(Visitor *visitor);
106 int getRankOfNode(Node *node) const;
107 virtual std::string typeName() {return "YACS__ENGINE__Switch";}
109 YACS::Event updateStateOnFinishedEventFrom(Node *node);
110 Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
111 std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const;
112 void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
113 InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
114 void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
115 void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
116 void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
117 void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const;
118 void checkControlDependancy(OutPort *start, InPort *end, bool cross,
119 std::map < ComposedNode *, std::list < OutPort * > >& fw,
120 std::vector<OutPort *>& fwCross,
121 std::map< ComposedNode *, std::list < OutPort *> >& bw,
122 LinkInfo& info) const;
123 void checkNoCyclePassingThrough(Node *node) throw(Exception);
125 int getNbOfCases() const;
126 static std::string getRepresentationOfCase(int i);