| The Gaudi Framework v27r1

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

- File List
- File Members

concurrentRun.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include "GaudiKernel/Bootstrap.h"
4 #include "GaudiKernel/IAppMgrUI.h"
5 #include "GaudiKernel/IProperty.h"
6 #include "GaudiKernel/ISvcLocator.h"
7 #include "GaudiKernel/Property.h"
8 #include "GaudiKernel/SmartIF.h"
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()
21 ("help,h", "produce help message")
22 ("config", value<std::string>(), "comma separated list of python configuration files")
23 ("post-option", value<std::string>(), "python command to be run after ConfigurableUser has been applied")
24 ("param", value<std::vector<std::string>>(), "parameters to the configuration file, multiple can be given")
25 ;
26 positional_options_description p;
27 p.add("config", 1);
28 variables_map vm;
29 try{
30 store(command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
31 }
32 catch(boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >){
33 std::cerr << "Unknown option(s) detected." << std::endl
34 << "Usage:" << std::endl
35 << desc << std::endl;
36 return(1);
37 }
38 notify(vm);
39
40 std::string fileName;
41 // handle the retrieved options
42 if (vm.count("help") or vm.count("h")) {
43 std::cout << desc << std::endl;
44 return 1;
45 }
46 if (!vm.count("config")) {
47 std::cout << "Please specify a config file" << std::endl;
48 return 1;
49 } else {
50 fileName = vm["config"].as<std::string>();
51 }
52
53 std::stringstream params;
54 if (0 != vm.count("param")) {
55 std::vector<std::string> vParams = vm["param"].as<std::vector<std::string>>();
56 std::cout << "Configuration parameters are:" << std::endl;
57 for(std::string s : vParams){
58 params << s << "\n";
59 std::cout << "\t"<< s << std::endl;
60 }
61 }
62
63 std::string postAction;
64 if (0 != vm.count("post-option")) {
65 postAction = vm["post-option"].as<std::string>();
66 }
67 // end of options handling
68
69 IInterface* iface = Gaudi::createApplicationMgr();
70 SmartIF<IProperty> propMgr ( iface );
71 SmartIF<IAppMgrUI> appUI ( iface );
72 propMgr->setProperty("JobOptionsType","PYTHON");
73 propMgr->setProperty("JobOptionsPath",fileName);
74 propMgr->setProperty("JobOptionsPreAction", params.str());
75 propMgr->setProperty("JobOptionsPostAction", postAction); //TODO: grep this from command line
76 return appUI->run();
77 }
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:227
std::endl
T endl(T...args)
Bootstrap.h
std::stringstream
STL class.
std::string
STL class.
gaudirun.options
list options
Definition: gaudirun.py:396
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
IProperty::setProperty
virtual StatusCode setProperty(const Property &p)=0
Set the property by property.
SmartIF.h
std::stringstream::str
T str(T...args)
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
IProperty.h
std::vector< std::string >
Property.h
gaudirun.s
string s
Definition: gaudirun.py:245
program_options
plotBacklogPyRoot.argc
tuple argc
Definition: plotBacklogPyRoot.py:128
std::cerr
ISvcLocator.h
Gaudi::createApplicationMgr
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)