ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHFlag.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHFlag.h
1 #ifndef PHOOL_PHFLAG_H
2 #define PHOOL_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  PHFlag() {}
23  virtual ~PHFlag() {}
24  virtual const std::string get_CharFlag(const std::string &name) const;
25  virtual const std::string get_CharFlag(const std::string &name, const std::string &defaultval);
26  virtual void set_CharFlag(const std::string &name, const std::string &flag);
27 
28  virtual double get_DoubleFlag(const std::string &name) const;
29  virtual double get_DoubleFlag(const std::string &name, const double defaultval);
30  virtual void set_DoubleFlag(const std::string &name, const double flag);
31 
32  virtual float get_FloatFlag(const std::string &name) const;
33  virtual float get_FloatFlag(const std::string &name, const float defaultval);
34  virtual void set_FloatFlag(const std::string &name, const float flag);
35 
36  virtual int get_IntFlag(const std::string &name) const;
37  virtual int get_IntFlag(const std::string &name, const int defaultval);
38  virtual void set_IntFlag(const std::string &name, const int flag);
39 
40  virtual const std::string get_StringFlag(const std::string &name) const {return get_CharFlag(name);}
41  virtual const std::string get_StringFlag(const std::string &name, const std::string &defaultval) {return get_CharFlag(name, defaultval);}
42  virtual void set_StringFlag(const std::string &name, const std::string &flag) {set_CharFlag(name, flag);}
43 
44  virtual void Print() const;
45  virtual void PrintDoubleFlags() const;
46  virtual void PrintIntFlags() const;
47  virtual void PrintFloatFlags() const;
48  virtual void PrintCharFlags() const;
49  virtual void PrintStringFlags() const {PrintCharFlags();}
50  virtual void ReadFromFile(const std::string &name);
51  virtual void WriteToFile(const std::string &name);
52 
53  virtual int FlagExist(const std::string &name) const;
54 
55  virtual const std::map<std::string, int> *IntMap() const { return &intflag; }
56  virtual const std::map<std::string, float> *FloatMap() const { return &floatflag; }
57  virtual const std::map<std::string, double> *DoubleMap() const { return &doubleflag; }
58  virtual const std::map<std::string, std::string> *CharMap() const { return &charflag; }
59  virtual void PrintStackTrace() const;
60 
61  protected:
62  std::map<std::string, int> intflag;
63  std::map<std::string, double> doubleflag;
64  std::map<std::string, float> floatflag;
65  std::map<std::string, std::string> charflag;
66 };
67 
68 #endif