#include <ConfigEditor.h>
Inheritance diagram for cfg::ConfigEditor:

Public Member Functions | |
| ConfigEditor (Config *config) | |
| A class to modify an existing configuration and publish changes. | |
| virtual | ~ConfigEditor () |
| virtual int | EditConfig (Config &cfg) |
| void | Apply () |
| void | Edit () |
| void | Reset () |
| void | Cancel () |
Private Attributes | |
| bool | fNewConfig |
| Have we created a config. during the edit? | |
| Config * | fConfig |
| The configuration to be edited. | |
| Config * | fConfigCopy |
| A copy of the original configuration. | |
Clients who wish to edit configurations should follow this pattern:
[1] Derive from this class and implement the EditConfig method [2] Conduct the edit like this:
{
cfg::Config* cfg = ...;
MyCfgConfigEditor ed(cfg); // Construct your editor
ed.Edit(); // Do the edit
}
Definition at line 27 of file ConfigEditor.h.
|
|
A class to modify an existing configuration and publish changes.
Definition at line 20 of file ConfigEditor.cxx. 00020 : 00021 fNewConfig ( false ), 00022 fConfig ( config ), 00023 fConfigCopy( 0 ) 00024 { }
|
|
|
Definition at line 28 of file ConfigEditor.cxx. References fConfigCopy. 00029 {
00030 //======================================================================
00031 // Free memory used during edit
00032 //======================================================================
00033 if (fConfigCopy) { delete fConfigCopy; fConfigCopy = 0; }
00034 }
|
|
|
Reimplemented in evdb::CfgEdit. Definition at line 75 of file ConfigEditor.cxx. References cfg::Table::AdoptConfig(), fConfig, cfg::Config::GetName(), cfg::Table::GetObservers(), cfg::Config::GetVersion(), and cfg::Table::Instance(). Referenced by Edit(). 00076 {
00077 //======================================================================
00078 // Apply the changes made to the configuration.
00079 //======================================================================
00080 cfg::Table& t = cfg::Table::Instance();
00081
00082 // Insert the configuration into the table of configurations
00083 if (fNewConfig) t.AdoptConfig(fConfig);
00084
00085 // Alert observers of this configuration to the change it its
00086 // state
00087 cfg::Table::ObsList olist;
00088 t.GetObservers(fConfig->GetName(), fConfig->GetVersion(), olist);
00089
00090 cfg::Table::ObsList::iterator itr(olist.begin());
00091 cfg::Table::ObsList::iterator itrEnd(olist.end());
00092 for (; itr!=itrEnd; ++itr) try {(*itr)->Update(*fConfig); }
00093 catch (cfg::Exception e) {
00094 std::cout << " *-> " << fConfig->GetName() << "."
00095 << fConfig->GetVersion() << " ";
00096 e.Print();
00097 exit(-1);
00098 }
00099 }
|
|
|
Reimplemented in evdb::CfgEdit. Definition at line 116 of file ConfigEditor.cxx. References cfg::Config::Copy(), fConfig, fConfigCopy, cfg::Config::GetSource(), and cfg::Config::GetVersion(). Referenced by Edit(). 00117 {
00118 //======================================================================
00119 // Cancel the edit operation
00120 //======================================================================
00121 cfg::Config::Copy(*fConfig,
00122 *fConfigCopy,
00123 fConfigCopy->GetVersion(),
00124 fConfigCopy->GetSource());
00125 if (fNewConfig) { delete fConfig; fConfig = 0; }
00126 }
|
|
|
Definition at line 38 of file ConfigEditor.cxx. References Apply(), Cancel(), cfg::Config::Copy(), EditConfig(), cfg::Config::EditOK(), fConfig, fConfigCopy, cfg::Config::GetName(), cfg::Config::GetSource(), and cfg::Config::GetVersion(). Referenced by evdb::CfgEdit::Apply(), and main(). 00039 {
00040 //======================================================================
00041 // Actually do the edit
00042 //======================================================================
00043
00044 // Test if the edit of the configuration is OK
00045 if (fConfig->EditOK()==false) return;
00046
00047 // Make a copy of the configuration prior to any changes
00048 fConfigCopy = new cfg::Config(fConfig->GetName(),"dummy","dummy");
00049 cfg::Config::Copy(*fConfigCopy,
00050 *fConfig,
00051 fConfig->GetVersion(),
00052 fConfig->GetSource());
00053
00054 // Make the edit
00055 int apply = this->EditConfig(*fConfig);
00056
00057 // Apply any changes
00058 if (apply==0) this->Cancel();
00059 else this->Apply();
00060 }
|
|
|
The user edit function. Modify cfg at by some means. Return 1 to apply changes made to cfg, 0 to discard them Reimplemented in TestEditor, and evdb::CfgEdit. Definition at line 64 of file ConfigEditor.cxx. Referenced by Edit(). 00065 {
00066 //======================================================================
00067 // User edit routine. Modify the configuration cfg.
00068 //======================================================================
00069 return 0; // Do not apply edits
00070 // return 1; // Apply edits
00071 }
|
|
|
Definition at line 103 of file ConfigEditor.cxx. References cfg::Config::Copy(), fConfig, fConfigCopy, cfg::Config::GetSource(), and cfg::Config::GetVersion(). 00104 {
00105 //======================================================================
00106 // Set the state of the configuration back to what it was prior to edit
00107 //======================================================================
00108 cfg::Config::Copy(*fConfig,
00109 *fConfigCopy,
00110 fConfigCopy->GetVersion(),
00111 fConfigCopy->GetSource());
00112 }
|
|
|
The configuration to be edited.
Definition at line 43 of file ConfigEditor.h. |
|
|
A copy of the original configuration.
Definition at line 44 of file ConfigEditor.h. Referenced by Cancel(), Edit(), Reset(), and ~ConfigEditor(). |
|
|
Have we created a config. during the edit?
Definition at line 42 of file ConfigEditor.h. |
1.3.9.1