bioprocessing  5.1.2
basevertex.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_BASEVERTEX
12 #define BIOPROCESSING_GRAPH_BASEVERTEX
13 
14 //--- cartobase --------------------------------------------------------------
15 #include <cartobase/smart/rcptr.h> // carto::rc_ptr
16 //----------------------------------------------------------------------------
17 
18 namespace bio {
19 
20  class BaseVertex;
21  class BaseVertexRef;
22 
23 //============================================================================
24 // BASE VERTEX: DECLARATION
25 //============================================================================
33  class BaseVertex: public carto::RCObject
34  {
35  //--- typedef ------------------------------------------------------------
36  protected:
37  typedef BaseVertex This;
38  public:
40  typedef BaseVertexRef Ref;
41 
42  //--- constructor --------------------------------------------------------
43  public:
46  virtual ~BaseVertex() {}
47 
48  //--- virtual operators --------------------------------------------------
49  public:
50  virtual bool operator>( const This & other ) const
51  {
52  return this > &other;
53  }
54  virtual bool operator<( const This & other ) const
55  {
56  return this < &other;
57  }
58  virtual bool operator==( const This & other ) const
59  {
60  return this == &other;
61  }
62  virtual bool operator!=( const This & other ) const
63  {
64  return this != &other;
65  }
66  virtual bool operator<=( const This & other ) const
67  {
68  return this <= &other;
69  }
70  virtual bool operator>=( const This & other ) const
71  {
72  return this >= &other;
73  }
74 
75  friend class BaseVertexRef;
76  };
77 
78 } // namespace bio
79 
80 //============================================================================
81 // BASE VERTEX: STREAM
82 //============================================================================
85 std::ostream & operator<<( std::ostream & os, const bio::BaseVertex & v )
86 {
87  os << "V{ " << (long
88 #if defined( _WIN64 )
89  long int
90 #endif
91  ) &v << " }";
92  return os;
93 }
94 
95 namespace bio {
96 
97 //============================================================================
98 // BASE VERTEX REF
99 //============================================================================
104  class BaseVertexRef: public carto::rc_ptr<BaseVertex>
105  {
106  //--- typedef ------------------------------------------------------------
107  protected:
108  typedef BaseVertexRef This;
109  typedef carto::rc_ptr<BaseVertex> Base;
110  typedef BaseVertex Pointed;
111  public:
113 
114  //--- constructor --------------------------------------------------------
115  public:
123  BaseVertexRef( Pointed * v ): Base(v) {}
126  BaseVertexRef( const Base & other ): Base(other) {}
127  virtual ~BaseVertexRef() {}
128 
129  //--- none factory -------------------------------------------------------
130  public:
133  static Vertex none() { return This( (Pointed*)0 ); }
134 
135  //--- virtual operators --------------------------------------------------
136  public:
139  virtual bool operator== ( const This & other ) const
140  {
141  if( !(*this) && !other )
142  return true;
143  else if( !(*this) || !other )
144  return false;
145  else
146  return *(this->get()) == *(other.get());
147  }
148  virtual bool operator!= ( const This & other ) const
149  {
150  return !( *this == other );
151  }
152  virtual bool operator> ( const This & other ) const
153  {
154  if( *this == other )
155  return false;
156  else
157  return this > &other;
158  }
159  virtual bool operator< ( const This & other ) const
160  {
161  if( *this == other )
162  return false;
163  else
164  return this < &other;
165  }
166  virtual bool operator>= ( const This & other ) const
167  {
168  return ( *this == other ) || ( *this > other );
169  }
170  virtual bool operator<= ( const This & other ) const
171  {
172  return ( *this == other ) || ( *this < other );
173  }
174 
175  //--- friends ------------------------------------------------------------
176  friend class BaseVertex;
177  };
178 
179 } // namespace bio
180 
181 //============================================================================
182 // BASE EDGE REF: STREAM
183 //============================================================================
187 std::ostream & operator<<( std::ostream & os, const bio::BaseVertexRef & v )
188 {
189  if( v.get() )
190  os << *v;
191  else
192  os << "V{ NULL }";
193  return os;
194 }
195 
196 #endif // BIOPROCESSING_GRAPH_BASEVERTEX
std::ostream & operator<<(std::ostream &os, const bio::BaseVertex &v)
Print of a BaseVertex.
Definition: basevertex.h:85
Reference counting pointer to a BaseVertex.
Definition: basevertex.h:105
BaseVertexRef This
Type of *this.
Definition: basevertex.h:108
static Vertex none()
Empty pointer factory.
Definition: basevertex.h:133
BaseVertexRef()
Default constructor.
Definition: basevertex.h:119
virtual ~BaseVertexRef()
Definition: basevertex.h:127
virtual bool operator>=(const This &other) const
Definition: basevertex.h:166
virtual bool operator!=(const This &other) const
Definition: basevertex.h:148
BaseVertexRef(Pointed *v)
Constructor from a pointer (the pointer should either be created by new, or be already referenced by ...
Definition: basevertex.h:123
virtual bool operator<(const This &other) const
Definition: basevertex.h:159
virtual bool operator==(const This &other) const
There is equality if both pointers are none, or if both pointed objects are equal.
Definition: basevertex.h:139
Pointed::Vertex Vertex
Useable type.
Definition: basevertex.h:112
virtual bool operator>(const This &other) const
Definition: basevertex.h:152
carto::rc_ptr< BaseVertex > Base
Base class type.
Definition: basevertex.h:109
BaseVertex Pointed
Pointed object type.
Definition: basevertex.h:110
virtual bool operator<=(const This &other) const
Definition: basevertex.h:170
BaseVertexRef(const Base &other)
Copy constructor (copies the reference, it does not duplicate the pointed object)
Definition: basevertex.h:126
Base class for vertices.
Definition: basevertex.h:34
BaseVertex This
Type of *this.
Definition: basevertex.h:37
virtual bool operator==(const This &other) const
Definition: basevertex.h:58
BaseVertex()
Default constructor.
Definition: basevertex.h:45
virtual bool operator>=(const This &other) const
Definition: basevertex.h:70
virtual bool operator>(const This &other) const
Definition: basevertex.h:50
virtual ~BaseVertex()
Definition: basevertex.h:46
BaseVertexRef Ref
RC pointer to the type.
Definition: basevertex.h:40
BaseVertexRef Vertex
Useable type (its RC pointer)
Definition: basevertex.h:39
virtual bool operator<(const This &other) const
Definition: basevertex.h:54
virtual bool operator<=(const This &other) const
Definition: basevertex.h:66
virtual bool operator!=(const This &other) const
Definition: basevertex.h:62