CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ALIFileIn.h
Go to the documentation of this file.
1 // COCOA class header file
2 //Id: ALIFileIn.h
3 //CAT: Model
4 //
5 // istream class for handling the reading of files
6 //
7 // History: v1.0
8 // Pedro Arce
9 
10 #ifndef FILEIN_H
11 #define FILEIN_H
12 
13 #include <fstream>
14 #include <iostream>
15 
16 #include <vector>
17 
19 
20 class ALIFileIn {
21 public:
22  ALIFileIn(){};
24 
25 private:
26  ALIFileIn(const ALIstring& name) : theName(name) {}
27 
28 public:
29  // Get the only instance opening the file
30  static ALIFileIn& getInstance(const ALIstring& name);
31  // Get the only instance when file should be already opened
32  static ALIFileIn& getInstanceOpened(const ALIstring& name);
33 
34  // Read a line and transform it to a vector of words
35  ALIint getWordsInLine(std::vector<ALIstring>& wl);
36 
37  // Print out an error message indicating the line being read
38  void ErrorInLine();
39 
40  // Access data members
41  const ALIint nline() { return theLineNo[theCurrentFile]; }
42 
43  const ALIstring& name() { return theName; }
44 
45  ALIbool eof();
46  void close();
47 
48 private:
49  void openNewFile(const char* filename);
50 
51 private:
52  std::vector<std::ifstream*> theFiles;
53  // Number of line being read
54  std::vector<ALIint> theLineNo;
55  std::vector<ALIstring> theNames;
56  int theCurrentFile; // index of file being read in theFiles
57 
58  // private DATA MEMEBERS
59  // Vector of class instances (each one identified by its name)
60  static std::vector<ALIFileIn*> theInstances;
61 
64 };
65 
66 #endif
std::vector< ALIstring > theNames
Definition: ALIFileIn.h:55
ALIbool eof()
Definition: ALIFileIn.cc:201
const ALIstring & name()
Definition: ALIFileIn.h:43
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:22
static std::vector< ALIFileIn * > theInstances
Definition: ALIFileIn.h:60
int ALIint
Definition: CocoaGlobals.h:15
static ALIFileIn & getInstanceOpened(const ALIstring &name)
Definition: ALIFileIn.cc:60
std::vector< ALIint > theLineNo
Definition: ALIFileIn.h:54
const ALIint nline()
Definition: ALIFileIn.h:41
int theCurrentFile
Definition: ALIFileIn.h:56
bool ALIbool
Definition: CocoaGlobals.h:19
void close()
Definition: ALIFileIn.cc:218
std::vector< std::ifstream * > theFiles
Definition: ALIFileIn.h:52
ALIFileIn(const ALIstring &name)
Definition: ALIFileIn.h:26
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:74
void ErrorInLine()
Definition: ALIFileIn.cc:196
ALIstring theName
Name of file.
Definition: ALIFileIn.h:63
std::string ALIstring
Definition: CocoaGlobals.h:9
tuple filename
Definition: lut2db_cfg.py:20
~ALIFileIn()
Definition: ALIFileIn.h:23
void openNewFile(const char *filename)
Definition: ALIFileIn.cc:38
ALIFileIn()
Definition: ALIFileIn.h:22