host-bmc: Implement Inventory Item interface
Adding support to host Inventory Item dbus interface. PLDM hosts the
dbus interface based on the entity type. The Inventory Item interface
is defined at [1].
Tested:
Functional test passed
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Item.interface.yaml
Change-Id: Ifed3cc01d825a69d64afcffd8447f7c8d9387913
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/inventory_item.hpp b/host-bmc/dbus/inventory_item.hpp
new file mode 100644
index 0000000..17699ee
--- /dev/null
+++ b/host-bmc/dbus/inventory_item.hpp
@@ -0,0 +1,48 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Inventory/Item/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemIntf = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Inventory::server::Item>;
+
+class InventoryItem : public ItemIntf
+{
+ public:
+ InventoryItem() = delete;
+ ~InventoryItem() = default;
+ InventoryItem(const InventoryItem&) = delete;
+ InventoryItem& operator=(const InventoryItem&) = delete;
+ InventoryItem(InventoryItem&&) = delete;
+ InventoryItem& operator=(InventoryItem&&) = delete;
+
+ InventoryItem(sdbusplus::bus_t& bus, const std::string& objPath) :
+ ItemIntf(bus, objPath.c_str()), path(objPath)
+ {}
+
+ /** Get value of PrettyName */
+ std::string prettyName() const override;
+
+ /** Set value of PrettyName */
+ std::string prettyName(std::string value) override;
+
+ /** Get value of Present */
+ bool present() const override;
+
+ /** Set value of Present */
+ bool present(bool value) override;
+
+ private:
+ std::string path;
+};
+
+} // namespace dbus
+} // namespace pldm