AmpGen
2.1
Toggle main menu visibility
Loading...
Searching...
No Matches
OptionsParser.h
Go to the documentation of this file.
1
#ifndef AMPGEN_OPTIONSPARSER_H
2
#define AMPGEN_OPTIONSPARSER_H
3
4
#include <iostream>
5
#include <vector>
6
#include <map>
7
#include <string>
8
#include <utility>
9
#include <functional>
10
#include "
AmpGen/MsgService.h
"
11
#include "
AmpGen/MetaUtils.h
"
12
13
namespace
AmpGen
{
14
15
class
ConfigurableBase
;
16
17
class
OptionsParser {
18
public
:
19
typedef
std::map<std::string, std::vector<std::string>>
::const_iterator
const_iterator
;
20
typedef
std::map<std::string, std::vector<std::string>>
::iterator
iterator
;
21
22
static
OptionsParser *
getMe
();
23
static
bool
printHelp
();
24
static
void
setArgs
(
int
argc,
char
**argv,
const
std::string &description =
""
);
25
static
void
setArg
(
const
std::string &arg);
26
void
setQuiet
();
27
void
addArg
(
const
std::string &arg);
28
void
setCommandLineArgs
(
int
argc,
char
**argv,
const
std::string &description =
""
);
29
void
import
(
const
std::string &fName);
30
iterator
find
(
const
std::string &name);
31
iterator
begin
();
32
iterator
end
();
33
const_iterator
begin
()
const
;
34
const_iterator
end
()
const
;
35
std::vector<std::vector<std::string>>
getInputOrdered
()
const
;
36
37
const
std::vector<const ConfigurableBase *> &
configurables
()
const
{
return
m_configurables; }
38
template
<
typename
T> T *
registerClass
(T *
object
) {
39
DEBUG
(
"Registering -> "
<<
type_string<T>
());
40
addToConfigurables
(
object
);
41
return
object;
42
}
43
void
print
()
const
;
44
void
addToConfigurables
(
const
ConfigurableBase
*);
45
46
private
:
47
std::vector<std::string> m_orderedKeys;
48
std::map<std::string, std::vector<std::string>> m_parsedLines;
49
std::map<std::string, std::function<void(std::vector<std::string>)>> m_keywords;
50
std::vector<const ConfigurableBase *> m_configurables;
51
52
bool
m_printHelp = {
false
};
53
bool
m_quiet = {
false
};
54
static
OptionsParser *gOptionsParser;
55
56
OptionsParser();
57
bool
ignoreThisLine(
const
std::string &line);
58
void
readStream(std::istream &
is
);
59
std::vector<std::string> makeParsedStrings(
const
std::string &line,
int
&braceDepth)
const
;
60
void
addArg
(
const
std::vector<std::string> &tokens);
61
};
62
}
// namespace AmpGen
63
64
#define REGISTER_CONFIGURABLE(CLASS_NAME) template <> CLASS_NAME *Configurable<CLASS_NAME>::gImpl = OptionsParser::getMe()->registerClass(new CLASS_NAME())
65
66
#endif
MetaUtils.h
MsgService.h
AmpGen::ConfigurableBase
Definition
ConfigurableBase.h:8
AmpGen::OptionsParser::getMe
static OptionsParser * getMe()
AmpGen::OptionsParser::iterator
std::map< std::string, std::vector< std::string > >::iterator iterator
Definition
OptionsParser.h:20
AmpGen::OptionsParser::setQuiet
void setQuiet()
AmpGen::OptionsParser::print
void print() const
AmpGen::OptionsParser::find
iterator find(const std::string &name)
AmpGen::OptionsParser::getInputOrdered
std::vector< std::vector< std::string > > getInputOrdered() const
AmpGen::OptionsParser::const_iterator
std::map< std::string, std::vector< std::string > >::const_iterator const_iterator
Definition
OptionsParser.h:19
AmpGen::OptionsParser::printHelp
static bool printHelp()
AmpGen::OptionsParser::end
const_iterator end() const
AmpGen::OptionsParser::begin
const_iterator begin() const
AmpGen::OptionsParser::registerClass
T * registerClass(T *object)
Definition
OptionsParser.h:38
AmpGen::OptionsParser::setArg
static void setArg(const std::string &arg)
AmpGen::OptionsParser::configurables
const std::vector< const ConfigurableBase * > & configurables() const
Definition
OptionsParser.h:37
AmpGen::OptionsParser::setArgs
static void setArgs(int argc, char **argv, const std::string &description="")
AmpGen::OptionsParser::addArg
void addArg(const std::string &arg)
AmpGen::OptionsParser::begin
iterator begin()
AmpGen::OptionsParser::end
iterator end()
AmpGen::OptionsParser::addToConfigurables
void addToConfigurables(const ConfigurableBase *)
AmpGen::OptionsParser::setCommandLineArgs
void setCommandLineArgs(int argc, char **argv, const std::string &description="")
DEBUG
#define DEBUG(X)
Used for printing verbose debugging messages, only if DEBUGLEVEL is defined.
Definition
MsgService.h:69
AmpGen
Definition
AddCPConjugate.h:2
AmpGen::is
bool is(const Expression &expression)
Definition
Expression.h:485
AmpGen::type_string
std::string type_string()
Utility classes for compile-time metaprogramming, such as identifying the types of arguments for gene...
Definition
MetaUtils.h:17
AmpGen
OptionsParser.h
Generated on
for AmpGen by
1.17.0