DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
wibmod
src
WIB1
conversions.cpp
Go to the documentation of this file.
1
2
// Implementations of Item value conversions
3
//
4
// note that these are classes declared in a source file;
5
// ItemConversion::FromString is the one and only interface
6
// for creating conversions
7
8
#include "
wibmod/WIB1/ItemConversion.hh
"
9
10
#include <boost/foreach.hpp>
11
#include <stdio.h>
// sscanf
12
13
using
boost::unordered_map;
14
15
namespace
itemconv
{
16
17
#define ARGS(...) __VA_ARGS__
18
#define EXPAND(x) x
19
#define STRIP(x) EXPAND(ARGS x)
20
#define DEFINE_CONVERSION_CLASS(name, body) \
21
class itemconv_##name : public ItemConversion \
22
{ \
23
STRIP(body) \
24
};
25
/*#define DEFINE_CONVERSION_CLASS_END \
26
public: \
27
itemconv_##name (unordered_map<std::string, std::string> params) { \
28
init(params); \
29
} \
30
};*/
31
#include "
wibmod/WIB1/conversions-impl.hh
"
32
#undef DEFINE_CONVERSION_CLASS
33
#undef STRIP
34
#undef EXPAND
35
#undef STRIP
36
37
}
38
39
ItemConversion
*
40
ItemConversion::FromString
(std::string convstring)
41
{
42
unordered_map<std::string, std::string> params;
43
int
i = 0;
44
while
(i < (
int
)convstring.size() && convstring[i] !=
' '
)
45
i++;
46
std::string fnname = std::string(convstring.c_str(), i);
47
while
(i < (
int
)convstring.size()) {
48
while
(i < (
int
)convstring.size() && convstring[i] ==
' '
)
49
i++;
50
int
pair_start = i;
51
while
(i < (
int
)convstring.size() && convstring[i] !=
' '
)
52
i++;
53
int
pair_end = i;
54
int
j = pair_start;
55
while
(j < (
int
)convstring.size() && convstring[j] !=
'='
)
56
j++;
57
std::string key = std::string(convstring.c_str(), pair_start, j - pair_start);
58
std::string value = std::string(convstring.c_str(), j + 1, pair_end - (j + 1));
59
params[key] = value;
60
}
61
62
// if (fnname==#name) return new itemconv::itemconv_##name(params);
63
64
#define DEFINE_CONVERSION_CLASS(name, body) \
65
if (fnname == #name) { \
66
itemconv::itemconv_##name* c = new itemconv::itemconv_##name(); \
67
c->init(params); \
68
return c; \
69
}
70
#include "
wibmod/WIB1/conversions-impl.hh
"
71
#undef DEFINE_CONVERSION_CLASS
72
73
return
NULL;
74
}
ItemConversion.hh
ItemConversion
Definition
ItemConversion.hh:7
ItemConversion::FromString
static ItemConversion * FromString(std::string convstring)
Definition
conversions.cpp:40
conversions-impl.hh
itemconv
Definition
conversions.cpp:15
Generated on
for DUNE-DAQ by
1.18.0