A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edge.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2017 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
34 
35 namespace genesis {
36 namespace tree {
37 
38 // =================================================================================================
39 // Accessors
40 // =================================================================================================
41 
45 size_t TreeEdge::index() const
46 {
47  return index_;
48 }
49 
54 {
55  return *link_p_;
56 }
57 
62 {
63  return *link_p_;
64 }
65 
70 {
71  return *link_s_;
72 }
73 
78 {
79  return *link_s_;
80 }
81 
86 {
87  return link_p_->node();
88 }
89 
94 {
95  return link_p_->node();
96 }
97 
102 {
103  return link_s_->node();
104 }
105 
110 {
111  return link_s_->node();
112 }
113 
117 bool TreeEdge::has_data() const
118 {
119  return data_.get() != nullptr;
120 }
121 
129 {
130  return data_.get();
131 }
132 
140 {
141  return data_.get();
142 }
143 
144 // =================================================================================================
145 // Modifiers
146 // =================================================================================================
147 
159 {
160  index_ = val;
161  return *this;
162 }
163 
173 {
174  link_p_ = val;
175  return *this;
176 }
177 
187 {
188  link_s_ = val;
189  return *this;
190 }
191 
200 TreeEdge& TreeEdge::reset_data( std::unique_ptr< BaseEdgeData > data )
201 {
202  data_ = std::move( data );
203  return *this;
204 }
205 
206 // =================================================================================================
207 // Member Functions
208 // =================================================================================================
209 
215 std::string TreeEdge::dump() const
216 {
217  // throw std::runtime_error( "Not implemented" );
218  // return "Node P: " + primary_node().data.name + ", Node S: " + secondary_node().data.name + "\t" + data.dump();
219  return "Base edge dump";
220 }
221 
222 } // namespace tree
223 } // namespace genesis
size_t index() const
Return the index of this Edge.
Definition: edge.cpp:45
TreeLink & secondary_link()
Return the TreeLink of this TreeEdge that points away from the root.
Definition: edge.cpp:69
BaseEdgeData * data_ptr()
Return a pointer to the data.
Definition: edge.cpp:128
TreeEdge & reset_data(std::unique_ptr< BaseEdgeData > data)
Reset the data pointer of this TreeEdge.
Definition: edge.cpp:200
TreeLink & primary_link()
Return the TreeLink of this TreeEdge that points towards the root.
Definition: edge.cpp:53
bool has_data() const
Return true if the TreeEdge has a data object assigned to it.
Definition: edge.cpp:117
TreeEdge & reset_secondary_link(TreeLink *val)
Reset the internal pointer to the secondary TreeLink of this TreeEdge.
Definition: edge.cpp:186
TreeNode & secondary_node()
Return the TreeNode of this TreeEdge that points away from the root.
Definition: edge.cpp:101
TreeEdge & reset_index(size_t val)
Reset the internal index of this TreeEdge.
Definition: edge.cpp:158
std::string dump() const
Returns a one-line dump summary of the data of this edge.
Definition: edge.cpp:215
TreeNode & primary_node()
Return the TreeNode of this TreeEdge that points towards the root.
Definition: edge.cpp:85
Base class for storing data on Edges of a Tree.
Definition: edge_data.hpp:66
TreeEdge & reset_primary_link(TreeLink *val)
Reset the internal pointer to the primary TreeLink of this TreeEdge.
Definition: edge.cpp:172