| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes | List of all members
Gaudi.Application Class Reference

Gaudi application entry point. More...

`#include <Gaudi/Application.h>`

Inheritance diagram for Gaudi.Application:
[legend]
Collaboration diagram for Gaudi.Application:
[legend]

## Public Types
using | Options = std::map< std::string, std::string >
using | Factory = Gaudi::PluginService::Factory< Application(Options)>

## Public Member Functions
def | __init__ (self, opts, appType="Gaudi::Application")
def | create (cls, appType, opts)
def | run (self)
def | __del__ (self)
| Application (Options opts)
| Construct and configure the application from the provided options. More...
virtual | ~Application ()
virtual int | run ()
| Implement the application main logic: More...
int | run (std::function< int(SmartIF< IStateful > &)> action)
| Run a user provided implementation of the application main logic. More...

## Static Public Member Functions
static Factory::ReturnType | create (std::string_view type, Options opts)
| Factory function to instantiate a derived class via GaudiPluginService. More...

## Protected Attributes
SmartIF< IStateful > | app
| Handle to the ApplicationMgr instance. More...

## Private Attributes
| _impl

## Detailed Description

Gaudi application entry point.

Gaudi::Application can be used to bootstrap a standard Gaudi application or to implement custom applications, either via a specialization that overrides the method run (which can be instantiated either directly or via the GaudiPluginService, with the helper `create`) or by passing a callable object to the dedicated `run` method.

Definition at line 62 of file __init__.py.

## Member Typedef Documentation

## ◆ Factory

using Gaudi.Application::Factory = Gaudi::PluginService::Factory<Application( Options )>

Definition at line 20 of file Application.h.

## ◆ Options

using Gaudi.Application::Options = std::map<std::string, std::string>

Definition at line 19 of file Application.h.

## Constructor & Destructor Documentation

## ◆ __init__()

def Gaudi.Application.__init__ | ( |  | self,
|  |  | opts,
|  |  | appType = `"Gaudi::Application"`
| ) |  |

Definition at line 63 of file __init__.py.

63 def __init__(self, opts, appType="Gaudi::Application"):
64 global _GaudiKernelLib
65 if _GaudiKernelLib is None:
66 # FIXME: note that we need PyDLL instead of CDLL if the calls to
67 # Python functions are not protected with the GIL.
68 gkl = _GaudiKernelLib = ctypes.PyDLL(
69 'libGaudiKernel.so', mode=ctypes.RTLD_GLOBAL)
70 gkl._py_Gaudi__Application__create.restype = ctypes.c_void_p
71 gkl._py_Gaudi__Application__run.argtypes = [ctypes.c_void_p]
72 gkl._py_Gaudi__Application__run.restype = ctypes.c_int
73 gkl._py_Gaudi__Application__delete.argtypes = [ctypes.c_void_p]
74
75 c_opts = (c_opt_t * len(opts))()
76 for idx, item in enumerate(opts.items()):
77 c_opts[idx].key, c_opts[idx].value = item
78
79 self._impl = _GaudiKernelLib._py_Gaudi__Application__create(
80 appType, c_opts, ctypes.c_long(len(c_opts)))
81

## ◆ __del__()

def Gaudi.Application.__del__ | ( |  | self | ) |

Definition at line 89 of file __init__.py.

89 def __del__(self):
90 _GaudiKernelLib._py_Gaudi__Application__delete(self._impl)

## ◆ Application()

Gaudi.Application::Application | ( | Options | opts | ) |

Construct and configure the application from the provided options.

Definition at line 41 of file Application.cpp.

41 {
42 // # Prepare the application
43 // - instantiate
44 app = Gaudi::createApplicationMgr();
45 GAUDI_ASSERT_THROW_NAME( app, "failure instantiating ApplicationMgr", "Gaudi::Application" );
46
47 // - main configuration
48 consumeOptions( app.as<IProperty>(), options );
49 // - start minimal services
50 GAUDI_ASSERT_THROW_NAME( app->configure(), "failure creating basic services", "Gaudi::Application" );
51
52 consumeOptions( SmartIF<IMessageSvc>{app}.as<IProperty>(), options );
53
54 // - prepare job configuration
55 {
56 auto sloc = app.as<ISvcLocator>();
57 auto jos = sloc->service<IJobOptionsSvc>( "JobOptionsSvc" );
58 std::for_each( begin( options ), end( options ), [&jos]( const auto& item ) {
59 std::string_view name = item.first;
60 const auto sep_pos = name.find_last_of( '.' );
61 std::string_view client = name.substr( 0, sep_pos );
62 name.remove_prefix( sep_pos + 1 );
63 jos->addPropertyToCatalogue( std::string{client}, Gaudi::Property<std::string>{std::string{name}, item.second} );
64 } );
65 }
66 }
SmartIF< IMessageSvc >
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
GAUDI_ASSERT_THROW_NAME
#define GAUDI_ASSERT_THROW_NAME(cond, msg, name)
Definition: Application.cpp:14
SmartIF::as
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:107
std::string
STL class.
gaudirun.options
options
Definition: gaudirun.py:285
Gaudi.Application::app
SmartIF< IStateful > app
Handle to the ApplicationMgr instance.
Definition: Application.h:40
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
IJobOptionsSvc
Main interface for the JobOptions service.
Definition: IJobOptionsSvc.h:20
IOTest.end
def end
Definition: IOTest.py:112
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20
std::for_each
T for_each(T... args)
IStateful::configure
virtual StatusCode configure()=0
Configuration (from OFFLINE to CONFIGURED).
Gaudi::createApplicationMgr
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)

## ◆ ~Application()

Gaudi.Application::~Application | ( |  | ) |
| virtual

Definition at line 68 of file Application.cpp.

68 { app->terminate().ignore(); }
IStateful::terminate
virtual StatusCode terminate()=0
Initialization (from CONFIGURED to OFFLINE).
Gaudi.Application::app
SmartIF< IStateful > app
Handle to the ApplicationMgr instance.
Definition: Application.h:40
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153

## Member Function Documentation

## ◆ create() [1/2]

Gaudi::Application::Factory::ReturnType Gaudi.Application::create | ( | std::string_view | type,
|  | Options | opts
| ) |  |
| static

Factory function to instantiate a derived class via GaudiPluginService.

Definition at line 36 of file Application.cpp.

36 {
37 if ( type == "Gaudi::Application" ) { return std::make_unique<Application>( std::move( opts ) ); }
38 return Factory::create( type, std::move( opts ) );
39 }
gaudirun.opts
opts
Definition: gaudirun.py:307
gaudirun.type
type
Definition: gaudirun.py:142
std::move
T move(T... args)

## ◆ create() [2/2]

def Gaudi.Application.create | ( |  | cls,
|  |  | appType,
|  |  | opts
| ) |  |

Definition at line 83 of file __init__.py.

83 def create(cls, appType, opts):
84 return cls(opts, appType=appType)
85
Gaudi.CommonGaudiConfigurables.cls
cls
Definition: CommonGaudiConfigurables.py:25

## ◆ run() [1/3]

int Gaudi.Application::run | ( |  | ) |
| virtual

Implement the application main logic:

- prepare for processing (initialize + start)
- loop over events
- terminate (stop + finalize)

Definition at line 70 of file Application.cpp.

70 {
71 auto prop = app.as<IProperty>();
72 auto processor = app.as<IEventProcessor>();
73
74 Gaudi::Property<int> evtMax;
75 evtMax.assign( prop->getProperty( "EvtMax" ) );
76
77 // - get ready to process events
78 if ( app->initialize() ) {
79 if ( app->start() ) {
80 // - main processing loop
81 if ( !processor->executeRun( evtMax ) ) setAppReturnCode( prop, Gaudi::ReturnCode::GenericFailure );
82
83 app->stop().ignore();
84 } else
85 setAppReturnCode( prop, Gaudi::ReturnCode::GenericFailure );
86 app->finalize().ignore();
87 } else
88 setAppReturnCode( prop, Gaudi::ReturnCode::GenericFailure );
89 return getAppReturnCode( prop );
90 }
Gaudi::getAppReturnCode
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.
Definition: AppReturnCode.h:69
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
SmartIF::as
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:107
Gaudi::ReturnCode::GenericFailure
constexpr int GenericFailure
Definition: AppReturnCode.h:18
IStateful::start
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
Gaudi.Application::app
SmartIF< IStateful > app
Handle to the ApplicationMgr instance.
Definition: Application.h:40
IStateful::stop
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
IStateful::initialize
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
Gaudi::setAppReturnCode
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:49
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
IStateful::finalize
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
IEventProcessor
The IEventProcessor is the interface to process events.
Definition: IEventProcessor.h:14
AtlasMCRecoFullPrecedenceDump.evtMax
int evtMax
Definition: AtlasMCRecoFullPrecedenceDump.py:13
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20

## ◆ run() [2/3]

int Gaudi.Application.run | ( | std::function< int(SmartIF< IStateful > &)> | action | ) |
| inline

Run a user provided implementation of the application main logic.

Definition at line 36 of file Application.h.

36 { return action( app ); }
Gaudi.Application::app
SmartIF< IStateful > app
Handle to the ApplicationMgr instance.
Definition: Application.h:40
gaudirun.action
action
Definition: gaudirun.py:136

## ◆ run() [3/3]

def Gaudi.Application.run | ( |  | self | ) |

Definition at line 86 of file __init__.py.

86 def run(self):
87 return _GaudiKernelLib._py_Gaudi__Application__run(self._impl)
88

## Member Data Documentation

## ◆ _impl

Gaudi.Application._impl
| private

Definition at line 79 of file __init__.py.

## ◆ app

SmartIF<IStateful> Gaudi.Application::app
| protected

Handle to the ApplicationMgr instance.

Definition at line 40 of file Application.h.

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

- Gaudi/python/Gaudi/__init__.py
- GaudiKernel/Gaudi/Application.h
- GaudiKernel/src/Lib/Application.cpp