Analysis Software
Documentation for sPHENIX simulation 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 
25  virtual double get_DoubleFlag(const std::string &name) const;
26  virtual double get_DoubleFlag(const std::string &name, const double defaultval);
27  virtual void set_DoubleFlag(const std::string &name, const double flag);
28 
29  virtual float get_FloatFlag(const std::string &name) const;
30  virtual float get_FloatFlag(const std::string &name, const float defaultval);
31  virtual void set_FloatFlag(const std::string &name, const float flag);
32 
33  virtual int get_IntFlag(const std::string &name) const;
34  virtual int get_IntFlag(const std::string &name, const int defaultval);
35  virtual void set_IntFlag(const std::string &name, const int flag);
36 
37  virtual uint64_t get_uint64Flag(const std::string &name) const;
38  virtual uint64_t get_uint64Flag(const std::string &name, const uint64_t defaultval);
39  virtual void set_uint64Flag(const std::string &name, const uint64_t flag);
40 
41  virtual const std::string get_StringFlag(const std::string &name) const;
42  virtual const std::string get_StringFlag(const std::string &name, const std::string &defaultval);
43  virtual void set_StringFlag(const std::string &name, const std::string &flag);
44 
45  virtual void Print() const;
46  virtual void PrintDoubleFlags() const;
47  virtual void PrintIntFlags() const;
48  virtual void Printuint64Flags() const;
49  virtual void PrintFloatFlags() const;
50  virtual void PrintStringFlags() const;
51  virtual void ReadFromFile(const std::string &name);
52  virtual void WriteToFile(const std::string &name);
53 
54  virtual int FlagExist(const std::string &name) const;
55 
56  virtual const std::map<std::string, uint64_t> *uint64Map() const { return &m_UInt64FlagMap; }
57  virtual const std::map<std::string, int> *IntMap() const { return &m_IntFlagMap; }
58  virtual const std::map<std::string, float> *FloatMap() const { return &m_FloatFlagMap; }
59  virtual const std::map<std::string, double> *DoubleMap() const { return &m_DoubleFlagMap; }
60  virtual const std::map<std::string, std::string> *StringMap() const { return &m_StringFlagMap; }
61  virtual void PrintStackTrace() const;
62 
63  virtual void ClearFlag(const std::string &name);
64  virtual void ClearAll();
65 
66  protected:
67  std::map<std::string, uint64_t> m_UInt64FlagMap;
68  std::map<std::string, int> m_IntFlagMap;
69  std::map<std::string, double> m_DoubleFlagMap;
70  std::map<std::string, float> m_FloatFlagMap;
71  std::map<std::string, std::string> m_StringFlagMap;
72 };
73 
74 #endif