Class Reference for E1039 Core & Analysis Software
PHFlag.h
Go to the documentation of this file.
1 #ifndef PHFLAG_H
2 #define PHFLAG_H
3 
4 /*
5  General purpose flag package:
6  Flags are identified by their name, Print() prints them out sorted
7  alphabetically.
8  To create e.g. an int flag called MYFLAG with value 10 use
9  set_IntFlag("MYFLAG",10);
10  get_IntFlag("MYFLAG") will return 10 now.
11  If an unitialised flag is used you'll get a warning printed out,
12  the return value in this case is 0 for Int, 0. for float and NULL for
13  char *
14 */
15 
16 #include <map>
17 #include <string>
18 
19 class PHFlag
20 {
21  public:
22 
23  PHFlag() {}
24  virtual ~PHFlag() {}
25 
26  virtual const std::string get_CharFlag(const std::string &flag) const;
27  virtual const std::string get_CharFlag(const std::string &name, const std::string &defaultval);
28  virtual void set_CharFlag(const std::string &name, const std::string &flag);
29 
30  virtual double get_DoubleFlag(const std::string &name) const;
31  virtual double get_DoubleFlag(const std::string &name, const double defaultval);
32  virtual void set_DoubleFlag(const std::string &name, const double flag);
33 
34  virtual float get_FloatFlag(const std::string &name) const;
35  virtual float get_FloatFlag(const std::string &name, const float defaultval);
36  virtual void set_FloatFlag(const std::string &name, const float flag);
37 
38  virtual int get_IntFlag(const std::string &name) const;
39  virtual int get_IntFlag(const std::string &name, const int defaultval);
40  virtual void set_IntFlag(const std::string &name, const int flag);
41 
42  virtual bool get_BoolFlag(const std::string &name) const;
43  virtual bool get_BoolFlag(const std::string &name, const bool defaultval);
44  virtual void set_BoolFlag(const std::string &name, const bool flag);
45 
46  virtual void Print() const;
47  virtual void PrintDoubleFlags() const;
48  virtual void PrintIntFlags() const;
49  virtual void PrintFloatFlags() const;
50  virtual void PrintCharFlags() const;
51  virtual void PrintBoolFlags() const;
52  virtual void ReadFromFile(const std::string& name, bool verbose = false);
53  virtual void WriteToFile(const std::string &name);
54 
55  virtual int FlagExist(const std::string &name) const;
56 
57  virtual const std::map<std::string, int> *IntMap() const {return &intflag;}
58  virtual const std::map<std::string, float> *FloatMap() const {return &floatflag;}
59  virtual const std::map<std::string, double> *DoubleMap() const {return &doubleflag;}
60  virtual const std::map<std::string, std::string> *CharMap() const {return &charflag;}
61  virtual const std::map<std::string, bool> *BoolMap() const {return &boolflag;}
62 
63  protected:
64 
65  std::map<std::string, int> intflag;
66  std::map<std::string, double> doubleflag;
67  std::map<std::string, float> floatflag;
68  std::map<std::string, std::string> charflag;
69  std::map<std::string, bool> boolflag;
70 
71 };
72 
73 #endif /* PHFLAG_H */
Definition: PHFlag.h:20
virtual double get_DoubleFlag(const std::string &name) const
Definition: PHFlag.cc:49
virtual void PrintIntFlags() const
Definition: PHFlag.cc:195
std::map< std::string, bool > boolflag
Definition: PHFlag.h:69
virtual int FlagExist(const std::string &name) const
Definition: PHFlag.cc:255
virtual void set_IntFlag(const std::string &name, const int flag)
Definition: PHFlag.cc:145
std::map< std::string, double > doubleflag
Definition: PHFlag.h:66
virtual void set_BoolFlag(const std::string &name, const bool flag)
Definition: PHFlag.cc:179
virtual void PrintBoolFlags() const
Definition: PHFlag.cc:243
virtual void set_DoubleFlag(const std::string &name, const double flag)
Definition: PHFlag.cc:77
virtual void set_CharFlag(const std::string &name, const std::string &flag)
Definition: PHFlag.cc:43
virtual const std::map< std::string, int > * IntMap() const
Definition: PHFlag.h:57
virtual const std::map< std::string, bool > * BoolMap() const
Definition: PHFlag.h:61
virtual const std::map< std::string, std::string > * CharMap() const
Definition: PHFlag.h:60
std::map< std::string, int > intflag
Definition: PHFlag.h:65
virtual void set_FloatFlag(const std::string &name, const float flag)
Definition: PHFlag.cc:111
virtual void WriteToFile(const std::string &name)
Definition: PHFlag.cc:354
virtual void PrintCharFlags() const
Definition: PHFlag.cc:231
virtual int get_IntFlag(const std::string &name) const
Definition: PHFlag.cc:117
virtual const std::string get_CharFlag(const std::string &flag) const
Definition: PHFlag.cc:13
virtual void ReadFromFile(const std::string &name, bool verbose=false)
Definition: PHFlag.cc:285
std::map< std::string, std::string > charflag
Definition: PHFlag.h:68
PHFlag()
Definition: PHFlag.h:23
std::map< std::string, float > floatflag
Definition: PHFlag.h:67
virtual const std::map< std::string, double > * DoubleMap() const
Definition: PHFlag.h:59
virtual void PrintDoubleFlags() const
Definition: PHFlag.cc:207
virtual void PrintFloatFlags() const
Definition: PHFlag.cc:219
virtual const std::map< std::string, float > * FloatMap() const
Definition: PHFlag.h:58
virtual ~PHFlag()
Definition: PHFlag.h:24
virtual bool get_BoolFlag(const std::string &name) const
Definition: PHFlag.cc:151
virtual void Print() const
Definition: PHFlag.cc:185
virtual float get_FloatFlag(const std::string &name) const
Definition: PHFlag.cc:83