Version: 9.16.0
Node.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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, or (at your option) any later version.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef __NODE_HXX__
21#define __NODE_HXX__
22
24#include "PlayGround.hxx"
25#include "AutoRefCnt.hxx"
26#include "InGate.hxx"
27#include "OutGate.hxx"
28#include "Exception.hxx"
29#include "define.hxx"
30
31#include <set>
32#include <string>
33#include <vector>
34#include <map>
35
36namespace YACS
37{
38 namespace ENGINE
39 {
41 class Task;
42 class InPort;
43 class OutPort;
44 class InputPort;
45 class OutputPort;
46 class InPropertyPort;
47 class ForEachLoop;
48 class DynParaLoop;
49 class ComposedNode;
50 class Proc;
51 class ElementaryNode;
52 class Switch;
53 class InputDataStreamPort;
54 class OutputDataStreamPort;
55 class Visitor;
56
58 {
61 };
62
63 class YACSLIBENGINE_EXPORT NodeStateNameMap : public std::map<YACS::StatesForNode, std::string>
64 {
65 public:
67 };
68
70 {
71 friend class Bloc;
72 friend class Loop;
73 friend class Switch;
74 friend class InputPort;
75 friend class OutputPort;
76 friend class InPropertyPort;
77 friend class DynParaLoop;
78 friend class ForEachLoop;
79 friend class ComposedNode;
80 friend class ElementaryNode;
81 friend class Visitor;
83 public:
85 protected:
89 std::string _name;
93 std::string _errorDetails;
94 static const char SEP_CHAR_IN_PORT[];
95 static int _total;
96 int _numId;
97 std::string _implementation;
98 std::map<std::string,std::string> _propertyMap;
99 Node *_eventReceiver=nullptr;
100 protected:
101 Node(const std::string& name);
102 Node(const Node& other, ComposedNode *father);
104 virtual void performDuplicationOfPlacement(const Node& other) = 0;
106 virtual void performShallowDuplicationOfPlacement(const Node& other) = 0;
107 virtual Node *simpleClone(ComposedNode *father, bool editionOnly=true) const = 0;
108 public:
109 virtual ~Node();
110 virtual void init(bool start=true);
111 virtual void shutdown(int level);
112 virtual void resetState(int level);
114 Node *clone(ComposedNode *father, bool editionOnly=true) const;
116 Node *cloneWithoutCompAndContDeepCpy(ComposedNode *father, bool editionOnly=true) const;
117 void setState(YACS::StatesForNode theState); // To centralize state changes
118 virtual YACS::StatesForNode getState() const { return _state; }
119 virtual YACS::StatesForNode getEffectiveState() const;
120 virtual YACS::StatesForNode getEffectiveState(const Node*) const;
121 std::string getColorState(YACS::StatesForNode state) const;
122 static std::string getStateName(YACS::StatesForNode state);
123 InGate *getInGate() { return &_inGate; }
124 OutGate *getOutGate() { return &_outGate; }
125 const std::string& getName() const { return _name; }
126 void setName(const std::string& name);
127 ComposedNode * getFather() const { return _father; }
128 const std::string getId() const;
129 bool exIsControlReady() const;
130 std::list<Node *> getOutNodes() const;
131 virtual void writeDot(std::ostream &os) const;
132 void writeDotInFile(const std::string& fileName) const;
133 virtual void exUpdateState();
134 virtual void exFailedState();
135 virtual void exDisabledState();
136 virtual void getReadyTasks(std::vector<Task *>& tasks) = 0;
137 virtual std::list<ElementaryNode *> getRecursiveConstituents() const = 0;
138 virtual std::list<ProgressWeight> getProgressWeight() const = 0;
139 virtual int getNumberOfInputPorts() const = 0;
140 virtual int getNumberOfOutputPorts() const = 0;
141 std::list<InPort *> getSetOfInPort() const;
142 std::list<OutPort *> getSetOfOutPort() const;
143 virtual std::list<InputPort *> getSetOfInputPort() const = 0;
144 virtual std::list<OutputPort *> getSetOfOutputPort() const = 0;
145 virtual std::list<InputPort *> getLocalInputPorts() const = 0;
146 virtual std::list<OutputPort *> getLocalOutputPorts() const = 0;
147 virtual std::set<InputPort *> edGetSetOfUnitializedInputPort() const;
148 virtual bool edAreAllInputPortInitialized() const;
149 virtual std::string getInPortName(const InPort *) const = 0;
150 virtual std::string getOutPortName(const OutPort *) const = 0;
151 virtual std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const = 0;
152 virtual std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const = 0;
153 InPort *getInPort(const std::string& name) const;
154 InPropertyPort *getInPropertyPort() const;
155 virtual OutPort *getOutPort(const std::string& name) const;
156 virtual std::set<OutPort *> getAllOutPortsLeavingCurrentScope() const = 0;
157 virtual std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const = 0;
158 virtual std::vector< std::pair<OutPort *, InPort *> > getSetOfLinksLeavingCurrentScope() const = 0;
159 virtual std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const =0;
160 virtual InputPort *getInputPort(const std::string& name) const;
161 virtual OutputPort *getOutputPort(const std::string& name) const = 0;
162 virtual InputDataStreamPort *getInputDataStreamPort(const std::string& name) const = 0;
163 virtual OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const = 0;
164 std::list<ComposedNode *> getAllAscendanceOf(ComposedNode *levelToStop = 0) const;
165 bool operator>(const Node& other) const;
166 bool operator<(const Node& other) const;
167 std::string getImplementation() const;
168 DynParaLoop *getClosestDPLAmongAncestors() const;
169 virtual ComposedNode *getRootNode() const;
170 virtual void setProperty(const std::string& name,const std::string& value);
171 virtual std::string getProperty(const std::string& name);
172 std::map<std::string,std::string> getProperties() ;
173 std::map<std::string,std::string> getPropertyMap() { return _propertyMap; }
174 virtual void setProperties(std::map<std::string,std::string> properties);
175 virtual Node *getChildByName(const std::string& name) const = 0;
176 virtual Proc *getProc();
177 virtual const Proc *getProc() const;
178 virtual void accept(Visitor *visitor) = 0;
179 virtual int getMaxLevelOfParallelism() const = 0;
180 virtual void getWeightRegardingDPL(ComplexWeight *weight) = 0;
182 std::string getQualifiedName() const;
183 int getNumId();
184 std::vector<std::pair<std::string,int> > getDPLScopeInfo(ComposedNode *gfn);
185 virtual void applyDPLScope(ComposedNode *gfn);
186 virtual void sendEvent(const std::string& event);
187 virtual void sendEvent2(const std::string& event, void *something);
188 static std::map<int,Node *> idMap;
189 virtual std::string typeName() { return "YACS__ENGINE__Node"; }
190 virtual std::string getErrorDetails() const { return _errorDetails; }
191 virtual void setErrorDetails(const std::string& error) { _errorDetails=error; }
192 virtual void modified();
193 virtual int isModified() { return _modified; }
194 virtual int isValid();
195 virtual void edUpdateState();
196 virtual std::string getErrorReport();
197 virtual std::string getContainerLog();
198 virtual void ensureLoading();
199 virtual void getCoupledNodes(std::set<Task*>& coupledNodes) { }
200 virtual void cleanNodes();
201 protected:
202 virtual void exForwardFailed();
203 virtual void exForwardFinished();
204 virtual void edDisconnectAllLinksWithMe();
205 static void checkValidityOfPortName(const std::string& name);
206 static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2);
207 public:
208 static void checkValidityOfNodeName(const std::string& name);
209 };
210
211 }
212}
213
214#endif
#define YACSLIBENGINE_EXPORT
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36
Base class for all composed nodes.
Base class for dynamically (fully or semifully) built graphs.
Definition: DynParaLoop.hxx:41
Base class for all calculation nodes.
Loop node for parametric calculation.
class for Input Property Ports
Base class for Input Ports.
Definition: InputPort.hxx:44
Base class for loop node.
Definition: Loop.hxx:147
Base class for all nodes.
Definition: Node.hxx:70
static std::map< int, Node * > idMap
Definition: Node.hxx:188
OutGate _outGate
Definition: Node.hxx:87
std::string _name
Definition: Node.hxx:89
virtual std::list< ProgressWeight > getProgressWeight() const =0
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope() const =0
virtual int getMaxLevelOfParallelism() const =0
virtual void setErrorDetails(const std::string &error)
Definition: Node.hxx:191
virtual int isModified()
Definition: Node.hxx:193
std::map< std::string, std::string > getPropertyMap()
Definition: Node.hxx:173
virtual std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const =0
virtual std::string getInPortName(const InPort *) const =0
ComposedNode * _father
Definition: Node.hxx:90
static int _total
Definition: Node.hxx:95
InGate _inGate
Definition: Node.hxx:86
virtual void getReadyTasks(std::vector< Task * > &tasks)=0
virtual void getCoupledNodes(std::set< Task * > &coupledNodes)
Definition: Node.hxx:199
const std::string & getName() const
Definition: Node.hxx:125
ComposedNode * getFather() const
Definition: Node.hxx:127
virtual std::list< OutputPort * > getLocalOutputPorts() const =0
virtual std::list< OutputPort * > getSetOfOutputPort() const =0
virtual void getWeightRegardingDPL(ComplexWeight *weight)=0
virtual std::list< InputPort * > getSetOfInputPort() const =0
virtual std::list< InputDataStreamPort * > getSetOfInputDataStreamPort() const =0
InPropertyPort * _inPropertyPort
Definition: Node.hxx:88
virtual std::string getOutPortName(const OutPort *) const =0
std::map< std::string, std::string > _propertyMap
Definition: Node.hxx:98
virtual int getNumberOfInputPorts() const =0
virtual void performDuplicationOfPlacement(const Node &other)=0
performs a duplication of placement using clone method of containers and components....
YACS::Colour _colour
Definition: Node.hxx:84
virtual std::list< ElementaryNode * > getRecursiveConstituents() const =0
virtual Node * getChildByName(const std::string &name) const =0
virtual Node * simpleClone(ComposedNode *father, bool editionOnly=true) const =0
friend void StateLoader(Node *node, YACS::StatesForNode state)
OutGate * getOutGate()
Definition: Node.hxx:124
virtual OutputPort * getOutputPort(const std::string &name) const =0
virtual std::string typeName()
Definition: Node.hxx:189
InGate * getInGate()
Definition: Node.hxx:123
virtual OutputDataStreamPort * getOutputDataStreamPort(const std::string &name) const =0
std::string _implementation
Definition: Node.hxx:97
virtual std::string getErrorDetails() const
Definition: Node.hxx:190
virtual std::list< InputPort * > getLocalInputPorts() const =0
virtual std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort() const =0
virtual int getNumberOfOutputPorts() const =0
virtual YACS::StatesForNode getState() const
Definition: Node.hxx:118
virtual void performShallowDuplicationOfPlacement(const Node &other)=0
performs a also duplication of placement but here containers and components are not copied at all wha...
virtual InputDataStreamPort * getInputDataStreamPort(const std::string &name) const =0
std::string _errorDetails
Definition: Node.hxx:93
YACS::StatesForNode _state
Definition: Node.hxx:91
virtual std::set< OutPort * > getAllOutPortsLeavingCurrentScope() const =0
virtual void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)=0
virtual void accept(Visitor *visitor)=0
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope() const =0
Base class for all schema objects.
Definition: Proc.hxx:44
Control node that emulates the C switch.
Definition: Switch.hxx:85
void YACSLIBENGINE_EXPORT StateLoader(Node *node, YACS::StatesForNode state)
Definition: Node.cxx:719
Colour
Definition: define.hxx:27
StatesForNode
Definition: define.hxx:34