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

Public Member Functions | |
| ConfigBuilder () | |
| virtual | ~ConfigBuilder () |
Protected Member Functions | |
| void | Publish (Config *cfg) |
| Base class methods for cfg::Config creation. | |
Creation of configurations is a slightly delicate business as there are in principle clients which need to be notified of the existance of the configuration. This class is designed to help with some of these issues. The basic decision the author needs to make is whether the configuration being created should be given "local" or "global" scope. If the configuration is to be made generally available to the rest of the program then one should use the "Publish" method below once the configuration construction is complete
Definition at line 23 of file ConfigBuilder.h.
|
|
Definition at line 25 of file ConfigBuilder.h.
00025 { }
|
|
|
Definition at line 26 of file ConfigBuilder.h.
00026 { }
|
|
|
Base class methods for cfg::Config creation.
Definition at line 15 of file ConfigBuilder.cxx. References cfg::Table::AdoptConfig(), cfg::Config::GetName(), cfg::Table::GetObservers(), cfg::Config::GetVersion(), cfg::Table::Instance(), cfg::Table::ObsList, and cfg::Config::SetReadOnly(). Referenced by cfg::configBuilder::Build(), TestBuilder::BuildCfg1(), and TestBuilder::BuildCfg2().
00016 {
00017 //======================================================================
00018 // Publish the configuration cfg so that it is visible to the rest of
00019 // the program. Note that responsibility for the deletion of cfg is
00020 // transferred to the cfg::Table class via this call. *Do not* delete a
00021 // configuration once you publish it!!
00022 //======================================================================
00023 cfg::Table& t = cfg::Table::Instance();
00024
00025 // Set read/write permissions based on policy
00026 cfg->SetReadOnly(-1); // -1 = determine from policy
00027
00028 // Insert the configuration into the table of configurations
00029 t.AdoptConfig(cfg);
00030
00031 // Alert observers of this configuration to the change it its
00032 // state
00033 cfg::Table::ObsList olist;
00034 t.GetObservers(cfg->GetName(), cfg->GetVersion(), olist);
00035
00036 cfg::Table::ObsList::iterator itr(olist.begin());
00037 cfg::Table::ObsList::iterator itrEnd(olist.end());
00038 for (; itr!=itrEnd; ++itr) try { (*itr)->Update(*cfg); }
00039 catch (cfg::Exception e) {
00040 std::cout << cfg->GetName() << "." << cfg->GetVersion() << " ";
00041 e.Print();
00042 exit(-1);
00043 }
00044 }
|
1.3.5