Expand conf namespace
Put rest of conf.hpp in the conf namespace. This is
largely a sed replace, and wrapping from_json in
conf namespace as it failed to build.
Change-Id: I9fe5c7b2fface44618c43af2367035afc39bcb64
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index adffd81..1a74adb 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -38,7 +38,7 @@
static DbusHelper helper;
SensorManager
- buildSensors(const std::map<std::string, struct SensorConfig>& config)
+ buildSensors(const std::map<std::string, struct conf::SensorConfig>& config)
{
SensorManager mgmr;
auto& hostSensorBus = mgmr.getHostBus();
@@ -50,7 +50,7 @@
std::unique_ptr<WriteInterface> wi;
std::string name = it.first;
- const struct SensorConfig* info = &it.second;
+ const struct conf::SensorConfig* info = &it.second;
std::cerr << "Sensor: " << name << " " << info->type << " ";
std::cerr << info->readPath << " " << info->writePath << "\n";
diff --git a/sensors/builder.hpp b/sensors/builder.hpp
index d646223..224d467 100644
--- a/sensors/builder.hpp
+++ b/sensors/builder.hpp
@@ -9,5 +9,5 @@
/**
* Build the sensors and associate them with a SensorManager.
*/
-SensorManager
- buildSensors(const std::map<std::string, struct SensorConfig>& config);
+SensorManager buildSensors(
+ const std::map<std::string, struct conf::SensorConfig>& config);
diff --git a/sensors/buildjson.cpp b/sensors/buildjson.cpp
index d62edfd..42a9286 100644
--- a/sensors/buildjson.cpp
+++ b/sensors/buildjson.cpp
@@ -23,7 +23,9 @@
using json = nlohmann::json;
-void from_json(const json& j, SensorConfig& s)
+namespace conf
+{
+void from_json(const json& j, conf::SensorConfig& s)
{
j.at("type").get_to(s.type);
j.at("readPath").get_to(s.readPath);
@@ -72,11 +74,12 @@
j.at("timeout").get_to(s.timeout);
}
}
+} // namespace conf
-std::map<std::string, struct SensorConfig>
+std::map<std::string, struct conf::SensorConfig>
buildSensorsFromJson(const json& data)
{
- std::map<std::string, struct SensorConfig> config;
+ std::map<std::string, struct conf::SensorConfig> config;
auto sensors = data["sensors"];
/* TODO: If no sensors, this is invalid, and we should except here or during
@@ -84,7 +87,7 @@
*/
for (const auto& sensor : sensors)
{
- config[sensor["name"]] = sensor.get<struct SensorConfig>();
+ config[sensor["name"]] = sensor.get<struct conf::SensorConfig>();
}
return config;
diff --git a/sensors/buildjson.hpp b/sensors/buildjson.hpp
index c5aacc7..0a38b93 100644
--- a/sensors/buildjson.hpp
+++ b/sensors/buildjson.hpp
@@ -16,5 +16,5 @@
* @param[in] data - the json data
* @return a map of sensors.
*/
-std::map<std::string, struct SensorConfig>
+std::map<std::string, struct conf::SensorConfig>
buildSensorsFromJson(const json& data);