bioprocessing  5.1.2
valuevertex.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2013 CEA
2  *
3  * This software and supporting documentation were developed by
4  * bioPICSEL
5  * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6  * 18, route du Panorama
7  * 92265 Fontenay-aux-Roses
8  * France
9  */
10 
11 #ifndef BIOPROCESSING_GRAPH_VALUEVERTEX
12 #define BIOPROCESSING_GRAPH_VALUEVERTEX
13 
14 //--- bioprocessing ----------------------------------------------------------
15 #include <bioprocessing/graph/basevertex.h> // bio::BaseVertex
16 //--- cartobase --------------------------------------------------------------
17 #include <cartobase/smart/rcptr.h> // carto::rc_ptr
18 //----------------------------------------------------------------------------
19 
20 namespace bio {
21 
22  template <typename T> class ValueVertex;
23  template <typename T> class ValueVertexRef;
24 
25 //============================================================================
26 // POINT VERTEX
27 //============================================================================
33  template <typename T>
34  class ValueVertex: public BaseVertex
35  {
36  //--- typedef ------------------------------------------------------------
37  protected:
38  typedef ValueVertex<T> This;
39  typedef BaseVertex Base;
40  public:
43  typedef typename T Type;
44 
45  //--- constructor --------------------------------------------------------
46  public:
48  ValueVertex( const Type & val ): _value(val) {}
49  virtual ~ValueVertex() {}
50 
51  //--- accessor -----------------------------------------------------------
52  public:
54  const Type & value() const { return _value; }
56  Type value() { return _value; }
57 
58  //--- members ------------------------------------------------------------
59  protected:
61 
62  //--- friends ------------------------------------------------------------
63  friend class ValueVertexRef<T>;
64  };
65 
66 
67 //============================================================================
68 // POINT VERTEX REF
69 //============================================================================
74  template <typename T>
76  {
77  //--- typedef ------------------------------------------------------------
78  protected:
80  typedef BaseVertexRef Base;
82  public:
84  typedef Pointed::Type Type;
85 
86  //--- constructor --------------------------------------------------------
87  protected:
90  public:
92  ValueVertexRef( const Type & val ): Base( new Pointed( val ) ) {}
96  ValueVertexRef( Pointed * v ): Base(v) {}
99  ValueVertexRef( const Base & other ): Base( other ) {}
100  virtual ~ValueVertexRef() {}
101 
102  //--- none factory -------------------------------------------------------
103  public:
106  static Vertex none() { return This( (Pointed*)0 ); }
107 
108  //--- accessor -----------------------------------------------------------
109  public:
111  const Type & value() const { return ((Pointed*)(this->get()))->value(); }
113  Type value() { return ((Pointed*)(this->get()))->value(); }
114  };
115 
116 } // namespace bio
117 
118 #endif // BIOPROCESSING_GRAPH_VALUEVERTEX
Reference counting pointer to a BaseVertex.
Definition: basevertex.h:105
carto::rc_ptr< BaseVertex > Base
Base class type.
Definition: basevertex.h:109
Base class for vertices.
Definition: basevertex.h:34
Reference counting pointer to a ValueVertex.
Definition: valuevertex.h:76
Pointed::Type Type
Value type.
Definition: valuevertex.h:84
BaseVertexRef Base
Base class (rc_ptr)
Definition: valuevertex.h:80
ValueVertexRef()
Default constructor (builds a non pointer)
Definition: valuevertex.h:89
ValueVertexRef(const Type &val)
Constructor from a value (creates a new instance)
Definition: valuevertex.h:92
const Type & value() const
Const accessor to th value.
Definition: valuevertex.h:111
virtual ~ValueVertexRef()
Definition: valuevertex.h:100
ValueVertex< T > Pointed
Pointed object type.
Definition: valuevertex.h:81
ValueVertexRef(Pointed *v)
Constructor from a pointer (the pointer should either be created by new, or be already referenced by ...
Definition: valuevertex.h:96
Pointed::Vertex Vertex
Useable type (RC)
Definition: valuevertex.h:83
ValueVertexRef(const Base &other)
Copy constructor (it copies the reference, it does not duplicate the pointed object)
Definition: valuevertex.h:99
ValueVertexRef< T > This
Type of *this.
Definition: valuevertex.h:79
static Vertex none()
Empty pointer factory.
Definition: valuevertex.h:106
Type value()
Non const accessor to th value.
Definition: valuevertex.h:113
Vertices with value.
Definition: valuevertex.h:35
ValueVertex< T > This
Type of *this.
Definition: valuevertex.h:38
ValueVertexRef< T > Vertex
Useable type (RC)
Definition: valuevertex.h:41
T Type
Value type.
Definition: valuevertex.h:43
virtual ~ValueVertex()
Definition: valuevertex.h:49
ValueVertex(const Type &val)
Constructor from a value.
Definition: valuevertex.h:48
ValueVertexRef< T > Ref
Reference type.
Definition: valuevertex.h:42
BaseVertex Base
Base class.
Definition: valuevertex.h:39
const Type & value() const
Const accessor to th value.
Definition: valuevertex.h:54
Type value()
Non const accessor to the value.
Definition: valuevertex.h:56