Gaudi Framework, version v23r0 |
Home | Generated: Mon Jan 30 2012 |
#include <JobOptionsSvc.h>
Public Types | |
typedef std::vector< const Property * > | PropertiesT |
Public Member Functions | |
JobOptionsSvc (const std::string &name, ISvcLocator *svc) | |
virtual | ~JobOptionsSvc () |
destructor | |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
Service finalization method. | |
virtual StatusCode | setMyProperties (const std::string &client, IProperty *me) |
Override default properties of the calling client. | |
virtual StatusCode | addPropertyToCatalogue (const std::string &client, const Property &property) |
Add a property into the JobOptions catalog. | |
virtual StatusCode | removePropertyFromCatalogue (const std::string &client, const std::string &name) |
Remove a property from the JobOptions catalog. | |
virtual const std::vector < const Property * > * | getProperties (const std::string &client) const |
Get the properties associated to a given client. | |
virtual std::vector< std::string > | getClients () const |
Get the list of clients. | |
virtual StatusCode | readOptions (const std::string &file, const std::string &path="") |
look for file 'file' into search path 'path' and read it to update existing JobOptionsCatalogue | |
StatusCode | setProperty (const Property &p) |
IProperty implementation (needed for initialisation) | |
StatusCode | getProperty (Property *p) const |
Private Member Functions | |
void | fillServiceCatalog (const Gaudi::Parsers::Catalog &catalog) |
void | dump (const std::string &file, const Gaudi::Parsers::Catalog &catalog) const |
Private Attributes | |
PropertyMgr | m_pmgr |
dump the content of Properties catalog to the predefined file | |
std::string | m_source_path |
std::string | m_source_type |
std::string | m_dir_search_path |
std::string | m_dump |
SvcCatalog | m_svc_catalog |
bool | m_dumped |
Definition at line 21 of file JobOptionsSvc.h.
typedef std::vector<const Property*> JobOptionsSvc::PropertiesT |
Definition at line 23 of file JobOptionsSvc.h.
JobOptionsSvc::JobOptionsSvc | ( | const std::string & | name, |
ISvcLocator * | svc | ||
) |
Definition at line 31 of file JobOptionsSvc.cpp.
: base_class(name,svc), m_pmgr() , m_source_path() , m_source_type() , m_dir_search_path() , m_dump() , m_dumped( false ) { std::string tmp ; tmp = System::getEnv ( "JOBOPTSEARCHPATH" ) ; if ( !tmp.empty() && ("UNKNOWN" != tmp) ) { m_dir_search_path = tmp ; } tmp = System::getEnv ( "JOBOPTSDUMPFILE" ) ; if ( !tmp.empty() && ("UNKNOWN" != tmp) ) { m_dump = tmp ; } m_pmgr.declareProperty( "TYPE" , m_source_type ) ; m_pmgr.declareProperty( "PATH" , m_source_path ) ; m_pmgr.declareProperty( "SEARCHPATH" , m_dir_search_path ) ; m_pmgr.declareProperty( "DUMPFILE" , m_dump ) ; }
virtual JobOptionsSvc::~JobOptionsSvc | ( | ) | [inline, virtual] |
StatusCode JobOptionsSvc::addPropertyToCatalogue | ( | const std::string & | client, |
const Property & | property | ||
) | [virtual] |
Add a property into the JobOptions catalog.
Definition at line 85 of file JobOptionsSvc.cpp.
{ Property* p = new StringProperty ( property.name(), "" ) ; if ( !property.load( *p ) ) { delete p ; return StatusCode::FAILURE ; } return m_svc_catalog.addProperty( client , p ); }
void JobOptionsSvc::dump | ( | const std::string & | file, |
const Gaudi::Parsers::Catalog & | catalog | ||
) | const [private] |
void JobOptionsSvc::fillServiceCatalog | ( | const Gaudi::Parsers::Catalog & | catalog ) | [private] |
StatusCode JobOptionsSvc::finalize | ( | ) | [virtual] |
Service finalization method.
Reimplemented from Service.
Definition at line 78 of file JobOptionsSvc.cpp.
{ // finalize the base class return Service::finalize(); }
std::vector< std::string > JobOptionsSvc::getClients | ( | ) | const [virtual] |
Get the list of clients.
Definition at line 136 of file JobOptionsSvc.cpp.
{ return m_svc_catalog.getClients(); }
const JobOptionsSvc::PropertiesT * JobOptionsSvc::getProperties | ( | const std::string & | client ) | const [virtual] |
Get the properties associated to a given client.
Definition at line 102 of file JobOptionsSvc.cpp.
{ return m_svc_catalog.getProperties(client); }
StatusCode JobOptionsSvc::getProperty | ( | Property * | p ) | const [virtual] |
Reimplemented from Service.
Definition at line 57 of file JobOptionsSvc.cpp.
{ return m_pmgr.getProperty( p ); }
StatusCode JobOptionsSvc::initialize | ( | ) | [virtual] |
Reimplemented from Service.
Definition at line 63 of file JobOptionsSvc.cpp.
{ // Call base class initializer StatusCode sc = Service::initialize(); if( !sc.isSuccess() ) return sc; // Read the job options if needed if ( this->m_source_type == "NONE" ) { sc = StatusCode::SUCCESS; } else { sc = this->readOptions( m_source_path , m_dir_search_path); } return sc; }
StatusCode JobOptionsSvc::readOptions | ( | const std::string & | file, |
const std::string & | path = "" |
||
) | [virtual] |
look for file 'file' into search path 'path' and read it to update existing JobOptionsCatalogue
file | file name |
path | search path |
Definition at line 169 of file JobOptionsSvc.cpp.
{ std::string search_path = path; if ( search_path.empty() && !m_dir_search_path.empty() ) { search_path = m_dir_search_path ; } // MsgStream my_log( this->msgSvc(), this->name() ); if (UNLIKELY(outputLevel() <= MSG::DEBUG)) my_log << MSG::DEBUG // debug << "Reading options from the file " << "'" << file << "'" << endmsg; gp::Messages messages(my_log); gp::Catalog catalog; gp::Units units; gp::PragmaOptions pragma; gp::Node ast; StatusCode sc = gp::ReadOptions(file, path, &messages, &catalog, &units, &pragma, &ast); // -------------------------------------------------------------------------- if ( sc.isSuccess() ) { if (pragma.IsPrintOptions()) { my_log << MSG::INFO << "Print options" << std::endl << catalog << endmsg; } if (pragma.IsPrintTree()) { my_log << MSG::INFO << "Print tree:" << std::endl << ast.ToString() << endmsg; } if (pragma.HasDumpFile()) { dump(pragma.dumpFile(), catalog); } my_log << MSG::INFO << "Job options successfully read in from " << file << endmsg; fillServiceCatalog(catalog); } else { my_log << MSG::FATAL << "Job options errors."<< endmsg; } // ---------------------------------------------------------------------------- return sc; }
StatusCode JobOptionsSvc::removePropertyFromCatalogue | ( | const std::string & | client, |
const std::string & | name | ||
) | [virtual] |
Remove a property from the JobOptions catalog.
Definition at line 95 of file JobOptionsSvc.cpp.
{ return m_svc_catalog.removeProperty(client,name); }
StatusCode JobOptionsSvc::setMyProperties | ( | const std::string & | client, |
IProperty * | me | ||
) | [virtual] |
Override default properties of the calling client.
client | Name of the client algorithm or service |
me | Address of the interface IProperty of the client |
Definition at line 107 of file JobOptionsSvc.cpp.
{ const SvcCatalog::PropertiesT* props = m_svc_catalog.getProperties(client); if ( NULL == props ){ return StatusCode::SUCCESS; } bool fail = false; for ( std::vector<const Property*>::const_iterator cur = props->begin(); cur != props->end(); cur++) { StatusCode sc = myInt->setProperty (**cur ) ; if ( sc.isFailure() ) { MsgStream my_log( this->msgSvc(), this->name() ); my_log << MSG::ERROR << "Unable to set the property '" << (*cur)->name() << "'" << " of '" << client << "'. " << "Check option and algorithm names, type and bounds." << endmsg; fail = true; } } return fail ? StatusCode::FAILURE : StatusCode::SUCCESS ; }
StatusCode JobOptionsSvc::setProperty | ( | const Property & | p ) | [virtual] |
IProperty implementation (needed for initialisation)
Reimplemented from Service.
Definition at line 52 of file JobOptionsSvc.cpp.
{ return m_pmgr.setProperty( p ); }
std::string JobOptionsSvc::m_dir_search_path [private] |
Definition at line 79 of file JobOptionsSvc.h.
std::string JobOptionsSvc::m_dump [private] |
Definition at line 80 of file JobOptionsSvc.h.
bool JobOptionsSvc::m_dumped [private] |
Definition at line 82 of file JobOptionsSvc.h.
PropertyMgr JobOptionsSvc::m_pmgr [private] |
dump the content of Properties catalog to the predefined file
Definition at line 76 of file JobOptionsSvc.h.
std::string JobOptionsSvc::m_source_path [private] |
Definition at line 77 of file JobOptionsSvc.h.
std::string JobOptionsSvc::m_source_type [private] |
Definition at line 78 of file JobOptionsSvc.h.
SvcCatalog JobOptionsSvc::m_svc_catalog [private] |
Definition at line 81 of file JobOptionsSvc.h.