1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "OutGate.hxx"
24 #include "Exception.hxx"
36 void StateLoader(Node* node, YACS::StatesForNode state);
47 class InputDataStreamPort;
48 class OutputDataStreamPort;
51 /*! \brief Base class for all nodes
62 friend class InputPort;
63 friend class OutputPort;
64 friend class DynParaLoop;
65 friend class ForEachLoop;
66 friend class ComposedNode;
67 friend class ElementaryNode;
69 friend void StateLoader(Node* node, YACS::StatesForNode state);
71 mutable YACS::Colour _colour;
76 ComposedNode *_father;
77 YACS::StatesForNode _state;
79 std::string _errorDetails;
80 static const char SEP_CHAR_IN_PORT[];
83 std::string _implementation;
84 std::map<std::string,std::string> _propertyMap;
86 Node(const std::string& name);
87 Node(const Node& other, ComposedNode *father);
88 virtual void performDuplicationOfPlacement(const Node& other) = 0;
89 virtual Node *simpleClone(ComposedNode *father, bool editionOnly=true) const = 0;
92 virtual void init(bool start=true);
93 //! \b This method \b MUST \b NEVER \b BE \b VIRTUAL
94 Node *clone(ComposedNode *father, bool editionOnly=true) const;
95 void setState(YACS::StatesForNode theState); // To centralize state changes
96 virtual YACS::StatesForNode getState() const { return _state; }
97 virtual YACS::StatesForNode getEffectiveState() const;
98 virtual YACS::StatesForNode getEffectiveState(const Node*) const;
99 std::string getColorState(YACS::StatesForNode state) const;
100 static std::string getStateName(YACS::StatesForNode state);
101 InGate *getInGate() { return &_inGate; }
102 OutGate *getOutGate() { return &_outGate; }
103 const std::string& getName() const { return _name; }
104 void setName(const std::string& name);
105 ComposedNode * getFather() const { return _father; }
106 const std::string getId() const;
107 bool exIsControlReady() const;
108 std::set<Node *> getOutNodes() const;
109 virtual void writeDot(std::ostream &os) const;
110 virtual void exUpdateState();
111 virtual void exFailedState();
112 virtual void exDisabledState();
113 virtual void getReadyTasks(std::vector<Task *>& tasks) = 0;
114 virtual std::list<ElementaryNode *> getRecursiveConstituents() const = 0;
115 virtual int getNumberOfInputPorts() const = 0;
116 virtual int getNumberOfOutputPorts() const = 0;
117 std::list<InPort *> getSetOfInPort() const;
118 std::list<OutPort *> getSetOfOutPort() const;
119 virtual std::list<InputPort *> getSetOfInputPort() const = 0;
120 virtual std::list<OutputPort *> getSetOfOutputPort() const = 0;
121 virtual std::list<InputPort *> getLocalInputPorts() const = 0;
122 virtual std::list<OutputPort *> getLocalOutputPorts() const = 0;
123 virtual std::set<InputPort *> edGetSetOfUnitializedInputPort() const;
124 virtual bool edAreAllInputPortInitialized() const;
125 virtual std::string getInPortName(const InPort *) const throw (Exception) = 0;
126 virtual std::string getOutPortName(const OutPort *) const throw (Exception) = 0;
127 virtual std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const = 0;
128 virtual std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const = 0;
129 InPort *getInPort(const std::string& name) const throw(Exception);
130 virtual OutPort *getOutPort(const std::string& name) const throw(Exception);
131 virtual std::set<OutPort *> getAllOutPortsLeavingCurrentScope() const = 0;
132 virtual std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const = 0;
133 virtual std::vector< std::pair<OutPort *, InPort *> > getSetOfLinksLeavingCurrentScope() const = 0;
134 virtual std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const =0;
135 virtual InputPort *getInputPort(const std::string& name) const throw(Exception) = 0;
136 virtual OutputPort *getOutputPort(const std::string& name) const throw(Exception) = 0;
137 virtual InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception) = 0;
138 virtual OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception) = 0;
139 std::list<ComposedNode *> getAllAscendanceOf(ComposedNode *levelToStop = 0) const;
140 bool operator>(const Node& other) const;
141 bool operator<(const Node& other) const;
142 std::string getImplementation() const;
143 virtual ComposedNode *getRootNode() const throw(Exception);
144 virtual void setProperty(const std::string& name,const std::string& value);
145 virtual Node *getChildByName(const std::string& name) const throw(Exception) = 0;
146 virtual void accept(Visitor *visitor) = 0;
147 std::string getQualifiedName() const;
149 virtual void sendEvent(const std::string& event);
150 static std::map<int,Node *> idMap;
151 virtual std::string typeName() {return "YACS__ENGINE__Node";}
152 virtual std::string getErrorDetails(){return _errorDetails;};
153 virtual void setErrorDetails(const std::string& error){_errorDetails=error;};
154 virtual void modified();
155 virtual int isModified(){return _modified;}
156 virtual int isValid();
157 virtual void edUpdateState();
158 virtual std::string getErrorReport();
159 virtual std::string getContainerLog();
160 virtual void ensureLoading();
162 virtual void exForwardFailed();
163 virtual void exForwardFinished();
164 virtual void edDisconnectAllLinksWithMe();
165 static void checkValidityOfPortName(const std::string& name) throw(Exception);
166 static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2) throw(Exception);
167 static std::map<int, std::string> _nodeStateName;