Version: 8.3.0
Node.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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 
23 #include "YACSlibEngineExport.hxx"
24 #include "InGate.hxx"
25 #include "OutGate.hxx"
26 #include "Exception.hxx"
27 #include "define.hxx"
28 
29 #include <set>
30 #include <string>
31 #include <vector>
32 #include <map>
33 
34 namespace YACS
35 {
36  namespace ENGINE
37  {
39  class Task;
40  class InPort;
41  class OutPort;
42  class InputPort;
43  class OutputPort;
44  class InPropertyPort;
45  class DynParaLoop;
46  class ForEachLoop;
47  class ComposedNode;
48  class Proc;
49  class ElementaryNode;
50  class Switch;
51  class InputDataStreamPort;
52  class OutputDataStreamPort;
53  class Visitor;
54 
56  {
59  };
60 
61  class YACSLIBENGINE_EXPORT NodeStateNameMap : public std::map<YACS::StatesForNode, std::string>
62  {
63  public:
65  };
66 
68  {
69  friend class Bloc;
70  friend class Loop;
71  friend class Switch;
72  friend class InputPort;
73  friend class OutputPort;
74  friend class InPropertyPort;
75  friend class DynParaLoop;
76  friend class ForEachLoop;
77  friend class ComposedNode;
78  friend class ElementaryNode;
79  friend class Visitor;
80  friend void StateLoader(Node* node, YACS::StatesForNode state);
81  public:
83  protected:
87  std::string _name;
90  int _modified;
91  std::string _errorDetails;
92  static const char SEP_CHAR_IN_PORT[];
93  static int _total;
94  int _numId;
95  std::string _implementation;
96  std::map<std::string,std::string> _propertyMap;
97  protected:
98  Node(const std::string& name);
99  Node(const Node& other, ComposedNode *father);
101  virtual void performDuplicationOfPlacement(const Node& other) = 0;
103  virtual void performShallowDuplicationOfPlacement(const Node& other) = 0;
104  virtual Node *simpleClone(ComposedNode *father, bool editionOnly=true) const = 0;
105  public:
106  virtual ~Node();
107  virtual void init(bool start=true);
108  virtual void shutdown(int level);
109  virtual void resetState(int level);
111  Node *clone(ComposedNode *father, bool editionOnly=true) const;
113  Node *cloneWithoutCompAndContDeepCpy(ComposedNode *father, bool editionOnly=true) const;
114  void setState(YACS::StatesForNode theState); // To centralize state changes
115  virtual YACS::StatesForNode getState() const { return _state; }
116  virtual YACS::StatesForNode getEffectiveState() const;
117  virtual YACS::StatesForNode getEffectiveState(const Node*) const;
118  std::string getColorState(YACS::StatesForNode state) const;
119  static std::string getStateName(YACS::StatesForNode state);
120  InGate *getInGate() { return &_inGate; }
121  OutGate *getOutGate() { return &_outGate; }
122  const std::string& getName() const { return _name; }
123  void setName(const std::string& name);
124  ComposedNode * getFather() const { return _father; }
125  const std::string getId() const;
126  bool exIsControlReady() const;
127  std::list<Node *> getOutNodes() const;
128  virtual void writeDot(std::ostream &os) const;
129  virtual void exUpdateState();
130  virtual void exFailedState();
131  virtual void exDisabledState();
132  virtual void getReadyTasks(std::vector<Task *>& tasks) = 0;
133  virtual std::list<ElementaryNode *> getRecursiveConstituents() const = 0;
134  virtual std::list<ProgressWeight> getProgressWeight() const = 0;
135  virtual int getNumberOfInputPorts() const = 0;
136  virtual int getNumberOfOutputPorts() const = 0;
137  std::list<InPort *> getSetOfInPort() const;
138  std::list<OutPort *> getSetOfOutPort() const;
139  virtual std::list<InputPort *> getSetOfInputPort() const = 0;
140  virtual std::list<OutputPort *> getSetOfOutputPort() const = 0;
141  virtual std::list<InputPort *> getLocalInputPorts() const = 0;
142  virtual std::list<OutputPort *> getLocalOutputPorts() const = 0;
143  virtual std::set<InputPort *> edGetSetOfUnitializedInputPort() const;
144  virtual bool edAreAllInputPortInitialized() const;
145  virtual std::string getInPortName(const InPort *) const throw (Exception) = 0;
146  virtual std::string getOutPortName(const OutPort *) const throw (Exception) = 0;
147  virtual std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const = 0;
148  virtual std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const = 0;
149  InPort *getInPort(const std::string& name) const throw(Exception);
150  InPropertyPort *getInPropertyPort() const throw(Exception);
151  virtual OutPort *getOutPort(const std::string& name) const throw(Exception);
152  virtual std::set<OutPort *> getAllOutPortsLeavingCurrentScope() const = 0;
153  virtual std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const = 0;
154  virtual std::vector< std::pair<OutPort *, InPort *> > getSetOfLinksLeavingCurrentScope() const = 0;
155  virtual std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const =0;
156  virtual InputPort *getInputPort(const std::string& name) const throw(Exception);
157  virtual OutputPort *getOutputPort(const std::string& name) const throw(Exception) = 0;
158  virtual InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception) = 0;
159  virtual OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception) = 0;
160  std::list<ComposedNode *> getAllAscendanceOf(ComposedNode *levelToStop = 0) const;
161  bool operator>(const Node& other) const;
162  bool operator<(const Node& other) const;
163  std::string getImplementation() const;
164  virtual ComposedNode *getRootNode() const throw(Exception);
165  virtual void setProperty(const std::string& name,const std::string& value);
166  virtual std::string getProperty(const std::string& name);
167  std::map<std::string,std::string> getProperties() ;
168  std::map<std::string,std::string> getPropertyMap() { return _propertyMap; }
169  virtual void setProperties(std::map<std::string,std::string> properties);
170  virtual Node *getChildByName(const std::string& name) const throw(Exception) = 0;
171  virtual Proc *getProc();
172  virtual const Proc *getProc() const;
173  virtual void accept(Visitor *visitor) = 0;
174  virtual int getMaxLevelOfParallelism() const = 0;
175  std::string getQualifiedName() const;
176  int getNumId();
177  std::vector<std::pair<std::string,int> > getDPLScopeInfo(ComposedNode *gfn);
178  virtual void applyDPLScope(ComposedNode *gfn);
179  virtual void sendEvent(const std::string& event);
180  virtual void sendEvent2(const std::string& event, void *something);
181  static std::map<int,Node *> idMap;
182  virtual std::string typeName() { return "YACS__ENGINE__Node"; }
183  virtual std::string getErrorDetails() const { return _errorDetails; }
184  virtual void setErrorDetails(const std::string& error) { _errorDetails=error; }
185  virtual void modified();
186  virtual int isModified() { return _modified; }
187  virtual int isValid();
188  virtual void edUpdateState();
189  virtual std::string getErrorReport();
190  virtual std::string getContainerLog();
191  virtual void ensureLoading();
192  virtual void getCoupledNodes(std::set<Task*>& coupledNodes) { }
193  virtual void cleanNodes();
194  protected:
195  virtual void exForwardFailed();
196  virtual void exForwardFinished();
197  virtual void edDisconnectAllLinksWithMe();
198  static void checkValidityOfPortName(const std::string& name) throw(Exception);
199  static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2) throw(Exception);
200  };
201 
202  }
203 }
204 
205 #endif