EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRegistry.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRegistry.h
1 
2 #ifndef FAIRREGISTRY_H
3 #define FAIRREGISTRY_H
4 
5 #include <iostream>
6 #include <map>
7 #include <string>
8 
9 //#include <typeinfo>
10 
11 #include <TNamed.h>
12 
13 class FairRegistryItem;
14 //class type_info;
15 
16 class FairRegistry : public TNamed
17 {
18  public:
19  typedef std::map<std::string,FairRegistryItem*> tRegMap;
20  typedef void (*ErrorHandler)(void);
21 
25  explicit FairRegistry(bool readonly = true);
26 
28  FairRegistry(const FairRegistry& rhs);
29 
30  virtual ~FairRegistry();
31 
33  FairRegistry& operator=(const FairRegistry& rhs);
34 
36  void Merge(const FairRegistry& rhs);
37 
39  unsigned int Size() const { return fMap.size(); }
40 
42  bool KeyExists(const char* key) const;
43  void RemoveKey(const char* key);
44 
46  void Clear(Option_t* option=""); //*MENU*
47 
49  void Dump(void) const; //*MENU*
50 
52  virtual std::ostream& PrintStream(std::ostream& os) const;
53  virtual std::istream& ReadStream(std::istream& is);
54 
55  // TObject::Print().
56  virtual void Print(Option_t* option="") const; //*MENU*
57  virtual std::ostream& PrettyPrint(std::ostream& os) const;
58 
59  // TObject::Browse()
60  // The default implementation crashes TBrowser, doing nothing is better.
61  virtual void Browse(TBrowser*) {}
62 
64  virtual bool ValuesLocked(void) const { return fValuesLocked; }
65  virtual void LockValues(void) { fValuesLocked = true; } //*MENU*
66  virtual void UnLockValues(void) { fValuesLocked = false; } //*MENU*
67 
69  virtual bool KeysLocked(void) const { return fKeysLocked; }
70  virtual void LockKeys(void) { fKeysLocked = true; } //*MENU*
71  virtual void UnLockKeys(void) { fKeysLocked = false; } //*MENU*
72 
77  void SetDirty(bool is_dirty = true) { fDirty = is_dirty; }
78  bool IsDirty() { return fDirty; }
79 
80 
82 
83 
86 // bool Get(const char* key, bool& b) const;
87  bool Get(const char* key, char& c) const;
88  bool Get(const char* key, const char*& s) const;
89  bool Get(const char* key, int& i) const;
90  bool Get(const char* key, double& d) const;
91  bool Get(const char* key, FairRegistry& r) const;
92 
95  const std::type_info& GetType(const char* key) const;
97  std::string GetTypeAsString(const char* key) const;
99  std::string GetValueAsString(const char* key) const;
100 
101 
105 // bool GetBool(const char* key) const;
106  char GetChar(const char* key) const;
107  const char* GetCharString(const char* key) const;
108  int GetInt(const char* key) const;
109  double GetDouble(const char* key) const;
110  FairRegistry GetFairRegistry(const char* key) const;
111 
114 // bool Set(const char* key, bool b);
115  bool Set(const char* key, char c);
116  bool Set(const char* key, const char* s);
117  bool Set(const char* key, int i);
118  bool Set(const char* key, double d);
119  bool Set(const char* key, FairRegistry r);
120 
122  {
123 
124  public:
125  FairRegistryKey();
126  FairRegistryKey(const FairRegistry* r);
127  virtual ~FairRegistryKey();
128 
129  const char* operator()(void);
130 
131  private:
132 
134  std::map<std::string,FairRegistryItem*>::iterator fIt;
135 
136  // FairRegistryKey(const FairRegistryKey&);
138 
139  }; // end of class RegistryKey
140 
141  FairRegistryKey Key(void) const;
142 
143  private:
147 #ifndef __CINT__
148  friend class FairRegistryKey;
150 #endif
151  bool fDirty;
152 
153  ClassDef(FairRegistry,1)
154 }; // end of class Registry
155 
156 inline std::ostream& operator<<(std::ostream& os, const FairRegistry& r) { return r.PrintStream(os); }
157 
158 
159 #include "FairRegistryItemXxx.h"
160 
161 #endif // FAIRREGISTRY_H