A simple class to query a user to supply values for a registry. Internally stores three TDbiRegistry objects, current, default and reset. More...
#include <TDbiCfgDialog.hxx>
Public Member Functions | |
TDbiCfgDialog () | |
TDbiCfgDialog (const TDbiRegistry ¤t, const TDbiRegistry &deflt) | |
virtual | ~TDbiCfgDialog () |
virtual TDbiRegistry & | Query () |
void | SetCurrent (const TDbiRegistry &r) |
void | SetDefault (const TDbiRegistry &r) |
Copy the registry r to the set of values to display as default values. | |
Protected Attributes | |
TDbiRegistry | fCurrent |
TDbiRegistry | fDefault |
TDbiRegistry | fResult |
A simple class to query a user to supply values for a registry. Internally stores three TDbiRegistry objects, current, default and reset.
Definition at line 18 of file TDbiCfgDialog.hxx.
TDbiCfgDialog::TDbiCfgDialog | ( | ) |
Definition at line 14 of file TDbiCfgDialog.cxx.
TDbiCfgDialog::TDbiCfgDialog | ( | const TDbiRegistry & | current, | |
const TDbiRegistry & | deflt | |||
) |
Definition at line 22 of file TDbiCfgDialog.cxx.
TDbiCfgDialog::~TDbiCfgDialog | ( | ) | [virtual] |
Definition at line 30 of file TDbiCfgDialog.cxx.
TDbiRegistry & TDbiCfgDialog::Query | ( | ) | [virtual] |
Conduct the dialog with the user to load new values into the registry. Return the registry stuffed with the new values. Can get one of either char, string, int or double.
Definition at line 63 of file TDbiCfgDialog.cxx.
References fCurrent, fDefault, fResult, TDbiRegistry::Get(), TDbiRegistry::Key(), PROMPT, TDbiRegistry::Set(), and TDbiRegistry::UnLockValues().
Referenced by TDbiCfgPromptConfigurable::Set(), and TDbiCfgConfigurable::Set().
00064 { 00065 00066 TDbiRegistry::TDbiRegistryKey rk = fCurrent.Key(); 00067 00068 // Setup result registry 00069 fResult = fCurrent; 00070 fResult.UnLockValues(); 00071 00072 const char* k; // Key name 00073 while ( (k=rk()) ) { 00074 // bool b; // Temp. bool value 00075 char c; // Temp. char value 00076 const char* s; // Temp. string value 00077 int i; // Temp. int value 00078 double d; // Temp. double value 00079 TDbiRegistry r; // Temp. TDbiRegistry value 00080 00081 // Use the 'current' registry to divine the types of junk... 00082 // Currently there's no good way to do this and TDbiRegistry spits 00083 // warnings at you for even trying... 00084 bool isBool = false; 00085 // bool isBool = fDefault.Get(k, b); 00086 bool isChar = fDefault.Get(k, c); 00087 bool isString = fDefault.Get(k, s); 00088 bool isInt = fDefault.Get(k, i); 00089 bool isDouble = fDefault.Get(k, d); 00090 bool isTDbiRegistry = false; 00091 // bool isTDbiRegistry = fCurrent.Get(k, r); 00092 00093 #define PROMPT(t,c,d) \ 00094 std::cout << " "<<t<<" "<<k<<" = ["<<d<<"] "<<c<<" =? "; 00095 // OK, now get the user's input. One "if" per type... 00096 if (isBool) { 00097 // bool b1, b_in; 00098 // fDefault.Get(k, b1); 00099 // PROMPT("bool",b,b1); 00100 // std::cin >> b_in; 00101 // fResult.Set(k, d_in); 00102 } 00103 else if (isChar) { 00104 char c1, c_in; 00105 fDefault.Get(k, c1); 00106 PROMPT("char",c,c1); 00107 std::cin >> c_in; 00108 fResult.Set(k, c_in); 00109 } 00110 else if (isString) { 00111 const char* s1; 00112 std::string s_in; 00113 fDefault.Get(k, s1); 00114 PROMPT("string",s,s1); 00115 std::cin >> s_in; 00116 // This is OK, TDbiRegistry allocates space and stores a copy 00117 // of the string, not just the pointer 00118 fResult.Set(k, s_in.c_str()); 00119 } 00120 else if (isInt) { 00121 int i1, i_in; 00122 fDefault.Get(k, i1); 00123 PROMPT("int",i,i1); 00124 std::cin >> i_in; 00125 fResult.Set(k, i_in); 00126 } 00127 else if (isDouble) { 00128 double d1, d_in; 00129 fDefault.Get(k, d1); 00130 PROMPT("double",d,d1); 00131 std::cin >> d_in; 00132 fResult.Set(k, d_in); 00133 } 00134 else if (isTDbiRegistry) { 00135 // TDbiRegistry r1, r_in; 00136 // std::string rins; 00137 // fDefault.Get(k, r1); 00138 // PROMPT("TDbiRegistry",r,r1); 00139 // std::cin >> r_ins; 00140 // r_in << r_ins; 00141 // fResult.Set(k, r_in); 00142 } 00143 } // loop over keys 00144 return fResult; 00145 }
void TDbiCfgDialog::SetCurrent | ( | const TDbiRegistry & | r | ) |
Copy the registry r to the set of values to display as current values
Definition at line 37 of file TDbiCfgDialog.cxx.
References fCurrent, TDbiRegistry::LockValues(), and TDbiRegistry::UnLockValues().
Referenced by TDbiCfgPromptConfigurable::Set(), and TDbiCfgConfigurable::Set().
00038 { 00039 00040 fCurrent.UnLockValues(); 00041 fCurrent = r; 00042 fCurrent.LockValues(); 00043 }
void TDbiCfgDialog::SetDefault | ( | const TDbiRegistry & | r | ) |
Copy the registry r to the set of values to display as default values.
Definition at line 49 of file TDbiCfgDialog.cxx.
References fCurrent, fDefault, TDbiRegistry::LockValues(), and TDbiRegistry::UnLockValues().
Referenced by TDbiCfgPromptConfigurable::Set(), and TDbiCfgConfigurable::Set().
00050 { 00051 00052 fDefault.UnLockValues(); 00053 fDefault = r; 00054 fCurrent.LockValues(); 00055 }
TDbiRegistry TDbiCfgDialog::fCurrent [protected] |
Definition at line 31 of file TDbiCfgDialog.hxx.
Referenced by Query(), SetCurrent(), and SetDefault().
TDbiRegistry TDbiCfgDialog::fDefault [protected] |
Definition at line 32 of file TDbiCfgDialog.hxx.
Referenced by Query(), and SetDefault().
TDbiRegistry TDbiCfgDialog::fResult [protected] |
Definition at line 33 of file TDbiCfgDialog.hxx.
Referenced by Query().