| The Gaudi Framework v30r0 (c919700c)

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

- File List
- File Members

concurrentRun.cpp
Go to the documentation of this file.
1 #include "GaudiKernel/Bootstrap.h"
2 #include "GaudiKernel/IAppMgrUI.h"
3 #include "GaudiKernel/IProperty.h"
4 #include "GaudiKernel/ISvcLocator.h"
5 #include "GaudiKernel/Property.h"
6 #include "GaudiKernel/SmartIF.h"
7 #include <iostream>
8 #include <string>
9
10 // boost includes
11 #include "boost/program_options.hpp"
12
13 using namespace boost::program_options;
14
15 //-----------------------------------------------------------------------------
16 int main( int argc, char** argv )
17 {
18 // Declare the command line options and read them in
19 options_description desc( "Allowed options" );
20 desc.add_options()( "help,h", "produce help message" )( "config", value<std::string>(),
21 "comma separated list of python configuration files" )(
22 "post-option", value<std::string>(), "python command to be run after ConfigurableUser has been applied" )(
23 "param", value<std::vector<std::string>>(), "parameters to the configuration file, multiple can be given" );
24 positional_options_description p;
25 p.add( "config", 1 );
26 variables_map vm;
27 try {
28 store( command_line_parser( argc, argv ).options( desc ).positional( p ).run(), vm );
29 } catch ( boost::exception_detail::clone_impl<
30 boost::exception_detail::error_info_injector<boost::program_options::unknown_option>> ) {
31 std::cerr << "Unknown option(s) detected." << std::endl << "Usage:" << std::endl << desc << std::endl;
32 return ( 1 );
33 }
34 notify( vm );
35
36 std::string fileName;
37 // handle the retrieved options
38 if ( vm.count( "help" ) or vm.count( "h" ) ) {
39 std::cout << desc << std::endl;
40 return 1;
41 }
42 if ( !vm.count( "config" ) ) {
43 std::cout << "Please specify a config file" << std::endl;
44 return 1;
45 } else {
46 fileName = vm["config"].as<std::string>();
47 }
48
49 std::stringstream params;
50 if ( 0 != vm.count( "param" ) ) {
51 std::vector<std::string> vParams = vm["param"].as<std::vector<std::string>>();
52 std::cout << "Configuration parameters are:" << std::endl;
53 for ( std::string s : vParams ) {
54 params << s << "\n";
55 std::cout << "\t" << s << std::endl;
56 }
57 }
58
59 std::string postAction;
60 if ( 0 != vm.count( "post-option" ) ) {
61 postAction = vm["post-option"].as<std::string>();
62 }
63 // end of options handling
64
65 IInterface* iface = Gaudi::createApplicationMgr();
66 SmartIF<IProperty> propMgr( iface );
67 SmartIF<IAppMgrUI> appUI( iface );
68 propMgr->setProperty( "JobOptionsType", "PYTHON" );
69 propMgr->setProperty( "JobOptionsPath", fileName );
70 propMgr->setProperty( "JobOptionsPreAction", params.str() );
71 propMgr->setProperty( "JobOptionsPostAction", postAction ); // TODO: grep this from command line
72 return appUI->run().getCode();
73 }
SmartIF< IProperty >
IAppMgrUI::run
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
main
int main(int argc, char **argv)
Definition: concurrentRun.cpp:16
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:69
IAppMgrUI.h
gaudirun.argv
list argv
Definition: gaudirun.py:235
std::endl
T endl(T...args)
Bootstrap.h
std::stringstream
STL class.
std::string
STL class.
gaudirun.options
options
Definition: gaudirun.py:223
IProperty::setProperty
virtual StatusCode setProperty(const Gaudi::Details::PropertyBase &p)=0
Set the property by property.
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
SmartIF.h
plotBacklogPyRoot.argc
argc
Definition: plotBacklogPyRoot.py:138
IProperty.h
std::vector< std::string >
Property.h
gaudirun.s
string s
Definition: gaudirun.py:253
program_options
std::cerr
ISvcLocator.h
Gaudi::createApplicationMgr
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)