|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TAXONOMY_TAXON_H_
2 #define GENESIS_TAXONOMY_TAXON_H_
48 void swap( Taxon& lhs, Taxon& rhs );
101 explicit Taxon( std::string
const&
name, std::string
const&
rank =
"", std::string
const&
id =
"" );
103 virtual ~Taxon()
override =
default;
158 std::string
const&
name()
const;
163 void name( std::string
const& value );
168 std::string
const&
rank()
const;
169 void rank( std::string
const& value );
174 std::string
const&
id()
const;
175 void id( std::string
const& value );
196 template<
class TaxonDataType >
199 return dynamic_cast< TaxonDataType&
>( *data_ );
202 template<
class TaxonDataType >
203 TaxonDataType
const&
data()
const
205 return dynamic_cast< TaxonDataType const&
>( *data_ );
208 template<
class TaxonDataType >
211 return dynamic_cast< TaxonDataType*
>( data_.get() );
214 template<
class TaxonDataType >
217 return dynamic_cast< TaxonDataType const*
>( data_.get() );
272 std::unique_ptr< BaseTaxonData > data_;
279 #endif // include guard
Taxon & operator=(Taxon const &)
Copy assignment operator.
Taxon const * parent() const
Return a pointer to the parent of this taxon, or a nullptr if this is the top level taxon.
Base class for storing data on Taxa of a Taxonomy.
virtual ~Taxon() override=default
friend Taxonomy
Taxonomy is a friend, as it needs access to parent_ in order to ensure consistency.
Taxon & add_child_(Taxon const &child, bool merge_duplicates) override
Virtual implementation function for adding a child taxon.
Taxon()
Default constructor. Does nothing. Yields an empty Taxon.
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
std::string const & rank() const
Return the rank of this taxon.
TaxonDataType const * data_cast() const
void swap(Taxon &lhs, Taxon &rhs)
std::string const & name() const
Return the name of this taxon.
BaseTaxonData * data_ptr()
Return a pointer to the data.
TaxonDataType * data_cast()
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.
void merge_duplicates(Sample &smp)
Look for Pqueries with the same name and merge them.
Taxon & reset_data(std::unique_ptr< BaseTaxonData > data)
Reset the data pointer of this Taxon.
TaxonDataType const & data() const
bool has_data() const
Return true if the Taxon has a data object assigned to it.
friend void swap(Taxon &lhs, Taxon &rhs)
Swapperator for Taxon.
std::string const & id() const
Set the ID of this taxon.