#include <ZDCJSONConfig.h>
|
| template<typename T > |
| bool | checkType (T value, JSON::value_t paramType, int paramSize=-1) |
| |
| template<typename T > |
| void | setAllParameter (const std::string &key, T value) |
| |
| template<typename T > |
| void | setChannelParameter (unsigned int side, unsigned int chanIndex, const std::string &key, T value) |
| |
| template<typename T > |
| void | setPerSideParameter (unsigned int side, std::string key, T value) |
| |
| template<typename T > |
| std::pair< bool, std::string > | ParsePerChannelParams (const std::string ¶mKey, const T ¶mValue, JSON::value_t paramType, size_t paramSize) |
| |
Definition at line 15 of file ZDCJSONConfig.h.
◆ JSON
◆ JSONParamDescr
◆ JSONParamList
◆ ZDCJSONConfig()
| ZDCJSONConfig::ZDCJSONConfig |
( |
const std::vector< std::string > & |
sideNames, |
|
|
size_t |
numChannelsPerSide |
|
) |
| |
|
inline |
◆ ~ZDCJSONConfig()
| ZDCJSONConfig::~ZDCJSONConfig |
( |
| ) |
|
|
inline |
◆ checkType()
template<typename T >
| bool ZDCJSONConfig::checkType |
( |
T |
value, |
|
|
JSON::value_t |
paramType, |
|
|
int |
paramSize = -1 |
|
) |
| |
|
inlineprivate |
Definition at line 33 of file ZDCJSONConfig.h.
35 if (
value.is_null())
return false;
37 if (
value.type() == paramType) {
38 if (paramSize == -1)
return true;
39 else if (
value.size() ==
size_t(paramSize))
return true;
43 if (
value.is_primitive()) {
44 if (paramType == JSON::value_t::number_float) {
45 if (
value.type() == JSON::value_t::number_integer ||
46 value.type() == JSON::value_t::number_unsigned)
return true;
48 else if (paramType == JSON::value_t::number_integer &&
49 value.type() == JSON::value_t::number_unsigned)
return true;
50 else if (paramType == JSON::value_t::number_integer &&
51 value.type() == JSON::value_t::number_float) {
53 if (std::abs(std::floor(fvalue)-fvalue) < 1
e-6)
return true;
◆ dumpGlobal()
| auto ZDCJSONConfig::dumpGlobal |
( |
| ) |
|
|
inline |
◆ getChannelConfig()
| const JSON& ZDCJSONConfig::getChannelConfig |
( |
size_t |
side, |
|
|
size_t |
channel |
|
) |
| const |
|
inline |
◆ getGlobalParam()
template<typename T >
| bool ZDCJSONConfig::getGlobalParam |
( |
std::string |
key, |
|
|
T & |
returnValue |
|
) |
| |
|
inline |
Definition at line 114 of file ZDCJSONConfig.h.
121 if (
iter.value().is_null())
return false;
123 returnValue =
iter.value().get_to(returnValue);
◆ haveConfig()
| bool ZDCJSONConfig::haveConfig |
( |
| ) |
const |
|
inline |
◆ ParseConfig()
Definition at line 9 of file ZDCJSONConfig.cxx.
12 std::string resultString =
"success";
16 if (
value.is_null()) {
18 resultString =
"Found null value for parameter " +
key;
25 auto iter = configParamList.find(
key);
26 if (
iter == configParamList.end()) {
28 resultString =
"Found unknown parameter: " +
key +
": JSON=" +
config.dump();
32 auto paramType = std::get<0>(
iter->second);
33 auto paramSize = std::get<1>(
iter->second);
34 auto paramSingleOnly = !std::get<2>(
iter->second);
38 if (paramSingleOnly) {
41 resultString =
"Incorrect JSON type for parameter " +
key;
64 resultString = std::move(ppcResultString);
71 resultString =
"Incorrect JSON type for parameter " +
key;
84 return {
result, resultString};
◆ ParsePerChannelParams()
template<typename T >
| std::pair< bool, std::string > ZDCJSONConfig::ParsePerChannelParams |
( |
const std::string & |
paramKey, |
|
|
const T & |
paramValue, |
|
|
JSON::value_t |
paramType, |
|
|
size_t |
paramSize |
|
) |
| |
|
private |
Definition at line 88 of file ZDCJSONConfig.cxx.
91 std::string resultString =
"success";
93 for (
auto [
key,
value] : paramValue.items()) {
110 if (
value.size() == 1) {
117 resultString =
"Incorrect JSON type for parameter " +
key;
126 size_t elementSize =
value[0].size();
127 size_t arrayLength =
value.size();
134 else if (arrayLength == paramSize) {
142 resultString =
"Invalid value format for array parameter " + paramKey +
" on side " +
m_sideLabels[
side];
157 resultString =
"Invalid array length for parameter " + paramKey +
" on side " +
m_sideLabels[
side];
167 resultString =
"Incorrect JSON type for parameter " + paramKey +
"paramType = " +
182 int chanIndex = std::stoi(keyRemainder);
185 resultString =
"Invalid channel specifier in values for parameter " +
key;
191 resultString =
"Incorrect JSON type for parameter " +
key;
199 resultString =
"Invalid channel specifier for parameter " +
key;
209 resultString =
"Exception caught while parsing key " +
key;
213 return {
result, resultString};
◆ setAllParameter()
template<typename T >
| void ZDCJSONConfig::setAllParameter |
( |
const std::string & |
key, |
|
|
T |
value |
|
) |
| |
|
inlineprivate |
◆ setChannelParameter()
template<typename T >
| void ZDCJSONConfig::setChannelParameter |
( |
unsigned int |
side, |
|
|
unsigned int |
chanIndex, |
|
|
const std::string & |
key, |
|
|
T |
value |
|
) |
| |
|
inlineprivate |
◆ setPerSideParameter()
template<typename T >
| void ZDCJSONConfig::setPerSideParameter |
( |
unsigned int |
side, |
|
|
std::string |
key, |
|
|
T |
value |
|
) |
| |
|
inlineprivate |
◆ m_channelConfig
| std::vector<JSON> ZDCJSONConfig::m_channelConfig |
|
private |
◆ m_globalConfig
| JSON ZDCJSONConfig::m_globalConfig |
|
private |
◆ m_haveConfig
| bool ZDCJSONConfig::m_haveConfig {false} |
|
private |
◆ m_nSides
| size_t ZDCJSONConfig::m_nSides {0} |
|
private |
◆ m_numChannelsPerSide
| size_t ZDCJSONConfig::m_numChannelsPerSide {0} |
|
private |
◆ m_sideLabels
| std::vector<std::string> ZDCJSONConfig::m_sideLabels |
|
private |
The documentation for this class was generated from the following files: