All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GaudiMain.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // Description: Main Program for Gaudi applications
4 //
5 //------------------------------------------------------------------------------
6 #include "GaudiKernel/SmartIF.h"
7 #include "GaudiKernel/Bootstrap.h"
8 #include "GaudiKernel/IAppMgrUI.h"
9 #include "GaudiKernel/IProperty.h"
10 #include "GaudiKernel/Property.h"
11 #include "GaudiKernel/StatusCode.h"
12 #include <iostream>
13 
14 extern "C" GAUDI_API int GaudiMain(int argc,char **argv) {
16  SmartIF<IAppMgrUI> appMgr ( iface );
17  auto propMgr = appMgr.as<IProperty>();
18 
19  if( !appMgr || !propMgr ) {
20  std::cout << "Fatal error while creating the ApplicationMgr " << std::endl;
21  return 1;
22  }
23 
24  // Get the input configuration file from arguments
25  std:: string opts = (argc>1) ? argv[1] : "jobOptions.txt";
26 
27  propMgr->setProperty( "JobOptionsPath", opts ).ignore();
28 
29  if( opts.compare( opts.length() - 3, 3, ".py" ) == 0 ) {
30  propMgr->setProperty( "EvtSel", "NONE" ).ignore();
31  propMgr->setProperty( "JobOptionsType", "NONE" ).ignore();
32  propMgr->setProperty( "DLLs", "['GaudiPython']" ).ignore();
33  propMgr->setProperty( "Runable", "PythonScriptingSvc" ).ignore();
34  }
35 
36  // Run the application manager and process events
37  StatusCode sc = appMgr->run();
38  IntegerProperty returnCode("ReturnCode", 0);
39  propMgr->getProperty(&returnCode).ignore();
40  // Release Application Manager
41  propMgr.reset();
42  appMgr.reset();
43  // All done - exit
44  if (sc.isFailure() && returnCode.value() == 0) {
45  // propagate a valid error code in case of failure
46  returnCode.setValue(1);
47  }
48  return returnCode.value();
49 }
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
#define GAUDI_API
Definition: Kernel.h:107
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
Definition: Property.h:406
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
list argv
Definition: gaudirun.py:227
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:110
dictionary opts
Definition: ana.py:111
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
const TYPE & value() const
explicit conversion
Definition: Property.h:341
tuple appMgr
Definition: IOTest.py:83
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:88
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)