GraphNodeBase< NODEDATA, EDGE > Class Template Reference

#include <graph.h>

Detailed Description

template<typename NODEDATA, typename EDGE>
class maxon::GraphNodeBase< NODEDATA, EDGE >

Basic node template for a graph, reppresent a node with attached strokes pointers list basically an node with an adjacency list.

Template Parameters
NODEDATACustom Data attched to the node.
EDGEEdge type have to be GraphEdgeBase<this->Type>.

GraphNodeBase is the protected base class of GraphNode. GraphNode adds no further data members, therefore both have the same memory layout. You only have to work with GraphNodeBase when you implement GraphModelInterface and need access to its data members.

Public Types

typedef GraphNodeBase< NODEDATA, EDGE > NodeType
 

Public Member Functions

 GraphNodeBase ()
 
 GraphNodeBase (const NODEDATA &data, Vector pos=Vector())
 
 ~GraphNodeBase ()
 
 GraphNodeBase (GraphNodeBase &&src)
 
Result< void > CopyFrom (const GraphNodeBase &src)
 
Vector GetPosition () const
 
void SetPosition (const Vector &pos)
 
Int GetEdgesCount () const
 
Result< EDGE * > GetEdge (Int pos) const
 
Result< NodeType * > GetNeighbor (Int pos) const
 
Result< EDGE * > FindEdge (NodeType *otherHand)
 
Result< void > AddEdge (EDGE *edge)
 
Result< void > DeleteEdge (Int32 pos)
 
Result< void > DeleteEdge (EDGE *edge)
 
const NODEDATA * GetData () const
 
Result< void > SetData (const NODEDATA &data)
 
void Visit ()
 
void Unvisit ()
 
Bool IsVisited () const
 
void Reset ()
 
const GraphNodeBaseGetBase () const
 
GraphNodeBaseGetBase ()
 

Public Attributes

GraphModelRef _graph
 
Int _mem [MEMCOUNT]
 

Static Public Attributes

static const Int MEMCOUNT
 

Protected Member Functions

const GraphNodeGetGraphNode () const
 
GraphModelInterfacePrivateGetGraph () const
 
const ThreadReferencedErrorGetErrorStorage () const
 

Protected Attributes

NODEDATA _data
 
Vector _pos
 
Bool _visited
 
BaseArray< EDGE * > _edges
 

Static Private Attributes

static constexpr Bool HAS_ERROR
 

Member Typedef Documentation

◆ NodeType

typedef GraphNodeBase<NODEDATA, EDGE> NodeType

Constructor & Destructor Documentation

◆ GraphNodeBase() [1/3]

GraphNodeBase ( )
explicit

◆ GraphNodeBase() [2/3]

GraphNodeBase ( const NODEDATA &  data,
Vector  pos = Vector() 
)
explicit

◆ ~GraphNodeBase()

◆ GraphNodeBase() [3/3]

GraphNodeBase ( GraphNodeBase< NODEDATA, EDGE > &&  src)

Member Function Documentation

◆ CopyFrom()

Result<void> CopyFrom ( const GraphNodeBase< NODEDATA, EDGE > &  src)

◆ GetPosition()

Vector GetPosition ( ) const

Get the Node position.

Returns
The Node position.

◆ SetPosition()

void SetPosition ( const Vector pos)

Set the Node position.

Parameters
[in]posThe new Node position.

◆ GetEdgesCount()

Int GetEdgesCount ( ) const

Get the edges count for this point.

Returns
The PenPoint::EdgeType count.

◆ GetEdge()

Result<EDGE*> GetEdge ( Int  pos) const

Get the edges at pos in the list.

Parameters
[in]posThe edge index position.
Returns
The PenPoint::EdgeType pointer pos or error if pos is out of bounds.

◆ GetNeighbor()

Result<NodeType*> GetNeighbor ( Int  pos) const

Get The other hand of the edge at index pos.

Parameters
[in]posthe edge index.
Returns
The node pointer otherwise an error.

◆ FindEdge()

Result<EDGE*> FindEdge ( NodeType otherHand)

Find an edge in between this node and otherHand node.

Parameters
[in]otherHandThe other node which create the edge.
Returns
The edge pointer of an error if used nodes does not share any edge.

◆ AddEdge()

Result<void> AddEdge ( EDGE *  edge)

Add a new edges to the point.

Parameters
[in]edgeThe edge to add.
Returns
OK on success.

◆ DeleteEdge() [1/2]

Result<void> DeleteEdge ( Int32  pos)

Remove the edge at pos.

Parameters
[in]posThe edge list index.
Returns
OK on success.

◆ DeleteEdge() [2/2]

Result<void> DeleteEdge ( EDGE *  edge)

Remove edge form the list.

Parameters
[in]edgeThe edge to be removed.
Returns
OK on success.

◆ GetData()

const NODEDATA* GetData ( void  ) const

Get a pointer to user data.

Returns
The user data pointer.

◆ SetData()

Result<void> SetData ( const NODEDATA &  data)

Replace current user data with the passed one, data is duplicated.

Parameters
[in]dataThe new data to be used.
Returns
OK on success.

◆ Visit()

void Visit ( )

Process this node.

◆ Unvisit()

void Unvisit ( )

Reset the processing status.

◆ IsVisited()

Bool IsVisited ( ) const

Get the processing status.

Returns
The processing status.

◆ Reset()

void Reset ( void  )

Free memory and reset all values, could be extended for each implementation.

◆ GetBase() [1/2]

const GraphNodeBase& GetBase ( ) const

Returns this GraphNode, downcasted to its protected base class GraphNodeBase. This function is needed by implementations of GraphModelInterface to access the protected data members of GraphNodeBase.

Returns
OK on success.

◆ GetBase() [2/2]

GraphNodeBase& GetBase ( )

Returns this GraphNode, downcasted to its protected base class GraphNodeBase. This function is needed by implementations of GraphModelInterface to access the protected data members of GraphNodeBase.

Returns
OK on success.

◆ GetGraphNode()

const GraphNode & GetGraphNode ( ) const
protected

◆ PrivateGetGraph()

GraphModelInterface* PrivateGetGraph ( ) const
protected

◆ GetErrorStorage()

const ThreadReferencedError& GetErrorStorage ( ) const
protected

Member Data Documentation

◆ _data

NODEDATA _data
protected

◆ _pos

Vector _pos
protected

◆ _visited

Bool _visited
protected

◆ _edges

BaseArray<EDGE*> _edges
protected

◆ _graph

GraphModelRef _graph

The graph model of this graph node.

◆ MEMCOUNT

const Int MEMCOUNT
static

Number of Int elements in _mem, currently 5.

◆ _mem

Int _mem[MEMCOUNT]
mutable

Some storage space for free use by the GraphModelInterface implementation. Typically this holds information to identify the graph node such as a path.

◆ HAS_ERROR

constexpr Bool HAS_ERROR
staticconstexprprivate