CfgDialog Class Reference

#include <CfgDialog.h>

List of all members.

Public Member Functions

 CfgDialog ()
 CfgDialog (const Registry &current, const Registry &deflt)
virtual ~CfgDialog ()
virtual RegistryQuery ()
void SetCurrent (const Registry &r)
void SetDefault (const Registry &r)

Protected Attributes

Registry fCurrent
Registry fDefault
Registry fResult


Detailed Description

Definition at line 14 of file CfgDialog.h.


Constructor & Destructor Documentation

CfgDialog::CfgDialog (  ) 

Definition at line 14 of file CfgDialog.cxx.

00014                      :
00015   fCurrent(),
00016   fDefault(),
00017   fResult()
00018 { }

CfgDialog::CfgDialog ( const Registry current,
const Registry deflt 
)

Definition at line 22 of file CfgDialog.cxx.

00022                                                               :
00023   fCurrent(cur),
00024   fDefault(defl),
00025   fResult()
00026 { }

CfgDialog::~CfgDialog (  )  [virtual]

Definition at line 30 of file CfgDialog.cxx.

00030 { }


Member Function Documentation

Registry & CfgDialog::Query (  )  [virtual]

Definition at line 59 of file CfgDialog.cxx.

References fCurrent, fDefault, fResult, Registry::Get(), Registry::Key(), PROMPT, Registry::Set(), and Registry::UnLockValues().

Referenced by CfgPromptConfigurable::Set(), and CfgConfigurable::Set().

00060 {
00061 //======================================================================
00062 // Conduct the dialog with the user to load new values into the
00063 // registry. Return the registry stuffed with the new values.
00064 //======================================================================
00065   Registry::RegistryKey rk = fCurrent.Key();
00066 
00067   // Setup result registry
00068   fResult = fCurrent;
00069   fResult.UnLockValues();
00070   
00071   const char* k; // Key name
00072   while ( (k=rk()) ) {
00073     // bool      b; // Temp. bool value
00074     char            c; // Temp. char value
00075     const char*     s; // Temp. string value
00076     int             i; // Temp. int value
00077     double          d; // Temp. double value
00078     Registry        r; // Temp. Registry value
00079 
00080     // Use the 'current' registry to divine the types of junk...
00081     // Currently there's no good way to do this and Registry spits
00082     // warnings at you for even trying...
00083     bool isBool   = false;
00084     // bool isBool   = fDefault.Get(k, b);
00085     bool isChar   = fDefault.Get(k, c);
00086     bool isString = fDefault.Get(k, s);
00087     bool isInt    = fDefault.Get(k, i);
00088     bool isDouble = fDefault.Get(k, d);
00089     bool isRegistry = false;
00090     // bool isRegistry = fCurrent.Get(k, r);
00091 
00092 #define PROMPT(t,c,d) \
00093 std::cout << " "<<t<<" "<<k<<" = ["<<d<<"] "<<c<<" =? ";
00094     // OK, now get the user's input. One "if" per type...
00095     if (isBool) {
00096       // bool b1, b_in;
00097       // fDefault.Get(k, b1);
00098       // PROMPT("bool",b,b1);
00099       // std::cin >> b_in;
00100       // fResult.Set(k, d_in);
00101     }
00102     else if (isChar) {
00103       char c1, c_in;
00104       fDefault.Get(k, c1);
00105       PROMPT("char",c,c1);
00106       std::cin >> c_in;
00107       fResult.Set(k, c_in);
00108     }
00109     else if (isString) {
00110       const char* s1;
00111       std::string s_in;
00112       fDefault.Get(k, s1);
00113       PROMPT("string",s,s1);
00114       std::cin >> s_in;
00115       // This is OK, Registry allocates space and stores a copy
00116       // of the string, not just the pointer
00117       fResult.Set(k, s_in.c_str());
00118     }
00119     else if (isInt) {
00120       int i1, i_in;
00121       fDefault.Get(k, i1);
00122       PROMPT("int",i,i1);
00123       std::cin >> i_in;
00124       fResult.Set(k, i_in);
00125     }
00126     else if (isDouble) {
00127       double d1, d_in;
00128       fDefault.Get(k, d1);
00129       PROMPT("double",d,d1);
00130       std::cin >> d_in;
00131       fResult.Set(k, d_in);
00132     }
00133     else if (isRegistry) {
00134       // Registry r1, r_in;
00135       // std::string rins;
00136       // fDefault.Get(k, r1);
00137       // PROMPT("Registry",r,r1);
00138       // std::cin >> r_ins;
00139       // r_in << r_ins;
00140       // fResult.Set(k, r_in);
00141     }
00142   } // loop over keys
00143   return fResult;
00144 }

void CfgDialog::SetCurrent ( const Registry r  ) 

Definition at line 34 of file CfgDialog.cxx.

References fCurrent, Registry::LockValues(), and Registry::UnLockValues().

Referenced by CfgPromptConfigurable::Set(), and CfgConfigurable::Set().

00035 {
00036 //======================================================================
00037 // Copy the registry r to the set of values to display as current
00038 // values
00039 //======================================================================
00040   fCurrent.UnLockValues();
00041   fCurrent = r;
00042   fCurrent.LockValues();
00043 }

void CfgDialog::SetDefault ( const Registry r  ) 

Definition at line 47 of file CfgDialog.cxx.

References fCurrent, fDefault, Registry::LockValues(), and Registry::UnLockValues().

Referenced by CfgPromptConfigurable::Set(), and CfgConfigurable::Set().

00048 {
00049 //======================================================================
00050 // Copy the registry r to the set of values to display as default values
00051 //======================================================================
00052   fDefault.UnLockValues();
00053   fDefault = r;
00054   fCurrent.LockValues();
00055 }


Member Data Documentation

Registry CfgDialog::fCurrent [protected]

Definition at line 27 of file CfgDialog.h.

Referenced by Query(), SetCurrent(), and SetDefault().

Registry CfgDialog::fDefault [protected]

Definition at line 28 of file CfgDialog.h.

Referenced by Query(), and SetDefault().

Registry CfgDialog::fResult [protected]

Definition at line 29 of file CfgDialog.h.

Referenced by Query().


The documentation for this class was generated from the following files:
Generated on Mon Aug 11 01:05:39 2014 for loon by  doxygen 1.4.7