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
|
// COCOA class header file
//Id: ALIFileIn.h
//CAT: Model
//
// istream class for handling the reading of files
//
// History: v1.0
// Pedro Arce
#ifndef FILEIN_H
#define FILEIN_H
#include <fstream>
#include <iostream>
#include <vector>
#include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
class ALIFileIn {
public:
ALIFileIn() {}
~ALIFileIn() {}
private:
ALIFileIn(const ALIstring& name) : theName(name) {}
public:
// Get the only instance opening the file
static ALIFileIn& getInstance(const ALIstring& name);
// Get the only instance when file should be already opened
static ALIFileIn& getInstanceOpened(const ALIstring& name);
// Read a line and transform it to a vector of words
ALIint getWordsInLine(std::vector<ALIstring>& wl);
// Print out an error message indicating the line being read
void ErrorInLine();
// Access data members
const ALIint nline() { return theLineNo[theCurrentFile]; }
const ALIstring& name() { return theName; }
ALIbool eof();
void close();
private:
void openNewFile(const char* filename);
private:
std::vector<std::ifstream*> theFiles;
// Number of line being read
std::vector<ALIint> theLineNo;
std::vector<ALIstring> theNames;
int theCurrentFile; // index of file being read in theFiles
// private DATA MEMEBERS
// Vector of class instances (each one identified by its name)
static std::vector<ALIFileIn*> theInstances;
/// Name of file
ALIstring theName;
};
#endif
|