| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

GaudiMain.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // Description: Main Program for Gaudi applications
4 //
5 //------------------------------------------------------------------------------
6 #include "GaudiKernel/Bootstrap.h"
7 #include "GaudiKernel/IAppMgrUI.h"
8 #include "GaudiKernel/IProperty.h"
9 #include "GaudiKernel/Property.h"
10 #include "GaudiKernel/SmartIF.h"
11 #include "GaudiKernel/StatusCode.h"
12 #include <iostream>
13
14 extern "C" GAUDI_API int GaudiMain( int argc, char** argv )
15 {
16 IInterface* iface = Gaudi::createApplicationMgr();
17 SmartIF<IAppMgrUI> appMgr( iface );
18 auto propMgr = appMgr.as<IProperty>();
19
20 if ( !appMgr || !propMgr ) {
21 std::cout << "Fatal error while creating the ApplicationMgr " << std::endl;
22 return 1;
23 }
24
25 // Get the input configuration file from arguments
26 std::string opts = ( argc > 1 ) ? argv[1] : "jobOptions.txt";
27
28 propMgr->setProperty( "JobOptionsPath", opts ).ignore();
29
30 if ( opts.compare( opts.length() - 3, 3, ".py" ) == 0 ) {
31 propMgr->setProperty( "EvtSel", "NONE" ).ignore();
32 propMgr->setProperty( "JobOptionsType", "NONE" ).ignore();
33 propMgr->setProperty( "DLLs", "['GaudiPython']" ).ignore();
34 propMgr->setProperty( "Runable", "PythonScriptingSvc" ).ignore();
35 }
36
37 // Run the application manager and process events
38 StatusCode sc = appMgr->run();
39 Gaudi::Property<int> returnCode( "ReturnCode", 0 );
40 propMgr->getProperty( &returnCode ).ignore();
41 // Release Application Manager
42 propMgr.reset();
43 appMgr.reset();
44 // All done - exit
45 if ( sc.isFailure() && returnCode == 0 ) {
46 // propagate a valid error code in case of failure
47 returnCode.setValue( 1 );
48 }
49 return returnCode.value();
50 }
SmartIF< IAppMgrUI >
IAppMgrUI::run
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
Gaudi::Property::setValue
bool setValue(const ValueType &v)
Definition: Property.h:481
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
IAppMgrUI.h
gaudirun.argv
list argv
Definition: gaudirun.py:235
std::endl
T endl(T...args)
Bootstrap.h
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
gaudirun.opts
opts
Definition: gaudirun.py:244
std::string
STL class.
SmartIF::as
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:115
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
SmartIF.h
plotBacklogPyRoot.argc
argc
Definition: plotBacklogPyRoot.py:138
std::string::length
T length(T...args)
IProperty.h
Property.h
IOTest.appMgr
appMgr
Definition: IOTest.py:94
GaudiMain
GAUDI_API int GaudiMain(int argc, char **argv)
Definition: GaudiMain.cpp:14
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:479
StatusCode.h
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
std::cout
std::string::compare
T compare(T...args)
Gaudi::createApplicationMgr
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)