| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# JobOptionsSvc Class Reference

`#include <JobOptionsSvc.h>`

Inheritance diagram for JobOptionsSvc:

[legend]
Collaboration diagram for JobOptionsSvc:

[legend]

List of all members.

## Detailed Description

Definition at line 22 of file JobOptionsSvc.h.

## Public Types
typedef std::vector< const Property * > | PropertiesT
## Public Member Functions
| JobOptionsSvc (const std::string &name, ISvcLocator *svc)
| Constructor.
virtual | ~JobOptionsSvc ()
| destructor
virtual StatusCode | initialize ()
| Service initialization method.
virtual StatusCode | finalize ()
| Service finalization method.
virtual StatusCode | setMyProperties (const std::string &client, IProperty *myInt)
| IJobOptionsSvc::setMyProperties.
virtual StatusCode | addPropertyToCatalogue (const std::string &client, const Property &property)
| implementation of IJobOptionsSvc::addPropertyToCatalogue
virtual StatusCode | removePropertyFromCatalogue (const std::string &client, const std::string &name)
| implementation of IJobOptionsSvc::removePropertyFromCatalogue
virtual const PropertiesT * | getProperties (const std::string &client) const
| inmplementation of IJobOptionsSvc::getProperties
virtual std::vector< std::string > | getClients () const
| inmplementation of IJobOptionsSvc::getClients
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
| Get the property by property.
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface)
| IInterface implementation.
std::ostream & | fillStream (std::ostream &o) const
| dump the content of Properties catalogue to std::ostream
void | dump (const std::string &file) const
| dump the content of Properties catalogue to the file
void | dump ()
| dump the content of Properties catalogue to the predefined file
## Private Member Functions
void | fillParserCatalogue ()
| Fill parser catalogue before parse.
void | fillServiceCatalogue ()
| Fill service catalogue after parse.
MSG::Level | convertSeverity (const Gaudi::Parsers::Message::Severity &severity)
| convert the severity
## Private Attributes
std::string | m_source_path
std::string | m_source_type
std::string | m_dirSearchPath
std::string | m_dump
| optional output file to dump all properties
bool | m_dumped
PropertyMgr | m_pmgr
Gaudi::Parsers::Catalogue | m_pcatalogue
std::vector< std::string > | m_included
JobOptionsCatalogue | m_catalogue

## Member Typedef Documentation

typedef std::vector<const Property*> JobOptionsSvc::PropertiesT

Definition at line 32 of file JobOptionsSvc.h.

## Constructor & Destructor Documentation

JobOptionsSvc::JobOptionsSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc |
| ) |  |  |

Constructor.

Definition at line 33 of file JobOptionsSvc.cpp.

    00035   : Service(name,svc)
    00036   , m_source_path     ()
    00037   , m_source_type     ()
    00038   , m_dirSearchPath   ()
    00039   , m_dump            ()
    00040   , m_dumped ( false )
    00041 {
    00042   std::string tmp ;
    00043   tmp = System::getEnv ( "JOBOPTSEARCHPATH" ) ;
    00044   if ( !tmp.empty() && ("UNKNOWN" != tmp) ) { m_dirSearchPath = tmp ; }
    00045   tmp = System::getEnv ( "JOBOPTSDUMPFILE"  ) ;
    00046   if ( !tmp.empty() && ("UNKNOWN" != tmp) ) { m_dump          = tmp ; }
    00047
    00048   m_pmgr.declareProperty( "TYPE"       , m_source_type   ) ;
    00049   m_pmgr.declareProperty( "PATH"       , m_source_path   ) ;
    00050   m_pmgr.declareProperty( "SEARCHPATH" , m_dirSearchPath ) ;
    00051   m_pmgr.declareProperty( "DUMPFILE"   , m_dump          ) ;
    00052 }

JobOptionsSvc::~JobOptionsSvc | ( |  | ) | `[virtual]`

destructor

Definition at line 282 of file JobOptionsSvc.cpp.

    00283 {
    00284   // dump needed? @attention JobOptionsSvc::finalize is never invoked!
    00285   if ( !m_dump.empty() && !m_dumped ) { dump() ;}
    00286 }

## Member Function Documentation

StatusCode JobOptionsSvc::initialize | ( |  | ) | `[virtual]`

Service initialization method.

Reimplemented from Service.

Definition at line 92 of file JobOptionsSvc.cpp.

    00093 {
    00094   // Call base class initializer
    00095   StatusCode sc = Service::initialize();
    00096   if( !sc.isSuccess() ) return sc;
    00097   // Read the job options if needed
    00098   if ( this->m_source_type == "NONE" ) {
    00099     sc =  StatusCode::SUCCESS;
    00100   }
    00101   else {
    00102     sc = this->readOptions( m_source_path , m_dirSearchPath);
    00103   }
    00104   return sc;
    00105 }

StatusCode JobOptionsSvc::finalize | ( | void |  | ) | `[virtual]`

Service finalization method.

Reimplemented from Service.

Definition at line 245 of file JobOptionsSvc.cpp.

    00246 {
    00247   // dump the properties catalogue if needed
    00248   if ( !m_dump.empty() && !m_dumped ) { dump() ;}
    00249    // finalize the base class
    00250   return Service::finalize() ;
    00251 }

StatusCode JobOptionsSvc::setMyProperties | ( | const std::string & | client,
|  | IProperty * | myInt |
| ) |  |  | `[virtual]`

IJobOptionsSvc::setMyProperties.

Implements IJobOptionsSvc.

Definition at line 64 of file JobOptionsSvc.cpp.

    00066 {
    00067   const JobOptionsCatalogue::PropertiesT* props =
    00068     m_catalogue.getProperties(client);
    00069
    00070   if ( NULL == props ){ return StatusCode::SUCCESS; }
    00071
    00072   bool fail = false;
    00073   for ( std::vector<const Property*>::const_iterator cur = props->begin();
    00074     cur != props->end(); cur++)
    00075   {
    00076     StatusCode sc = myInt->setProperty (**cur ) ;
    00077     if ( sc.isFailure() )
    00078     {
    00079       MsgStream my_log( this->msgSvc(), this->name() );
    00080       my_log
    00081         << MSG::ERROR
    00082         << "Unable to set the property '" << (*cur)->name() << "'"
    00083         <<                        " of '" << client         << "'. "
    00084         << "Check option and algorithm names, type and bounds."
    00085         << endreq;
    00086       fail = true;
    00087     }
    00088   }
    00089   return fail ? StatusCode::FAILURE : StatusCode::SUCCESS ;
    00090 }

StatusCode JobOptionsSvc::addPropertyToCatalogue | ( | const std::string & | client,
|  | const Property & | property |
| ) |  |  | `[virtual]`

implementation of IJobOptionsSvc::addPropertyToCatalogue

Implements IJobOptionsSvc.

Definition at line 169 of file JobOptionsSvc.cpp.

    00171 {
    00172   Property* p = new StringProperty ( property.name(), "" ) ;
    00173   if ( !property.load( *p ) ) { delete p ; return StatusCode::FAILURE ; }
    00174   return m_catalogue.addProperty( client , p );
    00175 }

StatusCode JobOptionsSvc::removePropertyFromCatalogue | ( | const std::string & | client,
|  | const std::string & | name |
| ) |  |  | `[virtual]`

implementation of IJobOptionsSvc::removePropertyFromCatalogue

Implements IJobOptionsSvc.

Definition at line 179 of file JobOptionsSvc.cpp.

    00181 {
    00182   return m_catalogue.removeProperty(client,name);
    00183 }

const JobOptionsSvc::PropertiesT * JobOptionsSvc::getProperties | ( | const std::string & | client | ) | const`[virtual]`

inmplementation of IJobOptionsSvc::getProperties

Implements IJobOptionsSvc.

Definition at line 186 of file JobOptionsSvc.cpp.

    00187 {
    00188   return m_catalogue.getProperties(client);
    00189 }

std::vector< std::string > JobOptionsSvc::getClients | ( |  | ) | const`[virtual]`

inmplementation of IJobOptionsSvc::getClients

Implements IJobOptionsSvc.

Definition at line 191 of file JobOptionsSvc.cpp.

    00192 {
    00193   return m_catalogue.getClients();
    00194 }

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

Parameters:

  | File | file name
  | Path | search path

Returns:
  status code

Implements IJobOptionsSvc.

Definition at line 123 of file JobOptionsSvc.cpp.

    00125 {
    00126   // use the default non-empty path (if any) if no path specified
    00127   if ( path.empty() && !m_dirSearchPath.empty() )
    00128   { return readOptions ( file , m_dirSearchPath ) ; }
    00129   //
    00130   MsgStream my_log( this->msgSvc(), this->name() );
    00131   // --------------------------------------------------------------------------
    00132   std::vector<Gaudi::Parsers::Message> messages;
    00133   // --------------------------------------------------------------------------
    00134   // fillParserCatalogue();
    00135   // --------------------------------------------------------------------------
    00136   my_log << MSG::DEBUG                             // debug
    00137          << "Job-options read from the file "
    00138          << "'" << file << "'"
    00139          << MSG::INFO                              // switch
    00140          << std::endl ;
    00141   // create the parser & parse the file
    00142   Gaudi::Parsers::Parser parser (m_pcatalogue, m_included, path, my_log.stream() ) ;
    00143   StatusCode sc = Gaudi::Parsers::parse
    00144     ( parser , file , messages ) ;
    00145   my_log << endreq ;
    00146
    00147   // --------------------------------------------------------------------------
    00148   if ( sc.isSuccess() )
    00149   {
    00150     my_log << MSG::INFO
    00151            << "Job options successfully read in from " << file << endreq;
    00152     fillServiceCatalogue();
    00153   }
    00154   else
    00155   {
    00156     my_log << MSG::FATAL << "Job options errors."<< endreq;
    00157   }
    00158   // ----------------------------------------------------------------------------
    00159   for ( std::vector<Gaudi::Parsers::Message>::const_iterator
    00160           cur=messages.begin(); cur!=messages.end();cur++)
    00161   {
    00162     my_log << convertSeverity(cur->severity()) << cur->message() << endreq;
    00163   }
    00164   // ----------------------------------------------------------------------------
    00165   return sc;
    00166 }

StatusCode JobOptionsSvc::setProperty | ( | const Property & | p | ) | `[virtual]`

IProperty implementation (needed for initialisation).

Implements IProperty.

Definition at line 54 of file JobOptionsSvc.cpp.

    00055 {
    00056         return m_pmgr.setProperty( p );
    00057 }

StatusCode JobOptionsSvc::getProperty | ( | Property * | p | ) | const`[virtual]`

Get the property by property.

Implements IProperty.

Definition at line 59 of file JobOptionsSvc.cpp.

    00060 {
    00061         return m_pmgr.getProperty( p );
    00062 }

StatusCode JobOptionsSvc::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvInterface |
| ) |  |  | `[virtual]`

IInterface implementation.

Reimplemented from Service.

Definition at line 107 of file JobOptionsSvc.cpp.

    00109 {
    00110   if ( IID_IJobOptionsSvc == riid )  {
    00111     *ppvInterface = static_cast<IJobOptionsSvc*>( this ) ;
    00112   }
    00113   else if ( IID_IProperty == riid ) {
    00114     *ppvInterface = static_cast<IProperty*>( this ) ;
    00115   }
    00116   else  {
    00117     return Service::queryInterface(riid, ppvInterface);
    00118   }
    00119   addRef();
    00120   return StatusCode::SUCCESS;
    00121 }

std::ostream & JobOptionsSvc::fillStream | ( | std::ostream & | o | ) | const

dump the content of Properties catalogue to std::ostream

Definition at line 279 of file JobOptionsSvc.cpp.

    00280 { return  o << m_pcatalogue ; }

void JobOptionsSvc::dump | ( | const std::string & | file | ) | const

dump the content of Properties catalogue to the file

Definition at line 262 of file JobOptionsSvc.cpp.

    00263 {
    00264   MsgStream log ( msgSvc() , name() ) ;
    00265   std::ofstream out
    00266     ( file.c_str() , std::ios_base::out | std::ios_base::trunc ) ;
    00267   // perform the actual dumping
    00268   if ( !out )
    00269   {
    00270     log << MSG::ERROR << "Unable to open dump-file \""+file+"\"" << endreq ;
    00271     return ;                                                   // RETURN
    00272   }
    00273   else
    00274   { log << MSG::INFO << "Properties are dumped into \""+file+"\"" << endreq ; }
    00275   // perform the actual dump:
    00276   fillStream ( out ) ;
    00277 }

void JobOptionsSvc::dump | ( |  | ) |

dump the content of Properties catalogue to the predefined file

< avoid double dump

Definition at line 253 of file JobOptionsSvc.cpp.

    00254 {
    00255   // avoid double dump
    00256   if ( m_dump.empty() || m_dumped ) { return ; }               // RETURN
    00257   dump ( m_dump ) ;
    00258   // avoid double dump
    00259   m_dumped = true ;
    00260 }

void JobOptionsSvc::fillParserCatalogue | ( |  | ) | `[private]`

Fill parser catalogue before parse.

Definition at line 197 of file JobOptionsSvc.cpp.

    00197                                        {
    00198   std::vector<std::string> clients = getClients();
    00199   for(std::vector<std::string>::const_iterator client = clients.begin();
    00200     client != clients.end(); client++){
    00201        const PropertiesT* props = getProperties(*client);
    00202        for(PropertiesT::const_iterator prop = props->begin();
    00203         prop != props->end(); prop++){
    00204          m_pcatalogue.addProperty(*client,(*prop)->name(),
    00205            (*prop)->toString());
    00206         }
    00207    }
    00208 }

void JobOptionsSvc::fillServiceCatalogue | ( |  | ) | `[private]`

Fill service catalogue after parse.

Definition at line 211 of file JobOptionsSvc.cpp.

    00212 {
    00213   typedef Gaudi::Parsers::Catalogue::CatalogueT      _Catalogue ;
    00214   typedef std::vector<Gaudi::Parsers::PropertyEntry> _Entries   ;
    00215   _Catalogue catalogue = m_pcatalogue.catalogue();
    00216   for  ( _Catalogue::const_iterator curObj = catalogue.begin() ;
    00217          curObj!=catalogue.end(); ++curObj)
    00218   {
    00219     for ( _Entries::const_iterator curProp = curObj->second.begin() ;
    00220           curProp!=curObj->second.end(); ++curProp)
    00221     {
    00222       StringProperty tmp (curProp->name(), curProp->value() ) ;
    00223       addPropertyToCatalogue ( curObj->first , tmp ) ;
    00224     }
    00225   }
    00226 }

MSG::Level JobOptionsSvc::convertSeverity | ( | const Gaudi::Parsers::Message::Severity & | severity | ) | `[private]`

convert the severity

Definition at line 230 of file JobOptionsSvc.cpp.

    00231 {
    00232   switch ( severity )
    00233   {
    00234   case Gaudi::Parsers::Message::E_ERROR   :
    00235     return MSG::FATAL   ;
    00236   case Gaudi::Parsers::Message::E_WARNING :
    00237     return MSG::WARNING ;
    00238   case Gaudi::Parsers::Message::E_NOTICE  :
    00239     return MSG::INFO    ;
    00240   default:
    00241     return MSG::DEBUG   ;
    00242   }
    00243 }

## Member Data Documentation

std::string JobOptionsSvc::m_source_path`[private]`

Definition at line 92 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_source_type`[private]`

Definition at line 93 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_dirSearchPath`[private]`

Definition at line 94 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_dump`[private]`

optional output file to dump all properties

Definition at line 96 of file JobOptionsSvc.h.

bool JobOptionsSvc::m_dumped`[private]`

Definition at line 97 of file JobOptionsSvc.h.

PropertyMgr JobOptionsSvc::m_pmgr`[private]`

Definition at line 98 of file JobOptionsSvc.h.

Gaudi::Parsers::Catalogue JobOptionsSvc::m_pcatalogue`[private]`

Definition at line 99 of file JobOptionsSvc.h.

std::vector<std::string> JobOptionsSvc::m_included`[private]`

Definition at line 100 of file JobOptionsSvc.h.

JobOptionsCatalogue JobOptionsSvc::m_catalogue`[private]`

Definition at line 101 of file JobOptionsSvc.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiSvc/src/JobOptionsSvc/JobOptionsSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiSvc/src/JobOptionsSvc/JobOptionsSvc.cpp