Gaudi Framework, version v23r8

Home   Generated: Fri May 31 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
PythonScriptingSvc Class Reference

This service handles scripting implemented using Python. More...

#include <GaudiPython/PythonScriptingSvc.h>

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

Public Member Functions

 PythonScriptingSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
 
virtual StatusCode initialize ()
 Initialize the service. [IService::initialize()].
 
virtual StatusCode finalize ()
 Finalize the service. [IService::finalize()].
 
virtual StatusCode run ()
 Run the service by taking full control. [IRunable::run()].
 
- Public Member Functions inherited from extends1< Service, IRunable >
 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< IRunable >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from IRunable
 DeclareInterfaceID (IRunable, 2, 0)
 InterfaceID.
 
- 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.
 

Protected Member Functions

virtual ~PythonScriptingSvc ()
 Destructor.
 

Private Attributes

std::string m_startupScript
 Startup script.
 

Additional Inherited Members

- Public Types inherited from extends1< Service, IRunable >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IRunable
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 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

This service handles scripting implemented using Python.

Author
Pere Mato
David Quarrie
Date
2001

Definition at line 16 of file PythonScriptingSvc.h.

Constructor & Destructor Documentation

PythonScriptingSvc::PythonScriptingSvc ( const std::string name,
ISvcLocator svc 
)

Standard Constructor.

Definition at line 26 of file PythonScriptingSvc.cpp.

: base_class(name, svc) {
// Declare the startup script Property
declareProperty( "StartupScript", m_startupScript = "" );
}
PythonScriptingSvc::~PythonScriptingSvc ( )
protectedvirtual

Destructor.

Definition at line 34 of file PythonScriptingSvc.cpp.

{ }

Member Function Documentation

StatusCode PythonScriptingSvc::finalize ( )
virtual

Finalize the service. [IService::finalize()].

Reimplemented from Service.

Definition at line 100 of file PythonScriptingSvc.cpp.

{
// Finalize this specific service
if ( sc.isFailure() ) {
return sc;
}
// Shutdown the Python interpreter
Py_Finalize();
}
StatusCode PythonScriptingSvc::initialize ( )
virtual

Initialize the service. [IService::initialize()].

Reimplemented from Service.

Definition at line 38 of file PythonScriptingSvc.cpp.

{
// initialize the Service Base class
if ( sc.isFailure() ) return sc;
// Setup startup script. If none is explicitly specified, then
// use the ApplicationMgr JobOptionsPath property as long as
// the JobOptionsType property is set to "NONE".
if( m_startupScript == "" ) {
if ( prpMgr.isValid() ) {
tmp.assign(prpMgr->getProperty("JobOptionsType"));
if ( tmp.value( ) == "NONE" ) {
tmp.assign(prpMgr->getProperty("JobOptionsPath"));
}
}
}
char* progName[] = { const_cast<char*>("GaudiPython") };
// Initialize the Python interpreter. Required.
Py_Initialize();
// Set argv for Tkinter (needs program name)
PySys_SetArgv( 1, progName );
// Get the Python version
std::string fullversion = Py_GetVersion();
std::string version( fullversion, 0, fullversion.find_first_of(' '));
std::string vers(version, 0, version.find_first_of('.',version.find_first_of('.')+1));
log << MSG::INFO << "Python version: [" << vers << "]" << endmsg;
#if defined(linux)
// This is hack to make global the python symbols
// which are needed by the other python modules
// (eg. readline, math, etc,) libraries.
std::string libname = "libpython" + vers + ".so";
dlopen(libname.c_str(), RTLD_GLOBAL | RTLD_LAZY);
#endif
// Startup commands
PyRun_SimpleString( "from gaudimodule import *" );
PyRun_SimpleString( "g = AppMgr()" );
// backward compatibility with SIPython
PyRun_SimpleString( "theApp = g" );
PyRun_SimpleString( "def Service(n): return g.service(n)" );
PyRun_SimpleString( "def Algorithm(n): return g.algorithm(n)" );
PyRun_SimpleString( "def Property(n): return g.service(n)" );
// For command-line completion (unix only)
#if !defined( _WIN32 )
PyRun_SimpleString( "import rlcompleter");
PyRun_SimpleString( "rlcompleter.readline.parse_and_bind('tab: complete')");
#endif
}
StatusCode PythonScriptingSvc::run ( )
virtual

Run the service by taking full control. [IRunable::run()].

Implements IRunable.

Definition at line 115 of file PythonScriptingSvc.cpp.

{
if ( m_startupScript != "" ) {
if( file ) {
char ch;
while( file.get(ch) ) stream.put(ch);
PyRun_SimpleString( const_cast<char*>(stream.str().c_str()) );
file.close();
}
else {
log << MSG::WARNING << "Python startup file " << m_startupScript << " not found" << endmsg;
}
}
PyRun_InteractiveLoop(stdin, "\0");
}

Member Data Documentation

std::string PythonScriptingSvc::m_startupScript
private

Startup script.

Definition at line 36 of file PythonScriptingSvc.h.


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

Generated at Fri May 31 2013 15:09:21 for Gaudi Framework, version v23r8 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004