EntityManager: Make MapperGetSubTreeResponse type comprehensible
From there, rework a bunch of uses of the unaliased types to use the new
aliased types and fix up some of the variable names to improve
readability.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I498e0d93091cae43e59907ee1908afc97ac601ee
diff --git a/include/EntityManager.hpp b/include/EntityManager.hpp
index eb8a86d..2b4565b 100644
--- a/include/EntityManager.hpp
+++ b/include/EntityManager.hpp
@@ -30,16 +30,8 @@
#include <optional>
#include <string>
-// paths - > interfaces -> properties
-using MapperGetSubTreeResponse = boost::container::flat_map<
- std::string,
- boost::container::flat_map<
- std::string,
- boost::container::flat_map<std::string, DBusValueVariant>>>;
-
-// vector of tuple<map<propertyName, variant>, D-Bus path>>
-using FoundDeviceT = std::vector<std::tuple<
- boost::container::flat_map<std::string, DBusValueVariant>, std::string>>;
+// The string is the path to the object hosting the interface
+using FoundDeviceT = std::vector<std::tuple<DBusInterface, std::string>>;
struct CmpStr
{
diff --git a/include/Utils.hpp b/include/Utils.hpp
index fa155f9..13c199c 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -35,6 +35,10 @@
using DBusValueVariant =
std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t,
int16_t, uint16_t, uint8_t, bool, std::vector<uint8_t>>;
+using DBusInterface = boost::container::flat_map<std::string, DBusValueVariant>;
+using DBusObject = boost::container::flat_map<std::string, DBusInterface>;
+using MapperGetSubTreeResponse =
+ boost::container::flat_map<std::string, DBusObject>;
enum class TemplateOperation
{
@@ -137,18 +141,13 @@
}
std::optional<std::string> templateCharReplace(
- nlohmann::json::iterator& keyPair,
- const boost::container::flat_map<
- std::string, boost::container::flat_map<std::string, DBusValueVariant>>&
- allInterfaces,
- const size_t foundDeviceIdx,
+ nlohmann::json::iterator& keyPair, const DBusObject& object,
+ const size_t index,
const std::optional<std::string>& replaceStr = std::nullopt);
std::optional<std::string> templateCharReplace(
- nlohmann::json::iterator& keyPair,
- const boost::container::flat_map<std::string, DBusValueVariant>&
- foundDevice,
- const size_t foundDeviceIdx,
+ nlohmann::json::iterator& keyPair, const DBusInterface& interface,
+ const size_t index,
const std::optional<std::string>& replaceStr = std::nullopt);
inline bool deviceHasLogging(const nlohmann::json& json)