A library for working with phylogenetic and population genetic data.
v0.27.0
nexus/document.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_FORMATS_NEXUS_DOCUMENT_H_
2 #define GENESIS_UTILS_FORMATS_NEXUS_DOCUMENT_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
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 
37 
39 
40 #include <memory>
41 #include <string>
42 #include <vector>
43 
44 namespace genesis {
45 namespace utils {
46 
47 // =================================================================================================
48 // Nexus Document
49 // =================================================================================================
50 
55 {
56 public:
57 
58  // ---------------------------------------------------------------------
59  // Constructor and Rule of Five
60  // ---------------------------------------------------------------------
61 
62  NexusDocument() = default;
63  ~NexusDocument() = default;
64 
65  // NexusDocument( NexusDocument const& ) = default;
66  NexusDocument( NexusDocument&& ) = default;
67 
68  NexusDocument& operator= ( NexusDocument const& ) = default;
69  NexusDocument& operator= ( NexusDocument&& ) = default;
70 
71  // ---------------------------------------------------------------------
72  // Member Types
73  // ---------------------------------------------------------------------
74 
75  using container = std::vector<std::unique_ptr<NexusBlock>>;
76  using const_iterator = container::const_iterator;
77 
78  // ---------------------------------------------------------------------
79  // Accessors
80  // ---------------------------------------------------------------------
81 
82  bool has_block( std::string block_name ) const;
83 
84  NexusBlock const* get_block( std::string block_name ) const;
85  NexusBlock* get_block( std::string block_name );
86 
87  // ---------------------------------------------------------------------
88  // Modifiers
89  // ---------------------------------------------------------------------
90 
91  // void push_back_block(NexusBlock const& block)
92  // {
93  // data_.push_back( utils::make_unique<NexusBlock>(block) );
94  // }
95 
96  // void set_block_trees( Trees const& trees );
97  // void set_block_taxa( Taxa const& taxa );
98 
99  NexusBlock* set_block( std::unique_ptr<NexusBlock> block );
100 
101  // ---------------------------------------------------------------------
102  // Iterators
103  // ---------------------------------------------------------------------
104 
105 public:
106 
108  {
109  return data_.cbegin();
110  }
111 
113  {
114  return data_.cend();
115  }
116 
117  // ---------------------------------------------------------------------
118  // Data Members
119  // ---------------------------------------------------------------------
120 
121 private:
122 
123  container data_;
124 
125 };
126 
127 } // namespace utils
128 } // namespace genesis
129 
130 #endif // include guard
genesis::utils::NexusBlock
Definition: block.hpp:47
genesis::utils::NexusDocument::container
std::vector< std::unique_ptr< NexusBlock > > container
Definition: nexus/document.hpp:75
genesis::utils::NexusDocument
Definition: nexus/document.hpp:54
block.hpp
genesis::utils::NexusDocument::operator=
NexusDocument & operator=(NexusDocument const &)=default
std.hpp
Provides some valuable additions to STD.
genesis::utils::NexusDocument::has_block
bool has_block(std::string block_name) const
Definition: nexus/document.cpp:40
trees.hpp
genesis::utils::NexusDocument::get_block
NexusBlock const * get_block(std::string block_name) const
Definition: nexus/document.cpp:45
genesis::utils::NexusDocument::begin
const_iterator begin() const
Definition: nexus/document.hpp:107
taxa.hpp
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::utils::NexusDocument::NexusDocument
NexusDocument()=default
genesis::utils::NexusDocument::~NexusDocument
~NexusDocument()=default
genesis::utils::NexusDocument::const_iterator
container::const_iterator const_iterator
Definition: nexus/document.hpp:76
genesis::utils::NexusDocument::end
const_iterator end() const
Definition: nexus/document.hpp:112
genesis::utils::NexusDocument::set_block
NexusBlock * set_block(std::unique_ptr< NexusBlock > block)
Definition: nexus/document.cpp:71