Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Types | Public Member Functions | Private Member Functions | Private Attributes

JobOptionsSvc Class Reference

#include <JobOptionsSvc.h>

Inheritance diagram for JobOptionsSvc:
Inheritance graph
[legend]
Collaboration diagram for JobOptionsSvc:
Collaboration graph
[legend]

List of all members.

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::stringgetClients () 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

Detailed Description

Definition at line 21 of file JobOptionsSvc.h.


Member Typedef Documentation

Definition at line 23 of file JobOptionsSvc.h.


Constructor & Destructor Documentation

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]

destructor

Definition at line 31 of file JobOptionsSvc.h.

{};

Member Function Documentation

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

Parameters:
filefile name
pathsearch path
Returns:
status code

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.

Parameters:
clientName of the client algorithm or service
meAddress 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 );
}

Member Data Documentation

Definition at line 79 of file JobOptionsSvc.h.

Definition at line 80 of file JobOptionsSvc.h.

bool JobOptionsSvc::m_dumped [private]

Definition at line 82 of file JobOptionsSvc.h.

dump the content of Properties catalog to the predefined file

Definition at line 76 of file JobOptionsSvc.h.

Definition at line 77 of file JobOptionsSvc.h.

Definition at line 78 of file JobOptionsSvc.h.

Definition at line 81 of file JobOptionsSvc.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:18 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004