The Gaudi Framework  v30r3 (a5ef0a68)
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 {
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 
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 }
virtual StatusCode run()=0
Run the complete job (from initialize to terminate)
int main(int argc, char **argv)
list argv
Definition: gaudirun.py:235
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:277
string s
Definition: gaudirun.py:253
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:146
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)