sensors/zones: place in namespace and cleanup
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I527dbc8477a232945f696227a7b0b2adbee45175
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index 1cea61a..8a1f54a 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -35,13 +35,12 @@
#include "sysfs/sysfswrite.hpp"
#include "util.hpp"
+namespace pid_control
+{
+
static constexpr bool deferSignals = true;
static DbusHelper helper;
-using ::pid_control::getReadInterfaceType;
-using ::pid_control::getWriteInterfaceType;
-using ::pid_control::IOInterfaceType;
-
SensorManager
buildSensors(const std::map<std::string, struct conf::SensorConfig>& config,
sdbusplus::bus::bus& passive, sdbusplus::bus::bus& host)
@@ -186,3 +185,5 @@
return mgmr;
}
+
+} // namespace pid_control
diff --git a/sensors/builder.hpp b/sensors/builder.hpp
index 688a931..236fee7 100644
--- a/sensors/builder.hpp
+++ b/sensors/builder.hpp
@@ -6,9 +6,14 @@
#include <map>
#include <string>
+namespace pid_control
+{
+
/**
* Build the sensors and associate them with a SensorManager.
*/
SensorManager
buildSensors(const std::map<std::string, struct conf::SensorConfig>& config,
sdbusplus::bus::bus& passive, sdbusplus::bus::bus& host);
+
+} // namespace pid_control
diff --git a/sensors/buildjson.cpp b/sensors/buildjson.cpp
index 7e5e29a..2bfc143 100644
--- a/sensors/buildjson.cpp
+++ b/sensors/buildjson.cpp
@@ -25,6 +25,8 @@
using json = nlohmann::json;
+namespace pid_control
+{
namespace conf
{
void from_json(const json& j, conf::SensorConfig& s)
@@ -113,3 +115,4 @@
return config;
}
+} // namespace pid_control
diff --git a/sensors/buildjson.hpp b/sensors/buildjson.hpp
index 979cd87..ee82381 100644
--- a/sensors/buildjson.hpp
+++ b/sensors/buildjson.hpp
@@ -9,6 +9,9 @@
using json = nlohmann::json;
+namespace pid_control
+{
+
/**
* Given a json object generated from a configuration file, build the sensor
* configuration representation. This expecteds the json configuration to be
@@ -19,3 +22,5 @@
*/
std::map<std::string, struct conf::SensorConfig>
buildSensorsFromJson(const json& data);
+
+} // namespace pid_control
diff --git a/sensors/host.cpp b/sensors/host.cpp
index 96a0514..e05ac37 100644
--- a/sensors/host.cpp
+++ b/sensors/host.cpp
@@ -21,6 +21,9 @@
#include <memory>
#include <mutex>
+namespace pid_control
+{
+
template <typename T>
void scaleHelper(T& ptr, int64_t value)
{
@@ -92,3 +95,5 @@
{
throw std::runtime_error("Not Implemented.");
}
+
+} // namespace pid_control
diff --git a/sensors/host.hpp b/sensors/host.hpp
index 7983e8a..35c7f45 100644
--- a/sensors/host.hpp
+++ b/sensors/host.hpp
@@ -16,6 +16,9 @@
using ValueInterface = sdbusplus::xyz::openbmc_project::Sensor::server::Value;
using ValueObject = ServerObject<ValueInterface>;
+namespace pid_control
+{
+
class ValueHelper : public ValueInterface
{
@@ -62,3 +65,5 @@
std::chrono::high_resolution_clock::time_point _updated;
double _value = 0;
};
+
+} // namespace pid_control
diff --git a/sensors/manager.cpp b/sensors/manager.cpp
index 84f7435..95d2a6b 100644
--- a/sensors/manager.cpp
+++ b/sensors/manager.cpp
@@ -19,6 +19,12 @@
#include "conf.hpp"
+#include <memory>
+#include <string>
+
+namespace pid_control
+{
+
void SensorManager::addSensor(const std::string& type, const std::string& name,
std::unique_ptr<Sensor> sensor)
{
@@ -32,3 +38,5 @@
_sensorTypeList[type].push_back(name);
}
+
+} // namespace pid_control
diff --git a/sensors/manager.hpp b/sensors/manager.hpp
index 740ef00..6fcd275 100644
--- a/sensors/manager.hpp
+++ b/sensors/manager.hpp
@@ -10,6 +10,9 @@
#include <string>
#include <vector>
+namespace pid_control
+{
+
/*
* The SensorManager holds all sensors across all zones.
*/
@@ -61,3 +64,5 @@
static constexpr auto SensorRoot = "/xyz/openbmc_project/extsensors";
};
+
+} // namespace pid_control
diff --git a/sensors/pluggable.cpp b/sensors/pluggable.cpp
index eb3eab9..07d3d0e 100644
--- a/sensors/pluggable.cpp
+++ b/sensors/pluggable.cpp
@@ -16,12 +16,8 @@
#include "pluggable.hpp"
-#include "dbus/dbuspassive.hpp"
-#include "sysfs/sysfswrite.hpp"
-
-#include <iostream>
-#include <memory>
-#include <string>
+namespace pid_control
+{
ReadReturn PluggableSensor::read(void)
{
@@ -36,4 +32,6 @@
bool PluggableSensor::getFailed(void)
{
return _reader->getFailed();
-}
\ No newline at end of file
+}
+
+} // namespace pid_control
diff --git a/sensors/pluggable.hpp b/sensors/pluggable.hpp
index 756b5cb..23aea99 100644
--- a/sensors/pluggable.hpp
+++ b/sensors/pluggable.hpp
@@ -3,11 +3,12 @@
#include "interfaces.hpp"
#include "sensor.hpp"
-#include <sdbusplus/bus.hpp>
-
#include <memory>
#include <string>
+namespace pid_control
+{
+
/*
* A Sensor that can use any reader or writer you provide.
*/
@@ -29,3 +30,5 @@
std::unique_ptr<ReadInterface> _reader;
std::unique_ptr<WriteInterface> _writer;
};
+
+} // namespace pid_control
diff --git a/sensors/sensor.hpp b/sensors/sensor.hpp
index 01f4c02..8258b7b 100644
--- a/sensors/sensor.hpp
+++ b/sensors/sensor.hpp
@@ -4,6 +4,9 @@
#include <string>
+namespace pid_control
+{
+
/**
* Abstract base class for all sensors.
*/
@@ -55,3 +58,5 @@
std::string _name;
int64_t _timeout;
};
+
+} // namespace pid_control