clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: I1ac255c58971ac5cc4697b8bb1069067aad02d18
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/src/main.cpp b/src/main.cpp
index bea8a13..59a2d30 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,13 +20,13 @@
signals.async_wait(
[&ioc](const boost::system::error_code ec, const int& sig) {
- if (ec)
- {
- throw std::runtime_error("Signal should not be canceled");
- }
+ if (ec)
+ {
+ throw std::runtime_error("Signal should not be canceled");
+ }
- ioc.stop();
- });
+ ioc.stop();
+ });
phosphor::logging::log<phosphor::logging::level::INFO>(
"Telemetry starting");
diff --git a/src/metric.cpp b/src/metric.cpp
index f7a0642..222af3c 100644
--- a/src/metric.cpp
+++ b/src/metric.cpp
@@ -30,12 +30,12 @@
void Metric::unregisterFromUpdates(interfaces::MetricListener& listener)
{
- listeners.erase(
- std::remove_if(listeners.begin(), listeners.end(),
- [&listener](const interfaces::MetricListener& item) {
- return &item == &listener;
- }),
- listeners.end());
+ listeners.erase(std::remove_if(
+ listeners.begin(), listeners.end(),
+ [&listener](const interfaces::MetricListener& item) {
+ return &item == &listener;
+ }),
+ listeners.end());
}
void Metric::initialize()
@@ -108,9 +108,10 @@
metrics::CollectionData&
Metric::findAssociatedData(const interfaces::Sensor& notifier)
{
- auto it = std::find_if(
- sensors.begin(), sensors.end(),
- [¬ifier](const auto& sensor) { return sensor.get() == ¬ifier; });
+ auto it = std::find_if(sensors.begin(), sensors.end(),
+ [¬ifier](const auto& sensor) {
+ return sensor.get() == ¬ifier;
+ });
auto index = std::distance(sensors.begin(), it);
return *collectionAlgorithms.at(index);
}
diff --git a/src/metrics/collection_data.cpp b/src/metrics/collection_data.cpp
index 7ab5354..3610cba 100644
--- a/src/metrics/collection_data.cpp
+++ b/src/metrics/collection_data.cpp
@@ -85,8 +85,8 @@
if (timestamp > duration.t)
{
- readings.front().first =
- std::max(readings.front().first, timestamp - duration.t);
+ readings.front().first = std::max(readings.front().first,
+ timestamp - duration.t);
}
}
@@ -139,9 +139,8 @@
case CollectionTimeScope::interval:
std::generate_n(std::back_inserter(result), size,
[cf = makeCollectionFunction(op), duration] {
- return std::make_unique<DataInterval>(cf,
- duration);
- });
+ return std::make_unique<DataInterval>(cf, duration);
+ });
break;
case CollectionTimeScope::point:
std::generate_n(std::back_inserter(result), size,
@@ -150,8 +149,8 @@
case CollectionTimeScope::startup:
std::generate_n(std::back_inserter(result), size,
[cf = makeCollectionFunction(op)] {
- return std::make_unique<DataStartup>(cf);
- });
+ return std::make_unique<DataStartup>(cf);
+ });
break;
}
diff --git a/src/metrics/collection_function.cpp b/src/metrics/collection_function.cpp
index 717bb68..7170936 100644
--- a/src/metrics/collection_function.cpp
+++ b/src/metrics/collection_function.cpp
@@ -14,10 +14,8 @@
return std::min_element(
readings.begin(), readings.end(),
[](const auto& left, const auto& right) {
- return std::make_tuple(!std::isfinite(left.second),
- left.second) <
- std::make_tuple(!std::isfinite(right.second),
- right.second);
+ return std::make_tuple(!std::isfinite(left.second), left.second) <
+ std::make_tuple(!std::isfinite(right.second), right.second);
})
->second;
}
@@ -40,10 +38,8 @@
return std::max_element(
readings.begin(), readings.end(),
[](const auto& left, const auto& right) {
- return std::make_tuple(std::isfinite(left.second),
- left.second) <
- std::make_tuple(std::isfinite(right.second),
- right.second);
+ return std::make_tuple(std::isfinite(left.second), left.second) <
+ std::make_tuple(std::isfinite(right.second), right.second);
})
->second;
}
diff --git a/src/numeric_threshold.cpp b/src/numeric_threshold.cpp
index 0b60dac..5980e23 100644
--- a/src/numeric_threshold.cpp
+++ b/src/numeric_threshold.cpp
@@ -57,10 +57,10 @@
return;
}
- bool crossedDecreasing =
- thresholdValue < prevValue && thresholdValue > value;
- bool crossedIncreasing =
- thresholdValue > prevValue && thresholdValue < value;
+ bool crossedDecreasing = thresholdValue < prevValue &&
+ thresholdValue > value;
+ bool crossedIncreasing = thresholdValue > prevValue &&
+ thresholdValue < value;
if (!crossedDecreasing && !crossedIncreasing && thresholdValue == prevValue)
{
diff --git a/src/report.cpp b/src/report.cpp
index 9e69b62..dbc1a9a 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -48,34 +48,34 @@
return metric->dumpConfiguration();
}));
- readingParametersPastVersion =
- utils::transform(readingParameters, [](const auto& item) {
- const auto& [sensorData, operationType, id, collectionTimeScope,
- collectionDuration] = item;
+ readingParametersPastVersion = utils::transform(readingParameters,
+ [](const auto& item) {
+ const auto& [sensorData, operationType, id, collectionTimeScope,
+ collectionDuration] = item;
- return ReadingParametersPastVersion::value_type(
- std::get<0>(sensorData.front()), operationType, id,
- std::get<1>(sensorData.front()));
- });
+ return ReadingParametersPastVersion::value_type(
+ std::get<0>(sensorData.front()), operationType, id,
+ std::get<1>(sensorData.front()));
+ });
reportActions.insert(ReportAction::logToMetricReportsCollection);
deleteIface = objServer->add_unique_interface(
getPath(), deleteIfaceName,
[this, &ioc, &reportManager](auto& dbusIface) {
- dbusIface.register_method("Delete", [this, &ioc, &reportManager] {
- if (persistency)
- {
- persistency = false;
+ dbusIface.register_method("Delete", [this, &ioc, &reportManager] {
+ if (persistency)
+ {
+ persistency = false;
- reportIface->signal_property("Persistency");
- }
+ reportIface->signal_property("Persistency");
+ }
- boost::asio::post(ioc, [this, &reportManager] {
- reportManager.removeReport(this);
- });
+ boost::asio::post(ioc, [this, &reportManager] {
+ reportManager.removeReport(this);
});
});
+ });
errorMessages = verify();
state.set<ReportFlags::enabled, ReportFlags::valid>(enabledIn,
@@ -86,29 +86,29 @@
messanger.on_receive<messages::TriggerPresenceChangedInd>(
[this](const auto& msg) {
- const auto oldSize = triggerIds.size();
+ const auto oldSize = triggerIds.size();
- if (msg.presence == messages::Presence::Exist)
+ if (msg.presence == messages::Presence::Exist)
+ {
+ if (utils::contains(msg.reportIds, id))
{
- if (utils::contains(msg.reportIds, id))
- {
- triggerIds.insert(msg.triggerId);
- }
- else if (!utils::contains(msg.reportIds, id))
- {
- triggerIds.erase(msg.triggerId);
- }
+ triggerIds.insert(msg.triggerId);
}
- else if (msg.presence == messages::Presence::Removed)
+ else if (!utils::contains(msg.reportIds, id))
{
triggerIds.erase(msg.triggerId);
}
+ }
+ else if (msg.presence == messages::Presence::Removed)
+ {
+ triggerIds.erase(msg.triggerId);
+ }
- if (triggerIds.size() != oldSize)
- {
- reportIface->signal_property("Triggers");
- }
- });
+ if (triggerIds.size() != oldSize)
+ {
+ reportIface->signal_property("Triggers");
+ }
+ });
messanger.on_receive<messages::UpdateReportInd>([this](const auto& msg) {
if (utils::contains(msg.reportIds, id))
@@ -191,8 +191,8 @@
void Report::setReadingBuffer(const ReportUpdates newReportUpdates)
{
- const auto newBufferSize =
- deduceBufferSize(newReportUpdates, reportingType);
+ const auto newBufferSize = deduceBufferSize(newReportUpdates,
+ reportingType);
if (readingsBuffer.size() != newBufferSize)
{
readingsBuffer.clearAndResize(newBufferSize);
@@ -211,73 +211,72 @@
std::unique_ptr<sdbusplus::asio::dbus_interface>
Report::makeReportInterface(const interfaces::ReportFactory& reportFactory)
{
- auto dbusIface =
- objServer->add_unique_interface(getPath(), reportIfaceName);
+ auto dbusIface = objServer->add_unique_interface(getPath(),
+ reportIfaceName);
dbusIface->register_property_rw<bool>(
"Enabled", sdbusplus::vtable::property_::emits_change,
[this](bool newVal, auto& oldValue) {
- if (newVal != state.get<ReportFlags::enabled>())
- {
- state.set<ReportFlags::enabled>(oldValue = newVal);
+ if (newVal != state.get<ReportFlags::enabled>())
+ {
+ state.set<ReportFlags::enabled>(oldValue = newVal);
- persistency = storeConfiguration();
- }
- return 1;
+ persistency = storeConfiguration();
+ }
+ return 1;
},
[this](const auto&) { return state.get<ReportFlags::enabled>(); });
dbusIface->register_property_r<
std::vector<std::tuple<std::string, std::string>>>(
"ErrorMessages", sdbusplus::vtable::property_::emits_change,
[this](const auto&) {
- return utils::transform(errorMessages, [](const auto& em) {
- return std::tuple<std::string, std::string>(
- utils::enumToString(em.error), em.arg0);
- });
+ return utils::transform(errorMessages, [](const auto& em) {
+ return std::tuple<std::string, std::string>(
+ utils::enumToString(em.error), em.arg0);
+ });
});
dbusIface->register_property_rw<uint64_t>(
"Interval", sdbusplus::vtable::property_::emits_change,
[this](uint64_t newVal, auto& oldVal) {
- const Milliseconds newValT{newVal};
- if (newValT < ReportManager::minInterval &&
- newValT != Milliseconds{0})
+ const Milliseconds newValT{newVal};
+ if (newValT < ReportManager::minInterval && newValT != Milliseconds{0})
+ {
+ throw errors::InvalidArgument("Interval");
+ }
+
+ if (newValT != interval)
+ {
+ oldVal = newVal;
+ interval = newValT;
+
+ errorMessages = verify();
+ if (state.set<ReportFlags::valid>(errorMessages.empty()) ==
+ StateEvent::active)
{
- throw errors::InvalidArgument("Interval");
+ scheduleTimer();
}
- if (newValT != interval)
- {
- oldVal = newVal;
- interval = newValT;
-
- errorMessages = verify();
- if (state.set<ReportFlags::valid>(errorMessages.empty()) ==
- StateEvent::active)
- {
- scheduleTimer();
- }
-
- persistency = storeConfiguration();
- }
- return 1;
+ persistency = storeConfiguration();
+ }
+ return 1;
},
[this](const auto&) { return interval.count(); });
dbusIface->register_property_rw<bool>(
"Persistency", sdbusplus::vtable::property_::emits_change,
[this](bool newVal, auto& oldVal) {
- if (newVal == persistency)
- {
- return 1;
- }
- if (newVal)
- {
- persistency = oldVal = storeConfiguration();
- }
- else
- {
- reportStorage.remove(reportFileName());
- persistency = oldVal = false;
- }
+ if (newVal == persistency)
+ {
return 1;
+ }
+ if (newVal)
+ {
+ persistency = oldVal = storeConfiguration();
+ }
+ else
+ {
+ reportStorage.remove(reportFileName());
+ persistency = oldVal = false;
+ }
+ return 1;
},
[this](const auto&) { return persistency; });
@@ -287,24 +286,24 @@
dbusIface->register_property_rw<std::string>(
"ReportingType", sdbusplus::vtable::property_::emits_change,
[this](auto newVal, auto& oldVal) {
- ReportingType tmp = utils::toReportingType(newVal);
- if (tmp != reportingType)
+ ReportingType tmp = utils::toReportingType(newVal);
+ if (tmp != reportingType)
+ {
+ reportingType = tmp;
+ oldVal = std::move(newVal);
+
+ errorMessages = verify();
+ if (state.set<ReportFlags::valid>(errorMessages.empty()) ==
+ StateEvent::active)
{
- reportingType = tmp;
- oldVal = std::move(newVal);
-
- errorMessages = verify();
- if (state.set<ReportFlags::valid>(errorMessages.empty()) ==
- StateEvent::active)
- {
- scheduleTimer();
- }
-
- persistency = storeConfiguration();
-
- setReadingBuffer(reportUpdates);
+ scheduleTimer();
}
- return 1;
+
+ persistency = storeConfiguration();
+
+ setReadingBuffer(reportUpdates);
+ }
+ return 1;
},
[this](const auto&) { return utils::enumToString(reportingType); });
dbusIface->register_property_r(
@@ -315,60 +314,58 @@
"ReadingParametersFutureVersion", readingParameters,
sdbusplus::vtable::property_::emits_change,
[this, &reportFactory](auto newVal, auto& oldVal) {
- auto labeledMetricParams =
- reportFactory.convertMetricParams(newVal);
- ReportManager::verifyMetricParameters(labeledMetricParams);
- reportFactory.updateMetrics(metrics,
- state.get<ReportFlags::enabled>(),
- labeledMetricParams);
- readingParameters = toReadingParameters(
- utils::transform(metrics, [](const auto& metric) {
- return metric->dumpConfiguration();
- }));
- metricCount = getMetricCount(metrics);
- setReadingBuffer(reportUpdates);
- persistency = storeConfiguration();
- oldVal = std::move(newVal);
- return 1;
+ auto labeledMetricParams = reportFactory.convertMetricParams(newVal);
+ ReportManager::verifyMetricParameters(labeledMetricParams);
+ reportFactory.updateMetrics(metrics, state.get<ReportFlags::enabled>(),
+ labeledMetricParams);
+ readingParameters = toReadingParameters(
+ utils::transform(metrics, [](const auto& metric) {
+ return metric->dumpConfiguration();
+ }));
+ metricCount = getMetricCount(metrics);
+ setReadingBuffer(reportUpdates);
+ persistency = storeConfiguration();
+ oldVal = std::move(newVal);
+ return 1;
},
[this](const auto&) { return readingParameters; });
- dbusIface->register_property_r<bool>(
- "EmitsReadingsUpdate", sdbusplus::vtable::property_::none,
- [this](const auto&) {
- return reportActions.contains(ReportAction::emitsReadingsUpdate);
- });
+ dbusIface->register_property_r<bool>("EmitsReadingsUpdate",
+ sdbusplus::vtable::property_::none,
+ [this](const auto&) {
+ return reportActions.contains(ReportAction::emitsReadingsUpdate);
+ });
dbusIface->register_property_r<std::string>(
"Name", sdbusplus::vtable::property_::const_,
[this](const auto&) { return name; });
- dbusIface->register_property_r<bool>(
- "LogToMetricReportsCollection", sdbusplus::vtable::property_::const_,
- [this](const auto&) {
- return reportActions.contains(
- ReportAction::logToMetricReportsCollection);
- });
+ dbusIface->register_property_r<bool>("LogToMetricReportsCollection",
+ sdbusplus::vtable::property_::const_,
+ [this](const auto&) {
+ return reportActions.contains(
+ ReportAction::logToMetricReportsCollection);
+ });
dbusIface->register_property_rw<std::vector<std::string>>(
"ReportActions", sdbusplus::vtable::property_::emits_change,
[this](auto newVal, auto& oldVal) {
- auto tmp = utils::transform<std::unordered_set>(
- newVal, [](const auto& reportAction) {
- return utils::toReportAction(reportAction);
- });
- tmp.insert(ReportAction::logToMetricReportsCollection);
+ auto tmp = utils::transform<std::unordered_set>(
+ newVal, [](const auto& reportAction) {
+ return utils::toReportAction(reportAction);
+ });
+ tmp.insert(ReportAction::logToMetricReportsCollection);
- if (tmp != reportActions)
- {
- reportActions = tmp;
- persistency = storeConfiguration();
- oldVal = std::move(newVal);
- }
- return 1;
+ if (tmp != reportActions)
+ {
+ reportActions = tmp;
+ persistency = storeConfiguration();
+ oldVal = std::move(newVal);
+ }
+ return 1;
},
[this](const auto&) {
- return utils::transform<std::vector>(
- reportActions, [](const auto reportAction) {
- return utils::enumToString(reportAction);
- });
+ return utils::transform<std::vector>(reportActions,
+ [](const auto reportAction) {
+ return utils::enumToString(reportAction);
});
+ });
dbusIface->register_property_r<uint64_t>(
"AppendLimit", sdbusplus::vtable::property_::emits_change,
[this](const auto&) { return appendLimit; });
@@ -376,19 +373,19 @@
"ReportUpdates", std::string(),
sdbusplus::vtable::property_::emits_change,
[this](auto newVal, auto& oldVal) {
- setReportUpdates(utils::toReportUpdates(newVal));
- oldVal = newVal;
- return 1;
+ setReportUpdates(utils::toReportUpdates(newVal));
+ oldVal = newVal;
+ return 1;
},
[this](const auto&) { return utils::enumToString(reportUpdates); });
dbusIface->register_property_r(
"Triggers", std::vector<sdbusplus::message::object_path>{},
sdbusplus::vtable::property_::emits_change, [this](const auto&) {
- return utils::transform<std::vector>(
- triggerIds, [](const auto& triggerId) {
- return utils::pathAppend(utils::constants::triggerDirPath,
- triggerId);
- });
+ return utils::transform<std::vector>(triggerIds,
+ [](const auto& triggerId) {
+ return utils::pathAppend(utils::constants::triggerDirPath,
+ triggerId);
+ });
});
dbusIface->register_method("Update", [this] {
if (reportingType == ReportingType::onRequest)
@@ -515,17 +512,17 @@
data["Id"] = id;
data["Name"] = name;
data["ReportingType"] = utils::toUnderlying(reportingType);
- data["ReportActions"] =
- utils::transform(reportActions, [](const auto reportAction) {
- return utils::toUnderlying(reportAction);
- });
+ data["ReportActions"] = utils::transform(reportActions,
+ [](const auto reportAction) {
+ return utils::toUnderlying(reportAction);
+ });
data["Interval"] = interval.count();
data["AppendLimit"] = appendLimit;
data["ReportUpdates"] = utils::toUnderlying(reportUpdates);
- data["ReadingParameters"] =
- utils::transform(metrics, [](const auto& metric) {
- return metric->dumpConfiguration();
- });
+ data["ReadingParameters"] = utils::transform(metrics,
+ [](const auto& metric) {
+ return metric->dumpConfiguration();
+ });
if (shouldStoreMetricValues())
{
diff --git a/src/report.hpp b/src/report.hpp
index d3c88ec..be22c4f 100644
--- a/src/report.hpp
+++ b/src/report.hpp
@@ -32,8 +32,7 @@
class OnChangeContext
{
public:
- OnChangeContext(Report& report) : report(report)
- {}
+ OnChangeContext(Report& report) : report(report) {}
~OnChangeContext()
{
diff --git a/src/report_factory.cpp b/src/report_factory.cpp
index 8b150e1..d3a9bb0 100644
--- a/src/report_factory.cpp
+++ b/src/report_factory.cpp
@@ -58,9 +58,8 @@
{
auto existing = std::find_if(oldMetrics.begin(), oldMetrics.end(),
[labeledMetricParam](auto metric) {
- return labeledMetricParam ==
- metric->dumpConfiguration();
- });
+ return labeledMetricParam == metric->dumpConfiguration();
+ });
if (existing != oldMetrics.end())
{
@@ -152,8 +151,8 @@
{
auto it = std::find_if(tree.begin(), tree.end(),
[path = sensorPath](const auto& v) {
- return v.first == path;
- });
+ return v.first == path;
+ });
if (it != tree.end() && it->second.size() == 1)
{
diff --git a/src/report_manager.cpp b/src/report_manager.cpp
index d12e6aa..69a110c 100644
--- a/src/report_manager.cpp
+++ b/src/report_manager.cpp
@@ -44,118 +44,112 @@
loadFromPersistent();
reportManagerIface = objServer->add_unique_interface(
- reportManagerPath, reportManagerIfaceName, [this](auto& dbusIface) {
- dbusIface.register_property_r(
- "MaxReports", size_t{}, sdbusplus::vtable::property_::const_,
- [](const auto&) { return maxReports; });
- dbusIface.register_property_r(
- "MinInterval", uint64_t{}, sdbusplus::vtable::property_::const_,
- [](const auto&) -> uint64_t { return minInterval.count(); });
- dbusIface.register_property_r(
- "SupportedOperationTypes", std::vector<std::string>{},
- sdbusplus::vtable::property_::const_,
- [](const auto&) -> std::vector<std::string> {
- return utils::transform<std::vector>(
- utils::convDataOperationType, [](const auto& item) {
- return std::string(item.first);
- });
- });
+ reportManagerPath, reportManagerIfaceName,
+ [this](auto& dbusIface) {
+ dbusIface.register_property_r("MaxReports", size_t{},
+ sdbusplus::vtable::property_::const_,
+ [](const auto&) { return maxReports; });
+ dbusIface.register_property_r(
+ "MinInterval", uint64_t{}, sdbusplus::vtable::property_::const_,
+ [](const auto&) -> uint64_t { return minInterval.count(); });
+ dbusIface.register_property_r(
+ "SupportedOperationTypes", std::vector<std::string>{},
+ sdbusplus::vtable::property_::const_,
+ [](const auto&) -> std::vector<std::string> {
+ return utils::transform<std::vector>(
+ utils::convDataOperationType,
+ [](const auto& item) { return std::string(item.first); });
+ });
- dbusIface.register_method(
- "AddReport", [this](boost::asio::yield_context& yield,
- const std::string& reportId,
- const std::string& reportingType,
- const bool emitsReadingsUpdate,
- const bool logToMetricReportsCollection,
- const uint64_t interval,
- ReadingParametersPastVersion metricParams) {
- constexpr auto enabledDefault = true;
- constexpr ReportUpdates reportUpdatesDefault =
- ReportUpdates::overwrite;
+ dbusIface.register_method(
+ "AddReport",
+ [this](boost::asio::yield_context& yield,
+ const std::string& reportId,
+ const std::string& reportingType,
+ const bool emitsReadingsUpdate,
+ const bool logToMetricReportsCollection,
+ const uint64_t interval,
+ ReadingParametersPastVersion metricParams) {
+ constexpr auto enabledDefault = true;
+ constexpr ReportUpdates reportUpdatesDefault =
+ ReportUpdates::overwrite;
- std::vector<ReportAction> reportActions;
+ std::vector<ReportAction> reportActions;
- if (emitsReadingsUpdate)
- {
- reportActions.emplace_back(
- ReportAction::emitsReadingsUpdate);
- }
- if (logToMetricReportsCollection)
- {
- reportActions.emplace_back(
- ReportAction::logToMetricReportsCollection);
- }
+ if (emitsReadingsUpdate)
+ {
+ reportActions.emplace_back(ReportAction::emitsReadingsUpdate);
+ }
+ if (logToMetricReportsCollection)
+ {
+ reportActions.emplace_back(
+ ReportAction::logToMetricReportsCollection);
+ }
- return addReport(yield, reportId, reportId,
- utils::toReportingType(reportingType),
- reportActions, Milliseconds(interval),
- maxAppendLimit, reportUpdatesDefault,
- convertToReadingParameters(
- std::move(metricParams)),
- enabledDefault)
- .getPath();
- });
+ return addReport(
+ yield, reportId, reportId,
+ utils::toReportingType(reportingType), reportActions,
+ Milliseconds(interval), maxAppendLimit,
+ reportUpdatesDefault,
+ convertToReadingParameters(std::move(metricParams)),
+ enabledDefault)
+ .getPath();
+ });
- dbusIface.register_method(
- "AddReportFutureVersion",
- [this](
- boost::asio::yield_context& yield,
- const std::vector<
- std::pair<std::string, AddReportFutureVersionVariant>>&
- properties) {
- std::optional<std::string> reportId;
- std::optional<std::string> reportName;
- std::optional<std::string> reportingType;
- std::optional<std::vector<std::string>> reportActions;
- std::optional<uint64_t> interval;
- std::optional<uint64_t> appendLimit;
- std::optional<std::string> reportUpdates;
- std::optional<ReadingParameters> metricParams;
- std::optional<ReadingParameters> readingParameters;
- std::optional<bool> enabled;
+ dbusIface.register_method(
+ "AddReportFutureVersion",
+ [this](boost::asio::yield_context& yield,
+ const std::vector<
+ std::pair<std::string, AddReportFutureVersionVariant>>&
+ properties) {
+ std::optional<std::string> reportId;
+ std::optional<std::string> reportName;
+ std::optional<std::string> reportingType;
+ std::optional<std::vector<std::string>> reportActions;
+ std::optional<uint64_t> interval;
+ std::optional<uint64_t> appendLimit;
+ std::optional<std::string> reportUpdates;
+ std::optional<ReadingParameters> metricParams;
+ std::optional<ReadingParameters> readingParameters;
+ std::optional<bool> enabled;
- try
- {
- sdbusplus::unpackProperties(
- properties, "Id", reportId, "Name", reportName,
- "ReportingType", reportingType, "ReportActions",
- reportActions, "Interval", interval, "AppendLimit",
- appendLimit, "ReportUpdates", reportUpdates,
- "MetricParams", metricParams, "Enabled", enabled,
- "ReadingParameters", readingParameters);
- }
- catch (const sdbusplus::exception::UnpackPropertyError& e)
- {
- throw errors::InvalidArgument(e.propertyName);
- }
+ try
+ {
+ sdbusplus::unpackProperties(
+ properties, "Id", reportId, "Name", reportName,
+ "ReportingType", reportingType, "ReportActions",
+ reportActions, "Interval", interval, "AppendLimit",
+ appendLimit, "ReportUpdates", reportUpdates, "MetricParams",
+ metricParams, "Enabled", enabled, "ReadingParameters",
+ readingParameters);
+ }
+ catch (const sdbusplus::exception::UnpackPropertyError& e)
+ {
+ throw errors::InvalidArgument(e.propertyName);
+ }
- if (readingParameters == std::nullopt)
- {
- readingParameters = metricParams;
- }
+ if (readingParameters == std::nullopt)
+ {
+ readingParameters = metricParams;
+ }
- return addReport(
- yield, reportId.value_or(""),
- reportName.value_or(""),
- utils::toReportingType(
- reportingType.value_or(utils::enumToString(
- ReportingType::onRequest))),
- utils::transform(
- reportActions.value_or(
- std::vector<std::string>{}),
- [](const auto& reportAction) {
- return utils::toReportAction(
- reportAction);
- }),
- Milliseconds(interval.value_or(0)),
- appendLimit.value_or(maxAppendLimit),
- utils::toReportUpdates(
- reportUpdates.value_or(utils::enumToString(
- ReportUpdates::overwrite))),
- readingParameters.value_or(ReadingParameters{}),
- enabled.value_or(true))
- .getPath();
- });
+ return addReport(
+ yield, reportId.value_or(""), reportName.value_or(""),
+ utils::toReportingType(reportingType.value_or(
+ utils::enumToString(ReportingType::onRequest))),
+ utils::transform(
+ reportActions.value_or(std::vector<std::string>{}),
+ [](const auto& reportAction) {
+ return utils::toReportAction(reportAction);
+ }),
+ Milliseconds(interval.value_or(0)),
+ appendLimit.value_or(maxAppendLimit),
+ utils::toReportUpdates(reportUpdates.value_or(
+ utils::enumToString(ReportUpdates::overwrite))),
+ readingParameters.value_or(ReadingParameters{}),
+ enabled.value_or(true))
+ .getPath();
+ });
});
}
@@ -240,8 +234,8 @@
const uint64_t appendLimit, const ReportUpdates reportUpdates,
ReadingParameters metricParams, const bool enabled)
{
- auto labeledMetricParams =
- reportFactory->convertMetricParams(yield, metricParams);
+ auto labeledMetricParams = reportFactory->convertMetricParams(yield,
+ metricParams);
return addReport(reportId, reportName, reportingType, reportActions,
interval, appendLimit, reportUpdates,
@@ -295,7 +289,7 @@
std::vector<ReportAction> reportActions = utils::transform(
data->at("ReportActions").get<std::vector<uint32_t>>(),
[](const auto reportAction) {
- return utils::toReportAction(reportAction);
+ return utils::toReportAction(reportAction);
});
uint64_t interval = data->at("Interval").get<uint64_t>();
uint64_t appendLimit = data->at("AppendLimit").get<uint64_t>();
diff --git a/src/sensor.cpp b/src/sensor.cpp
index ce25a86..efebc5d 100644
--- a/src/sensor.cpp
+++ b/src/sensor.cpp
@@ -49,18 +49,18 @@
"xyz.openbmc_project.Sensor.Value", "Value",
[lock, id = sensorId, weakSelf = weak_from_this()](
boost::system::error_code ec, double newValue) {
- if (ec)
- {
- phosphor::logging::log<phosphor::logging::level::WARNING>(
- "DBus 'GetProperty' call failed on Sensor Value",
- phosphor::logging::entry("SENSOR_PATH=%s", id.path.c_str()),
- phosphor::logging::entry("ERROR_CODE=%d", ec.value()));
- return;
- }
- if (auto self = weakSelf.lock())
- {
- self->updateValue(newValue);
- }
+ if (ec)
+ {
+ phosphor::logging::log<phosphor::logging::level::WARNING>(
+ "DBus 'GetProperty' call failed on Sensor Value",
+ phosphor::logging::entry("SENSOR_PATH=%s", id.path.c_str()),
+ phosphor::logging::entry("ERROR_CODE=%d", ec.value()));
+ return;
+ }
+ if (auto self = weakSelf.lock())
+ {
+ self->updateValue(newValue);
+ }
});
}
@@ -96,8 +96,8 @@
std::remove_if(
listeners.begin(), listeners.end(),
[listenerToUnregister = listener.get()](const auto& listener) {
- return (listener.expired() ||
- listener.lock().get() == listenerToUnregister);
+ return (listener.expired() ||
+ listener.lock().get() == listenerToUnregister);
}),
listeners.end());
}
@@ -137,7 +137,7 @@
signalMonitor = std::make_unique<sdbusplus::bus::match_t>(
*bus, param,
[weakSelf = weak_from_this()](sdbusplus::message_t& message) {
- signalProc(weakSelf, message);
+ signalProc(weakSelf, message);
});
}
diff --git a/src/state.hpp b/src/state.hpp
index 91a7daf..fedc8c5 100644
--- a/src/state.hpp
+++ b/src/state.hpp
@@ -23,8 +23,7 @@
class State
{
public:
- explicit State(Object& object) : object(object)
- {}
+ explicit State(Object& object) : object(object) {}
template <Flags... Indexes>
StateEvent set(boolean auto... values)
diff --git a/src/trigger.cpp b/src/trigger.cpp
index ff08638..a167d3c 100644
--- a/src/trigger.cpp
+++ b/src/trigger.cpp
@@ -52,20 +52,20 @@
"Persistent", persistent,
sdbusplus::vtable::property_::emits_change,
[this](bool newVal, const auto&) {
- if (newVal == persistent)
- {
- return 1;
- }
- if (newVal)
- {
- persistent = storeConfiguration();
- }
- else
- {
- triggerStorage.remove(fileName);
- persistent = false;
- }
- return 1;
+ if (newVal == persistent)
+ {
+ return 1;
+ }
+ if (newVal)
+ {
+ persistent = storeConfiguration();
+ }
+ else
+ {
+ triggerStorage.remove(fileName);
+ persistent = false;
+ }
+ return 1;
},
[this](const auto&) { return persistent; });
@@ -73,60 +73,57 @@
"Thresholds", TriggerThresholdParams{},
sdbusplus::vtable::property_::emits_change,
[this, &triggerFactory](auto newVal, auto& oldVal) {
- auto newThresholdParams = std::visit(
- utils::ToLabeledThresholdParamConversion(), newVal);
- TriggerManager::verifyThresholdParams(newThresholdParams);
- triggerFactory.updateThresholds(
- thresholds, *id, triggerActions, reportIds, sensors,
- newThresholdParams);
- oldVal = std::move(newVal);
- return 1;
+ auto newThresholdParams =
+ std::visit(utils::ToLabeledThresholdParamConversion(), newVal);
+ TriggerManager::verifyThresholdParams(newThresholdParams);
+ triggerFactory.updateThresholds(thresholds, *id, triggerActions,
+ reportIds, sensors,
+ newThresholdParams);
+ oldVal = std::move(newVal);
+ return 1;
},
[this](const auto&) {
- return fromLabeledThresholdParam(getLabeledThresholds());
- });
+ return fromLabeledThresholdParam(getLabeledThresholds());
+ });
dbusIface.register_property_rw(
"Sensors", SensorsInfo{},
sdbusplus::vtable::property_::emits_change,
[this, &triggerFactory](auto newVal, auto& oldVal) {
- auto labeledSensorInfo =
- triggerFactory.getLabeledSensorsInfo(newVal);
- triggerFactory.updateSensors(sensors, labeledSensorInfo);
- for (const auto& threshold : thresholds)
- {
- threshold->updateSensors(sensors);
- }
- oldVal = std::move(newVal);
- return 1;
+ auto labeledSensorInfo =
+ triggerFactory.getLabeledSensorsInfo(newVal);
+ triggerFactory.updateSensors(sensors, labeledSensorInfo);
+ for (const auto& threshold : thresholds)
+ {
+ threshold->updateSensors(sensors);
+ }
+ oldVal = std::move(newVal);
+ return 1;
},
[this](const auto&) {
- return utils::fromLabeledSensorsInfo(
- getLabeledSensorInfo());
- });
+ return utils::fromLabeledSensorsInfo(getLabeledSensorInfo());
+ });
dbusIface.register_property_rw(
"Reports", std::vector<sdbusplus::message::object_path>(),
sdbusplus::vtable::property_::emits_change,
[this](auto newVal, auto& oldVal) {
- auto newReportIds = utils::transform<std::vector>(
- newVal, [](const auto& path) {
- return utils::reportPathToId(path);
- });
- TriggerManager::verifyReportIds(newReportIds);
- *reportIds = newReportIds;
- messanger.send(messages::TriggerPresenceChangedInd{
- messages::Presence::Exist, *id, *reportIds});
- oldVal = std::move(newVal);
- return 1;
+ auto newReportIds = utils::transform<std::vector>(
+ newVal,
+ [](const auto& path) { return utils::reportPathToId(path); });
+ TriggerManager::verifyReportIds(newReportIds);
+ *reportIds = newReportIds;
+ messanger.send(messages::TriggerPresenceChangedInd{
+ messages::Presence::Exist, *id, *reportIds});
+ oldVal = std::move(newVal);
+ return 1;
},
[this](const auto&) {
- return utils::transform<std::vector>(
- *reportIds, [](const auto& id) {
- return utils::pathAppend(
- utils::constants::reportDirPath, id);
- });
- });
+ return utils::transform<std::vector>(*reportIds,
+ [](const auto& id) {
+ return utils::pathAppend(utils::constants::reportDirPath, id);
+ });
+ });
dbusIface.register_property_r(
"Discrete", isDiscreate(), sdbusplus::vtable::property_::const_,
@@ -135,24 +132,23 @@
dbusIface.register_property_rw(
"Name", name, sdbusplus::vtable::property_::emits_change,
[this](auto newVal, auto& oldVal) {
- if (newVal.length() > utils::constants::maxIdNameLength)
- {
- throw errors::InvalidArgument("Name",
- "Name is too long.");
- }
- name = oldVal = newVal;
- return 1;
+ if (newVal.length() > utils::constants::maxIdNameLength)
+ {
+ throw errors::InvalidArgument("Name", "Name is too long.");
+ }
+ name = oldVal = newVal;
+ return 1;
},
[this](const auto&) { return name; });
- dbusIface.register_property_r(
- "TriggerActions", std::vector<std::string>(),
- sdbusplus::vtable::property_::const_, [this](const auto&) {
- return utils::transform(triggerActions,
- [](const auto& action) {
- return actionToString(action);
- });
- });
+ dbusIface.register_property_r("TriggerActions",
+ std::vector<std::string>(),
+ sdbusplus::vtable::property_::const_,
+ [this](const auto&) {
+ return utils::transform(triggerActions, [](const auto& action) {
+ return actionToString(action);
+ });
+ });
});
for (const auto& threshold : thresholds)
@@ -162,11 +158,11 @@
messanger.on_receive<messages::CollectTriggerIdReq>(
[this](const auto& msg) {
- if (utils::contains(*reportIds, msg.reportId))
- {
- messanger.send(messages::CollectTriggerIdResp{*id});
- }
- });
+ if (utils::contains(*reportIds, msg.reportId))
+ {
+ messanger.send(messages::CollectTriggerIdResp{*id});
+ }
+ });
messanger.send(messages::TriggerPresenceChangedInd{
messages::Presence::Exist, *id, *reportIds});
@@ -186,10 +182,10 @@
data["Id"] = *id;
data["Name"] = name;
data["ThresholdParamsDiscriminator"] = labeledThresholdParams.index();
- data["TriggerActions"] =
- utils::transform(triggerActions, [](const auto& action) {
- return actionToString(action);
- });
+ data["TriggerActions"] = utils::transform(triggerActions,
+ [](const auto& action) {
+ return actionToString(action);
+ });
data["ThresholdParams"] =
utils::labeledThresholdParamsToJson(labeledThresholdParams);
data["ReportIds"] = *reportIds;
diff --git a/src/trigger_actions.hpp b/src/trigger_actions.hpp
index a74cc7a..14f6294 100644
--- a/src/trigger_actions.hpp
+++ b/src/trigger_actions.hpp
@@ -68,8 +68,7 @@
class LogToJournal : public interfaces::TriggerAction
{
public:
- explicit LogToJournal(::discrete::Severity severity) : severity(severity)
- {}
+ explicit LogToJournal(::discrete::Severity severity) : severity(severity) {}
void commit(const std::string& triggerId, const ThresholdName thresholdName,
const std::string& sensorName, const Milliseconds timestamp,
@@ -107,8 +106,7 @@
class LogToJournal : public interfaces::TriggerAction
{
public:
- LogToJournal()
- {}
+ LogToJournal() {}
void commit(const std::string& triggerId, const ThresholdName thresholdName,
const std::string& sensorName, const Milliseconds timestamp,
@@ -118,8 +116,7 @@
class LogToRedfishEventLog : public interfaces::TriggerAction
{
public:
- LogToRedfishEventLog()
- {}
+ LogToRedfishEventLog() {}
void commit(const std::string& triggerId, const ThresholdName thresholdName,
const std::string& sensorName, const Milliseconds timestamp,
diff --git a/src/trigger_factory.cpp b/src/trigger_factory.cpp
index 615d42d..9ac8f49 100644
--- a/src/trigger_factory.cpp
+++ b/src/trigger_factory.cpp
@@ -223,10 +223,10 @@
const std::vector<LabeledSensorInfo>& labeledSensorsInfo) const
{
const auto& sensors = getSensors(labeledSensorsInfo);
- auto triggerActions =
- utils::transform(triggerActionsIn, [](const auto& triggerActionStr) {
- return toTriggerAction(triggerActionStr);
- });
+ auto triggerActions = utils::transform(triggerActionsIn,
+ [](const auto& triggerActionStr) {
+ return toTriggerAction(triggerActionStr);
+ });
std::vector<std::shared_ptr<interfaces::Threshold>> thresholds;
auto id = std::make_unique<const std::string>(idIn);
@@ -260,9 +260,8 @@
{
auto existing = std::find_if(oldSensors.begin(), oldSensors.end(),
[labeledSensorInfo](auto sensor) {
- return labeledSensorInfo ==
- sensor->getLabeledSensorInfo();
- });
+ return labeledSensorInfo == sensor->getLabeledSensorInfo();
+ });
if (existing != oldSensors.end())
{
@@ -311,9 +310,10 @@
{
return utils::transform(sensorsInfo, [&tree](const auto& item) {
const auto& [sensorPath, metadata] = item;
- auto found = std::find_if(
- tree.begin(), tree.end(),
- [path = sensorPath](const auto& x) { return x.first == path; });
+ auto found = std::find_if(tree.begin(), tree.end(),
+ [path = sensorPath](const auto& x) {
+ return x.first == path;
+ });
if (tree.end() != found)
{
diff --git a/src/trigger_manager.cpp b/src/trigger_manager.cpp
index fc6bbcd..984b434 100644
--- a/src/trigger_manager.cpp
+++ b/src/trigger_manager.cpp
@@ -21,36 +21,33 @@
{
loadFromPersistent();
- managerIface = objServer->add_unique_interface(
- triggerManagerPath, triggerManagerIfaceName, [this](auto& iface) {
- iface.register_method(
- "AddTrigger",
- [this](
- boost::asio::yield_context& yield, const std::string& id,
- const std::string& name,
- const std::vector<std::string>& triggerActions,
- const SensorsInfo& sensors,
- const std::vector<sdbusplus::message::object_path>& reports,
- const TriggerThresholdParamsExt& thresholds) {
- LabeledTriggerThresholdParams
- labeledTriggerThresholdParams = std::visit(
- utils::ToLabeledThresholdParamConversion(),
- thresholds);
+ managerIface = objServer->add_unique_interface(triggerManagerPath,
+ triggerManagerIfaceName,
+ [this](auto& iface) {
+ iface.register_method(
+ "AddTrigger",
+ [this](boost::asio::yield_context& yield, const std::string& id,
+ const std::string& name,
+ const std::vector<std::string>& triggerActions,
+ const SensorsInfo& sensors,
+ const std::vector<sdbusplus::message::object_path>& reports,
+ const TriggerThresholdParamsExt& thresholds) {
+ LabeledTriggerThresholdParams labeledTriggerThresholdParams =
+ std::visit(utils::ToLabeledThresholdParamConversion(),
+ thresholds);
- std::vector<LabeledSensorInfo> labeledSensorsInfo =
- triggerFactory->getLabeledSensorsInfo(yield, sensors);
+ std::vector<LabeledSensorInfo> labeledSensorsInfo =
+ triggerFactory->getLabeledSensorsInfo(yield, sensors);
- auto reportIds = utils::transform<std::vector>(
- reports, [](const auto& item) {
- return utils::reportPathToId(item);
- });
+ auto reportIds = utils::transform<std::vector>(
+ reports,
+ [](const auto& item) { return utils::reportPathToId(item); });
- return addTrigger(id, name, triggerActions,
- labeledSensorsInfo, reportIds,
- labeledTriggerThresholdParams)
- .getPath();
- });
- });
+ return addTrigger(id, name, triggerActions, labeledSensorsInfo,
+ reportIds, labeledTriggerThresholdParams)
+ .getPath();
+ });
+ });
}
void TriggerManager::removeTrigger(const interfaces::Trigger* trigger)
diff --git a/src/types/error_type.hpp b/src/types/error_type.hpp
index 00e9bb1..ae2dd4b 100644
--- a/src/types/error_type.hpp
+++ b/src/types/error_type.hpp
@@ -23,9 +23,9 @@
static constexpr auto propertyName = ConstexprString{"ErrorType"};
};
-constexpr auto convDataErrorType =
- std::array{std::make_pair<std::string_view, ErrorType>(
- "PropertyConflict", ErrorType::propertyConflict)};
+constexpr auto convDataErrorType = std::array{
+ std::make_pair<std::string_view, ErrorType>("PropertyConflict",
+ ErrorType::propertyConflict)};
inline ErrorType toErrorType(std::underlying_type_t<ErrorType> value)
{
diff --git a/src/types/readings.cpp b/src/types/readings.cpp
index 2f6246b..5782158 100644
--- a/src/types/readings.cpp
+++ b/src/types/readings.cpp
@@ -9,11 +9,11 @@
LabeledReadings toLabeledReadings(const Readings& readings)
{
- return LabeledReadings{
- std::get<0>(readings),
- utils::transform(std::get<1>(readings), [](const auto& readingData) {
- return LabeledReadingData{readingData};
- })};
+ return LabeledReadings{std::get<0>(readings),
+ utils::transform(std::get<1>(readings),
+ [](const auto& readingData) {
+ return LabeledReadingData{readingData};
+ })};
}
Readings toReadings(const LabeledReadings& labeledReadings)
@@ -21,8 +21,8 @@
return Readings{labeledReadings.at_label<ts::Timestamp>(),
utils::transform(labeledReadings.at_label<ts::Readings>(),
[](const auto& labeledReadingData) {
- return labeledReadingData.to_tuple();
- })};
+ return labeledReadingData.to_tuple();
+ })};
}
} // namespace utils
diff --git a/src/types/report_types.cpp b/src/types/report_types.cpp
index 72bce4b..4fb0b4e 100644
--- a/src/types/report_types.cpp
+++ b/src/types/report_types.cpp
@@ -7,21 +7,20 @@
{
namespace ts = utils::tstring;
- return utils::transform(
- labeled, [](const LabeledMetricParameters& metricParams) {
- return ReadingParameters::value_type(
- utils::transform(
- metricParams.at_label<ts::SensorPath>(),
- [](const LabeledSensorInfo& sensorParameters) {
- return std::tuple<sdbusplus::message::object_path,
- std::string>(
- sensorParameters.at_label<ts::Path>(),
- sensorParameters.at_label<ts::Metadata>());
- }),
- utils::enumToString(metricParams.at_label<ts::OperationType>()),
- metricParams.at_label<ts::Id>(),
- utils::enumToString(
- metricParams.at_label<ts::CollectionTimeScope>()),
- metricParams.at_label<ts::CollectionDuration>().t.count());
- });
+ return utils::transform(labeled,
+ [](const LabeledMetricParameters& metricParams) {
+ return ReadingParameters::value_type(
+ utils::transform(
+ metricParams.at_label<ts::SensorPath>(),
+ [](const LabeledSensorInfo& sensorParameters) {
+ return std::tuple<sdbusplus::message::object_path, std::string>(
+ sensorParameters.at_label<ts::Path>(),
+ sensorParameters.at_label<ts::Metadata>());
+ }),
+ utils::enumToString(metricParams.at_label<ts::OperationType>()),
+ metricParams.at_label<ts::Id>(),
+ utils::enumToString(
+ metricParams.at_label<ts::CollectionTimeScope>()),
+ metricParams.at_label<ts::CollectionDuration>().t.count());
+ });
}
diff --git a/src/types/report_updates.hpp b/src/types/report_updates.hpp
index 8313a94..a3dfe81 100644
--- a/src/types/report_updates.hpp
+++ b/src/types/report_updates.hpp
@@ -25,13 +25,13 @@
static constexpr auto propertyName = ConstexprString{"ReportUpdates"};
};
-constexpr auto convDataReportUpdates =
- std::array{std::make_pair<std::string_view, ReportUpdates>(
- "Overwrite", ReportUpdates::overwrite),
- std::make_pair<std::string_view, ReportUpdates>(
- "AppendStopsWhenFull", ReportUpdates::appendStopsWhenFull),
- std::make_pair<std::string_view, ReportUpdates>(
- "AppendWrapsWhenFull", ReportUpdates::appendWrapsWhenFull)};
+constexpr auto convDataReportUpdates = std::array{
+ std::make_pair<std::string_view, ReportUpdates>("Overwrite",
+ ReportUpdates::overwrite),
+ std::make_pair<std::string_view, ReportUpdates>(
+ "AppendStopsWhenFull", ReportUpdates::appendStopsWhenFull),
+ std::make_pair<std::string_view, ReportUpdates>(
+ "AppendWrapsWhenFull", ReportUpdates::appendWrapsWhenFull)};
inline ReportUpdates
toReportUpdates(std::underlying_type_t<ReportUpdates> value)
diff --git a/src/utils/conversion.hpp b/src/utils/conversion.hpp
index e92249a..f528044 100644
--- a/src/utils/conversion.hpp
+++ b/src/utils/conversion.hpp
@@ -90,9 +90,10 @@
inline T toEnum(const std::array<std::pair<std::string_view, T>, N>& data,
const std::string& value)
{
- auto it = std::find_if(
- std::begin(data), std::end(data),
- [&value](const auto& item) { return item.first == value; });
+ auto it = std::find_if(std::begin(data), std::end(data),
+ [&value](const auto& item) {
+ return item.first == value;
+ });
if (it == std::end(data))
{
throwConversionError(EnumTraits<T>::propertyName);
@@ -105,9 +106,10 @@
enumToString(const std::array<std::pair<std::string_view, T>, N>& data,
T value)
{
- auto it = std::find_if(
- std::begin(data), std::end(data),
- [value](const auto& item) { return item.second == value; });
+ auto it = std::find_if(std::begin(data), std::end(data),
+ [value](const auto& item) {
+ return item.second == value;
+ });
if (it == std::end(data))
{
throwConversionError(EnumTraits<T>::propertyName);
diff --git a/src/utils/conversion_trigger.cpp b/src/utils/conversion_trigger.cpp
index d65eae9..a8417e5 100644
--- a/src/utils/conversion_trigger.cpp
+++ b/src/utils/conversion_trigger.cpp
@@ -21,8 +21,8 @@
const std::vector<numeric::ThresholdParam>& arg) const
{
return utils::transform(arg, [](const auto& thresholdParam) {
- const auto& [type, dwellTime, direction, thresholdValue] =
- thresholdParam;
+ const auto& [type, dwellTime, direction,
+ thresholdValue] = thresholdParam;
return numeric::LabeledThresholdParam(numeric::toType(type), dwellTime,
numeric::toDirection(direction),
thresholdValue);
@@ -33,8 +33,8 @@
const std::vector<discrete::ThresholdParam>& arg) const
{
return utils::transform(arg, [](const auto& thresholdParam) {
- const auto& [userId, severity, dwellTime, thresholdValue] =
- thresholdParam;
+ const auto& [userId, severity, dwellTime,
+ thresholdValue] = thresholdParam;
return discrete::LabeledThresholdParam(
userId, discrete::toSeverity(severity), dwellTime, thresholdValue);
});
@@ -44,14 +44,14 @@
const std::vector<numeric::LabeledThresholdParam>& arg) const
{
return utils::transform(
- arg, [](const numeric::LabeledThresholdParam& labeledThresholdParam) {
- return numeric::ThresholdParam(
- numeric::typeToString(
- labeledThresholdParam.at_label<ts::Type>()),
- labeledThresholdParam.at_label<ts::DwellTime>(),
- numeric::directionToString(
- labeledThresholdParam.at_label<ts::Direction>()),
- labeledThresholdParam.at_label<ts::ThresholdValue>());
+ arg,
+ [](const numeric::LabeledThresholdParam& labeledThresholdParam) {
+ return numeric::ThresholdParam(
+ numeric::typeToString(labeledThresholdParam.at_label<ts::Type>()),
+ labeledThresholdParam.at_label<ts::DwellTime>(),
+ numeric::directionToString(
+ labeledThresholdParam.at_label<ts::Direction>()),
+ labeledThresholdParam.at_label<ts::ThresholdValue>());
});
}
diff --git a/src/utils/conversion_trigger.hpp b/src/utils/conversion_trigger.hpp
index 8719df2..10b0c03 100644
--- a/src/utils/conversion_trigger.hpp
+++ b/src/utils/conversion_trigger.hpp
@@ -45,8 +45,8 @@
inline constexpr bool is_variant_v = is_variant<T>::value;
template <typename AlternativeT, typename VariantT>
- requires is_variant_v<VariantT> bool
-isFirstElementOfType(const std::vector<VariantT>& collection)
+ requires is_variant_v<VariantT>
+bool isFirstElementOfType(const std::vector<VariantT>& collection)
{
if (collection.empty())
{
diff --git a/src/utils/ensure.hpp b/src/utils/ensure.hpp
index 8c4fc99..8b7567e 100644
--- a/src/utils/ensure.hpp
+++ b/src/utils/ensure.hpp
@@ -15,8 +15,7 @@
Ensure(U&& functor) : functor(std::forward<U>(functor))
{}
- Ensure(F functor) : functor(std::move(functor))
- {}
+ Ensure(F functor) : functor(std::move(functor)) {}
Ensure(Ensure&& other) = delete;
Ensure(const Ensure&) = delete;
diff --git a/src/utils/labeled_tuple.hpp b/src/utils/labeled_tuple.hpp
index c4120c9..b320c3b 100644
--- a/src/utils/labeled_tuple.hpp
+++ b/src/utils/labeled_tuple.hpp
@@ -151,10 +151,8 @@
LabeledTuple(const LabeledTuple&) = default;
LabeledTuple(LabeledTuple&&) = default;
- explicit LabeledTuple(tuple_type v) : value(std::move(v))
- {}
- LabeledTuple(Args... args) : value(std::move(args)...)
- {}
+ explicit LabeledTuple(tuple_type v) : value(std::move(v)) {}
+ LabeledTuple(Args... args) : value(std::move(args)...) {}
LabeledTuple& operator=(const LabeledTuple&) = default;
LabeledTuple& operator=(LabeledTuple&&) = default;
@@ -209,11 +207,9 @@
{
return std::apply(
[&](auto&&... x) {
- return std::apply(
- [&](auto&&... y) {
- return (true && ... && detail::eq(x, y));
- },
- value);
+ return std::apply(
+ [&](auto&&... y) { return (true && ... && detail::eq(x, y)); },
+ value);
},
other.value);
}
diff --git a/src/utils/make_id_name.cpp b/src/utils/make_id_name.cpp
index 1390dad..1148622 100644
--- a/src/utils/make_id_name.cpp
+++ b/src/utils/make_id_name.cpp
@@ -49,19 +49,17 @@
{
strippedId = defaultName;
}
- strippedId.erase(
- std::remove_if(
- strippedId.begin(), strippedId.end(),
- [](char c) {
- return c == '/' ||
- utils::constants::allowedCharactersInPath.find(c) ==
- std::string_view::npos;
- }),
- strippedId.end());
+ strippedId.erase(std::remove_if(
+ strippedId.begin(), strippedId.end(),
+ [](char c) {
+ return c == '/' || utils::constants::allowedCharactersInPath.find(c) ==
+ std::string_view::npos;
+ }),
+ strippedId.end());
size_t idx = 0;
- std::string tmpId =
- prefixes + strippedId.substr(0, constants::maxIdNameLength);
+ std::string tmpId = prefixes +
+ strippedId.substr(0, constants::maxIdNameLength);
while (std::find(conflictIds.begin(), conflictIds.end(), tmpId) !=
conflictIds.end())
diff --git a/src/utils/messanger_service.cpp b/src/utils/messanger_service.cpp
index e04de34..25f154c 100644
--- a/src/utils/messanger_service.cpp
+++ b/src/utils/messanger_service.cpp
@@ -16,11 +16,11 @@
void MessangerService::destroy(MessangerService::Context& context)
{
- contexts_.erase(std::remove_if(contexts_.begin(), contexts_.end(),
- [&context](const auto& item) {
- return item.get() == &context;
- }),
- contexts_.end());
+ contexts_.erase(
+ std::remove_if(
+ contexts_.begin(), contexts_.end(),
+ [&context](const auto& item) { return item.get() == &context; }),
+ contexts_.end());
}
boost::asio::execution_context::id MessangerService::id = {};
diff --git a/src/utils/messanger_service.hpp b/src/utils/messanger_service.hpp
index 86dd2ff..f79bcc7 100644
--- a/src/utils/messanger_service.hpp
+++ b/src/utils/messanger_service.hpp
@@ -20,8 +20,7 @@
MessangerService(boost::asio::execution_context& execution_context);
~MessangerService() = default;
- void shutdown()
- {}
+ void shutdown() {}
Context& create();
void destroy(Context& context);
diff --git a/src/utils/threshold_operations.hpp b/src/utils/threshold_operations.hpp
index 99ae4a5..42d469e 100644
--- a/src/utils/threshold_operations.hpp
+++ b/src/utils/threshold_operations.hpp
@@ -22,10 +22,11 @@
getDetails(ThresholdType* thresholdPtr,
const interfaces::Sensor& sensor)
{
- auto it = std::find_if(
- thresholdPtr->sensorDetails.begin(),
- thresholdPtr->sensorDetails.end(),
- [&sensor](const auto& x) { return &sensor == x.first.get(); });
+ auto it = std::find_if(thresholdPtr->sensorDetails.begin(),
+ thresholdPtr->sensorDetails.end(),
+ [&sensor](const auto& x) {
+ return &sensor == x.first.get();
+ });
return *it->second;
}