File: tproject.h

package info (click to toggle)
treeviewx 0.5.1%2Bgit20100823.7e4d0e9-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 2,688 kB
  • sloc: cpp: 14,362; xml: 82; makefile: 66
file content (110 lines) | stat: -rwxr-xr-x 3,038 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * TreeView
 * A phylogenetic tree viewer.
 * Copyright (C) 2001 Roderic D. M. Page <r.page@bio.gla.ac.uk>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */
 
 // $Id: tproject.h,v 1.9 2005/08/31 08:55:25 rdmp1c Exp $
 
#ifndef TPROJECTH
#define TPROJECTH

#include "profile.h"

/**
 * @class TProject
 * Encapsulates a profile of trees and operations on those trees. This is basically
 * a wrapper around the Profile class, and is designed for use in GUI programs.
 *
 * @see Profile
 *
 */

template <class T> class TProject
{
public:
	/**
	 * Constructor
	 */	
	TProject () { CurrentTree = 0; };
	/**
	 * Destructor
	 */	
	virtual ~TProject () {};
	/**
	 * True if the current tree has edge lengths
	 */	
	virtual bool CurrentTreeHasEdgeLengths () { return GetCurrentTree().GetHasEdgeLengths(); };
	/**
	 * True if the current tree has internal node labels
	 */	
	virtual bool CurrentTreeHasInternallabels () { return GetCurrentTree().GetHasInternalLabels(); };
	/**
	 * Get the current tree object
	 * @return The tree
	 */	

	virtual T GetCurrentTree () { return p.GetIthTree (CurrentTree); };
	/**
	 * Get the index of the current tree
	 * @return The index
	 */	
	virtual int GetCurrentTreeNumber () const { return CurrentTree; };
	/**
	 * @return The number of trees in the profile
	 */	
	virtual int GetNumTrees() { return p.GetNumTrees (); };
	/**
	 * @brief The name of the ith tree in the profile
	 *
	 * @param i the index of the tree in the range 0 - (n-1)
	 * @return The tree
	 */
	virtual std::string GetIthTreeName (int i) { return p.GetIthTreeName (i); };
	/**
	 * Read one or more trees from an input stream
	 * @param f an input stream
	 * @return True if trees read in successfully
	 */	
	virtual bool ReadTrees (std::istream &f) { return p.ReadTrees (f); };
	/**
	 * Set the index of the current tree
	 * @param i the index of the tree in the range 0 - (n-1)
	 */	
	virtual void SetCurrentTreeNumber (const int i) { CurrentTree = i; };
	/**
	 * Write trees to output stream
	 * @param f an output stream
	 * @return True if trees written successfully
	 */	
	virtual bool WriteTrees (std::ostream &f, const int format = 0, const char *endOfLine = "\n") 
	{ return p.WriteTrees (f, format, endOfLine); };

protected:
	/**
	 * The index of the current tree
	 */
	int CurrentTree;
	/**
	 * The profile of trees
	 */	
	Profile <T> p;
};



#endif