| The Gaudi Framework v32r1 (f65d50dc)

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 // Declare the command line options and read them in
18 options_description desc( "Allowed options" );
19 desc.add_options()( "help,h", "produce help message" )( "config", value<std::string>(),
20 "comma separated list of python configuration files" )(
21 "post-option", value<std::string>(), "python command to be run after ConfigurableUser has been applied" )(
22 "param", value<std::vector<std::string>>(), "parameters to the configuration file, multiple can be given" );
23 positional_options_description p;
24 p.add( "config", 1 );
25 variables_map vm;
26 try {
27 store( command_line_parser( argc, argv ).options( desc ).positional( p ).run(), vm );
28 } catch ( boost::exception_detail::clone_impl<
29 boost::exception_detail::error_info_injector<boost::program_options::unknown_option>>& ) {
30 std::cerr << "Unknown option(s) detected." << std::endl << "Usage:" << std::endl << desc << std::endl;
31 return ( 1 );
32 }
33 notify( vm );
34
35 std::string fileName;
36 // handle the retrieved options
37 if ( vm.count( "help" ) or vm.count( "h" ) ) {
38 std::cout << desc << std::endl;
39 return 1;
40 }
41 if ( !vm.count( "config" ) ) {
42 std::cout << "Please specify a config file" << std::endl;
43 return 1;
44 } else {
45 fileName = vm["config"].as<std::string>();
46 }
47
48 std::stringstream params;
49 if ( 0 != vm.count( "param" ) ) {
50 std::vector<std::string> vParams = vm["param"].as<std::vector<std::string>>();
51 std::cout << "Configuration parameters are:" << std::endl;
52 for ( std::string s : vParams ) {
53 params << s << "\n";
54 std::cout << "\t" << s << std::endl;
55 }
56 }
57
58 std::string postAction;
59 if ( 0 != vm.count( "post-option" ) ) { postAction = vm["post-option"].as<std::string>(); }
60 // end of options handling
61
62 IInterface* iface = Gaudi::createApplicationMgr();
63 SmartIF<IProperty> propMgr( iface );
64 SmartIF<IAppMgrUI> appUI( iface );
65 propMgr->setProperty( "JobOptionsType", "PYTHON" );
66 propMgr->setProperty( "JobOptionsPath", fileName );
67 propMgr->setProperty( "JobOptionsPreAction", params.str() );
68 propMgr->setProperty( "JobOptionsPostAction", postAction ); // TODO: grep this from command line
69 return appUI->run().getCode();
70 }
StatusCode::getCode
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:137
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
IAppMgrUI.h
gaudirun.argv
list argv
Definition: gaudirun.py:298
std::endl
T endl(T... args)
Bootstrap.h
std::stringstream
STL class.
std::string
STL class.
gaudirun.options
options
Definition: gaudirun.py:285
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:244
SmartIF.h
std::stringstream::str
T str(T... args)
plotBacklogPyRoot.argc
argc
Definition: plotBacklogPyRoot.py:142
IProperty.h
std::vector< std::string >
Property.h
gaudirun.s
string s
Definition: gaudirun.py:316
std::cerr
ISvcLocator.h
Gaudi::createApplicationMgr
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)