Add support for child D-Bus objects
Add the ability for the Manager class to store D-Bus objects
that are children of the main interface objects, where being
a child just means the object path extends the parent path.
There can be multiple of these objects per logging entry, and
they have the same lifespan as the parent objects.
This is in preparation for creating callout objects for an
error log, where a log can have multiple callouts.
Tested: When child objects are created and stored, they show
up on D-Bus until deleted.
Change-Id: I00c612db183b74654f529a7a694bb62856766413
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/manager.cpp b/manager.cpp
index 94b4af1..c01cdc5 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -72,6 +72,7 @@
void Manager::erase(EntryID id)
{
+ childEntries.erase(id);
entries.erase(id);
}
@@ -93,6 +94,40 @@
}
}
+void Manager::addChildInterface(const std::string& objectPath,
+ InterfaceType type,
+ std::experimental::any& object)
+{
+ auto id = getEntryID(objectPath);
+ auto entry = childEntries.find(id);
+
+ // childEntries is:
+ // A map of error log entry IDs to:
+ // a map of interface types to:
+ // a vector of interface objects
+
+ if (entry == childEntries.end())
+ {
+ ObjectList objects{object};
+ InterfaceMapMulti interfaces;
+ interfaces.emplace(type, std::move(objects));
+ childEntries.emplace(id, std::move(interfaces));
+ }
+ else
+ {
+ auto i = entry->second.find(type);
+ if (i == entry->second.end())
+ {
+ ObjectList objects{objects};
+ entry->second.emplace(type, objects);
+ }
+ else
+ {
+ i->second.emplace_back(object);
+ }
+ }
+}
+
#ifdef USE_POLICY_INTERFACE
void Manager::createPolicyInterface(const std::string& objectPath,
const DbusPropertyMap& properties)