Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CfgPromptConfigurable.h

Go to the documentation of this file.
00001 #ifndef CFGPROMPTCONFIGURABLE
00002 #define CFGPROMPTCONFIGURABLE
00003 
00052 
00053 
00054 #include <string>
00055 #include "Registry/Registry.h"
00056 
00057 class CfgDialog;
00058 
00059 class CfgPromptConfigurable
00060 {
00061  public:
00062   CfgPromptConfigurable();
00063   CfgPromptConfigurable(const Registry& r) {InitializeConfig(r);};
00064   virtual ~CfgPromptConfigurable() {};
00065 
00066   // For reading out current configuration.
00067   const Registry& GetConfig() const { return fConfig; };
00068 
00069   // Wrappers for Registry setters.
00070   void UnLockKeys()   { fConfig.UnLockKeys(); };
00071   void LockKeys()     { fConfig.LockKeys(); };
00072   void UnLockValues() { fConfig.UnLockValues(); };
00073   void LockValues()   { fConfig.LockValues(); };
00074 
00075   // These functions all modify the current registry, and call ConfigModified() if 
00076   // a valid key changes.
00077   void Set(const char* key, char val);
00078   void Set(const char* key, const char* val);
00079   void Set(const char* key, double val);
00080   void Set(const char* key, int val);
00081   void Set(const char* key, const Registry& val);
00082   void Set(const char* setstring);  // like modules.
00083   void Set(CfgDialog* d=0);
00084   
00085 
00086   // This is the one that does all the work:
00087   void Set(const Registry& stuff, Bool_t recursive = false); // Sets multiple things at once.
00088 
00089   // String operation routines.
00090   static Bool_t Split(const char* line, char sep, std::string& a, std::string& b);
00091   static Bool_t Split(const std::string& line, char sep, std::string& a, std::string& b) 
00092   { return Split(line.c_str(),sep,a,b); };
00093   static Bool_t IsInt(const std::string& s, Int_t& val);
00094   static Bool_t IsFloat(const std::string& s, Double_t& val);
00095 
00096   // Registry operation routines.
00097   static Bool_t SafeMerge(Registry& modify, 
00098                           const Registry& stuff, 
00099                           Bool_t recursive = false );
00100 
00101 
00102  protected:
00103   // This call sets up the object in it's 'default' condition,
00104   // and defines all the valid keys. Should be called from constructor.
00105   void         InitializeConfig(const Registry& initConfig);  
00106 
00107   // This method is called whenever the current configuration changes in any significant way.
00108   virtual void ConfigModified(void)=0; // To be defined by user.
00109 
00110  private:
00111   Registry fConfig;
00112   Registry fDefaultConfig;
00113 
00114   ClassDef(CfgPromptConfigurable,1);
00115 };
00116 
00117 #endif

Generated on Mon Feb 15 11:06:31 2010 for loon by  doxygen 1.3.9.1