led-layout: use common types everywhere
Rather than scattered map and set typedefs, centralize the two common
structures into 'ledlayout.hpp': ActionSet, GroupMap. Use them
everywhere where previous raw maps and sets were used.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I0ed5203146a6486a49caf4000f545ded0088dc15
diff --git a/manager/json-parser.hpp b/manager/json-parser.hpp
index 06fb096..e8819ef 100644
--- a/manager/json-parser.hpp
+++ b/manager/json-parser.hpp
@@ -15,8 +15,6 @@
namespace fs = std::filesystem;
using Json = nlohmann::json;
-using LedAction = std::set<phosphor::led::Layout::LedAction>;
-using LedMap = std::unordered_map<std::string, LedAction>;
// Priority for a particular LED needs to stay SAME across all groups
// phosphor::led::Layout::Action can only be one of `Blink` and `On`
@@ -101,11 +99,11 @@
/** @brief Load JSON config and return led map (JSON version 1)
*
- * @return LedMap - Generated an std::unordered_map of LedAction
+ * @return phosphor::led::GroupMap
*/
-const LedMap loadJsonConfigV1(const Json& json)
+const phosphor::led::GroupMap loadJsonConfigV1(const Json& json)
{
- LedMap ledMap{};
+ phosphor::led::GroupMap ledMap{};
PriorityMap priorityMap{};
// define the default JSON as empty
@@ -119,7 +117,7 @@
auto objpath = tmpPath.string();
auto members = entry.value("members", empty);
- LedAction ledActions{};
+ phosphor::led::ActionSet ledActions{};
for (const auto& member : members)
{
auto name = member.value("Name", "");
@@ -149,9 +147,9 @@
/** @brief Load JSON config and return led map
*
- * @return LedMap - Generated an std::unordered_map of LedAction
+ * @return phosphor::led::GroupMap
*/
-const LedMap loadJsonConfig(const fs::path& path)
+const phosphor::led::GroupMap loadJsonConfig(const fs::path& path)
{
auto json = readJson(path);
@@ -167,18 +165,18 @@
throw std::runtime_error("Unsupported version");
}
- return LedMap{};
+ return phosphor::led::GroupMap{};
}
/** @brief Get led map from LED groups JSON config
*
* @param[in] config - Path to the JSON config.
- * @return LedMap - Generated an std::unordered_map of LedAction
+ * @return phosphor::led::GroupMap
*
* @note if config is an empty string, daemon will interrogate dbus for
* compatible strings.
*/
-const LedMap getSystemLedMap(fs::path config)
+const phosphor::led::GroupMap getSystemLedMap(fs::path config)
{
if (config.empty())
{