cafe::Config Class Reference
[CAF Environment (Cafe)]

#include <Config.hpp>

List of all members.


Detailed Description

Provide access to configuration information for a given package called 'name'.

To use it, just instantiate an object of this type. All lookups will be prepended with the 'name' given.

Config config("MyTest"); std::string value = config.get("MyValue","MyDefault");

will look up 'Mytest.MyValue: ...' in the configuration file.

The configuration file is searched in the following places:

Definition at line 36 of file Config.hpp.

Public Member Functions

 Config (const std::string &name)
virtual ~Config ()
void set (const std::string &key, const std::string &value)
 Set/Override an entry in the configuration database.

void dumpConfig (std::ostream &stream)
 Dump config DB to given output stream.

void dumpConfig (TDirectory *const dir, std::string const name="configDB")
 Dump config DB to given TDirectory.

Accessor
Return the default value if the parameter isn't set

std::string get (const std::string &key, const std::string &def)
 Get string value from config DB.

std::string get (const std::string &key, const char *def)
 Get string value from config DB.

int get (const std::string &key, int def)
 Get integer value from config DB.

double get (const std::string &key, double def)
 Get floating point value from config DB.

bool get (const std::string &key, bool def)
 Get boolean value from config DB.

std::vector< std::string > getVString (const std::string &key, const std::string &delim="")
 Get list of strings of config DB.

std::vector< float > getVFloat (const std::string &key, const std::string &delim="")
 Get list of floats from config DB.

std::vector< int > getVInt (const std::string &key, const std::string &delim="")
 Get list of integers from config DB.


Static Public Member Functions

std::vector< std::string > checkConfiguration ()
 Check that every processor P has accessed all the variables of the form 'P.X: ...'.

std::vector< std::string > variables (const std::string &name)
 return list of all variables specified for the processor with name "name"

void resolve ()
 Re-run the variable expansion process.


Static Private Member Functions

std::string replace (TEnv *env, const std::string &input)
TEnv & getEnv ()

Private Attributes

std::string _name

Static Private Attributes

std::set< std::string > s_accessed
 static


Constructor & Destructor Documentation

cafe::Config::Config const std::string &  name  )  [explicit]
 

Definition at line 25 of file Config.cpp.

cafe::Config::~Config  )  [virtual]
 

Definition at line 29 of file Config.cpp.


Member Function Documentation

std::vector< std::string > cafe::Config::checkConfiguration  )  [static]
 

Check that every processor P has accessed all the variables of the form 'P.X: ...'.

Report any variables that have not been accessed.

Definition at line 290 of file Config.cpp.

References getEnv(), and s_accessed.

void cafe::Config::dumpConfig TDirectory *const   dir,
std::string const   name = "configDB"
 

Dump config DB to given TDirectory.

Definition at line 163 of file Config.cpp.

References getEnv().

void cafe::Config::dumpConfig std::ostream &  stream  ) 
 

Dump config DB to given output stream.

Definition at line 148 of file Config.cpp.

References getEnv().

Referenced by cafe::ConfigDumper::begin(), and cafe::ConfigDumper::finish().

bool cafe::Config::get const std::string &  key,
bool  def
 

Get boolean value from config DB.

Definition at line 86 of file Config.cpp.

References _name, getEnv(), and s_accessed.

double cafe::Config::get const std::string &  key,
double  def
 

Get floating point value from config DB.

Definition at line 79 of file Config.cpp.

References _name, getEnv(), and s_accessed.

int cafe::Config::get const std::string &  key,
int  def
 

Get integer value from config DB.

Definition at line 72 of file Config.cpp.

References _name, getEnv(), and s_accessed.

std::string cafe::Config::get const std::string &  key,
const char *  def
 

Get string value from config DB.

This is needed because otherwise the 'bool' version of get() will be called for const char strings.

Definition at line 65 of file Config.cpp.

References _name, getEnv(), and s_accessed.

std::string cafe::Config::get const std::string &  key,
const std::string &  def
 

Get string value from config DB.

Definition at line 59 of file Config.cpp.

Referenced by cafe::AssociatedTracks::AssociatedTracks(), cafe::BadLBNs::BadLBNs(), cafe::Stat::begin(), cafe::Hist1D::begin(), cafe::Controller::begin(), cafe::ConfigDumper::ConfigDumper(), cafe::Controller::Controller(), cafe::EventList::EventList(), cafe::EventMultiSplitter::EventMultiSplitter(), cafe::Friend::Friend(), getVFloat(), getVInt(), getVString(), cafe::GoodRuns::GoodRuns(), cafe::Hist1D::Hist1D(), cafe::Hist2D::Hist2D(), cafe::Hist3D::Hist3D(), cafe::If::If(), cafe::IfPr::IfPr(), cafe::Stat::print_html(), cafe::RandomProcessor::RandomProcessor(), cafe::RandomSelectUserObjects< T >::RandomSelectUserObjects(), cafe::RemoveObjects::RemoveObjects(), cafe::Processor::resolve(), cafe::RunController::RunController(), cafe::Select::Select(), cafe::SelectObjects::SelectObjects(), cafe::SelectUserObjects< T >::SelectUserObjects(), cafe::StageinlistExpander::StageinlistExpander(), cafe::Trigger::Trigger(), and cafe::Write::Write().

TEnv & cafe::Config::getEnv  )  [static, private]
 

Definition at line 195 of file Config.cpp.

References cafe::_cleanup, and s_accessed.

Referenced by checkConfiguration(), dumpConfig(), get(), resolve(), set(), and variables().

std::vector< float > cafe::Config::getVFloat const std::string &  key,
const std::string &  delim = ""
 

Get list of floats from config DB.

Definition at line 111 of file Config.cpp.

References _name, get(), and s_accessed.

std::vector< int > cafe::Config::getVInt const std::string &  key,
const std::string &  delim = ""
 

Get list of integers from config DB.

Definition at line 127 of file Config.cpp.

References _name, get(), and s_accessed.

std::vector< std::string > cafe::Config::getVString const std::string &  key,
const std::string &  delim = ""
 

Get list of strings of config DB.

Definition at line 93 of file Config.cpp.

References _name, get(), and s_accessed.

Referenced by cafe::AssociatedTracks::AssociatedTracks(), cafe::BadLBNs::BadLBNs(), cafe::Stat::begin(), cafe::Controller::Controller(), cafe::EventFlags::EventFlags(), cafe::EventList::EventList(), cafe::GoodRuns::GoodRuns(), cafe::Hist1D::Hist1D(), cafe::Hist2D::Hist2D(), cafe::Hist3D::Hist3D(), cafe::IfPr::IfPr(), cafe::Permute::Permute(), cafe::Plugins::Plugins(), cafe::RandomSelectUserObjects< T >::RandomSelectUserObjects(), cafe::RemoveObjects::RemoveObjects(), cafe::RunController::RunController(), cafe::Select::Select(), cafe::SelectUserObjects< T >::SelectUserObjects(), cafe::Trigger::Trigger(), and cafe::Write::Write().

std::string cafe::Config::replace TEnv *  env,
const std::string &  input
[static, private]
 

Definition at line 32 of file Config.cpp.

References s_accessed.

Referenced by resolve().

void cafe::Config::resolve  )  [static]
 

Re-run the variable expansion process.

Normally this is done automaticall when all input files have been read, so you don't need to call this.

Definition at line 269 of file Config.cpp.

References getEnv(), and replace().

void cafe::Config::set const std::string &  key,
const std::string &  value
 

Set/Override an entry in the configuration database.

Definition at line 143 of file Config.cpp.

References getEnv().

Referenced by main(), and cafe::Permute::Permute().

std::vector< std::string > cafe::Config::variables const std::string &  name  )  [static]
 

return list of all variables specified for the processor with name "name"

Definition at line 326 of file Config.cpp.

References getEnv().


Member Data Documentation

std::string cafe::Config::_name [private]
 

Definition at line 100 of file Config.hpp.

Referenced by get(), getVFloat(), getVInt(), and getVString().

std::set< std::string > cafe::Config::s_accessed [static, private]
 

static

Definition at line 23 of file Config.cpp.

Referenced by checkConfiguration(), get(), getEnv(), getVFloat(), getVInt(), getVString(), and replace().


The documentation for this class was generated from the following files:
Generated on Thu Apr 3 04:14:27 2008 for CAF by doxygen 1.3.4