A library for working with phylogenetic and population genetic data.
v0.27.0
compact.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_PRINTER_COMPACT_H_
2 #define GENESIS_TREE_PRINTER_COMPACT_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 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 <iosfwd>
35 #include <functional>
36 #include <string>
37 
38 namespace genesis {
39 namespace tree {
40 
41 // =================================================================================================
42 // Forward Declarations
43 // =================================================================================================
44 
45 class Tree;
46 class TreeNode;
47 class TreeEdge;
48 class TreeLink;
49 
50 // =================================================================================================
51 // Printer Compact
52 // =================================================================================================
53 
83 {
84 public:
85 
86  // -------------------------------------------------------------------------
87  // Constructor and Rule of Five
88  // -------------------------------------------------------------------------
89 
93  PrinterCompact() = default;
94 
98  ~PrinterCompact() = default;
99 
103  PrinterCompact( PrinterCompact const& ) = default;
104 
108  PrinterCompact( PrinterCompact&& ) = default;
109 
113  PrinterCompact& operator= ( PrinterCompact const& ) = default;
114 
118  PrinterCompact& operator= ( PrinterCompact&& ) = default;
119 
120  // -------------------------------------------------------------------------
121  // Print
122  // -------------------------------------------------------------------------
123 
133  void print (
134  std::ostream& out,
135  Tree const& tree,
136  std::function<std::string (
137  TreeNode const& node,
138  TreeEdge const& edge
139  )> const print_line
140  );
141 
150  std::string print (
151  Tree const& tree,
152  std::function<std::string (
153  TreeNode const& node,
154  TreeEdge const& edge
155  )> const print_line
156  );
157 
169  std::string print ( Tree const& tree );
170 
171  // std::string operator() ( Tree const& tree );
172 
173  // -------------------------------------------------------------------------
174  // Settings
175  // -------------------------------------------------------------------------
176 
185  PrinterCompact& limit( long value )
186  {
187  limit_ = value;
188  return *this;
189  }
190 
196  long limit() const
197  {
198  return limit_;
199  }
200 
201  // -------------------------------------------------------------------------
202  // Data Members
203  // -------------------------------------------------------------------------
204 
205 private:
206 
207  long limit_ = -1;
208 
209 };
210 
211 } // namespace tree
212 } // namespace genesis
213 
214 #endif // include guard
genesis::tree::PrinterCompact
Print a Tree in a compact form, i.e., each node and edge on one line.
Definition: compact.hpp:82
genesis::tree::PrinterCompact::~PrinterCompact
~PrinterCompact()=default
Default destructor.
genesis::tree::PrinterCompact::limit
PrinterCompact & limit(long value)
Set the line limit.
Definition: compact.hpp:185
genesis::tree::Tree
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:97
genesis::tree::TreeEdge
Definition: edge.hpp:60
genesis::tree::TreeNode
Definition: tree/tree/node.hpp:58
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::tree::PrinterCompact::PrinterCompact
PrinterCompact()=default
Default constructor.
genesis::tree::PrinterCompact::operator=
PrinterCompact & operator=(PrinterCompact const &)=default
Deault copy assignment.
genesis::tree::PrinterCompact::print
void print(std::ostream &out, Tree const &tree, std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const print_line)
Print a compact representation of a Tree to an output stream, using a given function for output of th...
Definition: compact.cpp:50
genesis::tree::PrinterCompact::limit
long limit() const
Get the current line limit.
Definition: compact.hpp:196