Minor refactoring in thresholds
No functional changes
Tested:
- All unit tests are passing
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I96360276cc7e7797a9e90a577804e94014e0bd91
diff --git a/src/discrete_threshold.cpp b/src/discrete_threshold.cpp
index ba915b1..2acb2bf 100644
--- a/src/discrete_threshold.cpp
+++ b/src/discrete_threshold.cpp
@@ -26,18 +26,18 @@
void DiscreteThreshold::initialize()
{
- ThresholdOperations().initialize(this);
+ ThresholdOperations::initialize(this);
}
void DiscreteThreshold::updateSensors(Sensors newSensors)
{
- ThresholdOperations().updateSensors(this, std::move(newSensors));
+ ThresholdOperations::updateSensors(this, std::move(newSensors));
}
DiscreteThreshold::ThresholdDetail&
DiscreteThreshold::getDetails(const interfaces::Sensor& sensor)
{
- return ThresholdOperations().getDetails(this, sensor);
+ return ThresholdOperations::getDetails(this, sensor);
}
std::shared_ptr<DiscreteThreshold::ThresholdDetail>
diff --git a/src/discrete_threshold.hpp b/src/discrete_threshold.hpp
index a471027..48510de 100644
--- a/src/discrete_threshold.hpp
+++ b/src/discrete_threshold.hpp
@@ -60,6 +60,8 @@
sensorName(name),
dwell(dwell), timer(ioc)
{}
+ ThresholdDetail(const ThresholdDetail&) = delete;
+ ThresholdDetail(ThresholdDetail&&) = delete;
};
using SensorDetails =
std::unordered_map<std::shared_ptr<interfaces::Sensor>,
diff --git a/src/numeric_threshold.cpp b/src/numeric_threshold.cpp
index 9bda509..24683a2 100644
--- a/src/numeric_threshold.cpp
+++ b/src/numeric_threshold.cpp
@@ -22,18 +22,18 @@
void NumericThreshold::initialize()
{
- ThresholdOperations().initialize(this);
+ ThresholdOperations::initialize(this);
}
void NumericThreshold::updateSensors(Sensors newSensors)
{
- ThresholdOperations().updateSensors(this, std::move(newSensors));
+ ThresholdOperations::updateSensors(this, std::move(newSensors));
}
NumericThreshold::ThresholdDetail&
NumericThreshold::getDetails(const interfaces::Sensor& sensor)
{
- return ThresholdOperations().getDetails(this, sensor);
+ return ThresholdOperations::getDetails(this, sensor);
}
std::shared_ptr<NumericThreshold::ThresholdDetail>
diff --git a/src/numeric_threshold.hpp b/src/numeric_threshold.hpp
index d70729a..4e47721 100644
--- a/src/numeric_threshold.hpp
+++ b/src/numeric_threshold.hpp
@@ -29,8 +29,8 @@
Milliseconds dwellTime, numeric::Direction direction,
double thresholdValue, numeric::Type type,
std::unique_ptr<interfaces::Clock> clock);
- ~NumericThreshold()
- {}
+ NumericThreshold(const NumericThreshold&) = delete;
+ NumericThreshold(NumericThreshold&&) = delete;
void initialize() override;
void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override;
@@ -60,6 +60,8 @@
sensorName(name),
prevValue(prevValue), dwell(dwell), timer(ioc)
{}
+ ThresholdDetail(const ThresholdDetail&) = delete;
+ ThresholdDetail(ThresholdDetail&&) = delete;
};
using SensorDetails =
std::unordered_map<std::shared_ptr<interfaces::Sensor>,
diff --git a/src/on_change_threshold.hpp b/src/on_change_threshold.hpp
index a19a86f..91a595f 100644
--- a/src/on_change_threshold.hpp
+++ b/src/on_change_threshold.hpp
@@ -23,8 +23,8 @@
const std::string& triggerId, Sensors sensors,
std::vector<std::unique_ptr<interfaces::TriggerAction>> actions,
std::unique_ptr<interfaces::Clock> clock);
- ~OnChangeThreshold()
- {}
+ OnChangeThreshold(const OnChangeThreshold&) = delete;
+ OnChangeThreshold(OnChangeThreshold&&) = delete;
void initialize() override;
void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override;
diff --git a/src/utils/threshold_operations.hpp b/src/utils/threshold_operations.hpp
index 04b0195..99ae4a5 100644
--- a/src/utils/threshold_operations.hpp
+++ b/src/utils/threshold_operations.hpp
@@ -7,7 +7,7 @@
struct ThresholdOperations
{
template <typename ThresholdType>
- void initialize(ThresholdType* thresholdPtr)
+ static void initialize(ThresholdType* thresholdPtr)
{
for ([[maybe_unused]] auto& [sensor, detail] :
thresholdPtr->sensorDetails)
@@ -18,7 +18,7 @@
}
template <typename ThresholdType>
- typename ThresholdType::ThresholdDetail&
+ static typename ThresholdType::ThresholdDetail&
getDetails(ThresholdType* thresholdPtr,
const interfaces::Sensor& sensor)
{
@@ -30,7 +30,7 @@
}
template <typename ThresholdType>
- void updateSensors(ThresholdType* thresholdPtr, Sensors newSensors)
+ static void updateSensors(ThresholdType* thresholdPtr, Sensors newSensors)
{
typename ThresholdType::SensorDetails newSensorDetails;
typename ThresholdType::SensorDetails oldSensorDetails =