Refactor PropertiesChanged handler setup
Most sensor daemons had pretty much the same duplicated open-coded
pattern for setting up PropertiesChanged signal matches; introduce a
helper function to reduce the duplication and make things more readable.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I803a21eea2f6d7fc71b50d54bb8fd57a104f3349
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index 2745c08..fcf55d2 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -458,11 +458,9 @@
}
};
- auto eventMatch = std::make_unique<sdbusplus::bus::match_t>(
- static_cast<sdbusplus::bus_t&>(*systemBus),
- "type='signal',member='PropertiesChanged',path_namespace='" +
- std::string(inventoryPath) + "',arg0namespace='" + sensorType + "'",
- eventHandler);
+ std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
+ setupPropertiesChangedMatches(
+ *systemBus, std::to_array<const char*>({sensorType}), eventHandler);
if (initializeLanStatus(systemBus))
{