CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
21 class ALIFileIn
22 {
23  public:
24  ALIFileIn(){};
26  private:
27  ALIFileIn( const ALIstring& name ): theName(name){}
28 
29  public:
30  // Get the only instance opening the file
31  static ALIFileIn& getInstance( const ALIstring& name );
32  // Get the only instance when file should be already opened
33  static ALIFileIn& getInstanceOpened( const ALIstring& name );
34 
35  // Read a line and transform it to a vector of words
36  ALIint getWordsInLine( std::vector<ALIstring>& wl );
37 
38  // Print out an error message indicating the line being read
39  void ErrorInLine();
40 
41  // Access data members
42  const ALIint nline() { return theLineNo[theCurrentFile]; }
43 
44  const ALIstring& name() { return theName; }
45 
46  ALIbool eof();
47  void close();
48 
49  private:
50  void openNewFile( const char* filename );
51 
52  private:
53  std::vector< std::ifstream* > theFiles;
54  // Number of line being read
55  std::vector<ALIint> theLineNo;
56  std::vector<ALIstring> theNames;
57  int theCurrentFile; // index of file being read in theFiles
58 
59  // private DATA MEMEBERS
60  // Vector of class instances (each one identified by its name)
61  static std::vector<ALIFileIn*> theInstances;
62 
65 
66 };
67 
68 #endif
std::vector< ALIstring > theNames
Definition: ALIFileIn.h:56
ALIbool eof()
Definition: ALIFileIn.cc:218
const ALIstring & name()
Definition: ALIFileIn.h:44
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:23
static std::vector< ALIFileIn * > theInstances
Definition: ALIFileIn.h:61
int ALIint
Definition: CocoaGlobals.h:15
static ALIFileIn & getInstanceOpened(const ALIstring &name)
Definition: ALIFileIn.cc:73
std::vector< ALIint > theLineNo
Definition: ALIFileIn.h:55
const ALIint nline()
Definition: ALIFileIn.h:42
int theCurrentFile
Definition: ALIFileIn.h:57
bool ALIbool
Definition: CocoaGlobals.h:19
void close()
Definition: ALIFileIn.cc:236
ALIFileIn(const ALIstring &name)
Definition: ALIFileIn.h:27
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:90
void ErrorInLine()
Definition: ALIFileIn.cc:211
ALIstring theName
Name of file.
Definition: ALIFileIn.h:64
std::string ALIstring
Definition: CocoaGlobals.h:9
tuple filename
Definition: lut2db_cfg.py:20
~ALIFileIn()
Definition: ALIFileIn.h:25
void openNewFile(const char *filename)
Definition: ALIFileIn.cc:48
std::vector< std::ifstream * > theFiles
Definition: ALIFileIn.h:53
ALIFileIn()
Definition: ALIFileIn.h:24