#include <graph/vertex.h>
Public Types | |
typedef VertexContent | content_t |
Type of the content of the vertex. | |
typedef CountedContent < VertexContent > | counted_content_t |
Type of the reference-counted content. | |
typedef vertex_identity_t | identity_t |
Type of the identifier of the vertex. | |
typedef content_t * | pointer |
Type of the equivalent pointer. | |
typedef counted_content_t * | real_pointer |
Pointer to the reference-counted content. | |
typedef content_t & | reference |
typedef WeakVertex< VERTEX_ARGS > | weak_ref_t |
Public Member Functions | |
real_pointer | acquire () |
Return the content, and reset the value in the vertex. | |
real_pointer | content () const |
Return the reference-counted object. | |
identity_t | id () const |
Return the identifier of a vertex. | |
bool | isNull () const |
Test if a vertex is a null vertex. | |
bool | isWeakRef () const |
Return true if the current object hold a weak reference on a vertex. | |
size_t | num () const |
Return a number unique to each vertex, globally. | |
operator bool () const | |
Convert a vertex to true if it is not null. | |
template<typename T1 > | |
bool | operator!= (const Vertex< T1 > &other) const |
Two vertices of different types cannot be equal. | |
bool | operator!= (const Vertex &other) const |
Comparison operators. | |
reference | operator* () const |
Access to the data. | |
pointer | operator-> () const |
Access to the data. | |
template<typename R > | |
const R & | operator->* (R VertexContent::*ptr) const |
Constant access to the data via pointer to member. | |
template<typename R > | |
R & | operator->* (R VertexContent::*ptr) |
Access to the data via pointer to member. | |
bool | operator< (const Vertex &other) const |
Comparison operators. | |
bool | operator<= (const Vertex &other) const |
Comparison operators. | |
Vertex & | operator= (const weak_ref_t &other) |
Vertex & | operator= (const identity_t &id) |
Vertex & | operator= (const Vertex &other) |
Change the vertex held by the current object. | |
template<typename T1 > | |
bool | operator== (const Vertex< T1 > &) const |
Two vertices of different types cannot be equal. | |
bool | operator== (const Vertex &other) const |
Comparison operators. | |
bool | operator> (const Vertex &other) const |
Comparison operators. | |
bool | operator>= (const Vertex &other) const |
Comparison operators. | |
bool | serialize (storage::VVEStorage &) |
Serialization method. | |
Vertex (const weak_ref_t &w) | |
Construct a strong reference from a weak one. | |
Vertex (real_pointer content) | |
Create a vertex using a counted content. | |
Vertex (const Vertex ©) | |
Copy a vertex. | |
Vertex (identity_t id) | |
Creates a reference on the vertex of identifier id . | |
Vertex (int i) | |
Create an empty vertex (argument really should be 0). | |
Vertex () | |
Creates a new vertex with a new content. | |
weak_ref_t | weakRef () const |
Construct a weak reference on the current vertex. | |
~Vertex () | |
Desctructor. | |
Public Attributes | |
void * | cache |
Cache information for iteration optimization. | |
identity_t | cache_source |
Label of the reference vertex for the cache information. | |
Static Public Attributes | |
static Vertex | null |
Null vertex. | |
Protected Member Functions | |
void | release () |
Release the current pointer. | |
Protected Attributes | |
real_pointer | _content |
Content of the vertex. | |
Friends | |
class | WeakVertex< VERTEX_ARGS > |
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. This identifier can be used to retrieve a weak reference on the data.
Definition at line 116 of file vertex.h.
typedef VertexContent graph::Vertex< VertexContent >::content_t |
Type of the content of the vertex.
Reimplemented in graph::WeakVertex< VertexContent >.
typedef CountedContent<VertexContent> graph::Vertex< VertexContent >::counted_content_t |
typedef vertex_identity_t graph::Vertex< VertexContent >::identity_t |
Type of the identifier of the vertex.
Reimplemented in graph::WeakVertex< VertexContent >.
typedef content_t* graph::Vertex< VertexContent >::pointer |
Type of the equivalent pointer.
Reimplemented in graph::WeakVertex< VertexContent >.
typedef counted_content_t* graph::Vertex< VertexContent >::real_pointer |
graph::Vertex< TEMPLATE_VERTEX >::Vertex | ( | ) | [inline] |
Creates a new vertex with a new content.
Example:
struct VertexContent { int a; } // ... Vertex<VertexContent> v; v->a = 10;
Definition at line 623 of file vertex.h.
References graph::Vertex< VertexContent >::_content.
00624 : _content(0) 00625 #ifndef VVVERTEX_NO_CACHE 00626 , cache_source(0) 00627 , cache(0) 00628 #endif 00629 { 00630 #ifdef USE_ALLOCATOR 00631 _content = alloc.allocate(1); 00632 ::new(_content) counted_content_t(); 00633 #elif defined(DEBUG_ALLOC) // defined USE_ALLOCATOR 00634 try 00635 { 00636 _content = new counted_content_t(); 00637 } 00638 catch(std::bad_alloc& ) 00639 { 00640 _content = 0; 00641 } 00642 #else 00643 _content = new counted_content_t(); 00644 #endif // defined USE_ALLOCATOR 00645 }
graph::Vertex< TEMPLATE_VERTEX >::Vertex | ( | int | i | ) | [inline, explicit] |
graph::Vertex< TEMPLATE_VERTEX >::Vertex | ( | identity_t | id | ) | [inline, explicit] |
Creates a reference on the vertex of identifier id
.
If id
is 0, creates a null vertex.
[in] | id | Label of the vertex to retrieve. |
Example:
typedef Vertex<VertexContent> vertex; vertex v; vertex::identity_t i = v.id(); vertex v1(i); assert(v1 == v);
Definition at line 659 of file vertex.h.
References graph::Vertex< VertexContent >::_content, and graph::CountedContent< Content >::count.
graph::Vertex< TEMPLATE_VERTEX >::Vertex | ( | const Vertex< VertexContent > & | copy | ) | [inline] |
Copy a vertex.
The data is not copied. The quality of the copy (i.e. weak/strong reference) is the same as the copied.
Definition at line 724 of file vertex.h.
References graph::Vertex< VertexContent >::_content, and graph::CountedContent< Content >::count.
graph::Vertex< TEMPLATE_VERTEX >::Vertex | ( | real_pointer | content | ) | [inline] |
Create a vertex using a counted content.
The vertex add to the ownership of the content
Definition at line 676 of file vertex.h.
References graph::Vertex< VertexContent >::_content, and graph::CountedContent< Content >::count.
graph::Vertex< VertexContent >::Vertex | ( | const weak_ref_t & | w | ) | [explicit] |
Construct a strong reference from a weak one.
graph::Vertex< TEMPLATE_VERTEX >::~Vertex | ( | ) | [inline] |
real_pointer graph::Vertex< VertexContent >::acquire | ( | ) | [inline] |
Return the content, and reset the value in the vertex.
Definition at line 267 of file vertex.h.
00267 { real_pointer p = _content; _content = 0; return p; }
real_pointer graph::Vertex< VertexContent >::content | ( | ) | const [inline] |
identity_t graph::Vertex< VertexContent >::id | ( | ) | const [inline] |
Return the identifier of a vertex.
Definition at line 395 of file vertex.h.
Referenced by graph::VVGraph< VertexContent, EdgeContent, compact >::arc(), graph::VVGraph< VertexContent, EdgeContent, compact >::edge(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::edge(), graph::VVGraph< VertexContent, EdgeContent, compact >::findInVertex(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::findInVertex(), graph::VVGraph< VertexContent, EdgeContent, compact >::insertEdge(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::insertEdge(), graph::VVGraph< VertexContent, EdgeContent, compact >::insertEdges(), graph::Vertex< VERTEX_ARGS >::operator!=(), graph::Vertex< VERTEX_ARGS >::operator<(), graph::Vertex< VERTEX_ARGS >::operator<=(), graph::Vertex< VERTEX_ARGS >::operator==(), graph::Vertex< VERTEX_ARGS >::operator>(), graph::Vertex< VERTEX_ARGS >::operator>=(), graph::VVGraph< VertexContent, EdgeContent, compact >::replace(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::replace(), graph::VVGraph< VertexContent, EdgeContent, compact >::spliceAfter(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::spliceAfter(), graph::VVGraph< VertexContent, EdgeContent, compact >::spliceBefore(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::spliceBefore(), graph::VVGraph< VertexContent, EdgeContent, compact >::updateEdgeCache(), and graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::updateEdgeCache().
00395 { return (identity_t)_content; }
bool graph::Vertex< VertexContent >::isNull | ( | ) | const [inline] |
Test if a vertex is a null vertex.
Reimplemented in graph::WeakVertex< VertexContent >.
Definition at line 390 of file vertex.h.
Referenced by graph::VVGraph< VertexContent, EdgeContent, compact >::anyIn(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::anyIn(), vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::connectFromJunctions(), graph::VVGraph< VertexContent, EdgeContent, compact >::empty(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::empty(), graph::VVGraph< VertexContent, EdgeContent, compact >::findInVertex(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::findInVertex(), graph::VVGraph< VertexContent, EdgeContent, compact >::iAnyIn(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::iAnyIn(), graph::VVGraph< VertexContent, EdgeContent, compact >::iEmpty(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::iEmpty(), graph::VVGraph< VertexContent, EdgeContent, compact >::iNeighbors(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::iNeighbors(), graph::VVGraph< VertexContent, EdgeContent, compact >::insertEdge(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::insertEdge(), graph::VVGraph< VertexContent, EdgeContent, compact >::insertEdges(), graph::VVGraph< VertexContent, EdgeContent, compact >::iValence(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::iValence(), graph::VVGraph< VertexContent, EdgeContent, compact >::neighbors(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::neighbors(), graph::VVGraph< VertexContent, EdgeContent, compact >::replace(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::replace(), graph::VVGraph< VertexContent, EdgeContent, compact >::spliceAfter(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::spliceAfter(), graph::VVGraph< VertexContent, EdgeContent, compact >::spliceBefore(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::spliceBefore(), graph::VVGraph< VertexContent, EdgeContent, compact >::valence(), and graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::valence().
00390 { return _content == 0; }
bool graph::Vertex< VertexContent >::isWeakRef | ( | ) | const [inline] |
size_t graph::Vertex< VertexContent >::num | ( | ) | const [inline] |
Return a number unique to each vertex, globally.
This method can be removed by defining NO_NUMBER_VERTICES at compile time
Definition at line 405 of file vertex.h.
Referenced by graph::Vertex< VERTEX_ARGS >::operator<(), graph::Vertex< VERTEX_ARGS >::operator<=(), graph::Vertex< VERTEX_ARGS >::operator>(), and graph::Vertex< VERTEX_ARGS >::operator>=().
00405 { return _content->num; }
graph::Vertex< VertexContent >::operator bool | ( | ) | const [inline] |
bool graph::Vertex< VertexContent >::operator!= | ( | const Vertex< T1 > & | other | ) | const [inline] |
bool graph::Vertex< VertexContent >::operator!= | ( | const Vertex< VertexContent > & | other | ) | const [inline] |
reference graph::Vertex< VertexContent >::operator* | ( | ) | const [inline] |
pointer graph::Vertex< VertexContent >::operator-> | ( | ) | const [inline] |
const R& graph::Vertex< VertexContent >::operator->* | ( | R VertexContent::* | ptr | ) | const [inline] |
R& graph::Vertex< VertexContent >::operator->* | ( | R VertexContent::* | ptr | ) | [inline] |
bool graph::Vertex< VertexContent >::operator< | ( | const Vertex< VertexContent > & | other | ) | const [inline] |
bool graph::Vertex< VertexContent >::operator<= | ( | const Vertex< VertexContent > & | other | ) | const [inline] |
Vertex< VERTEX_ARGS > & graph::Vertex< TEMPLATE_VERTEX >::operator= | ( | const Vertex< VertexContent > & | other | ) | [inline] |
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 821 of file vertex.h.
References graph::Vertex< VertexContent >::_content.
bool graph::Vertex< VertexContent >::operator== | ( | const Vertex< T1 > & | ) | const [inline] |
bool graph::Vertex< VertexContent >::operator== | ( | const Vertex< VertexContent > & | other | ) | const [inline] |
bool graph::Vertex< VertexContent >::operator> | ( | const Vertex< VertexContent > & | other | ) | const [inline] |
bool graph::Vertex< VertexContent >::operator>= | ( | const Vertex< VertexContent > & | other | ) | const [inline] |
void graph::Vertex< TEMPLATE_VERTEX >::release | ( | ) | [inline, protected] |
Release the current pointer.
Definition at line 797 of file vertex.h.
00798 { 00799 if( _content ) 00800 { 00801 --(_content->count); 00802 if(_content->count == 0) 00803 { 00804 #ifdef USE_ALLOCATOR 00805 _content->~counted_content_t(); 00806 alloc.deallocate(_content, 1); 00807 #else // defined USE_ALLOCATOR 00808 delete _content; 00809 #endif 00810 } 00811 } 00812 }
bool graph::Vertex< VertexContent >::serialize | ( | storage::VVEStorage & | ) |
Serialization method.
Vertex< VERTEX_ARGS >::weak_ref_t graph::Vertex< TEMPLATE_VERTEX >::weakRef | ( | ) | const [inline] |
real_pointer graph::Vertex< VertexContent >::_content [mutable, protected] |
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 457 of file vertex.h.
Referenced by graph::Vertex< VERTEX_ARGS >::acquire(), graph::Vertex< VERTEX_ARGS >::content(), graph::Vertex< VERTEX_ARGS >::id(), graph::Vertex< VERTEX_ARGS >::isNull(), graph::Vertex< VERTEX_ARGS >::num(), graph::Vertex< VERTEX_ARGS >::operator bool(), graph::Vertex< VERTEX_ARGS >::operator*(), graph::Vertex< VERTEX_ARGS >::operator->(), graph::Vertex< VERTEX_ARGS >::operator->*(), graph::Vertex< VertexContent >::operator=(), graph::WeakVertex< VertexContent >::operator=(), graph::Vertex< VertexContent >::Vertex(), and graph::WeakVertex< VertexContent >::WeakVertex().
void* graph::Vertex< VertexContent >::cache [mutable] |
Cache information for iteration optimization.
Definition at line 479 of file vertex.h.
Referenced by graph::VVGraph< VertexContent, EdgeContent, compact >::findInVertex(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::findInVertex(), graph::VVGraph< VertexContent, EdgeContent, compact >::findVertex(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::findVertex(), graph::VVGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), graph::_EmptyEdgeContent, false >::store_vertices(), graph::VVGraph< VertexContent, EdgeContent, compact >::updateEdgeCache(), and graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::updateEdgeCache().
identity_t graph::Vertex< VertexContent >::cache_source [mutable] |
Label of the reference vertex for the cache information.
Definition at line 472 of file vertex.h.
Referenced by graph::VVGraph< VertexContent, EdgeContent, compact >::findInVertex(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::findInVertex(), graph::VVGraph< VertexContent, EdgeContent, compact >::findVertex(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::findVertex(), graph::VVGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), graph::_EmptyEdgeContent, false >::store_vertices(), graph::VVGraph< VertexContent, EdgeContent, compact >::updateEdgeCache(), and graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::updateEdgeCache().
Vertex< VERTEX_ARGS > graph::Vertex< TEMPLATE_VERTEX >::null [inline, static] |
Null vertex.
Useful to return a constant reference on a vertex all the time.
Example:
const vertex& fct(bool cond) { static vertex a; if(cond) return a; return vertex::null; }
Definition at line 439 of file vertex.h.
Referenced by vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::adjacentCell(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::adjacentCells(), graph::VVGraph< VertexContent, EdgeContent, compact >::any(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::any_vertex1(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::any_vertex2(), graph::VVGraph< VertexContent, EdgeContent, compact >::anyIn(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::anyIn(), graph::VVGraph< VertexContent, EdgeContent, compact >::flagged(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::flagged(), graph::VVGraph< VertexContent, EdgeContent, compact >::iAnyIn(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::iAnyIn(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::interfaceWall(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::interfaceWallSpan(), graph::VVGraph< VertexContent, EdgeContent, compact >::nextTo(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::nextTo(), graph::VVGraph< VertexContent, EdgeContent, compact >::prevTo(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::prevTo(), graph::VVGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), graph::_EmptyEdgeContent, false >::reference(), graph::VVBiGraph< typename cell::content_t, typename junction::content_t >::reference(), graph::VVGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), graph::_EmptyEdgeContent, false >::source(), graph::VVBiGraph< typename cell::content_t, typename junction::content_t >::source(), graph::VVGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), graph::_EmptyEdgeContent, false >::store_vertices(), graph::VVGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), graph::_EmptyEdgeContent, false >::target(), and graph::VVBiGraph< typename cell::content_t, typename junction::content_t >::target().