00001 //////////////////////////////////////////////////////////////////////// 00002 // $Id: TDbiCfgConfigurable.hxx,v 1.1 2011/01/18 05:49:19 finch Exp $ 00003 // 00004 /// \class TDbiCfgConfigurable 00005 /// \brief A base class for classes configured using registries. 00006 ///\verbatim 00007 /// Configurable classes must implement the "Config" method which 00008 /// in order to make any necessary changes needed to reflect the 00009 /// change in configuration. 00010 /// 00011 /// The "Update" method can be called frequently. It will call 00012 /// Config() if and only if the configuration has changed since the 00013 /// last call to Config(). If no parameters have changed, the method 00014 /// returns very quickly as no actions are taken. 00015 /// 00016 /// 00017 /// To use this class, you *must* do the following in your constructor: 00018 /// class C : public TDbiCfgConfigurable 00019 /// { 00020 /// C:C() { 00021 /// // fill the default config: 00022 /// TDbiRegistry r; 00023 /// r.Set("a",42); 00024 /// r.Set("b",6.9); 00025 /// // etc. And prime the actual configuration: 00026 /// this->CommitDefaultConfig(r); 00027 /// } 00028 /// 00029 /// This ensures that the configuration used in the future starts with 00030 /// the correct defaults. 00031 /// 00032 /// messier@huhepl.harvard.edu 00033 /// 00034 /// 2002/08/23, modifed to inherit from TDbiRegistry and 00035 /// not call Config() in the sub constructor. bv@bnl.gov 00036 /// 00037 /// 2002/08/29, not IsA, but HaveA TDbiRegistry. bv@bnl.gov 00038 /// \endverbatim 00039 //////////////////////////////////////////////////////////////////////// 00040 #ifndef CFGCONFIGURABLE_H 00041 #define CFGCONFIGURABLE_H 00042 #ifndef REGISTRY_H 00043 # include "TDbiRegistry.hxx" 00044 #endif 00045 00046 class TDbiCfgDialog; 00047 00048 00049 00050 #ifndef ROOT_Rtypes 00051 #if !defined(__CINT__) || defined(__MAKECINT__) 00052 #include "Rtypes.h" 00053 #endif 00054 #endif 00055 00056 00057 class TDbiCfgConfigurable 00058 { 00059 00060 public: 00061 00062 TDbiCfgConfigurable(); 00063 virtual ~TDbiCfgConfigurable(); 00064 00065 /// Subclass should implement this method: 00066 virtual void Config() = 0; 00067 00068 /// Access default and main configuration 00069 virtual const TDbiRegistry& DefaultConfig() const; 00070 TDbiRegistry& GetConfig(); 00071 const TDbiRegistry& GetConfig() const; 00072 00073 /// Call anytime. Triggers Config() only if it has been modifed 00074 /// since last calling. 00075 int Update(); 00076 00077 /// Set config via interactive dialog 00078 void Set(TDbiCfgDialog* d=0); 00079 00080 /// Set config via string 00081 void Set(const char* s); 00082 00083 protected: 00084 virtual void CommitDefaultConfig(const TDbiRegistry& r); 00085 00086 private: 00087 TDbiRegistry fDefConfig, fConfig; 00088 00089 00090 ClassDef(TDbiCfgConfigurable,1) 00091 }; 00092 00093 00094 #endif // CFGCONFIGURABLE_H 00095 ////////////////////////////////////////////////////////////////////////