A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tree/default/tree.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_DEFAULT_TREE_H_
2 #define GENESIS_TREE_DEFAULT_TREE_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 
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 DefaultTree = Tree;
49 
54 
59 
64 
65 // =================================================================================================
66 // Default Tree Node Data
67 // =================================================================================================
68 
80 {
81  // -------------------------------------------------------------------
82  // Constructor and Rule of Five
83  // -------------------------------------------------------------------
84 
85 public:
86 
87  virtual ~DefaultNodeData() = default;
88 
89  // Move ctor and assignment.
90  DefaultNodeData( DefaultNodeData&& ) = delete;
92 
93 protected:
94 
95  DefaultNodeData() = default;
96 
97  // Copy ctor and assignment.
98  DefaultNodeData( DefaultNodeData const& ) = default;
99  DefaultNodeData& operator= ( DefaultNodeData const& ) = default;
100 
101 public:
102 
103  static std::unique_ptr< DefaultNodeData > create()
104  {
105  return std::unique_ptr< DefaultNodeData >( new DefaultNodeData() );
106  }
107 
108  virtual std::unique_ptr< BaseNodeData > recreate() const override
109  {
110  return std::unique_ptr< DefaultNodeData >( new DefaultNodeData() );
111  }
112 
113  virtual std::unique_ptr< BaseNodeData > clone() const override
114  {
115  return std::unique_ptr< DefaultNodeData >( new DefaultNodeData( *this ));
116  }
117 
118  // -----------------------------------------------------
119  // Data Members
120  // -----------------------------------------------------
121 
127  std::string name;
128 
129 };
130 
131 // =================================================================================================
132 // Default Tree Edge Data
133 // =================================================================================================
134 
145 {
146  // -------------------------------------------------------------------
147  // Constructor and Rule of Five
148  // -------------------------------------------------------------------
149 
150 public:
151 
152  virtual ~DefaultEdgeData() = default;
153 
154  // Move ctor and assignment.
155  DefaultEdgeData( DefaultEdgeData&& ) = delete;
157 
158 protected:
159 
160  DefaultEdgeData() = default;
161 
162  // Copy ctor and assignment.
163  DefaultEdgeData( DefaultEdgeData const& ) = default;
164  DefaultEdgeData& operator= ( DefaultEdgeData const& ) = default;
165 
166 public:
167 
168  static std::unique_ptr< DefaultEdgeData > create()
169  {
170  return std::unique_ptr< DefaultEdgeData >( new DefaultEdgeData() );
171  };
172 
173  virtual std::unique_ptr< BaseEdgeData > recreate() const override
174  {
175  return std::unique_ptr< DefaultEdgeData >( new DefaultEdgeData() );
176  }
177 
178  virtual std::unique_ptr< BaseEdgeData > clone() const override
179  {
180  return std::unique_ptr< DefaultEdgeData >( new DefaultEdgeData( *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
virtual std::unique_ptr< BaseEdgeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Tree DefaultTree
Alias for a Tree with data types DefaultNodeData and DefaultEdgeData.
Definition: epca.hpp:51
static std::unique_ptr< DefaultEdgeData > create()
DefaultEdgeData & operator=(DefaultEdgeData &&)=delete
Base class for storing data on Nodes of a Tree.
Definition: node_data.hpp:66
Default class containing the commonly needed data for tree nodes.
virtual ~DefaultNodeData()=default
Default class containing the commonly needed data for tree edges.
virtual std::unique_ptr< BaseNodeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
virtual ~DefaultEdgeData()=default
virtual std::unique_ptr< BaseNodeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
static std::unique_ptr< DefaultNodeData > create()
double branch_length
Branch length of the edge.
std::string name
Name of the node.
Header of Tree class.
DefaultNodeData & operator=(DefaultNodeData &&)=delete
Base class for storing data on Edges of a Tree.
Definition: edge_data.hpp:66
virtual std::unique_ptr< BaseEdgeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...