A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
taxopath_generator.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TAXONOMY_FORMATS_TAXOPATH_GENERATOR_H_
2 #define GENESIS_TAXONOMY_FORMATS_TAXOPATH_GENERATOR_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <string>
35 #include <vector>
36 
37 namespace genesis {
38 namespace taxonomy {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 class Taxon;
45 class Taxopath;
46 
47 // =================================================================================================
48 // Taxopath Generator
49 // =================================================================================================
50 
75 {
76 public:
77 
78  enum class TaxonField
79  {
80  kName,
81  kRank,
82  kId
83  };
84 
85  // -------------------------------------------------------------------------
86  // Constructors and Rule of Five
87  // -------------------------------------------------------------------------
88 
89  TaxopathGenerator() = default;
90  ~TaxopathGenerator() = default;
91 
92  TaxopathGenerator( TaxopathGenerator const& ) = default;
93  TaxopathGenerator( TaxopathGenerator&& ) = default;
94 
95  TaxopathGenerator& operator= ( TaxopathGenerator const& ) = default;
97 
98  // -------------------------------------------------------------------------
99  // Generating
100  // -------------------------------------------------------------------------
101 
107  std::string to_string( Taxopath const& taxopath ) const;
108 
115  std::string operator() ( Taxopath const& taxopath ) const;
116 
122  std::string to_string( Taxon const& taxon ) const;
123 
130  std::string operator() ( Taxon const& taxon ) const;
131 
132  // -------------------------------------------------------------------------
133  // Properties
134  // -------------------------------------------------------------------------
135 
143 
149  TaxonField field() const;
150 
157  TaxopathGenerator& delimiter( std::string const& value );
158 
164  std::string delimiter() const;
165 
181 
187  bool trim_nested_duplicates() const;
188 
198  TaxopathGenerator& append_delimiter( bool value );
199 
205  bool append_delimiter() const;
206 
207  // -------------------------------------------------------------------------
208  // Data Members
209  // -------------------------------------------------------------------------
210 
211 private:
212 
213  TaxonField field_ = TaxonField::kName;
214  std::string delimiter_ = ";";
215  bool trim_nested_duplicates_ = false;
216  bool append_delimiter_ = false;
217 
218 };
219 
220 } // namespace taxonomy
221 } // namespace genesis
222 
223 #endif // include guard
Helper class to generate a taxonomic path string from a Taxopath object or a Taxon.
TaxonField field() const
Return the currelty set field to use for describing a Taxon.
bool append_delimiter() const
Return whether currently a delimiter is appended to the taxonomic path string.
bool trim_nested_duplicates() const
Return the currently set value whether to trim nested duplicates of taxa names.
std::string delimiter() const
Return the currelty set value used to join the taxonomic path string elements.
std::string operator()(Taxopath const &taxopath) const
Shortcut function alias for to_string( Taxopath ).
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
Definition: taxon.hpp:76
Helper class to store a taxonomic path.
Definition: taxopath.hpp:81
std::string to_string(Taxopath const &taxopath) const
Return a string representation of a Taxopath.
TaxopathGenerator & operator=(TaxopathGenerator const &)=default