Add manager interface server binding
Eventually any DBus interfaces in phosphor-dbus-interfaces will
have bindings generated and available in a shared library.
Add the generated Manager interface directly to the repository until
that happens.
Change-Id: I9e1ac3266ca6467bbddbbd12ed2d2de6c079765b
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/Makefile.am b/Makefile.am
index 9bc1cf2..3915eab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
phosphor_inventory_SOURCES = \
app.cpp \
- server.cpp \
+ xyz.openbmc_project.Inventory.Manager.cpp \
manager.cpp
phosphor_inventory_LDFLAGS = $(SYSTEMD_LIBS)
phosphor_inventory_CFLAGS = $(SYSTEMD_CFLAGS)
diff --git a/test/Makefile.am b/test/Makefile.am
index 2c340ea..48d2bb5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,4 +6,4 @@
phosphor_inventory_test_CFLAGS = $(SYSTEMD_CFLAGS)
phosphor_inventory_test_LDADD = ${top_builddir}/manager.o \
${top_builddir}/filters.o \
- ${top_builddir}/server.o
+ ${top_builddir}/xyz.openbmc_project.Inventory.Manager.o
diff --git a/xyz.openbmc_project.Inventory.Manager.cpp b/xyz.openbmc_project.Inventory.Manager.cpp
new file mode 100644
index 0000000..bbe5667
--- /dev/null
+++ b/xyz.openbmc_project.Inventory.Manager.cpp
@@ -0,0 +1,71 @@
+#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/Inventory/Manager/server.hpp>
+
+namespace sdbusplus
+{
+namespace server
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Inventory
+{
+
+Manager::Manager(bus::bus& bus, const char* path)
+ : _xyz_openbmc_project_Inventory_Manager_interface(
+ bus, path, _interface, _vtable, this)
+{
+}
+
+
+int Manager::_callback_Notify(
+ sd_bus_message* msg, void* context, sd_bus_error* error)
+{
+ auto m = message::message(sd_bus_message_ref(msg));
+
+ std::string path{};
+ std::map<std::string, std::map<std::string, sdbusplus::message::variant<std::string>>> object{};
+
+ m.read(path, object);
+
+ auto o = static_cast<Manager*>(context);
+ o->notify(path, object);
+
+ auto reply = m.new_method_return();
+ // No data to append on reply.
+
+ reply.method_return();
+
+ return 0;
+}
+
+namespace details
+{
+namespace Manager
+{
+static const auto _param_Notify =
+ utility::tuple_to_array(message::types::type_id<
+ std::string, std::map<std::string, std::map<std::string, sdbusplus::message::variant<std::string>>>>());
+}
+}
+
+
+
+const vtable::vtable_t Manager::_vtable[] = {
+ vtable::start(),
+
+ vtable::method("Notify",
+ details::Manager::_param_Notify
+ .data(),
+ nullptr,
+ _callback_Notify),
+ vtable::end()
+};
+
+} // namespace Inventory
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace server
+} // namespace sdbusplus
+
diff --git a/xyz/openbmc_project/Inventory/Manager/server.hpp b/xyz/openbmc_project/Inventory/Manager/server.hpp
new file mode 100644
index 0000000..9c3118b
--- /dev/null
+++ b/xyz/openbmc_project/Inventory/Manager/server.hpp
@@ -0,0 +1,74 @@
+#pragma once
+#include <tuple>
+#include <systemd/sd-bus.h>
+#include <sdbusplus/server.hpp>
+
+namespace sdbusplus
+{
+namespace server
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Inventory
+{
+
+class Manager
+{
+ public:
+ /* Define all of the basic class operations:
+ * Not allowed:
+ * - Default constructor to avoid nullptrs.
+ * - Copy operations due to internal unique_ptr.
+ * Allowed:
+ * - Move operations.
+ * - Destructor.
+ */
+ Manager() = delete;
+ Manager(const Manager&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = default;
+ Manager& operator=(Manager&&) = default;
+ virtual ~Manager() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ */
+ Manager(bus::bus& bus, const char* path);
+
+
+ /** @brief Implementation for Notify
+ * Signal the implementing service that an item is ready to have its state managed.
+ *
+ * @param[in] path - The path of the item to be managed, relative to the inventory namespace root.
+ * @param[in] object - The fully enumerated item to be managed.
+ */
+ virtual void notify(
+ std::string path,
+ std::map<std::string, std::map<std::string, sdbusplus::message::variant<std::string>>> object) = 0;
+
+
+
+ private:
+
+ /** @brief sd-bus callback for Notify
+ */
+ static int _callback_Notify(
+ sd_bus_message*, void*, sd_bus_error*);
+
+
+ static constexpr auto _interface = "xyz.openbmc_project.Inventory.Manager";
+ static const vtable::vtable_t _vtable[];
+ interface::interface _xyz_openbmc_project_Inventory_Manager_interface;
+
+
+};
+
+} // namespace Inventory
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace server
+} // namespace sdbusplus
+