The Gaudi Framework  v29r0 (ff2e7097)
concurrentRun.cpp File Reference
#include "GaudiKernel/Bootstrap.h"
#include "GaudiKernel/IAppMgrUI.h"
#include "GaudiKernel/IProperty.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/Property.h"
#include "GaudiKernel/SmartIF.h"
#include <iostream>
#include <string>
#include "boost/program_options.hpp"
Include dependency graph for concurrentRun.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file concurrentRun.cpp.

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();
73 }
list argv
Definition: gaudirun.py:235
T endl(T...args)
STL class.
Definition of the basic interface.
Definition: IInterface.h:277
string s
Definition: gaudirun.py:253
GAUDI_API IAppMgrUI * createApplicationMgr(const std::string &dllname, const std::string &factname)