Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
concurrentRun.cpp
Go to the documentation of this file.
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 
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 }
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
int main(int argc, char **argv)
list argv
Definition: gaudirun.py:294
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:244
string s
Definition: gaudirun.py:312
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:137
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)