Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

cfg::ConfigBuilder Class Reference

A class with the necesarry permissions to create configurations. More...

#include <ConfigBuilder.h>

Inheritance diagram for cfg::ConfigBuilder:

cfg::configBuilder TestBuilder List of all members.

Public Member Functions

 ConfigBuilder ()
virtual ~ConfigBuilder ()

Protected Member Functions

void Publish (Config *cfg)
 Base class methods for cfg::Config creation.

Detailed Description

A class with the necesarry permissions to create configurations.

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.


Constructor & Destructor Documentation

cfg::ConfigBuilder::ConfigBuilder  )  [inline]
 

Definition at line 25 of file ConfigBuilder.h.

00025 { }

virtual cfg::ConfigBuilder::~ConfigBuilder  )  [inline, virtual]
 

Definition at line 26 of file ConfigBuilder.h.

00026 { }


Member Function Documentation

void cfg::ConfigBuilder::Publish Config cfg  )  [protected]
 

Base class methods for cfg::Config creation.

Definition at line 18 of file ConfigBuilder.cxx.

References cfg::Table::AdoptConfig(), cfg::Config::GetName(), cfg::Table::GetObservers(), cfg::Config::GetVersion(), cfg::Table::Instance(), and cfg::Config::SetReadOnly().

Referenced by cfg::configBuilder::Build(), TestBuilder::BuildCfg1(), and TestBuilder::BuildCfg2().

00019 {
00020 //======================================================================
00021 // Publish the configuration cfg so that it is visible to the rest of
00022 // the program. Note that responsibility for the deletion of cfg is
00023 // transferred to the cfg::Table class via this call. *Do not* delete a
00024 // configuration once you publish it!!
00025 //======================================================================
00026   cfg::Table& t = cfg::Table::Instance();
00027   
00028   // Set read/write permissions based on policy
00029   cfg->SetReadOnly(-1); // -1 = determine from policy
00030 
00031   // Insert the configuration into the table of configurations
00032   t.AdoptConfig(cfg);
00033   
00034   // Alert observers of this configuration to the change it its
00035   // state
00036   cfg::Table::ObsList olist;
00037   t.GetObservers(cfg->GetName(), cfg->GetVersion(), olist);
00038 
00039   cfg::Table::ObsList::iterator    itr(olist.begin());
00040   cfg::Table::ObsList::iterator itrEnd(olist.end());
00041   for (; itr!=itrEnd; ++itr) try { (*itr)->Update(*cfg); }
00042   catch (cfg::Exception e) {
00043     std::cout << cfg->GetName() << "." << cfg->GetVersion() << " ";
00044     e.Print();
00045     exit(-1);
00046   }
00047 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 21 04:45:35 2009 for NOvA Offline by  doxygen 1.3.9.1