TDbiRegistry.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TDBIREGISTRY_H
00019 #define TDBIREGISTRY_H
00020
00021 #include <iostream>
00022 #include <map>
00023 #include <string>
00024
00025 #include <TNamed.h>
00026
00027 class TDbiRegistryItem;
00028 class type_info;
00029
00030 #include "TDbiRegistryItemXxx.hxx"
00031
00032
00033 class TDbiRegistry : public TNamed
00034 {
00035 public:
00036 typedef std::map<std::string,TDbiRegistryItem*> tRegMap;
00037 typedef void (*ErrorHandler)(void);
00038
00039
00040
00041
00042 explicit TDbiRegistry(bool readonly = true);
00043
00044
00045 TDbiRegistry(const TDbiRegistry& rhs);
00046
00047 virtual ~TDbiRegistry();
00048
00049
00050 TDbiRegistry& operator=(const TDbiRegistry& rhs);
00051
00052
00053 void Merge(const TDbiRegistry& rhs);
00054
00055
00056 unsigned int Size() const { return fMap.size(); }
00057
00058
00059 bool KeyExists(const char* key) const;
00060 void RemoveKey(const char* key);
00061
00062
00063 void Clear(Option_t *option="");
00064
00065
00066 void Dump(void) const;
00067
00068
00069 virtual std::ostream& PrintStream(std::ostream& os) const;
00070 virtual std::istream& ReadStream(std::istream& is);
00071
00072
00073 virtual void Print(Option_t *option="") const;
00074 virtual std::ostream& PrettyPrint(std::ostream& os) const;
00075
00076
00077
00078 virtual void Browse(TBrowser*){}
00079
00080
00081 virtual bool ValuesLocked(void) const { return fValuesLocked; }
00082
00083 virtual void LockValues(void) { fValuesLocked = true; }
00084
00085 virtual void UnLockValues(void) { fValuesLocked = false; }
00086
00087
00088 virtual bool KeysLocked(void) const { return fKeysLocked; }
00089
00090 virtual void LockKeys(void) { fKeysLocked = true; }
00091
00092 virtual void UnLockKeys(void) { fKeysLocked = false; }
00093
00094
00095
00096
00097
00098 void SetDirty(bool is_dirty = true) { fDirty = is_dirty; }
00099 bool IsDirty() { return fDirty; }
00100
00101
00102 void SetErrorHandler(ErrorHandler eh) { fErrorHandler = eh; }
00103
00104
00105
00106
00107 bool Get(const char* key, char& c) const;
00108
00109
00110 bool Get(const char* key, const char*& s) const;
00111
00112
00113 bool Get(const char* key, int& i) const;
00114
00115
00116 bool Get(const char* key, double& d) const;
00117
00118
00119 bool Get(const char* key, TDbiRegistry& r) const;
00120
00121
00122
00123 const type_info& GetType(const char* key) const;
00124
00125 std::string GetTypeAsString(const char* key) const;
00126
00127 std::string GetValueAsString(const char* key) const;
00128
00129
00130
00131
00132
00133
00134
00135 char GetChar(const char* key) const;
00136
00137
00138
00139 const char* GetCharString(const char* key) const;
00140
00141
00142
00143 int GetInt(const char* key) const;
00144
00145
00146
00147 double GetDouble(const char* key) const;
00148
00149
00150
00151 TDbiRegistry GetTDbiRegistry(const char* key) const;
00152
00153
00154
00155
00156 bool Set(const char* key, char c);
00157 bool Set(const char* key, const char* s);
00158 bool Set(const char* key, int i);
00159 bool Set(const char* key, double d);
00160 bool Set(const char* key, TDbiRegistry r);
00161
00162
00163 class TDbiRegistryKey
00164 {
00165
00166 public:
00167 TDbiRegistryKey();
00168 TDbiRegistryKey(const TDbiRegistry* r);
00169 virtual ~TDbiRegistryKey();
00170
00171 const char* operator()(void);
00172
00173 private:
00174
00175 const TDbiRegistry* fReg;
00176 std::map<std::string,TDbiRegistryItem*>::iterator fIt;
00177 };
00178
00179 TDbiRegistryKey Key(void) const;
00180
00181 private:
00182 bool fValuesLocked;
00183 bool fKeysLocked;
00184 ErrorHandler fErrorHandler;
00185 #ifndef __CINT__
00186 friend class TDbiRegistryKey;
00187
00188 tRegMap fMap;
00189 #endif
00190 bool fDirty;
00191
00192 ClassDef(TDbiRegistry,1)
00193 };
00194
00195
00196 inline std::ostream& operator<<(std::ostream& os, const TDbiRegistry& r) { return r.PrintStream(os); }
00197
00198
00199 #include "TDbiRegistryItemXxx.hxx"
00200
00201 #endif // TDBIREGISTRY_H