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

ConfigBuilder.cxx

Go to the documentation of this file.
00001 
00002 // $Id: ConfigBuilder.cxx,v 1.1 2007/02/09 05:38:27 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #include "Config/ConfigBuilder.h"
00009 #include "Config/Param.h"
00010 #include "Config/Config.h"
00011 #include "Config/Observer.h"
00012 #include "Config/Table.h"
00013 #include <unistd.h>
00014 
00015 void cfg::ConfigBuilder::Publish(cfg::Config* cfg) 
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 }
00045 

Generated on Mon Dec 1 02:35:17 2008 for NOvA Offline by  doxygen 1.3.9.1