A toolkit for working with phylogenetic data.
v0.24.0
taxonomy_writer.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TAXONOMY_FORMATS_TAXONOMY_WRITER_H_
2 #define GENESIS_TAXONOMY_FORMATS_TAXONOMY_WRITER_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2020 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 
36 
37 #include <iosfwd>
38 #include <string>
39 
40 namespace genesis {
41 namespace taxonomy {
42 
43 // =================================================================================================
44 // Forward Declarations
45 // =================================================================================================
46 
47 class Taxonomy;
48 
49 // =================================================================================================
50 // Taxonomy Writer
51 // =================================================================================================
52 
57 {
58 public:
59 
60  // ---------------------------------------------------------------------
61  // Constructor and Rule of Five
62  // ---------------------------------------------------------------------
63 
64  TaxonomyWriter() = default;
65  ~TaxonomyWriter() = default;
66 
67  TaxonomyWriter( TaxonomyWriter const& ) = default;
68  TaxonomyWriter( TaxonomyWriter&& ) = default;
69 
70  TaxonomyWriter& operator= ( TaxonomyWriter const& ) = default;
72 
73  // ---------------------------------------------------------------------
74  // Writing
75  // ---------------------------------------------------------------------
76 
77  void write( Taxonomy const& tax, std::shared_ptr<utils::BaseOutputTarget> target ) const;
78 
79  // ---------------------------------------------------------------------
80  // Properties
81  // ---------------------------------------------------------------------
82 
83 public:
84 
86  {
87  return tax_gen_;
88  }
89 
90  TaxonomyWriter& write_ids( bool value )
91  {
92  write_ids_ = value;
93  return *this;
94  }
95 
96  bool write_ids() const
97  {
98  return write_ids_;
99  }
100 
102  {
103  write_ranks_ = value;
104  return *this;
105  }
106 
107  bool write_ranks() const
108  {
109  return write_ranks_;
110  }
111 
112  // ---------------------------------------------------------------------
113  // Members
114  // ---------------------------------------------------------------------
115 
116 private:
117 
118  bool write_ids_ = true;
119  bool write_ranks_ = true;
120 
121  TaxopathGenerator tax_gen_;
122 
123 };
124 
125 } // namespace taxonomy
126 } // namespace genesis
127 
128 #endif // include guard
Helper class to generate a taxonomic path string from a Taxopath object or a Taxon.
TaxonomyWriter & write_ranks(bool value)
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.
TaxonomyWriter & operator=(TaxonomyWriter const &)=default
TaxonomyWriter & write_ids(bool value)
Write a Taxonomy as a list of Taxopaths.
TaxopathGenerator & taxopath_generator()
void write(Taxonomy const &tax, std::shared_ptr< utils::BaseOutputTarget > target) const