|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TAXONOMY_FUNCTIONS_OPERATORS_H_
2 #define GENESIS_TAXONOMY_FUNCTIONS_OPERATORS_H_
53 template<
class TaxonDataType >
64 if(
typeid( ref ) !=
typeid( TaxonDataType ) ) {
77 template<
class TaxonDataType >
84 if(
dynamic_cast< TaxonDataType const*
>( taxon.
data_ptr() ) ==
nullptr ) {
98 template<
class TaxonDataType >
102 if( taxon.
has_data() && ! allow_overwrite ) {
103 throw std::runtime_error(
104 "Trying to overwrite Taxonomy data that already has a value."
108 TaxonDataType::create()
116 #endif // include guard
void reset_taxonomy_data(Taxonomy &taxonomy, bool allow_overwrite=true)
(Re-)set all Taxon data of a Taxonomy to a specified data type.
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
void preorder_for_each(Taxonomy &tax, std::function< void(Taxon &)> fn, bool include_inner_taxa=true)
Apply a function to all taxa of the Taxonomy, traversing it in preorder.
BaseTaxonData * data_ptr()
Return a pointer to the data.
bool taxonomy_data_is_derived_from(Taxonomy const &taxonomy)
Check whether the data of a Taxonomy are derived from the specified data type.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Taxon & reset_data(std::unique_ptr< BaseTaxonData > data)
Reset the data pointer of this Taxon.
bool taxonomy_data_is(Taxonomy const &taxonomy)
Check whether the data of a Taxonomy are exactly of the specified data type.
bool has_data() const
Return true if the Taxon has a data object assigned to it.