From 5680aa99001cb50c707c4187cd8ada0c41a573dd Mon Sep 17 00:00:00 2001 From: Tobias Frust Date: Thu, 30 Jun 2016 10:13:01 +0200 Subject: implemented virtual DetectorModule with simple send via udp --- src/ConfigReader/ConfigReader.h | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/ConfigReader/ConfigReader.h (limited to 'src/ConfigReader/ConfigReader.h') diff --git a/src/ConfigReader/ConfigReader.h b/src/ConfigReader/ConfigReader.h new file mode 100644 index 0000000..2819f41 --- /dev/null +++ b/src/ConfigReader/ConfigReader.h @@ -0,0 +1,48 @@ +/* + * Copyright 2016 Tobias Frust + * + * ConfigReader.h + * + * Created on: 18.04.2016 + * Author: Tobias Frust (t.frust@hzdr.de) + */ + +#ifndef CONFIGREADER_H +#define CONFIGREADER_H +#pragma once + +#include + +#include + +#include + +class ConfigReader { +public: + ConfigReader(const char* configFile); + ConfigReader(const ConfigReader& configReader) { + } + + template + bool lookupValue(const std::string& identifier, T& value) { + bool ret = cfg.lookupValue(identifier.c_str(), value); + BOOST_LOG_TRIVIAL(debug) << "Configuration value " << identifier << ": " << value; + return ret; + } + + template + bool lookupValue(const std::string& identifier, int index, T& value) { + libconfig::Setting& s = cfg.lookup(identifier.c_str()); + if(s.getLength() > index){ + value = s[index]; + BOOST_LOG_TRIVIAL(debug) << "Configuration value " << identifier << "[" << index << "]: " << value; + return true; + } + return false; + } + +private: + libconfig::Config cfg; +}; + +#endif -- cgit v1.2.3