24 #include <Mangling.hpp> 26 #include <UnorderedMap.hpp> 49 template <
typename VertexContent,
typename Alloc>
class WeakVertex;
67 template <
typename VertexContent,
typename Alloc>
class Vertex {
78 , num(vertex_counter++)
86 , num(vertex_counter++)
92 , num(vertex_counter++)
98 typedef typename Alloc::template rebind<CountedContent>::other alloc_t;
117 cc->~CountedContent();
118 alloc.deallocate(cc, 1);
178 explicit Vertex(identity_t
id);
191 explicit Vertex(
const weak_ref_t& w);
238 return id() == other.
id();
246 return id() != other.
id();
254 return id() > other.
id();
262 return id() < other.
id();
270 return id() >= other.
id();
278 return id() <= other.
id();
291 identity_t
id()
const {
373 template <
typename VertexContent,
typename Alloc>
378 template <
typename VertexContent,
typename Alloc>
class WeakVertex :
public Vertex<VertexContent, Alloc> {
409 :
Vertex<VertexContent, Alloc>(0)
417 :
Vertex<VertexContent, Alloc>(0)
426 :
Vertex<VertexContent, Alloc>(0)
435 :
Vertex<VertexContent, Alloc>(0)
437 this->
content =
reinterpret_cast<CountedContent*
>(
id);
453 this->
content =
reinterpret_cast<CountedContent*
>(
id);
478 template <
typename VertexContent,
typename Alloc>
482 content = CountedContent::New();
485 template <
typename VertexContent,
typename Alloc>
509 template <
typename VertexContent,
typename Alloc>
516 template <
typename VertexContent,
typename Alloc>
523 template <
typename VertexContent,
typename Alloc>
534 template <
typename VertexContent,
typename Alloc>
541 return *
this = (
const identity_t&)(*(CountedContent::New(*
id)));
545 template <
typename VertexContent,
typename Alloc>
573 CountedContent::Delete(
content);
578 template <
typename VertexContent,
typename Alloc>
584 template <
typename VertexContent,
typename Alloc>
596 template <
typename VertexContent,
typename Alloc,
typename charT>
599 ss <<
"Vertex<" << util::demangle(
typeid(VertexContent).name()) <<
">(" << v.
id() <<
")";
609 template <
typename VertexContent,
typename Alloc>
610 struct hash<
mgx::graph::Vertex<VertexContent, Alloc> > {
613 return ((
size_t)v.
id()) >> 2;
617 template <
typename VertexContent,
typename Alloc>
618 struct hash<
mgx::graph::WeakVertex<VertexContent, Alloc> > {
621 return ((
size_t)v.
id()) >> 2;
identity_t id() const
Return the identifier of a vertex.
Definition: Vertex.hpp:291
void release()
Release the current pointer.
Definition: Vertex.hpp:567
bool operator!=(const Vertex &other) const
Comparison operators.
Definition: Vertex.hpp:245
unsigned int count
Reference count on the vertex.
Definition: Vertex.hpp:124
bool operator==(const Vertex &other) const
Comparison operators.
Definition: Vertex.hpp:237
bool operator<(const Vertex &other) const
Comparison operators.
Definition: Vertex.hpp:261
Vertex< VertexContent, Alloc > strong_ref
Strong reference corresponding to the weak one.
Definition: Vertex.hpp:395
WeakVertex(const identity_t &id)
Construct a weak reference from an id.
Definition: Vertex.hpp:434
VertexContent * pointer
Type of the equivalent pointer.
Definition: Vertex.hpp:145
WeakVertex()
Construct an empty weak vertex.
Definition: Vertex.hpp:408
weak_ref_t weakRef() const
Construct a weak reference on the current vertex.
Definition: Vertex.hpp:579
Vertex()
Creates a new vertex with a new content.
Definition: Vertex.hpp:479
Type of the reference counted content.
Definition: Vertex.hpp:74
VertexContent content_t
Type of the content of the vertex.
Definition: Vertex.hpp:138
size_t num() const
Return a number unique to each vertex, globally.
Definition: Vertex.hpp:298
Definition: Vertex.hpp:49
vertex_identity_t identity_t
Type of the identifier of the vertex.
Definition: Vertex.hpp:133
vertex_identity_t identity_t
Type of the identifier of the vertex.
Definition: Vertex.hpp:385
CountedContent * content
Content of the vertex.
Definition: Vertex.hpp:360
VertexContent & operator*() const
Access to the data.
Definition: Vertex.hpp:211
VertexContent * operator->() const
Access to the data.
Definition: Vertex.hpp:203
intptr_t vertex_identity_t
Type of the identifier of a vertex.
Definition: Vertex.hpp:42
Vertex & operator=(const Vertex &other)
Change the vertex held by the current object.
Definition: Vertex.hpp:585
void acquire()
Acquire the current pointer.
Definition: Vertex.hpp:556
bool operator<=(const Vertex &other) const
Comparison operators.
Definition: Vertex.hpp:277
mgx_EXPORT size_t vertex_counter
Number used to enumerate the vertices of all types.
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Vertex of a vv graph.
Definition: Vertex.hpp:67
WeakVertex(const strong_ref &v)
Construct a weak reference from a strong one.
Definition: Vertex.hpp:416
bool isWeakRef() const
Return true if the current object hold a weak reference on a vertex.
Definition: Vertex.hpp:310
unsigned int count() const
Serialization method.
Definition: Vertex.hpp:345
VertexContent * pointer
Type of the equivalent pointer.
Definition: Vertex.hpp:400
bool operator>=(const Vertex &other) const
Comparison operators.
Definition: Vertex.hpp:269
WeakVertex & operator=(const WeakVertex &other)
Set the content of the weak reference.
Definition: Vertex.hpp:445
WeakVertex(const WeakVertex ©)
Copy constructor.
Definition: Vertex.hpp:425
bool isNull() const
Test if a vertex is a null vertex.
Definition: Vertex.hpp:284
VertexContent content_t
Type of the content of the vertex.
Definition: Vertex.hpp:390
bool operator>(const Vertex &other) const
Comparison operators.
Definition: Vertex.hpp:253
static Vertex null
Null vertex.
Definition: Vertex.hpp:335
~Vertex()
Desctructor.
Definition: Vertex.hpp:474