presence: Complete current rpolicy type functions
Fill in the necessary function to return the associated policy
access pointer for the anyof and fallback presence sensor redundancy
policies..
Tested:
Anyof policy correctly followed on presence detection
Fallback policy correctly followed on presence detection
Change-Id: I7c503dda2ed74ddcdb25d1c54e3ab7308777914a
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/presence/json_config.cpp b/presence/json_config.cpp
index 44a3075..4c4db11 100644
--- a/presence/json_config.cpp
+++ b/presence/json_config.cpp
@@ -244,13 +244,28 @@
// Get an `Anyof` redundancy policy for the fan
std::unique_ptr<RedundancyPolicy> getAnyof(const fanPolicy& fan)
{
- return nullptr;
+ std::vector<std::reference_wrapper<PresenceSensor>> pSensors;
+ for (auto& fanSensor : std::get<fanPolicySensorListPos>(fan))
+ {
+ pSensors.emplace_back(*fanSensor);
+ }
+
+ return std::make_unique<AnyOf>(
+ std::get<fanPolicyFanPos>(fan), pSensors);
}
// Get a `Fallback` redundancy policy for the fan
std::unique_ptr<RedundancyPolicy> getFallback(const fanPolicy& fan)
{
- return nullptr;
+ std::vector<std::reference_wrapper<PresenceSensor>> pSensors;
+ for (auto& fanSensor : std::get<fanPolicySensorListPos>(fan))
+ {
+ // Place in the order given to fallback correctly
+ pSensors.emplace_back(*fanSensor);
+ }
+
+ return std::make_unique<Fallback>(
+ std::get<fanPolicyFanPos>(fan), pSensors);
}
} // namespace policy