]> git.donarmstrong.com Git - mothur.git/blob - fileoutput.h
started shared utilities, updates to venn and heatmap added tree.groups command
[mothur.git] / fileoutput.h
1 #ifndef FILEOUTPUT_H
2 #define FILEOUTPUT_H
3
4 #include "mothur.h"
5 #include "globaldata.hpp"
6
7 using namespace std;
8
9 /***********************************************************************/
10
11 class FileOutput {
12         
13 public:
14         FileOutput(){};
15         ~FileOutput(){};
16         virtual void output(int, vector<double>) = 0;
17         virtual void initFile(string) = 0;
18         virtual void resetFile() = 0;
19         virtual string getFileName() = 0;
20         virtual void initFile(string, vector<string>) = 0;
21         virtual void output(vector<double>) = 0;
22
23 protected:
24         GlobalData* globaldata;
25         int renameOk;
26
27 };      
28         
29 /***********************************************************************/
30
31 class ThreeColumnFile : public FileOutput {
32         
33 public:
34         ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { };
35         ~ThreeColumnFile();
36         void initFile(string);
37         void output(int, vector<double>);
38         void resetFile();
39         string getFileName()    { return inName;        };
40         
41         void initFile(string, vector<string>) {};
42         void output(vector<double>) {};
43
44 private:
45         string inName;
46         string outName;
47         ifstream inFile;
48         ofstream outFile;
49         int counter;
50 };
51
52
53 /***********************************************************************/
54 class OneColumnFile : public FileOutput {
55         
56         
57 public:
58         OneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) {};
59         ~OneColumnFile();
60         void output(int, vector<double>);
61         void initFile(string);
62         void resetFile();
63         string getFileName()    { return inName;        };
64         
65         void initFile(string, vector<string>) {};
66         void output(vector<double>) {};
67
68
69 private:
70         string outName;
71         ifstream inFile;
72         string inName;
73         ofstream outFile;
74         int counter;
75 };
76
77 /***********************************************************************/
78 class SharedOneColumnFile : public FileOutput {
79         
80         
81 public:
82         SharedOneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) {};
83         ~SharedOneColumnFile();
84         void output(int, vector<double>);
85         void initFile(string);
86         void resetFile();
87         string getFileName()    { return inName;        };
88         
89         void initFile(string, vector<string>) {};
90         void output(vector<double>) {};
91
92
93 private:
94         string outName;
95         ifstream inFile;
96         string inName;
97         ofstream outFile;
98         int counter;
99                 
100 };
101
102 /***********************************************************************/
103
104 class SharedThreeColumnFile : public FileOutput {
105         
106 public:
107         SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(getPathName(n) + ".temp." + getSimpleName(n)) {  };
108         ~SharedThreeColumnFile();
109         void initFile(string);
110         void output(int, vector<double>);
111         void resetFile();
112         string getFileName()    { return inName;        };
113         
114         
115         void initFile(string, vector<string>) {};
116         void output(vector<double>) {};
117
118 private:
119         string inName, groupLabel;
120         string outName;
121         ifstream inFile;
122         ofstream outFile;
123         int counter, numGroup;
124 };
125
126 /***********************************************************************/
127
128 class ThreeColumnFile2 : public FileOutput {
129         
130 public:
131         ThreeColumnFile2(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { globaldata = GlobalData::getInstance(); };
132         ~ThreeColumnFile2();
133         
134         //to make compatible with parent class
135         void output(int, vector<double>){};
136         void initFile(string){};
137         
138         void initFile(string, vector<string>);
139         void output(vector<double>);
140         void resetFile();
141         string getFileName()    { return inName;        };
142 private:
143         string inName;
144         string outName;
145         ifstream inFile;
146         ofstream outFile;
147         int counter;
148 };
149
150 /***********************************************************************/
151
152 #endif