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
bool has_data() const
Return true if the Taxon has a data object assigned to it.
Store a Taxonomy, i.e., a nested hierarchy of 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.
bool taxonomy_data_is_derived_from(Taxonomy const &taxonomy)
Check whether the data of a Taxonomy are derived from the specified data type.
void reset_taxonomy_data(Taxonomy &taxonomy, bool allow_overwrite=true)
(Re-)set all Taxon data of a Taxonomy to a specified data type.
bool taxonomy_data_is(Taxonomy const &taxonomy)
Check whether the data of a Taxonomy are exactly of the specified data type.
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank and sub-taxa.
Taxon & reset_data(std::unique_ptr< BaseTaxonData > data)
Reset the data pointer of this Taxon.
BaseTaxonData * data_ptr()
Return a pointer to the data.