A library for working with phylogenetic and population genetic data.
v0.27.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
genesis::taxonomy::TaxonomyWriter::taxopath_generator
TaxopathGenerator & taxopath_generator()
Definition: taxonomy_writer.hpp:85
genesis::taxonomy::TaxonomyWriter::write_ranks
TaxonomyWriter & write_ranks(bool value)
Definition: taxonomy_writer.hpp:101
genesis::taxonomy::TaxonomyWriter::write
void write(Taxonomy const &tax, std::shared_ptr< utils::BaseOutputTarget > target) const
Definition: taxonomy_writer.cpp:48
genesis::taxonomy::TaxopathGenerator
Helper class to generate a taxonomic path string from a Taxopath object or a Taxon.
Definition: taxopath_generator.hpp:74
genesis::taxonomy::TaxonomyWriter::write_ids
TaxonomyWriter & write_ids(bool value)
Definition: taxonomy_writer.hpp:90
taxopath_generator.hpp
genesis::taxonomy::TaxonomyWriter
Write a Taxonomy as a list of Taxopaths.
Definition: taxonomy_writer.hpp:56
genesis::taxonomy::TaxonomyWriter::write_ids
bool write_ids() const
Definition: taxonomy_writer.hpp:96
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::taxonomy::Taxonomy
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Definition: taxonomy/taxonomy.hpp:96
genesis::taxonomy::TaxonomyWriter::write_ranks
bool write_ranks() const
Definition: taxonomy_writer.hpp:107
genesis::taxonomy::TaxonomyWriter::operator=
TaxonomyWriter & operator=(TaxonomyWriter const &)=default
genesis::taxonomy::TaxonomyWriter::TaxonomyWriter
TaxonomyWriter()=default
output_target.hpp
genesis::taxonomy::TaxonomyWriter::~TaxonomyWriter
~TaxonomyWriter()=default