CFEL - ASG Software Suite  2.5.0
CASS
txt_reader.h
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file txt_reader.h contains class to read txt ascii files
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _TXTREADER_H_
10 #define _TXTREADER_H_
11 
12 #include <tr1/memory>
13 #include <fstream>
14 #include <string>
15 #include <vector>
16 
17 #include "file_reader.h"
18 #include "cass.h"
19 
20 namespace cass
21 {
22 class CASSEvent;
23 
24 /** class for reading txt files
25  *
26  * first line has to give the names of the variables, which are then ordered
27  * line by line.
28  *
29  * @cassttng TxtReader/\%filename\%/{Deliminator}\n
30  * The deliminator that is used to separate the values. Default is '\\t',
31  * which is a tab.
32  * @cassttng TxtReader/\%filename\%/{EventIdHeader}\n
33  * The name of the Header under which the Event Id is stored. Default
34  * is "".
35  * @cassttng TxtReader/\%filename\%/{LinesToSkip}\n
36  * How many lines do we have to skip before the line appears that
37  * contains the headers. Default is 3
38  *
39  * @author Lutz Foucar
40  */
41 class TxtReader : public FileReader
42 {
43 public:
44  /** constructor */
45  TxtReader();
46 
47  /** read the frms6 file contents put them into cassevent
48  *
49  * @return true when the workers should work on the filled cassevent,
50  * false if not.
51  * @param file the file that contains the data to be put into the cassevent
52  * @param event the CASSEvent where the data will be put into
53  */
54  bool operator()(std::ifstream &file, CASSEvent& event);
55 
56  /** load the settings of the reader */
57  void loadSettings();
58 
59  /** read the file header
60  *
61  * @param file the filestream to the header information of the file
62  */
63  void readHeaderInfo(std::ifstream &file);
64 
65 private:
66  /** the value names */
67  std::vector<std::string> _headers;
68 
69  /** a splitter object to split up the lines */
71 
72  /** the deliminator by which the values are separated in the ascii file */
73  char _delim;
74 
75  /** the header name under which the event id is stored */
76  std::string _eventIdhead;
77 
78  /** how many lines should be skipped before reading the header line */
79  size_t _linesToSkip;
80 };
81 }//end namespace cass
82 #endif
void loadSettings()
load the settings of the reader
Definition: txt_reader.cpp:29
Event to store all LCLS Data.
Definition: cass_event.h:32
base class for all file readers
Definition: file_reader.h:24
TxtReader()
constructor
Definition: txt_reader.cpp:25
Splitter _split
a splitter object to split up the lines
Definition: txt_reader.h:70
char _delim
the deliminator by which the values are separated in the ascii file
Definition: txt_reader.h:73
bool operator()(std::ifstream &file, CASSEvent &event)
read the frms6 file contents put them into cassevent
Definition: txt_reader.cpp:57
class for reading txt files
Definition: txt_reader.h:41
contains base class for all file readers
file contains global definitions for project cass
split the line into the values in that line
Definition: cass.h:156
std::vector< std::string > _headers
the value names
Definition: txt_reader.h:67
size_t _linesToSkip
how many lines should be skipped before reading the header line
Definition: txt_reader.h:79
void readHeaderInfo(std::ifstream &file)
read the file header
Definition: txt_reader.cpp:41
std::string _eventIdhead
the header name under which the event id is stored
Definition: txt_reader.h:76