MorphoGraphX  2.0-1-227
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
mgx::Vertex< VertexContent > Class Template Reference

#include <Vertex.hpp>

Classes

struct  CountedContent
 Type of the reference counted content. More...
 

Public Types

typedef vertex_identity_t identity_t
 Type of the identifier of the vertex. More...
 
typedef VertexContent content_t
 Type of the content of the vertex. More...
 
typedef VertexContent * pointer
 Type of the equivalent pointer. More...
 

Public Member Functions

 Vertex ()
 Creates a new vertex with a new content. More...
 
 Vertex (identity_t id)
 Creates a reference on the vertex of identifier id. More...
 
 Vertex (const Vertex &copy)
 Copy a vertex. More...
 
 ~Vertex ()
 Desctructor. More...
 
VertexContent * operator-> () const
 Access to the data. More...
 
VertexContent & operator* () const
 Access to the data. More...
 
Vertexoperator= (const Vertex &other)
 Change the vertex held by the current object. More...
 
Vertexoperator= (const identity_t &id)
 
Vertexoperator= (const VertexContent *value)
 
bool operator== (const Vertex &other) const
 Comparison operators. More...
 
bool operator!= (const Vertex &other) const
 Comparison operators. More...
 
bool operator> (const Vertex &other) const
 Comparison operators. More...
 
bool operator< (const Vertex &other) const
 Comparison operators. More...
 
bool operator>= (const Vertex &other) const
 Comparison operators. More...
 
bool operator<= (const Vertex &other) const
 Comparison operators. More...
 
bool isNull () const
 Test if a vertex is a null vertex. More...
 
identity_t id () const
 Return the identifier of a vertex. More...
 
size_t num () const
 Return a number unique to each vertex, globally. More...
 
 operator bool () const
 Convert a vertex to true if it is not null. More...
 
unsigned int count () const
 

Static Public Attributes

static Vertex null
 

Protected Member Functions

void release ()
 Release the current pointer. More...
 
void acquire ()
 Acquire the current pointer. More...
 

Protected Attributes

CountedContentcontent
 Content of the vertex. More...
 

Detailed Description

template<typename VertexContent>
class mgx::Vertex< VertexContent >

Vertex of a vv graph.

The vertexes handle their associated data using a reference counting scheme. As such, they can be used as smart pointers. They are also comparable (<,>,==,!=), which allow for use in any sorted structure and hashable for use in any hash table-based structure.

They also all have a unique identifier.

Definition at line 58 of file Vertex.hpp.

Member Typedef Documentation

◆ content_t

template<typename VertexContent >
typedef VertexContent mgx::Vertex< VertexContent >::content_t

Type of the content of the vertex.

Definition at line 98 of file Vertex.hpp.

◆ identity_t

template<typename VertexContent >
typedef vertex_identity_t mgx::Vertex< VertexContent >::identity_t

Type of the identifier of the vertex.

Definition at line 93 of file Vertex.hpp.

◆ pointer

template<typename VertexContent >
typedef VertexContent* mgx::Vertex< VertexContent >::pointer

Type of the equivalent pointer.

Definition at line 103 of file Vertex.hpp.

Constructor & Destructor Documentation

◆ Vertex() [1/3]

template<typename VertexContent >
mgx::Vertex< VertexContent >::Vertex

Creates a new vertex with a new content.

Example:

struct VertexContent { int a; }
// ...
Vertex<VertexContent> v;
v->a = 10;

Definition at line 296 of file Vertex.hpp.

◆ Vertex() [2/3]

template<typename VertexContent >
mgx::Vertex< VertexContent >::Vertex ( identity_t  id)
explicit

Creates a reference on the vertex of identifier id.

If id is 0, creates a null vertex.

Parameters
[in]idLabel of the vertex to retrieve.
Warning
This function is very unsafe if used with anything but 0 as an identifier.

Example:

typedef Vertex<VertexContent> vertex;
vertex::identity_t i = v.id();
vertex v1(i);
assert(v1 == v);

Definition at line 302 of file Vertex.hpp.

◆ Vertex() [3/3]

template<typename VertexContent >
mgx::Vertex< VertexContent >::Vertex ( const Vertex< VertexContent > &  copy)

Copy a vertex.

The data is not copied.

Definition at line 309 of file Vertex.hpp.

◆ ~Vertex()

template<typename VertexContent >
mgx::Vertex< VertexContent >::~Vertex

Desctructor.

Definition at line 290 of file Vertex.hpp.

Member Function Documentation

◆ acquire()

template<typename VertexContent >
void mgx::Vertex< VertexContent >::acquire
protected

Acquire the current pointer.

Definition at line 337 of file Vertex.hpp.

◆ count()

template<typename VertexContent >
unsigned int mgx::Vertex< VertexContent >::count ( ) const
inline

Definition at line 260 of file Vertex.hpp.

◆ id()

template<typename VertexContent >
identity_t mgx::Vertex< VertexContent >::id ( ) const
inline

Return the identifier of a vertex.

Definition at line 242 of file Vertex.hpp.

◆ isNull()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::isNull ( ) const
inline

Test if a vertex is a null vertex.

Definition at line 235 of file Vertex.hpp.

◆ num()

template<typename VertexContent >
size_t mgx::Vertex< VertexContent >::num ( ) const
inline

Return a number unique to each vertex, globally.

Definition at line 249 of file Vertex.hpp.

◆ operator bool()

template<typename VertexContent >
mgx::Vertex< VertexContent >::operator bool ( ) const
inline

Convert a vertex to true if it is not null.

Definition at line 256 of file Vertex.hpp.

◆ operator!=()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::operator!= ( const Vertex< VertexContent > &  other) const
inline

Comparison operators.

Note
the comparisons work on the identifiers, not the contents!

Definition at line 196 of file Vertex.hpp.

◆ operator*()

template<typename VertexContent >
VertexContent& mgx::Vertex< VertexContent >::operator* ( ) const
inline

Access to the data.

Warning
Do not try to access the data of the null vertex.

Definition at line 164 of file Vertex.hpp.

◆ operator->()

template<typename VertexContent >
VertexContent* mgx::Vertex< VertexContent >::operator-> ( ) const
inline

Access to the data.

Warning
Do not try to access the data of the null vertex.

Definition at line 155 of file Vertex.hpp.

◆ operator<()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::operator< ( const Vertex< VertexContent > &  other) const
inline

Comparison operators.

Note
the comparisons work on the identifiers, not the contents!

Definition at line 212 of file Vertex.hpp.

◆ operator<=()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::operator<= ( const Vertex< VertexContent > &  other) const
inline

Comparison operators.

Note
the comparisons work on the identifiers, not the contents!

Definition at line 228 of file Vertex.hpp.

◆ operator=() [1/3]

template<typename VertexContent >
Vertex< VertexContent > & mgx::Vertex< VertexContent >::operator= ( const identity_t id)

Definition at line 316 of file Vertex.hpp.

◆ operator=() [2/3]

template<typename VertexContent >
Vertex< VertexContent > & mgx::Vertex< VertexContent >::operator= ( const Vertex< VertexContent > &  other)

Change the vertex held by the current object.

The data is never modified by this operation. If you wish to copy the data of a vertex v1 into a vertex v2 use:

*v2 = *v1;

Definition at line 360 of file Vertex.hpp.

◆ operator=() [3/3]

template<typename VertexContent >
Vertex< VertexContent > & mgx::Vertex< VertexContent >::operator= ( const VertexContent *  value)

Definition at line 327 of file Vertex.hpp.

◆ operator==()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::operator== ( const Vertex< VertexContent > &  other) const
inline

Comparison operators.

Note
the comparisons work on the identifiers, not the contents!

Definition at line 188 of file Vertex.hpp.

◆ operator>()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::operator> ( const Vertex< VertexContent > &  other) const
inline

Comparison operators.

Note
the comparisons work on the identifiers, not the contents!

Definition at line 204 of file Vertex.hpp.

◆ operator>=()

template<typename VertexContent >
bool mgx::Vertex< VertexContent >::operator>= ( const Vertex< VertexContent > &  other) const
inline

Comparison operators.

Note
the comparisons work on the identifiers, not the contents!

Definition at line 220 of file Vertex.hpp.

◆ release()

template<typename VertexContent >
void mgx::Vertex< VertexContent >::release
protected

Release the current pointer.

Definition at line 348 of file Vertex.hpp.

Member Data Documentation

◆ content

template<typename VertexContent >
CountedContent* mgx::Vertex< VertexContent >::content
mutableprotected

Content of the vertex.

This member is mutable to allow for modification of constant references. This is useful as no operation on the vertex depend on this.

Definition at line 275 of file Vertex.hpp.

◆ null

template<typename VertexContent >
Vertex< VertexContent > mgx::Vertex< VertexContent >::null
static

Definition at line 258 of file Vertex.hpp.


The documentation for this class was generated from the following file:
mgx::vertex
vvGraph::vertex_t vertex
Type of a vertex.
Definition: Misc.hpp:50
mgx::Vertex::identity_t
vertex_identity_t identity_t
Type of the identifier of the vertex.
Definition: Vertex.hpp:93