Atoms Crowd  7.0.0
Node.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <AtomsGraph/Globals.h>
11 #include <AtomsGraph/Port.h>
12 #include <string>
13 #include <vector>
14 
15 namespace AtomsGraph
16 {
17 
18  class Port;
19 
20  class ATOMSGRAPH_EXPORT ComputeData
21  {
22  public:
23  ComputeData() : time(0.0) {}
24 
25  virtual ~ComputeData() {}
26 
27  double time;
28  };
29 
30  class ATOMSGRAPH_EXPORT Node
31  {
32  public:
33 
34  typedef std::vector<Port*>::iterator port_iterator;
35 
36  typedef std::vector<Port*>::const_iterator const_port_iterator;
37 
39 
43  virtual std::string typeStr() const = 0;
44 
46 
50  virtual unsigned int typeId() const = 0;
51 
53  Node();
54 
56  virtual ~Node();
57 
59 
62  virtual Node* clone() = 0;
63 
65  virtual bool compute(const ComputeData* computeData);
66 
68 
71  virtual void reset();
72 
74  void addInputPort(Port* port);
75 
77  template<class T>
78  T* getInputPort(const std::string& name);
79 
81  Port* getInputPort(const std::string& name);
82 
84  void removeInputPort(const std::string& name);
85 
87  std::vector<std::string> getInputPortNames() const;
88 
90  inline port_iterator inputPortBegin();
91 
93  inline port_iterator inputPortEnd();
94 
96  inline const_port_iterator inputPortCBegin() const;
97 
99  inline const_port_iterator inputPortCEnd() const;
100 
102  inline size_t numInputPorts() const;
103 
105  void addOutputPort(Port* port);
106 
108  template<class T>
109  T* getOutputPort(const std::string& name);
110 
112  Port* getOutputPort(const std::string& name);
113 
115  void removeOutputPort(const std::string& name);
116 
118  std::vector<std::string> getOutputPortNames() const;
119 
121  inline port_iterator outputPortBegin();
122 
124  inline port_iterator outputPortEnd();
125 
127  inline const_port_iterator outputPortCBegin() const;
128 
130  inline const_port_iterator outputPortCEnd() const;
131 
133  inline size_t numOutputPorts() const;
134 
136  void setDirty(bool value);
137 
139  inline bool isDirty() const;
140 
142  inline void setDirtyFlag();
143 
145  inline const std::string& name() const;
146 
148  inline void setName(const std::string& name);
149 
151  inline void setProfileTime(size_t value);
152 
154  inline size_t profileTime() const;
155 
157  virtual short baseNodeType() const;
158 
159  private:
160 
162  Node(const Node& other);
163 
165  Node& operator=(const Node& other);
166 
167  private:
168 
170  std::string m_sName;
171 
173  std::vector<Port*> m_vInputPorts;
174 
176  std::vector<Port*> m_vOutputPorts;
177 
179  size_t m_profileTime;
180 
182  bool m_isDirty;
183  };
184 }
185 
186 #include "Node.impl.h"
Definition: Node.h:21
Definition: Node.h:31
void setDirty(bool value)
Sets node dirty state.
void removeInputPort(const std::string &name)
Removes the input port with the given name.
virtual void reset()
Reset function.
virtual ~Node()
Destructor.
virtual short baseNodeType() const
Base node type.
Node()
Constructor.
virtual bool compute(const ComputeData *computeData)
Compute function.
std::vector< std::string > getInputPortNames() const
Gets all input port names.
virtual unsigned int typeId() const =0
Type id.
virtual Node * clone()=0
clone object
virtual std::string typeStr() const =0
Type string.
std::vector< std::string > getOutputPortNames() const
Gets all output port names.
void addOutputPort(Port *port)
Adds output port.
void removeOutputPort(const std::string &name)
Removes the output port with the given name.
Port * getInputPort(const std::string &name)
Gets the input port with the given name.
void addInputPort(Port *port)
Adds input port.
Port * getOutputPort(const std::string &name)
Gets the output port with the given name.
BasePort class.
Definition: Port.h:26
AtomsGraph namespace.
Definition: PosePort.h:15