Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
IoComponentMgr Class Reference

#include <IoComponentMgr.h>

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

Public Member Functions

 IoComponentMgr (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
 
virtual ~IoComponentMgr ()
 Destructor:
 
virtual bool io_hasitem (IIoComponent *iocomponent) const
 : check if the registry contains a given IIoComponent
 
virtual bool io_contains (IIoComponent *iocomponent, const std::string &fname) const
 : check if the registry contains a given IIoComponent and that component had
 
virtual StatusCode io_register (IIoComponent *iocomponent)
 : allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g.
 
virtual StatusCode io_register (IIoComponent *iocomponent, IIoComponentMgr::IoMode::Type iomode, const std::string &fname)
 : allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g.
 
virtual StatusCode io_retrieve (IIoComponent *iocomponent, std::string &fname)
 : retrieve the new filename for a given IIoComponent and
 
virtual StatusCode io_reinitialize ()
 : reinitialize the I/O subsystem.
 
virtual StatusCode io_finalize ()
 : finalize the I/O subsystem.
 
virtual StatusCode initialize ()
 Gaudi Service Implementation.
 
virtual StatusCode finalize ()
 
- Public Member Functions inherited from extends1< Service, IIoComponentMgr >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends1 (A1 a1)
 Templated constructor with 1 argument.
 
 extends1 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends1 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces1< IIoComponentMgr >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from IIoComponentMgr
 DeclareInterfaceID (IIoComponentMgr, 1, 0)
 
virtual ~IIoComponentMgr ()
 Destructor:
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID.
 
virtual const std::stringname () const =0
 Retrieve the name of the instance.
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes).
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual ~IInterface ()
 Virtual destructor.
 

Private Types

typedef std::map< std::string,
IIoComponent * > 
IoRegistry_t
 
typedef std::list< IIoComponent * > IoStack_t
 

Private Member Functions

 IoComponentMgr ()
 Default constructor:
 

Private Attributes

MsgStream m_log
 
IoRegistry_t m_ioregistry
 Registry of IIoComponents.
 
IoStack_t m_iostack
 Stack of IIoComponents to properly handle order of registration.
 
PyObject * m_dict
 pointer to a python dictionary holding the associations: { 'iocomp-name' : { 'oldfname' : [ 'iomode', 'newfname' ] } }
 
std::string m_dict_location
 location of the python dictionary
 

Friends

class SvcFactory< IoComponentMgr >
 

Additional Inherited Members

- Public Types inherited from extends1< Service, IIoComponentMgr >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IIoComponentMgr
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

Definition at line 29 of file IoComponentMgr.h.

Member Typedef Documentation

Definition at line 127 of file IoComponentMgr.h.

Definition at line 131 of file IoComponentMgr.h.

Constructor & Destructor Documentation

IoComponentMgr::IoComponentMgr ( const std::string name,
ISvcLocator pSvcLocator 
)

Constructor with parameters:

Definition at line 29 of file IoComponentMgr.cpp.

m_dict ( 0 )
{
//
// Property declaration
//
//declareProperty( "Property", m_nProperty );
// declareProperty ("Registry",
// m_dict_location = "GaudiMP.IoRegistry.registry",
// "Location of the python dictionary holding the "
// "associations: \n"
// " {component-name:{ 'old-fname' : ['io','new-fname'] }}\n"
// "\nSyntax: <python-module>.<python-module>.<fct-name> \n"
// " where fct-name is a function returning the wanted "
// " dictionary.");
}
IoComponentMgr::~IoComponentMgr ( )
virtual

Destructor:

Definition at line 51 of file IoComponentMgr.cpp.

{
Py_XDECREF (m_dict);
}
IoComponentMgr::IoComponentMgr ( )
private

Default constructor:

Member Function Documentation

StatusCode IoComponentMgr::finalize ( )
virtual

Reimplemented from Service.

Definition at line 134 of file IoComponentMgr.cpp.

{
m_log << MSG::INFO << "Finalizing " << name() << "..." << endmsg;
if (m_log.level() <= MSG::DEBUG) {
m_log << MSG::DEBUG << "Listing all monitored entries: " << std::endl;
std::string repr = "";
// PyObject_Repr returns a new ref.
PyObject* py_repr = PyObject_Repr (m_dict);
if ( py_repr && PyString_Check(py_repr) ) {
repr = PyString_AsString(py_repr);
}
Py_XDECREF( py_repr );
m_log << MSG::DEBUG << "content: " << repr << endmsg;
}
}
StatusCode IoComponentMgr::initialize ( )
virtual

Gaudi Service Implementation.

Reimplemented from Service.

Definition at line 58 of file IoComponentMgr.cpp.

{
m_log << MSG::INFO << "Initializing " << name() << "..." << endmsg;
if ( Service::initialize().isFailure() ) {
m_log << MSG::ERROR << "Unable to initialize Service base class" << endmsg;
}
if ( ! Py_IsInitialized() ) {
if (m_log.level() <= MSG::DEBUG) {
m_log << MSG::DEBUG << "Initializing Python" << endmsg;
}
PyEval_InitThreads();
Py_Initialize();
if ( ! Py_IsInitialized() ) {
m_log << MSG::ERROR << "Unable to initialize Python" << endmsg;
}
}
// retrieve the python dictionary holding the I/O registry
const std::string py_module_name = "GaudiMP.IoRegistry";
m_log << MSG::DEBUG << "importing module [" << py_module_name << "]..."
<< endmsg;
PyObject *module = PyImport_ImportModule ((char*)py_module_name.c_str());
if ( !module || !PyModule_Check (module) ) {
m_log << MSG::ERROR << "Could not import [" << py_module_name << "] !"
<< endmsg;
Py_XDECREF (module);
}
const std::string py_class_name = "IoRegistry";
PyObject *pyclass = PyDict_GetItemString (PyModule_GetDict(module),
(char*)py_class_name.c_str());
// borrowed ref.
Py_XINCREF (pyclass);
if ( !pyclass ) {
m_log << MSG::ERROR << "Could not import ["
<< py_class_name << "] from module ["
<< py_module_name << "] !"
<< endmsg ;
Py_XDECREF (pyclass);
Py_DECREF (module);
}
m_dict = PyObject_GetAttrString (pyclass, (char*)"instances");
if ( !m_dict || !PyDict_Check (m_dict) ) {
<< "could not retrieve attribute [instances] from class ["
<< py_module_name << "." << py_class_name << "] !" << endmsg;
Py_DECREF (pyclass);
Py_DECREF (module);
}
m_log << MSG::INFO << "python I/O registry retrieved [ok]" << endmsg;
if ( m_log.level() <= MSG::DEBUG ) {
std::string repr = "";
// PyObject_Repr returns a new ref.
PyObject* py_repr = PyObject_Repr (m_dict);
if ( py_repr && PyString_Check(py_repr) ) {
repr = PyString_AsString(py_repr);
}
Py_XDECREF( py_repr );
m_log << MSG::DEBUG << "content: " << repr << endmsg;
}
}
bool IoComponentMgr::io_contains ( IIoComponent iocomponent,
const std::string fname 
) const
virtual

: check if the registry contains a given IIoComponent and that component had

Parameters
<tt>fname</tt>as a filename

Implements IIoComponentMgr.

Definition at line 176 of file IoComponentMgr.cpp.

{
if ( 0 == iocomponent ) {
return false;
}
const std::string& ioname = iocomponent->name();
// m_dict is a python dictionary like so:
// { 'iocomp-name' : { 'oldfname' : [ 'iomode', 'newfname' ] } }
// -> check there is an 'iocomp-name' entry
// -> retrieve that entry
PyObject *o = PyDict_GetItemString (m_dict, (char*)ioname.c_str());
Py_XINCREF (o);
// -> check it is a dictionary
if ( NULL==o || !PyDict_Check (o) ) {
Py_XDECREF (o);
return false;
}
// -> check 'oldfname' exists
PyObject *item = PyDict_GetItemString (o, (char*)fname.c_str());
const bool contains = (item != 0);
if ( contains == false ) {
std::string repr = "";
// PyObject_Repr returns a new ref.
PyObject* py_repr = PyObject_Repr (o);
if ( py_repr && PyString_Check(py_repr) ) {
repr = PyString_AsString(py_repr);
}
Py_XDECREF( py_repr );
m_log << MSG::ERROR << "content: " << repr << endmsg;
}
Py_DECREF (o);
Py_XDECREF(item);
return contains;
}
StatusCode IoComponentMgr::io_finalize ( )
virtual

: finalize the I/O subsystem.

Hook to allow to e.g. give a chance to I/O subsystems to merge output files. Not sure how to do this correctly though...

Implements IIoComponentMgr.

Definition at line 452 of file IoComponentMgr.cpp.

{
}
bool IoComponentMgr::io_hasitem ( IIoComponent iocomponent) const
virtual

: check if the registry contains a given IIoComponent

Implements IIoComponentMgr.

Definition at line 162 of file IoComponentMgr.cpp.

{
if ( 0 == iocomponent ) {
return false;
}
const std::string& ioname = iocomponent->name();
return io != m_ioregistry.end();
}
StatusCode IoComponentMgr::io_register ( IIoComponent iocomponent)
virtual

: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g.

a fork(2) has been issued (this is usually handled by calling IIoComponent::io_reinit on every registered component)

Implements IIoComponentMgr.

Definition at line 229 of file IoComponentMgr.cpp.

{
if ( 0 == iocomponent ) {
<< "io_register (component) received a NULL pointer !" << endmsg;
}
const std::string& ioname = iocomponent->name();
if ( itr == m_ioregistry.end() ) {
iocomponent->addRef(); // ownership...
m_ioregistry[ioname] = iocomponent;
m_iostack.push_back (iocomponent);
} else {
m_log << MSG::INFO << "IoComponent[" << iocomponent->name()
<<"] already registered @" << (void*)itr->second << endmsg;
}
}
StatusCode IoComponentMgr::io_register ( IIoComponent iocomponent,
IIoComponentMgr::IoMode::Type  iomode,
const std::string fname 
)
virtual

: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g.

a fork(2) has been issued (this is usually handled by calling IIoComponent::io_reinit on every registered component)

Implements IIoComponentMgr.

Definition at line 256 of file IoComponentMgr.cpp.

{
if ( 0 == iocomponent ) {
}
const std::string& ioname = iocomponent->name();
if ( !io_hasitem (iocomponent) ) {
if ( !io_register (iocomponent).isSuccess() ) {
<< "could not register component [" << iocomponent->name() << "] "
<< "with the I/O component manager !"
<< endmsg;
}
}
// m_dict is a python dictionary like so:
// { 'iocomp-name' : { 'oldfname' : [ 'iomode', 'newfname' ] } }
// -> check there is an 'iocomp-name' entry
// -> retrieve that entry
PyObject *o = PyDict_GetItemString (m_dict, (char*)ioname.c_str());
// -> check it is a dictionary
if ( NULL==o ) {
o = PyDict_New();
if (NULL == o) {
m_log << MSG::ERROR << "could not create an I/O entry for ["
<< ioname << "] "
<< "in the I/O registry !" << endmsg;
}
if ( 0 != PyDict_SetItemString (m_dict, (char*)ioname.c_str(), o) ) {
Py_DECREF (o);
m_log << MSG::ERROR << "could not create an I/O entry for ["
<< ioname << "] " << "in the I/O registry !" << endmsg;
}
} else if ( !PyDict_Check (o) ) {
<< "internal consistency error (expected a dictionary !)"
<< endmsg;
} else {
// borrowed ref.
Py_INCREF (o);
}
// -> check if 'fname' has already been registered
switch (iomode) {
case IIoComponentMgr::IoMode::Input: mode ="<input>"; break;
case IIoComponentMgr::IoMode::Output:mode ="<output>";break;
default:
m_log << MSG::ERROR << "unknown value for iomode: [" << iomode << "] !"
<< endmsg;
Py_DECREF (o);
}
PyObject *val = PyDict_GetItemString (o, (char*)fname.c_str());
if ( 0 != val ) {
Py_DECREF (o);
}
val = PyList_New(2);
if ( 0 == val ) {
m_log << MSG::ERROR << "could not allocate a python-list !" << endmsg;
Py_DECREF (o);
}
int err = PyList_SetItem (val,
0, PyString_FromString ((char*)mode.c_str()));
if (err) {
Py_DECREF (val);
Py_DECREF (o);
m_log << MSG::ERROR << "could not set py-iomode !" << endmsg;
}
Py_INCREF (Py_None);
// PyList_SetItem steals the ref...
err = PyList_SetItem (val, 1, Py_None);
if (err) {
Py_DECREF (val);
Py_DECREF (o);
m_log << MSG::ERROR << "could not properly fill python-list !" << endmsg;
}
err = PyDict_SetItemString (o, (char*)fname.c_str(), val);
if (err) {
m_log << MSG::ERROR << "could not properly fill registry w/ python-list !"
<< endmsg;
Py_DECREF (val);
Py_DECREF (o);
}
Py_DECREF (o);
}
StatusCode IoComponentMgr::io_reinitialize ( )
virtual

: reinitialize the I/O subsystem.

This effectively calls IIoComponent::io_reinit on all the registered IIoComponent.

Implements IIoComponentMgr.

Definition at line 419 of file IoComponentMgr.cpp.

{
m_log << MSG::DEBUG << "reinitializing I/O subsystem..." << endmsg;
bool allgood = true;
for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
io != ioEnd;
++io ) {
m_log << MSG::DEBUG << " [" << (*io)->name() << "]->io_reinit()..."
<< endmsg;
if ( !(*io)->io_reinit().isSuccess() ) {
allgood = false;
m_log << MSG::ERROR << "problem in [" << (*io)->name()
<< "]->io_reinit() !" << endmsg;
}
// we are done with this guy... release it
(*io)->release();
}
// we are done.
// FIXME: shall we allow for multiple io_reinitialize ?
return allgood
}
StatusCode IoComponentMgr::io_retrieve ( IIoComponent iocomponent,
std::string fname 
)
virtual

: retrieve the new filename for a given IIoComponent and

Parameters
<tt>fname</tt>filename
<tt>oldfname</tt>filename

Implements IIoComponentMgr.

Definition at line 365 of file IoComponentMgr.cpp.

{
if ( 0 == iocomponent ) {
}
const std::string& ioname = iocomponent->name();
// m_dict is a python dictionary like so:
// { 'iocomp-name' : { 'oldfname' : [ 'iomode', 'newfname' ] } }
// -> check there is an 'iocomp-name' entry
// -> retrieve that entry
PyObject *o = PyDict_GetItemString (m_dict, (char*)ioname.c_str());
Py_XINCREF (o);
// -> check it is a dictionary
if ( NULL==o || !PyDict_Check (o) ) {
Py_XDECREF (o);
}
// -> check 'oldfname' exists
PyObject *pylist = PyDict_GetItemString (o, (char*)fname.c_str());
Py_XINCREF (pylist);
if ( NULL==pylist || !PyList_Check (pylist) ) {
Py_XDECREF(pylist);
Py_DECREF (o);
}
const std::size_t sz = PyList_Size (pylist);
if ( 2 != sz ) {
m_log << MSG::ERROR << "[" << ioname << "][" << fname << "] list has size ["
<< sz << " ! (expected sz==2)"
<< endmsg;
Py_DECREF (o);
Py_DECREF (pylist);
}
fname = PyString_AsString ( PyList_GetItem (pylist, 1) );
Py_DECREF (o);
Py_DECREF (pylist);
}

Friends And Related Function Documentation

friend class SvcFactory< IoComponentMgr >
friend

Definition at line 31 of file IoComponentMgr.h.

Member Data Documentation

PyObject* IoComponentMgr::m_dict
private

pointer to a python dictionary holding the associations: { 'iocomp-name' : { 'oldfname' : [ 'iomode', 'newfname' ] } }

Definition at line 138 of file IoComponentMgr.h.

std::string IoComponentMgr::m_dict_location
private

location of the python dictionary

Definition at line 141 of file IoComponentMgr.h.

IoRegistry_t IoComponentMgr::m_ioregistry
private

Registry of IIoComponents.

Definition at line 129 of file IoComponentMgr.h.

IoStack_t IoComponentMgr::m_iostack
private

Stack of IIoComponents to properly handle order of registration.

Definition at line 133 of file IoComponentMgr.h.

MsgStream IoComponentMgr::m_log
mutableprivate

Definition at line 125 of file IoComponentMgr.h.


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

Generated at Wed Jan 30 2013 17:13:47 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004