#include "TDbiCfgPromptConfigurable.hxx"
#include "TDbiCfgDialog.hxx"
#include <TSK_DBI_Log.hxx>
#include <MsgFormat.h>
#include <string.h>
#include <stdlib.h>
#include <typeinfo>
#include "TDbi.hxx"
#include <assert.h>
Go to the source code of this file.
Functions | |
ClassImp (TDbiCfgPromptConfigurable) TDbiCfgPromptConfigurable |
ClassImp | ( | TDbiCfgPromptConfigurable | ) |
A nice base class to use with configurable objects.
Like the TDbiCfg(Lazy)Configurable class, but doesn't use lazy execution.
How to use it: Set up defaults in the constructor (or somehwere else that happens soon) and call InitializeConfig() with them.
At any time, use the Set() commands to modify your object. By default, your object has keys locked and values unlocked: This means that:
Note that the Set() commands include: Set( key, int ) | Set( key, double ) |- Work like TDbiRegistry() commands, but with above safeties Set( key, const char* ) | Set( key, TDbiRegistry ) | Set( TDbiRegistry ) - Works like Merge(), but with above safeties Set( TDbiRegistry, true) - Ditto, but Merge()s sub-registries as well, with the same rules. Set( string ) - Works like JobControl parser i.e. Set("myint=1 myfloat=2.0 mystring=blahDeblah");
If the configuration changes, ConfigModified() will be called, letting you read the new configuration variables. But it's smart: your function only gets called if a variable has changed, not if they've stayed the same.
Example: class MyClass : public TDbiCfgPromptConfigurable { MyClass() { TDbiRegistry r; r.Set("Default1",1); r.Set("Default2",2.0); InitializeConfig(r); };
void ConfigModified() { GetConfig().Get("Default1",fDefault1); .. etc .. }
};
Definition at line 12 of file TDbiCfgPromptConfigurable.cxx.
00015 { 00016 //////////////////////////////////////////////////////////////////////////////////// 00017 /// TDbiCfgPromptConfigurable 00018 /// 00019 /// A nice base class to use with configurable objects. 00020 /// 00021 /// Like the TDbiCfg(Lazy)Configurable class, but doesn't use 00022 /// lazy execution. 00023 /// 00024 /// How to use it: 00025 /// Set up defaults in the constructor (or somehwere else that happens soon) 00026 /// and call InitializeConfig() with them. 00027 /// 00028 /// At any time, use the Set() commands to modify your object. 00029 /// By default, your object has keys locked and values unlocked: 00030 /// This means that: 00031 /// - If you try to set a key that doesn't exist, it fails. (Typo protection) 00032 /// - If you try to set a key to different type, it fails. (Type protection) 00033 /// 00034 /// Note that the Set() commands include: 00035 /// Set( key, int ) | 00036 /// Set( key, double ) |- Work like TDbiRegistry() commands, but with above safeties 00037 /// Set( key, const char* ) | 00038 /// Set( key, TDbiRegistry ) | 00039 /// Set( TDbiRegistry ) - Works like Merge(), but with above safeties 00040 /// Set( TDbiRegistry, true) - Ditto, but Merge()s sub-registries as well, with the same rules. 00041 /// Set( string ) - Works like JobControl parser 00042 /// i.e. Set("myint=1 myfloat=2.0 mystring=blahDeblah"); 00043 /// 00044 /// If the configuration changes, ConfigModified() will be called, letting 00045 /// you read the new configuration variables. But it's smart: your function 00046 /// only gets called if a variable has changed, not if they've stayed the same. 00047 /// 00048 /// Example: 00049 ///class MyClass : public TDbiCfgPromptConfigurable 00050 ///{ 00051 /// MyClass() { 00052 /// TDbiRegistry r; 00053 /// r.Set("Default1",1); 00054 /// r.Set("Default2",2.0); 00055 /// InitializeConfig(r); 00056 /// }; 00057 /// 00058 /// void ConfigModified() { 00059 /// GetConfig().Get("Default1",fDefault1); 00060 /// .. etc .. 00061 /// } 00062 /// 00063 ///}; 00064 }