A toolkit for working with phylogenetic data.
v0.24.0
tree/common_tree/tree.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_COMMON_TREE_TREE_H_
2 #define GENESIS_TREE_COMMON_TREE_TREE_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 
34 #include "genesis/tree/tree.hpp"
35 
36 #include <string>
37 
38 namespace genesis {
39 namespace tree {
40 
41 // =================================================================================================
42 // Typedefs
43 // =================================================================================================
44 
48 using CommonTree = Tree;
49 
54 
59 
64 
65 // =================================================================================================
66 // Common Tree Node Data
67 // =================================================================================================
68 
80 {
81  // -------------------------------------------------------------------
82  // Constructor and Rule of Five
83  // -------------------------------------------------------------------
84 
85 public:
86 
87  virtual ~CommonNodeData() override = default;
88 
89  // Move ctor and assignment.
90  CommonNodeData( CommonNodeData&& ) = delete;
92 
93 protected:
94 
95  CommonNodeData() = default;
96 
97  // Copy ctor and assignment.
98  CommonNodeData( CommonNodeData const& ) = default;
99  CommonNodeData& operator= ( CommonNodeData const& ) = default;
100 
101 public:
102 
103  static std::unique_ptr< CommonNodeData > create()
104  {
105  return std::unique_ptr< CommonNodeData >( new CommonNodeData() );
106  }
107 
108  virtual std::unique_ptr< BaseNodeData > recreate() const override
109  {
110  return std::unique_ptr< CommonNodeData >( new CommonNodeData() );
111  }
112 
113  virtual std::unique_ptr< BaseNodeData > clone() const override
114  {
115  return std::unique_ptr< CommonNodeData >( new CommonNodeData( *this ));
116  }
117 
118  // -----------------------------------------------------
119  // Data Members
120  // -----------------------------------------------------
121 
127  std::string name;
128 
129 };
130 
131 // =================================================================================================
132 // Common Tree Edge Data
133 // =================================================================================================
134 
145 {
146  // -------------------------------------------------------------------
147  // Constructor and Rule of Five
148  // -------------------------------------------------------------------
149 
150 public:
151 
152  virtual ~CommonEdgeData() override = default;
153 
154  // Move ctor and assignment.
155  CommonEdgeData( CommonEdgeData&& ) = delete;
157 
158 protected:
159 
160  CommonEdgeData() = default;
161 
162  // Copy ctor and assignment.
163  CommonEdgeData( CommonEdgeData const& ) = default;
164  CommonEdgeData& operator= ( CommonEdgeData const& ) = default;
165 
166 public:
167 
168  static std::unique_ptr< CommonEdgeData > create()
169  {
170  return std::unique_ptr< CommonEdgeData >( new CommonEdgeData() );
171  }
172 
173  virtual std::unique_ptr< BaseEdgeData > recreate() const override
174  {
175  return std::unique_ptr< CommonEdgeData >( new CommonEdgeData() );
176  }
177 
178  virtual std::unique_ptr< BaseEdgeData > clone() const override
179  {
180  return std::unique_ptr< CommonEdgeData >( new CommonEdgeData( *this ));
181  }
182 
183  // -----------------------------------------------------
184  // Data Members
185  // -----------------------------------------------------
186 
193  double branch_length = 0.0;
194 
195 };
196 
197 } // namespace tree
198 } // namespace genesis
199 
200 #endif // include guard
static std::unique_ptr< CommonEdgeData > create()
Tree CommonTree
Alias for a Tree with data types CommonNodeData and CommonEdgeData.
virtual std::unique_ptr< BaseEdgeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Base class for storing data on Nodes of a Tree.
Definition: node_data.hpp:66
virtual std::unique_ptr< BaseNodeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
virtual std::unique_ptr< BaseNodeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
virtual ~CommonNodeData() override=default
static std::unique_ptr< CommonNodeData > create()
std::string name
Name of the node.
virtual std::unique_ptr< BaseEdgeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Common class containing the commonly needed data for tree nodes.
Header of Tree class.
Base class for storing data on Edges of a Tree.
Definition: edge_data.hpp:66
Common class containing the commonly needed data for tree edges.
CommonNodeData & operator=(CommonNodeData &&)=delete