| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# JobOptionsSvc Class Reference

`#include <JobOptionsSvc.h>`

Inheritance diagram for JobOptionsSvc:

[legend]
Collaboration diagram for JobOptionsSvc:

[legend]

List of all members.

## 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
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

## Detailed Description

Definition at line 22 of file JobOptionsSvc.h.

## Member Typedef Documentation

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

Definition at line 30 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   : base_class(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 266 of file JobOptionsSvc.cpp.

    00267 {
    00268   // dump needed? @attention JobOptionsSvc::finalize is never invoked!
    00269   if ( !m_dump.empty() && !m_dumped ) { dump() ;}
    00270 }

## 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 | ( |  | ) | `[virtual]`

Service finalization method.

Reimplemented from Service.

Definition at line 229 of file JobOptionsSvc.cpp.

    00230 {
    00231   // dump the properties catalogue if needed
    00232   if ( !m_dump.empty() && !m_dumped ) { dump() ;}
    00233    // finalize the base class
    00234   return Service::finalize() ;
    00235 }

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

IJobOptionsSvc::setMyProperties.

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         << endmsg;
    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

Definition at line 153 of file JobOptionsSvc.cpp.

    00155 {
    00156   Property* p = new StringProperty ( property.name(), "" ) ;
    00157   if ( !property.load( *p ) ) { delete p ; return StatusCode::FAILURE ; }
    00158   return m_catalogue.addProperty( client , p );
    00159 }

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

implementation of IJobOptionsSvc::removePropertyFromCatalogue

Definition at line 163 of file JobOptionsSvc.cpp.

    00165 {
    00166   return m_catalogue.removeProperty(client,name);
    00167 }

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

inmplementation of IJobOptionsSvc::getProperties

Definition at line 170 of file JobOptionsSvc.cpp.

    00171 {
    00172   return m_catalogue.getProperties(client);
    00173 }

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

inmplementation of IJobOptionsSvc::getClients

Definition at line 175 of file JobOptionsSvc.cpp.

    00176 {
    00177   return m_catalogue.getClients();
    00178 }

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

Definition at line 107 of file JobOptionsSvc.cpp.

    00109 {
    00110   // use the default non-empty path (if any) if no path specified
    00111   if ( path.empty() && !m_dirSearchPath.empty() )
    00112   { return readOptions ( file , m_dirSearchPath ) ; }
    00113   //
    00114   MsgStream my_log( this->msgSvc(), this->name() );
    00115   // --------------------------------------------------------------------------
    00116   std::vector<Gaudi::Parsers::Message> messages;
    00117   // --------------------------------------------------------------------------
    00118   // fillParserCatalogue();
    00119   // --------------------------------------------------------------------------
    00120   my_log << MSG::DEBUG                             // debug
    00121          << "Job-options read from the file "
    00122          << "'" << file << "'"
    00123          << MSG::INFO                              // switch
    00124          << std::endl ;
    00125   // create the parser & parse the file
    00126   Gaudi::Parsers::Parser parser (m_pcatalogue, m_included, path, my_log.stream() ) ;
    00127   StatusCode sc = Gaudi::Parsers::parse
    00128     ( parser , file , messages ) ;
    00129   my_log << endmsg ;
    00130
    00131   // --------------------------------------------------------------------------
    00132   if ( sc.isSuccess() )
    00133   {
    00134     my_log << MSG::INFO
    00135            << "Job options successfully read in from " << file << endmsg;
    00136     fillServiceCatalogue();
    00137   }
    00138   else
    00139   {
    00140     my_log << MSG::FATAL << "Job options errors."<< endmsg;
    00141   }
    00142   // ----------------------------------------------------------------------------
    00143   for ( std::vector<Gaudi::Parsers::Message>::const_iterator
    00144           cur=messages.begin(); cur!=messages.end();cur++)
    00145   {
    00146     my_log << convertSeverity(cur->severity()) << cur->message() << endmsg;
    00147   }
    00148   // ----------------------------------------------------------------------------
    00149   return sc;
    00150 }

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

IProperty implementation (needed for initialisation).

Reimplemented from Service.

Definition at line 54 of file JobOptionsSvc.cpp.

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

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

Reimplemented from Service.

Definition at line 59 of file JobOptionsSvc.cpp.

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

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

dump the content of Properties catalogue to std::ostream

Definition at line 263 of file JobOptionsSvc.cpp.

    00264 { return  o << m_pcatalogue ; }

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

dump the content of Properties catalogue to the file

Definition at line 246 of file JobOptionsSvc.cpp.

    00247 {
    00248   MsgStream log ( msgSvc() , name() ) ;
    00249   std::ofstream out
    00250     ( file.c_str() , std::ios_base::out | std::ios_base::trunc ) ;
    00251   // perform the actual dumping
    00252   if ( !out )
    00253   {
    00254     log << MSG::ERROR << "Unable to open dump-file \""+file+"\"" << endmsg ;
    00255     return ;                                                   // RETURN
    00256   }
    00257   else
    00258   { log << MSG::INFO << "Properties are dumped into \""+file+"\"" << endmsg ; }
    00259   // perform the actual dump:
    00260   fillStream ( out ) ;
    00261 }

void JobOptionsSvc::dump | ( |  | ) |

dump the content of Properties catalogue to the predefined file

< avoid double dump

Definition at line 237 of file JobOptionsSvc.cpp.

    00238 {
    00239   // avoid double dump
    00240   if ( m_dump.empty() || m_dumped ) { return ; }               // RETURN
    00241   dump ( m_dump ) ;
    00242   // avoid double dump
    00243   m_dumped = true ;
    00244 }

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

Fill parser catalogue before parse.

Definition at line 181 of file JobOptionsSvc.cpp.

    00181                                        {
    00182   std::vector<std::string> clients = getClients();
    00183   for(std::vector<std::string>::const_iterator client = clients.begin();
    00184     client != clients.end(); client++){
    00185        const PropertiesT* props = getProperties(*client);
    00186        for(PropertiesT::const_iterator prop = props->begin();
    00187         prop != props->end(); prop++){
    00188          m_pcatalogue.addProperty(*client,(*prop)->name(),
    00189            (*prop)->toString());
    00190         }
    00191    }
    00192 }

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

Fill service catalogue after parse.

Definition at line 195 of file JobOptionsSvc.cpp.

    00196 {
    00197   typedef Gaudi::Parsers::Catalogue::CatalogueT      _Catalogue ;
    00198   typedef std::vector<Gaudi::Parsers::PropertyEntry> _Entries   ;
    00199   _Catalogue catalogue = m_pcatalogue.catalogue();
    00200   for  ( _Catalogue::const_iterator curObj = catalogue.begin() ;
    00201          curObj!=catalogue.end(); ++curObj)
    00202   {
    00203     for ( _Entries::const_iterator curProp = curObj->second.begin() ;
    00204           curProp!=curObj->second.end(); ++curProp)
    00205     {
    00206       StringProperty tmp (curProp->name(), curProp->value() ) ;
    00207       addPropertyToCatalogue ( curObj->first , tmp ) ;
    00208     }
    00209   }
    00210 }

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

convert the severity

Definition at line 214 of file JobOptionsSvc.cpp.

    00215 {
    00216   switch ( severity )
    00217   {
    00218   case Gaudi::Parsers::Message::E_ERROR   :
    00219     return MSG::FATAL   ;
    00220   case Gaudi::Parsers::Message::E_WARNING :
    00221     return MSG::WARNING ;
    00222   case Gaudi::Parsers::Message::E_NOTICE  :
    00223     return MSG::INFO    ;
    00224   default:
    00225     return MSG::DEBUG   ;
    00226   }
    00227 }

## Member Data Documentation

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

Definition at line 87 of file JobOptionsSvc.h.

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

Definition at line 88 of file JobOptionsSvc.h.

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

Definition at line 89 of file JobOptionsSvc.h.

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

optional output file to dump all properties

Definition at line 91 of file JobOptionsSvc.h.

bool JobOptionsSvc::m_dumped`[private]`

Definition at line 92 of file JobOptionsSvc.h.

PropertyMgr JobOptionsSvc::m_pmgr`[private]`

Definition at line 93 of file JobOptionsSvc.h.

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

Definition at line 94 of file JobOptionsSvc.h.

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

Definition at line 95 of file JobOptionsSvc.h.

JobOptionsCatalogue JobOptionsSvc::m_catalogue`[private]`

Definition at line 96 of file JobOptionsSvc.h.

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

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