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

Observer.cxx

Go to the documentation of this file.
00001 
00002 // $Id: Observer.cxx,v 1.1 2007/02/09 05:38:27 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #include "Config/Observer.h"
00009 #include "Config/Table.h"
00010 #include "Config/Exception.h"
00011 #include <unistd.h>
00012 
00013 //......................................................................
00014 
00015 cfg::Observer::~Observer() { this->RemoveAllWatches(); }
00016 
00017 //......................................................................
00018 
00019 void cfg::Observer::RemoveWatch(const char* config)
00020 {
00021 //======================================================================
00022 // Remove this observer from the list of clients of config
00023 //======================================================================
00024   cfg::Table::Instance().RemoveWatch(config,this);
00025 }
00026 
00027 //......................................................................
00028 
00029 void cfg::Observer::RemoveAllWatches()
00030 {
00031 //======================================================================
00032 // Remove all watches set by this observer
00033 //======================================================================
00034   cfg::Table::Instance().RemoveAllWatches(this);
00035 }
00036 
00037 //......................................................................
00038 
00039 void cfg::Observer::SetWatch(const char* config, const char* version)
00040 {
00041 //======================================================================
00042 // Set a watch for the named version of the configuration config
00043 //======================================================================
00044   // Set the new watch
00045   cfg::Table::Instance().SetWatch(config, version, this);
00046 
00047   // Trigger the first update
00048   cfg::Config* c = cfg::Table::Instance().GetConfig(config, version);
00049   if (c) try { this->Update(*c); }
00050   catch (cfg::Exception e) { 
00051     std::cout << " *-> " << config << "." << version << " ";
00052     e.Print(); 
00053     exit(-1);
00054   }
00055 }
00056 

Generated on Sat Oct 11 02:35:27 2008 for NOvA Offline by  doxygen 1.3.9.1