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
9
#include "
wibmod/WIB1/ItemConversion.hh
"
10
11
#include <stdio.h>
// sscanf
12
#include <boost/foreach.hpp>
13
14
using
boost::unordered_map;
15
16
namespace
itemconv
{
17
18
#define ARGS(...) __VA_ARGS__
19
#define EXPAND(x) x
20
#define STRIP(x) EXPAND( ARGS x )
21
#define DEFINE_CONVERSION_CLASS(name,body) \
22
class itemconv_##name : public ItemConversion { STRIP(body) };
23
/*#define DEFINE_CONVERSION_CLASS_END \
24
public: \
25
itemconv_##name (unordered_map<std::string, std::string> params) { \
26
init(params); \
27
} \
28
};*/
29
#include "
wibmod/WIB1/conversions-impl.hh
"
30
#undef DEFINE_CONVERSION_CLASS
31
#undef STRIP
32
#undef EXPAND
33
#undef STRIP
34
35
}
36
37
ItemConversion
*
ItemConversion::FromString
(std::string convstring) {
38
unordered_map<std::string, std::string> params;
39
int
i = 0;
40
while
(i < (
int
)convstring.size() && convstring[i]!=
' '
) i++;
41
std::string fnname = std::string(convstring.c_str(), i);
42
while
(i < (
int
)convstring.size()) {
43
while
(i < (
int
)convstring.size() && convstring[i]==
' '
) i++;
44
int
pair_start = i;
45
while
(i < (
int
)convstring.size() && convstring[i]!=
' '
) i++;
46
int
pair_end = i;
47
int
j = pair_start;
48
while
(j < (
int
)convstring.size() && convstring[j]!=
'='
) j++;
49
std::string key =
50
std::string(convstring.c_str(), pair_start, j-pair_start);
51
std::string value =
52
std::string(convstring.c_str(), j+1, pair_end-(j+1));
53
params[key]=value;
54
}
55
56
57
// if (fnname==#name) return new itemconv::itemconv_##name(params);
58
59
#define DEFINE_CONVERSION_CLASS(name,body) \
60
if (fnname==#name) { \
61
itemconv::itemconv_##name *c = new itemconv::itemconv_##name(); \
62
c->init(params); return c; }
63
#include "
wibmod/WIB1/conversions-impl.hh
"
64
#undef DEFINE_CONVERSION_CLASS
65
66
return
NULL;
67
}
68
ItemConversion.hh
ItemConversion::ItemConversion
ItemConversion()
Definition
ItemConversion.hh:11
ItemConversion::FromString
static ItemConversion * FromString(std::string convstring)
Definition
conversions.cpp:37
conversions-impl.hh
itemconv
Definition
conversions.cpp:16
Generated on
for DUNE-DAQ by
1.17.0