Atoms Crowd  4.1.0
PortTemplate.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/Port.h>
11 #include <AtomsGraph/PortTraits.h>
12 #include <AtomsGraph/Node.h>
13 
14 namespace AtomsGraph
15 {
16 
18  /*
19  This is the generic implementation of a port with get/set methods.
20  Specialize this class to create new port type.
21  */
22  template <class T>
23  class PortTemplate : public Port
24  {
25  public:
26 
27  typedef T valueType;
28 
30  explicit PortTemplate(const std::string& name);
31 
33  ~PortTemplate();
34 
36  virtual std::string typeStr() const;
37 
39  static std::string staticTypeStr();
40 
42  virtual void copyValue(Port *other);
43 
45  T get() const;
46 
48  const T& getRef() const;
49 
51  T& getRef();
52 
54  void set(const T& value);
55 
57 
59  void setLink(T* value);
60 
62  virtual void reset();
63 
64  private:
65 
66  PortTemplate(const PortTemplate& other);
67 
68  PortTemplate& operator=(const PortTemplate& other);
69 
70  private:
71 
72  T m_value;
73 
74  T* m_link;
75  };
76 
77 }
78 
79 #include "PortTemplate.impl.h"
AtomsGraph::PortTemplate::copyValue
virtual void copyValue(Port *other)
Copy data from a port.
Definition: PortTemplate.impl.h:13
AtomsGraph::Port::name
std::string name() const
Gets the port name.
Definition: Port.impl.h:40
AtomsGraph::PortTemplate::get
T get() const
Gets data.
Definition: PortTemplate.impl.h:48
AtomsGraph::PortTemplate::getRef
const T & getRef() const
Gets a reference of the port data.
Definition: PortTemplate.impl.h:58
AtomsGraph::PortTemplate::~PortTemplate
~PortTemplate()
Destructor.
Definition: PortTemplate.impl.h:29
AtomsGraph::PortTemplate::typeStr
virtual std::string typeStr() const
Gets the type string of this node.
Definition: PortTemplate.impl.h:34
AtomsGraph::PortTemplate::staticTypeStr
static std::string staticTypeStr()
Gets the type string of this node type.
AtomsGraph::PortTemplate::setLink
void setLink(T *value)
Set this port in link mode.
Definition: PortTemplate.impl.h:79
AtomsGraph::PortTemplate::PortTemplate
PortTemplate(const std::string &name)
Constructor.
Definition: PortTemplate.impl.h:20
AtomsGraph::PortTemplate
Generic node port class.
Definition: PortTemplate.h:24
AtomsGraph::PortTemplate::reset
virtual void reset()
Reset port to the default value.
Definition: PortTemplate.impl.h:85
AtomsGraph
AtomsGraph namespace.
Definition: PosePort.h:15
AtomsGraph::Port
BasePort class.
Definition: Port.h:26
AtomsGraph::PortTemplate::set
void set(const T &value)
Sets the port data.
Definition: PortTemplate.impl.h:40