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