The Gaudi Framework
v32r2 (46d42edc)
GaudiMain.cpp
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
//
3
// Description: Main Program for Gaudi applications
4
//
5
//------------------------------------------------------------------------------
6
#include <
Gaudi/Application.h
>
7
#include <gsl/span>
8
#include <iostream>
9
#include <string_view>
10
11
extern
"C"
GAUDI_API
int
GaudiMain
(
int
argc
,
char
**
argv
) {
12
Gaudi::Application::Options
opts
;
13
14
std::string_view appType{
"Gaudi::Application"
};
15
std::string_view optsFile;
16
17
gsl::span
args
{
argv
,
argc
};
18
19
auto
usage
= [
name
=
args
[0]](
std::ostream
& out ) ->
std::ostream
& {
20
return
out <<
"usage: "
<<
name
<<
" [options] option_file\n"
;
21
};
22
23
auto
arg =
args
.begin();
24
++arg;
// ignore application name
25
while
( arg !=
args
.end() ) {
26
std::string_view opt{*arg};
27
if
( opt ==
"--application"
)
28
appType = *++arg;
29
else
if
( opt ==
"-h"
|| opt ==
"--help"
) {
30
usage
(
std::cout
);
31
std::cout
<< R
"(
32
Options:
33
-h, --help show this help message and exit
34
--application APPLICATION
35
name of the application class to use [default: Gaudi::Application]
36
)";
37
return
EXIT_SUCCESS;
38
}
else
if
( opt[0] ==
'-'
) {
39
std::cerr
<<
"error: unknown option "
<< opt <<
'\n'
;
40
usage
(
std::cerr
);
41
return
EXIT_FAILURE;
42
}
else
{
43
optsFile = *arg++;
44
break
;
// we stop after the first positional argument
45
}
46
++arg;
47
}
48
if
( arg !=
args
.end() ) {
std::cerr
<<
"warning: ignoring extra positional arguments\n"
; }
49
if
( optsFile.empty() ) {
50
std::cerr
<<
"error: missing option file argument\n"
;
51
usage
(
std::cerr
);
52
return
EXIT_FAILURE;
53
}
54
55
if
( optsFile.size() > 3 && optsFile.substr( optsFile.size() - 3 ) ==
".py"
) {
56
opts
[
"ApplicationMgr.EvtSel"
] =
"NONE"
;
57
opts
[
"ApplicationMgr.JobOptionsType"
] =
"NONE"
;
58
opts
[
"ApplicationMgr.DLLs"
] =
"['GaudiPython']"
;
59
opts
[
"ApplicationMgr.Runable"
] =
"PythonScriptingSvc"
;
60
}
else
{
61
opts
[
"ApplicationMgr.JobOptionsPath"
] = optsFile;
62
}
63
64
auto
app =
Gaudi::Application::create
( appType,
std::move
(
opts
) );
65
if
( !app ) {
66
std::cerr
<<
"error: failure creating "
<< appType <<
'\n'
;
67
return
EXIT_FAILURE;
68
}
69
70
return
app->run();
71
}
gaudiComponentHelp.name
name
Definition:
gaudiComponentHelp.py:42
gaudirun.argv
list argv
Definition:
gaudirun.py:300
usage
void usage(std::string argv0)
Definition:
listcomponents.cpp:41
gaudirun.opts
opts
Definition:
gaudirun.py:309
gaudirun.args
args
Definition:
gaudirun.py:309
Gaudi.Application.create
def create(cls, appType, opts)
Definition:
__init__.py:86
std::move
T move(T... args)
plotBacklogPyRoot.argc
argc
Definition:
plotBacklogPyRoot.py:143
GaudiMain
GAUDI_API int GaudiMain(int argc, char **argv)
Definition:
GaudiMain.cpp:11
GAUDI_API
#define GAUDI_API
Definition:
Kernel.h:71
std::ostream
STL class.
Application.h
Gaudi.Application::Options
std::map< std::string, std::string > Options
Definition:
Application.h:19
GaudiKernel
src
Lib
GaudiMain.cpp
Generated on Sat Sep 28 2019 18:06:51 for The Gaudi Framework by
1.8.15