6 #include "Exception.hxx"
28 class InputDataStreamPort;
29 class OutputDataStreamPort;
32 /*! \brief Base class for all nodes
43 friend class InputPort;
44 friend class OutputPort;
45 friend class DynParaLoop;
46 friend class ForEachLoop;
47 friend class ComposedNode;
48 friend class ElementaryNode;
50 friend void StateLoader(Node* node, YACS::StatesForNode state);
52 mutable YACS::Colour _colour;
57 ComposedNode *_father;
58 YACS::StatesForNode _state;
59 static const char SEP_CHAR_IN_PORT[];
62 std::string _implementation;
63 std::map<std::string,std::string> _propertyMap;
65 Node(const std::string& name);
66 Node(const Node& other, ComposedNode *father);
67 virtual void performDuplicationOfPlacement(const Node& other) = 0;
68 virtual Node *simpleClone(ComposedNode *father, bool editionOnly=true) const = 0;
71 virtual void init(bool start=true);
72 //! \b This method \b MUST \b NEVER \b BE \b VIRTUAL
73 Node *clone(ComposedNode *father, bool editionOnly=true) const;
74 void setState(YACS::StatesForNode theState); // To centralize state changes
75 virtual YACS::StatesForNode getState() const { return _state; }
76 virtual YACS::StatesForNode getEffectiveState();
77 virtual YACS::StatesForNode getEffectiveState(Node*);
78 std::string getColorState(YACS::StatesForNode state);
79 InGate *getInGate() { return &_inGate; }
80 OutGate *getOutGate() { return &_outGate; }
81 const std::string& getName() const { return _name; }
82 ComposedNode * getFather() const { return _father; }
83 const std::string getId();
84 bool exIsControlReady() const;
85 std::set<Node *> getOutNodes() const;
86 virtual void writeDot(std::ostream &os);
87 virtual void exUpdateState();
88 virtual void exFailedState();
89 virtual void exDisabledState();
90 virtual void getReadyTasks(std::vector<Task *>& tasks) = 0;
91 virtual std::set<ElementaryNode *> getRecursiveConstituents() const = 0;
92 virtual int getNumberOfInputPorts() const = 0;
93 virtual int getNumberOfOutputPorts() const = 0;
94 std::list<InPort *> getSetOfInPort() const;
95 std::list<OutPort *> getSetOfOutPort() const;
96 virtual std::list<InputPort *> getSetOfInputPort() const = 0;
97 virtual std::list<OutputPort *> getSetOfOutputPort() const = 0;
98 virtual std::list<InputPort *> getLocalInputPorts() const = 0;
99 virtual std::list<OutputPort *> getLocalOutputPorts() const = 0;
100 virtual std::set<InputPort *> edGetSetOfUnitializedInputPort() const;
101 virtual bool edAreAllInputPortInitialized() const;
102 virtual std::string getInPortName(const InPort *) const throw (Exception) = 0;
103 virtual std::string getOutPortName(const OutPort *) const throw (Exception) = 0;
104 virtual std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const = 0;
105 virtual std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const = 0;
106 InPort *getInPort(const std::string& name) const throw(Exception);
107 virtual OutPort *getOutPort(const std::string& name) const throw(Exception);
108 virtual std::set<OutPort *> getAllOutPortsLeavingCurrentScope() const = 0;
109 virtual std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const = 0;
110 virtual InputPort *getInputPort(const std::string& name) const throw(Exception) = 0;
111 virtual OutputPort *getOutputPort(const std::string& name) const throw(Exception) = 0;
112 virtual InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception) = 0;
113 virtual OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception) = 0;
114 std::set<ComposedNode *> getAllAscendanceOf(ComposedNode *levelToStop = 0);
115 std::string getImplementation();
116 virtual ComposedNode *getRootNode() throw(Exception);
117 virtual void setProperty(const std::string& name,const std::string& value);
118 virtual Node *getChildByName(const std::string& name) const throw(Exception) = 0;
119 virtual void accept(Visitor *visitor) = 0;
120 std::string getQualifiedName() const;
122 virtual void sendEvent(const std::string& event);
123 static std::map<int,Node *> idMap;
125 virtual void exForwardFailed();
126 virtual void exForwardFinished();
127 virtual void edDisconnectAllLinksWithMe();
128 static void checkValidityOfPortName(const std::string& name) throw(Exception);
129 static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2) throw(Exception);
132 void StateLoader(Node* node, YACS::StatesForNode state);