Add interface exposing utility functions
Add utility functions enabling easy method calls on sdbusplus interface
binding objects.
Change-Id: Ie1d01f82604406705869fea0ec19d84c95d90474
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/manager.cpp b/manager.cpp
index b9e8ace..d3e2973 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -183,6 +183,31 @@
_refs.erase(_root + p);
}
+details::holder::Base& Manager::getInterfaceHolder(
+ const char *path, const char *interface)
+{
+ return const_cast<const Manager *>(
+ this)->getInterfaceHolder(path, interface);
+}
+
+details::holder::Base& Manager::getInterfaceHolder(
+ const char *path, const char *interface) const
+{
+ std::string p{path};
+ auto oit = _refs.find(_root + p);
+ if(oit == _refs.end())
+ throw std::runtime_error(
+ _root + p + " was not found");
+
+ auto &obj = oit->second;
+ auto iit = obj.find(interface);
+ if(iit == obj.end())
+ throw std::runtime_error(
+ "interface was not found");
+
+ return *iit->second;
+}
+
} // namespace manager
} // namespace inventory
} // namespace phosphor