All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
concurrentRun.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
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 
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 }
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
int main(int argc, char **argv)
list argv
Definition: gaudirun.py:227
T endl(T...args)
STL class.
virtual StatusCode setProperty(const Gaudi::Details::PropertyBase &p)=0
Set the property by property.
Definition of the basic interface.
Definition: IInterface.h:234
string s
Definition: gaudirun.py:245
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)