The Gaudi Framework  v30r3 (a5ef0a68)
GaudiMain.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // Description: Main Program for Gaudi applications
4 //
5 //------------------------------------------------------------------------------
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 {
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 }
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
bool setValue(const ValueType &v)
Definition: Property.h:542
Implementation of property with value of concrete type.
Definition: Property.h:381
list argv
Definition: gaudirun.py:235
T endl(T...args)
bool isFailure() const
Definition: StatusCode.h:139
STL class.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:115
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Definition of the basic interface.
Definition: IInterface.h:277
T length(T...args)
appMgr
Definition: IOTest.py:94
GAUDI_API int GaudiMain(int argc, char **argv)
Definition: GaudiMain.cpp:14
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:540
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
#define GAUDI_API
Definition: Kernel.h:104
T compare(T...args)
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)