add .clang-format
Change-Id: I6627b5569c2e0f730be7331403218b823a2c622f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index 106b154..881a9c2 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -20,15 +20,14 @@
/* Configuration. */
#include "conf.hpp"
-
#include "dbus/dbuspassive.hpp"
#include "dbus/dbuswrite.hpp"
#include "interfaces.hpp"
#include "notimpl/readonly.hpp"
#include "notimpl/writeonly.hpp"
#include "sensors/builder.hpp"
-#include "sensors/manager.hpp"
#include "sensors/host.hpp"
+#include "sensors/manager.hpp"
#include "sensors/pluggable.hpp"
#include "sysfs/sysfsread.hpp"
#include "sysfs/sysfswrite.hpp"
@@ -37,8 +36,7 @@
static constexpr bool deferSignals = true;
static DbusHelper helper;
-SensorManager BuildSensors(
- const std::map<std::string, struct sensor>& config)
+SensorManager BuildSensors(const std::map<std::string, struct sensor>& config)
{
SensorManager mgmr;
auto& HostSensorBus = mgmr.getHostBus();
@@ -60,17 +58,15 @@
// fan sensors can be ready any way and written others.
// fan sensors are the only sensors this is designed to write.
- // Nothing here should be write-only, although, in theory a fan could be.
- // I'm just not sure how that would fit together.
+ // Nothing here should be write-only, although, in theory a fan could
+ // be. I'm just not sure how that would fit together.
// TODO(venture): It should check with the ObjectMapper to check if
// that sensor exists on the Dbus.
switch (rtype)
{
case IOInterfaceType::DBUSPASSIVE:
ri = DbusPassive::CreateDbusPassive(PassiveListeningBus,
- info->type,
- name,
- &helper);
+ info->type, name, &helper);
/* TODO(venture): if this returns nullptr */
break;
case IOInterfaceType::EXTERNAL:
@@ -92,33 +88,25 @@
if (info->max > 0)
{
wi = std::make_unique<SysFsWritePercent>(
- info->writepath,
- info->min,
- info->max);
+ info->writepath, info->min, info->max);
}
else
{
- wi = std::make_unique<SysFsWrite>(
- info->writepath,
- info->min,
- info->max);
+ wi = std::make_unique<SysFsWrite>(info->writepath,
+ info->min, info->max);
}
break;
case IOInterfaceType::DBUSACTIVE:
if (info->max > 0)
{
- wi = std::make_unique<DbusWritePercent>(info->writepath,
- info->min,
- info->max,
- helper);
+ wi = std::make_unique<DbusWritePercent>(
+ info->writepath, info->min, info->max, helper);
}
else
{
- wi = std::make_unique<DbusWrite>(info->writepath,
- info->min,
- info->max,
- helper);
+ wi = std::make_unique<DbusWrite>(
+ info->writepath, info->min, info->max, helper);
}
break;
@@ -128,10 +116,7 @@
}
auto sensor = std::make_unique<PluggableSensor>(
- name,
- info->timeout,
- std::move(ri),
- std::move(wi));
+ name, info->timeout, std::move(ri), std::move(wi));
mgmr.addSensor(info->type, name, std::move(sensor));
}
else if (info->type == "temp" || info->type == "margin")
@@ -150,21 +135,15 @@
* not quite pluggable; but maybe it could be.
*/
auto sensor = HostSensor::CreateTemp(
- name,
- info->timeout,
- HostSensorBus,
- info->readpath.c_str(),
- deferSignals);
+ name, info->timeout, HostSensorBus, info->readpath.c_str(),
+ deferSignals);
mgmr.addSensor(info->type, name, std::move(sensor));
}
else
{
wi = std::make_unique<ReadOnlyNoExcept>();
auto sensor = std::make_unique<PluggableSensor>(
- name,
- info->timeout,
- std::move(ri),
- std::move(wi));
+ name, info->timeout, std::move(ri), std::move(wi));
mgmr.addSensor(info->type, name, std::move(sensor));
}
}
@@ -172,4 +151,3 @@
return mgmr;
}
-
diff --git a/sensors/builder.hpp b/sensors/builder.hpp
index edb30c3..78a578a 100644
--- a/sensors/builder.hpp
+++ b/sensors/builder.hpp
@@ -1,14 +1,12 @@
#pragma once
-#include <map>
-#include <string>
-
#include "sensors/manager.hpp"
#include "sensors/sensor.hpp"
+#include <map>
+#include <string>
+
/**
* Build the sensors and associate them with a SensorManager.
*/
-SensorManager BuildSensors(
- const std::map<std::string, struct sensor>& config);
-
+SensorManager BuildSensors(const std::map<std::string, struct sensor>& config);
diff --git a/sensors/builderconfig.cpp b/sensors/builderconfig.cpp
index f1d95a0..cb3fd81 100644
--- a/sensors/builderconfig.cpp
+++ b/sensors/builderconfig.cpp
@@ -21,7 +21,6 @@
/* Configuration. */
#include "conf.hpp"
-
#include "sensors/builder.hpp"
#include "sensors/manager.hpp"
@@ -46,7 +45,8 @@
}
catch (const FileIOException& fioex)
{
- std::cerr << "I/O error while reading file: " << fioex.what() << std::endl;
+ std::cerr << "I/O error while reading file: " << fioex.what()
+ << std::endl;
throw;
}
catch (const ParseException& pex)
@@ -71,7 +71,8 @@
std::string name;
struct sensor thisOne;
- /* Not a super fan of using this library for run-time configuration. */
+ /* Not a super fan of using this library for run-time configuration.
+ */
name = sensor.lookup("name").c_str();
thisOne.type = sensor.lookup("type").c_str();
thisOne.readpath = sensor.lookup("readpath").c_str();
@@ -89,20 +90,18 @@
// leaving for verification for now. and yea the above is
// necessary.
- std::cerr << "min: " << min
- << " max: " << max
- << " savedmin: " << thisOne.min
- << " savedmax: " << thisOne.max
- << " timeout: " << thisOne.timeout
- << std::endl;
+ std::cerr << "min: " << min << " max: " << max
+ << " savedmin: " << thisOne.min
+ << " savedmax: " << thisOne.max
+ << " timeout: " << thisOne.timeout << std::endl;
config[name] = thisOne;
}
}
- catch (const SettingTypeException &setex)
+ catch (const SettingTypeException& setex)
{
- std::cerr << "Setting '" << setex.getPath()
- << "' type exception!" << std::endl;
+ std::cerr << "Setting '" << setex.getPath() << "' type exception!"
+ << std::endl;
throw;
}
catch (const SettingNotFoundException& snex)
@@ -113,4 +112,3 @@
return BuildSensors(config);
}
-
diff --git a/sensors/builderconfig.hpp b/sensors/builderconfig.hpp
index 0948c69..649ca70 100644
--- a/sensors/builderconfig.hpp
+++ b/sensors/builderconfig.hpp
@@ -1,9 +1,9 @@
#pragma once
-#include <string>
-
#include "sensors/manager.hpp"
+#include <string>
+
/**
* Given a configuration file, parsable by libconfig++, parse it and then pass
* the information onto BuildSensors.
diff --git a/sensors/host.cpp b/sensors/host.cpp
index b38d651..30addd5 100644
--- a/sensors/host.cpp
+++ b/sensors/host.cpp
@@ -14,21 +14,20 @@
* limitations under the License.
*/
+#include "host.hpp"
+
#include <cmath>
#include <iostream>
#include <memory>
#include <mutex>
-#include "host.hpp"
-
-std::unique_ptr<Sensor> HostSensor::CreateTemp(
- const std::string& name,
- int64_t timeout,
- sdbusplus::bus::bus& bus,
- const char* objPath,
- bool defer)
+std::unique_ptr<Sensor> HostSensor::CreateTemp(const std::string& name,
+ int64_t timeout,
+ sdbusplus::bus::bus& bus,
+ const char* objPath, bool defer)
{
- auto sensor = std::make_unique<HostSensor>(name, timeout, bus, objPath, defer);
+ auto sensor =
+ std::make_unique<HostSensor>(name, timeout, bus, objPath, defer);
sensor->value(0);
// DegreesC and value of 0 are the defaults at present, therefore testing
@@ -65,10 +64,7 @@
std::lock_guard<std::mutex> guard(_lock);
/* This doesn't sanity check anything, that's the caller's job. */
- struct ReadReturn r = {
- _value,
- _updated
- };
+ struct ReadReturn r = {_value, _updated};
return r;
}
@@ -77,4 +73,3 @@
{
throw std::runtime_error("Not Implemented.");
}
-
diff --git a/sensors/host.hpp b/sensors/host.hpp
index 5d25aa0..ad3f834 100644
--- a/sensors/host.hpp
+++ b/sensors/host.hpp
@@ -1,13 +1,12 @@
#pragma once
-#include <memory>
-#include <mutex>
-
-#include <sdbusplus/bus.hpp>
-#include <sdbusplus/server.hpp>
+#include "sensor.hpp"
#include "xyz/openbmc_project/Sensor/Value/server.hpp"
-#include "sensor.hpp"
+#include <memory>
+#include <mutex>
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
template <typename... T>
using ServerObject = typename sdbusplus::server::object::object<T...>;
@@ -21,36 +20,31 @@
*/
class HostSensor : public Sensor, public ValueObject
{
- public:
- static std::unique_ptr<Sensor> CreateTemp(
- const std::string& name,
- int64_t timeout,
- sdbusplus::bus::bus& bus,
- const char* objPath,
- bool defer);
+ public:
+ static std::unique_ptr<Sensor> CreateTemp(const std::string& name,
+ int64_t timeout,
+ sdbusplus::bus::bus& bus,
+ const char* objPath, bool defer);
- HostSensor(const std::string& name,
- int64_t timeout,
- sdbusplus::bus::bus& bus,
- const char* objPath,
- bool defer)
- : Sensor(name, timeout),
- ValueObject(bus, objPath, defer)
- { }
+ HostSensor(const std::string& name, int64_t timeout,
+ sdbusplus::bus::bus& bus, const char* objPath, bool defer) :
+ Sensor(name, timeout),
+ ValueObject(bus, objPath, defer)
+ {
+ }
- /* Note: This must be int64_t because it's from ValueObject */
- int64_t value(int64_t value) override;
+ /* Note: This must be int64_t because it's from ValueObject */
+ int64_t value(int64_t value) override;
- ReadReturn read(void) override;
- void write(double value) override;
+ ReadReturn read(void) override;
+ void write(double value) override;
- private:
- /*
- * _lock will be used to make sure _updated & _value are updated
- * together.
- */
- std::mutex _lock;
- std::chrono::high_resolution_clock::time_point _updated;
- double _value = 0;
+ private:
+ /*
+ * _lock will be used to make sure _updated & _value are updated
+ * together.
+ */
+ std::mutex _lock;
+ std::chrono::high_resolution_clock::time_point _updated;
+ double _value = 0;
};
-
diff --git a/sensors/manager.cpp b/sensors/manager.cpp
index fad2c33..78b7e64 100644
--- a/sensors/manager.cpp
+++ b/sensors/manager.cpp
@@ -15,14 +15,12 @@
*/
/* Configuration. */
-#include "conf.hpp"
-
#include "sensors/manager.hpp"
-void SensorManager::addSensor(
- std::string type,
- std::string name,
- std::unique_ptr<Sensor> sensor)
+#include "conf.hpp"
+
+void SensorManager::addSensor(std::string type, std::string name,
+ std::unique_ptr<Sensor> sensor)
{
_sensorMap[name] = std::move(sensor);
diff --git a/sensors/manager.hpp b/sensors/manager.hpp
index ebf4962..97e20cf 100644
--- a/sensors/manager.hpp
+++ b/sensors/manager.hpp
@@ -1,73 +1,67 @@
#pragma once
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <sdbusplus/bus.hpp>
-#include <sdbusplus/server.hpp>
-
#include "sensors/sensor.hpp"
+#include <map>
+#include <memory>
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <string>
+#include <vector>
/*
* The SensorManager holds all sensors across all zones.
*/
class SensorManager
{
- public:
- SensorManager(sdbusplus::bus::bus&& pass, sdbusplus::bus::bus&& host)
- : _passiveListeningBus(std::move(pass)),
- _hostSensorBus(std::move(host))
- {
- // manager gets its interface from the bus. :D
- sdbusplus::server::manager::manager(_hostSensorBus, SensorRoot);
- }
+ public:
+ SensorManager(sdbusplus::bus::bus&& pass, sdbusplus::bus::bus&& host) :
+ _passiveListeningBus(std::move(pass)), _hostSensorBus(std::move(host))
+ {
+ // manager gets its interface from the bus. :D
+ sdbusplus::server::manager::manager(_hostSensorBus, SensorRoot);
+ }
- SensorManager()
- : SensorManager(std::move(sdbusplus::bus::new_default()),
- std::move(sdbusplus::bus::new_default()))
- {
- }
+ SensorManager() :
+ SensorManager(std::move(sdbusplus::bus::new_default()),
+ std::move(sdbusplus::bus::new_default()))
+ {
+ }
- ~SensorManager() = default;
- SensorManager(const SensorManager&) = delete;
- SensorManager& operator=(const SensorManager&) = delete;
- SensorManager(SensorManager&&) = default;
- SensorManager& operator=(SensorManager&&) = default;
+ ~SensorManager() = default;
+ SensorManager(const SensorManager&) = delete;
+ SensorManager& operator=(const SensorManager&) = delete;
+ SensorManager(SensorManager&&) = default;
+ SensorManager& operator=(SensorManager&&) = default;
- /*
- * Add a Sensor to the Manager.
- */
- void addSensor(
- std::string type,
- std::string name,
- std::unique_ptr<Sensor> sensor);
+ /*
+ * Add a Sensor to the Manager.
+ */
+ void addSensor(std::string type, std::string name,
+ std::unique_ptr<Sensor> sensor);
- // TODO(venture): Should implement read/write by name.
- Sensor* getSensor(const std::string& name) const
- {
- return _sensorMap.at(name).get();
- }
+ // TODO(venture): Should implement read/write by name.
+ Sensor* getSensor(const std::string& name) const
+ {
+ return _sensorMap.at(name).get();
+ }
- sdbusplus::bus::bus& getPassiveBus(void)
- {
- return _passiveListeningBus;
- }
+ sdbusplus::bus::bus& getPassiveBus(void)
+ {
+ return _passiveListeningBus;
+ }
- sdbusplus::bus::bus& getHostBus(void)
- {
- return _hostSensorBus;
- }
+ sdbusplus::bus::bus& getHostBus(void)
+ {
+ return _hostSensorBus;
+ }
- private:
- std::map<std::string, std::unique_ptr<Sensor>> _sensorMap;
- std::map<std::string, std::vector<std::string>> _sensorTypeList;
+ private:
+ std::map<std::string, std::unique_ptr<Sensor>> _sensorMap;
+ std::map<std::string, std::vector<std::string>> _sensorTypeList;
- sdbusplus::bus::bus _passiveListeningBus;
- sdbusplus::bus::bus _hostSensorBus;
+ sdbusplus::bus::bus _passiveListeningBus;
+ sdbusplus::bus::bus _hostSensorBus;
- static constexpr auto SensorRoot = "/xyz/openbmc_project/extsensors";
+ static constexpr auto SensorRoot = "/xyz/openbmc_project/extsensors";
};
-
diff --git a/sensors/pluggable.cpp b/sensors/pluggable.cpp
index 8039aea..8e4d789 100644
--- a/sensors/pluggable.cpp
+++ b/sensors/pluggable.cpp
@@ -16,14 +16,13 @@
#include "pluggable.hpp"
+#include "dbus/dbuspassive.hpp"
+#include "sysfs/sysfswrite.hpp"
+
#include <iostream>
#include <memory>
#include <string>
-#include "sysfs/sysfswrite.hpp"
-#include "dbus/dbuspassive.hpp"
-
-
ReadReturn PluggableSensor::read(void)
{
return _reader->read();
@@ -33,4 +32,3 @@
{
_writer->write(value);
}
-
diff --git a/sensors/pluggable.hpp b/sensors/pluggable.hpp
index 1eb6571..005d9ad 100644
--- a/sensors/pluggable.hpp
+++ b/sensors/pluggable.hpp
@@ -1,33 +1,30 @@
#pragma once
-#include <memory>
-#include <string>
-
-#include <sdbusplus/bus.hpp>
-
#include "interfaces.hpp"
#include "sensor.hpp"
+#include <memory>
+#include <sdbusplus/bus.hpp>
+#include <string>
/*
* A Sensor that can use any reader or writer you provide.
*/
class PluggableSensor : public Sensor
{
- public:
- PluggableSensor(const std::string& name,
- int64_t timeout,
- std::unique_ptr<ReadInterface> reader,
- std::unique_ptr<WriteInterface> writer)
- : Sensor(name, timeout),
- _reader(std::move(reader)),
- _writer(std::move(writer))
- { }
+ public:
+ PluggableSensor(const std::string& name, int64_t timeout,
+ std::unique_ptr<ReadInterface> reader,
+ std::unique_ptr<WriteInterface> writer) :
+ Sensor(name, timeout),
+ _reader(std::move(reader)), _writer(std::move(writer))
+ {
+ }
- ReadReturn read(void) override;
- void write(double value) override;
+ ReadReturn read(void) override;
+ void write(double value) override;
- private:
- std::unique_ptr<ReadInterface> _reader;
- std::unique_ptr<WriteInterface> _writer;
+ private:
+ std::unique_ptr<ReadInterface> _reader;
+ std::unique_ptr<WriteInterface> _writer;
};
diff --git a/sensors/sensor.hpp b/sensors/sensor.hpp
index dc5f3e0..9ff0584 100644
--- a/sensors/sensor.hpp
+++ b/sensors/sensor.hpp
@@ -1,41 +1,41 @@
#pragma once
-#include <chrono>
-#include <string>
-
#include "interfaces.hpp"
+#include <chrono>
+#include <string>
/**
* Abstract base class for all sensors.
*/
class Sensor
{
- public:
- Sensor(std::string name, int64_t timeout)
- : _name(name), _timeout(timeout)
- { }
+ public:
+ Sensor(std::string name, int64_t timeout) : _name(name), _timeout(timeout)
+ {
+ }
- virtual ~Sensor() { }
+ virtual ~Sensor()
+ {
+ }
- virtual ReadReturn read(void) = 0;
- virtual void write(double value) = 0;
+ virtual ReadReturn read(void) = 0;
+ virtual void write(double value) = 0;
- std::string GetName(void) const
- {
- return _name;
- }
+ std::string GetName(void) const
+ {
+ return _name;
+ }
- /* Returns the configurable timeout period
- * for this sensor in seconds (undecorated).
- */
- int64_t GetTimeout(void) const
- {
- return _timeout;
- }
+ /* Returns the configurable timeout period
+ * for this sensor in seconds (undecorated).
+ */
+ int64_t GetTimeout(void) const
+ {
+ return _timeout;
+ }
- private:
- std::string _name;
- int64_t _timeout;
+ private:
+ std::string _name;
+ int64_t _timeout;
};
-