]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/Node.hxx
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / Node.hxx
1 #ifndef __NODE_HXX__
2 #define __NODE_HXX__
3
4 #include "InGate.hxx"
5 #include "OutGate.hxx"
6 #include "Exception.hxx"
7 #include "define.hxx"
8
9 #include <set>
10 #include <string>
11 #include <vector>
12 #include <map>
13
14 namespace YACS
15 {
16   namespace ENGINE
17   {
18     class Task;
19     class InPort;
20     class OutPort;
21     class InputPort;
22     class OutputPort;
23     class DynParaLoop;
24     class ForEachLoop;
25     class ComposedNode;
26     class ElementaryNode;
27     class Switch;
28     class InputDataStreamPort;
29     class OutputDataStreamPort;
30     class Visitor;
31     
32 /*! \brief Base class for all nodes
33  *
34  * \ingroup Nodes
35  *
36  *
37  */
38     class Node
39     {
40       friend class Bloc;
41       friend class Loop;
42       friend class Switch;
43       friend class InputPort;
44       friend class OutputPort;
45       friend class DynParaLoop;
46       friend class ForEachLoop;
47       friend class ComposedNode;
48       friend class ElementaryNode;
49       friend class Visitor;
50       friend void StateLoader(Node* node, YACS::StatesForNode state);
51     public:
52       mutable YACS::Colour _colour;
53     protected:
54       InGate _inGate;
55       OutGate _outGate;
56       std::string _name;
57       ComposedNode *_father;
58       YACS::StatesForNode _state;
59       static const char SEP_CHAR_IN_PORT[];
60       static int _total;
61       int _numId;
62       std::string _implementation;
63       std::map<std::string,std::string> _propertyMap;
64     protected:
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;
69     public:
70       virtual ~Node();
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;
121       int getNumId();
122       virtual void sendEvent(const std::string& event);
123       static std::map<int,Node *> idMap;
124     protected:
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);
130     };
131
132     void StateLoader(Node* node, YACS::StatesForNode state);
133   }
134 }
135
136 #endif