A library for working with phylogenetic and population genetic data.
v0.27.0
TreeNode Class Reference

#include <genesis/tree/tree/node.hpp>

Detailed Description

Definition at line 58 of file tree/tree/node.hpp.

Public Member Functions

 TreeNode ()
 
 TreeNode (size_t index, TreeLink *primary_link)
 
 TreeNode (TreeNode &&)=delete
 
 TreeNode (TreeNode const &)=delete
 
 ~TreeNode ()=default
 
template<class NodeDataType >
NodeDataType & data ()
 
template<class NodeDataType >
NodeDataType const & data () const
 
template<class NodeDataType >
NodeDataType * data_cast ()
 
template<class NodeDataType >
NodeDataType const * data_cast () const
 
template<class NodeDataType >
bool data_is (bool allow_null=false) const
 Return true iff the TreeNode has a data object assigned to it that is of a particular given data type. More...
 
template<class NodeDataType >
bool data_is_derived_from (bool allow_null=false) const
 Return true iff the TreeNode has a data object assigned to it that is derived from a particular given data type. More...
 
BaseNodeDatadata_ptr ()
 Return a pointer to the data. More...
 
BaseNodeData const * data_ptr () const
 Return a const pointer to the data. More...
 
bool has_data () const
 Return true if the TreeNode has a data object assigned to it. More...
 
size_t index () const
 Return the index of this Node. More...
 
TreeLinklink ()
 Return the TreeLink that points towards the root. More...
 
TreeLink const & link () const
 Return the TreeLink that points towards the root. More...
 
TreeNodeoperator= (TreeNode &&)=delete
 
TreeNodeoperator= (TreeNode const &)=delete
 
TreeEdgeprimary_edge ()
 Return the TreeEdge that points towards the root. More...
 
TreeEdge const & primary_edge () const
 Return the TreeEdge that points towards the root. More...
 
TreeLinkprimary_link ()
 Return the TreeLink that points towards the root. More...
 
TreeLink const & primary_link () const
 Return the TreeLink that points towards the root. More...
 
TreeNodereset_data (std::unique_ptr< BaseNodeData > data)
 Reset the data pointer of this TreeNode. More...
 
TreeNodereset_index (size_t val)
 Reset the internal index of this TreeNode. More...
 
TreeNodereset_primary_link (TreeLink *val)
 Reset the internal pointer to the TreeLink of this TreeNode. More...
 

Friends

class Tree
 

Constructor & Destructor Documentation

◆ TreeNode() [1/4]

TreeNode ( )
inline

Definition at line 72 of file tree/tree/node.hpp.

◆ TreeNode() [2/4]

TreeNode ( size_t  index,
TreeLink primary_link 
)
inline

Definition at line 78 of file tree/tree/node.hpp.

◆ ~TreeNode()

~TreeNode ( )
default

◆ TreeNode() [3/4]

TreeNode ( TreeNode const &  )
delete

◆ TreeNode() [4/4]

TreeNode ( TreeNode &&  )
delete

Member Function Documentation

◆ data() [1/2]

NodeDataType& data ( )
inline

Definition at line 203 of file tree/tree/node.hpp.

◆ data() [2/2]

NodeDataType const& data ( ) const
inline

Definition at line 209 of file tree/tree/node.hpp.

◆ data_cast() [1/2]

NodeDataType* data_cast ( )
inline

Definition at line 215 of file tree/tree/node.hpp.

◆ data_cast() [2/2]

NodeDataType const* data_cast ( ) const
inline

Definition at line 221 of file tree/tree/node.hpp.

◆ data_is()

bool data_is ( bool  allow_null = false) const
inline

Return true iff the TreeNode has a data object assigned to it that is of a particular given data type.

Definition at line 178 of file tree/tree/node.hpp.

◆ data_is_derived_from()

bool data_is_derived_from ( bool  allow_null = false) const
inline

Return true iff the TreeNode has a data object assigned to it that is derived from a particular given data type.

Definition at line 193 of file tree/tree/node.hpp.

◆ data_ptr() [1/2]

BaseNodeData* data_ptr ( )
inline

Return a pointer to the data.

In most cases, using data<>() is more convenient. However, in some cases, this function might be necessary.

Definition at line 232 of file tree/tree/node.hpp.

◆ data_ptr() [2/2]

BaseNodeData const* data_ptr ( ) const
inline

Return a const pointer to the data.

In most cases, using data<>() is more convenient. However, in some cases, this function might be necessary.

Definition at line 243 of file tree/tree/node.hpp.

◆ has_data()

bool has_data ( ) const
inline

Return true if the TreeNode has a data object assigned to it.

Definition at line 168 of file tree/tree/node.hpp.

◆ index()

size_t index ( ) const
inline

Return the index of this Node.

Definition at line 102 of file tree/tree/node.hpp.

◆ link() [1/2]

TreeLink& link ( )
inline

Return the TreeLink that points towards the root.

This is just an alias for primary_link(), that is shorter to use when needed frequently in an algorithm.

Definition at line 129 of file tree/tree/node.hpp.

◆ link() [2/2]

TreeLink const& link ( ) const
inline

Return the TreeLink that points towards the root.

This is just an alias for primary_link(), that is shorter to use when needed frequently in an algorithm.

Definition at line 140 of file tree/tree/node.hpp.

◆ operator=() [1/2]

TreeNode& operator= ( TreeNode &&  )
delete

◆ operator=() [2/2]

TreeNode& operator= ( TreeNode const &  )
delete

◆ primary_edge() [1/2]

TreeEdge& primary_edge ( )
inline

Return the TreeEdge that points towards the root.

Definition at line 148 of file tree/tree/node.hpp.

◆ primary_edge() [2/2]

TreeEdge const& primary_edge ( ) const
inline

Return the TreeEdge that points towards the root.

Definition at line 156 of file tree/tree/node.hpp.

◆ primary_link() [1/2]

TreeLink& primary_link ( )
inline

Return the TreeLink that points towards the root.

Definition at line 110 of file tree/tree/node.hpp.

◆ primary_link() [2/2]

TreeLink const& primary_link ( ) const
inline

Return the TreeLink that points towards the root.

Definition at line 118 of file tree/tree/node.hpp.

◆ reset_data()

TreeNode& reset_data ( std::unique_ptr< BaseNodeData data)
inline

Reset the data pointer of this TreeNode.

Using this function, a TreeNode can be assigend new data. It is also possible to change the data type completely (as long as it derives from BaseNodeData). Be however aware that many functions that work with trees expcet a certain data type. Thus, changing it might break those functions and lead to exceptions and other errors.

Definition at line 290 of file tree/tree/node.hpp.

◆ reset_index()

TreeNode& reset_index ( size_t  val)
inline

Reset the internal index of this TreeNode.

This is a helper function that needs to be used with care and only in cases where appropriate. The index is an invariant that needs to be kept, as it needs to match the index in the Tree container.

This function exists to allow building and modifying a Tree without the need for many friend declarations. However, the function should rarely be needed outside of this context.

Definition at line 262 of file tree/tree/node.hpp.

◆ reset_primary_link()

TreeNode& reset_primary_link ( TreeLink val)
inline

Reset the internal pointer to the TreeLink of this TreeNode.

This is a helper function that needs to be used with care and only in cases where appropriate.

This function exists to allow building and modifying a Tree without the need for many friend declarations. However, the function should rarely be needed outside of this context.

Definition at line 276 of file tree/tree/node.hpp.

Friends And Related Function Documentation

◆ Tree

friend class Tree
friend

Definition at line 66 of file tree/tree/node.hpp.


The documentation for this class was generated from the following file: