All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiMain.cpp
Go to the documentation of this file.
1 // $Id: GaudiMain.cpp,v 1.4 2006/09/13 15:25:15 hmd Exp $
2 //------------------------------------------------------------------------------
3 //
4 // Description: Main Program for Gaudi applications
5 //
6 //------------------------------------------------------------------------------
7 #include "GaudiKernel/SmartIF.h"
10 #include "GaudiKernel/IProperty.h"
11 #include "GaudiKernel/Property.h"
12 #include "GaudiKernel/StatusCode.h"
13 #include <iostream>
14 
15 extern "C" GAUDI_API int GaudiMain(int argc,char **argv) {
17  SmartIF<IProperty> propMgr ( iface );
18  SmartIF<IAppMgrUI> appMgr ( iface );
19 
20  if( !appMgr.isValid() || !propMgr.isValid() ) {
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.substr( opts.length() - 3, 3 ) == ".py" ) {
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  IntegerProperty returnCode("ReturnCode", 0);
40  propMgr->getProperty(&returnCode).ignore();
41  // Release Application Manager
42  iface->release();
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 }
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
Definition: System.cpp:526
list argv
Definition: gaudirun.py:192
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
dictionary opts
Definition: ana.py:111
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
const TYPE & value() const
explicit conversion
Definition: Property.h:355
virtual bool setValue(const TYPE &value)
implementation of PropertyWithValue::setValue
Definition: Property.h:420
virtual unsigned long release()=0
Release Interface instance.
tuple appMgr
Definition: IOTest.py:83
GAUDI_API int GaudiMain(int argc, char **argv)
Definition: GaudiMain.cpp:15
#define GAUDI_API
Definition: Kernel.h:108
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)