|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TREE_TREE_NODE_H_
2 #define GENESIS_TREE_TREE_NODE_H_
150 return link_->
edge();
158 return link_->
edge();
170 return data_.get() !=
nullptr;
177 template<
class NodeDataType >
180 if( data_.get() ==
nullptr ) {
183 assert( data_.get() );
184 auto const& ref = *data_.get();
185 return (
typeid( ref ) ==
typeid( NodeDataType ));
192 template<
class NodeDataType >
195 if( data_.get() ==
nullptr ) {
198 assert( data_.get() );
199 return (
dynamic_cast< NodeDataType const*
>( data_.get() ) !=
nullptr );
202 template<
class NodeDataType >
205 return dynamic_cast< NodeDataType&
>( *data_ );
208 template<
class NodeDataType >
209 NodeDataType
const&
data()
const
211 return dynamic_cast< NodeDataType const&
>( *data_ );
214 template<
class NodeDataType >
217 return dynamic_cast< NodeDataType*
>( data_.get() );
220 template<
class NodeDataType >
223 return dynamic_cast< NodeDataType const*
>( data_.get() );
292 data_ = std::move(
data );
305 std::unique_ptr< BaseNodeData > data_;
312 #endif // include guard
TreeNode & reset_primary_link(TreeLink *val)
Reset the internal pointer to the TreeLink of this TreeNode.
TreeNode(size_t index, TreeLink *primary_link)
TreeLink const & primary_link() const
Return the TreeLink that points towards the root.
Provides some valuable additions to STD.
TreeNode & operator=(TreeNode const &)=delete
TreeLink & primary_link()
Return the TreeLink that points towards the root.
BaseNodeData const * data_ptr() const
Return a const pointer to the data.
Class for representing phylogenetic trees.
bool has_data() const
Return true if the TreeNode has a data object assigned to it.
NodeDataType const & data() const
NodeDataType const * data_cast() const
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...
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
TreeLink & link()
Return the TreeLink that points towards the root.
Base class for storing data on Nodes of a Tree.
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...
TreeNode & reset_data(std::unique_ptr< BaseNodeData > data)
Reset the data pointer of this TreeNode.
TreeEdge & primary_edge()
Return the TreeEdge that points towards the root.
size_t index() const
Return the index of this Node.
TreeEdge const & primary_edge() const
Return the TreeEdge that points towards the root.
TreeEdge & edge()
Return the TreeEdge of this TreeLink.
BaseNodeData * data_ptr()
Return a pointer to the data.
NodeDataType * data_cast()
TreeNode & reset_index(size_t val)
Reset the internal index of this TreeNode.
TreeLink const & link() const
Return the TreeLink that points towards the root.