Standardize Action -> Target Map Type
This change refactors the watchdog header to export the type of watchdog
action to systemd target map, so it can be directly used by other files.
This makes enumerating the map type more trivial.
Also convert to an unordered_map instead of map since we don't need the
ordering guarantees.
Tested:
Builds and tests still pass
Change-Id: I77d315210ec27fde295589479c50d46dc5d1b32a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index f24d45e..49890da 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -191,9 +191,8 @@
.action = Watchdog::Action::PowerOff,
.interval = static_cast<uint64_t>(fallbackIntervalMs),
};
- std::map<Watchdog::Action, Watchdog::TargetName> emptyActionTargets;
wdog = std::make_unique<Watchdog>(bus, TEST_PATH, eventP,
- std::move(emptyActionTargets),
+ Watchdog::ActionTargetMap(),
std::move(fallback));
EXPECT_EQ(primaryInterval, milliseconds(wdog->interval(primaryIntervalMs)));
EXPECT_FALSE(wdog->enabled());
@@ -275,9 +274,8 @@
.interval = static_cast<uint64_t>(fallbackIntervalMs),
.always = false,
};
- std::map<Watchdog::Action, Watchdog::TargetName> emptyActionTargets;
wdog = std::make_unique<Watchdog>(bus, TEST_PATH, eventP,
- std::move(emptyActionTargets),
+ Watchdog::ActionTargetMap(),
std::move(fallback));
EXPECT_EQ(primaryInterval, milliseconds(wdog->interval(primaryIntervalMs)));
EXPECT_FALSE(wdog->enabled());
@@ -330,9 +328,8 @@
.interval = static_cast<uint64_t>(fallbackIntervalMs),
.always = true,
};
- std::map<Watchdog::Action, Watchdog::TargetName> emptyActionTargets;
wdog = std::make_unique<Watchdog>(bus, TEST_PATH, eventP,
- std::move(emptyActionTargets),
+ Watchdog::ActionTargetMap(),
std::move(fallback));
EXPECT_EQ(primaryInterval, milliseconds(wdog->interval(primaryIntervalMs)));
EXPECT_FALSE(wdog->enabled());