InstanceIdDb: Move header from pldmd/ to common/

The header is used across all executables produced by the project, which
makes it "common".

Change-Id: I022b179fad1de8dba2ef39fd33bc240ec73a2d33
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/pldmd/dbus_impl_requester.hpp b/pldmd/dbus_impl_requester.hpp
index 2daaf18..84e861b 100644
--- a/pldmd/dbus_impl_requester.hpp
+++ b/pldmd/dbus_impl_requester.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "instance_id.hpp"
+#include "common/instance_id.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 #include "xyz/openbmc_project/PLDM/Requester/server.hpp"
 
diff --git a/pldmd/instance_id.hpp b/pldmd/instance_id.hpp
deleted file mode 100644
index 5de0963..0000000
--- a/pldmd/instance_id.hpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#pragma once
-
-#include "libpldm/instance-id.h"
-
-#include <cerrno>
-#include <cstdint>
-#include <exception>
-#include <string>
-#include <system_error>
-
-namespace pldm
-{
-
-/** @class InstanceId
- *  @brief Implementation of PLDM instance id as per DSP0240 v1.0.0
- */
-class InstanceIdDb
-{
-  public:
-    InstanceIdDb()
-    {
-        int rc = pldm_instance_db_init_default(&pldmInstanceIdDb);
-        if (rc)
-        {
-            throw std::system_category().default_error_condition(rc);
-        }
-    }
-
-    /** @brief Constructor
-     *
-     *  @param[in] path - instance ID database path
-     */
-    InstanceIdDb(const std::string& path)
-    {
-        int rc = pldm_instance_db_init(&pldmInstanceIdDb, path.c_str());
-        if (rc)
-        {
-            throw std::system_category().default_error_condition(rc);
-        }
-    }
-
-    ~InstanceIdDb()
-    {
-        /*
-         * Abandon error-reporting. We shouldn't throw an exception from the
-         * destructor, and the class has multiple consumers using incompatible
-         * logging strategies.
-         *
-         * Broadly, it should be possible to use strace to investigate.
-         */
-        pldm_instance_db_destroy(pldmInstanceIdDb);
-    }
-
-    /** @brief Allocate an instance ID for the given terminus
-     *  @param[in] tid - the terminus ID the instance ID is associated with
-     *  @return - PLDM instance id or -EAGAIN if there are no available instance
-     *            IDs
-     */
-    uint8_t next(uint8_t tid)
-    {
-        uint8_t id;
-        int rc = pldm_instance_id_alloc(pldmInstanceIdDb, tid, &id);
-
-        if (rc == -EAGAIN)
-        {
-            throw std::runtime_error("No free instance ids");
-        }
-
-        if (rc)
-        {
-            throw std::system_category().default_error_condition(rc);
-        }
-
-        return id;
-    }
-
-    /** @brief Mark an instance id as unused
-     *  @param[in] tid - the terminus ID the instance ID is associated with
-     *  @param[in] instanceId - PLDM instance id to be freed
-     */
-    void free(uint8_t tid, uint8_t instanceId)
-    {
-        int rc = pldm_instance_id_free(pldmInstanceIdDb, tid, instanceId);
-        if (rc == -EINVAL)
-        {
-            throw std::runtime_error(
-                "Instance ID " + std::to_string(instanceId) + " for TID " +
-                std::to_string(tid) + " was not previously allocated");
-        }
-        if (rc)
-        {
-            throw std::system_category().default_error_condition(rc);
-        }
-    }
-
-  private:
-    pldm_instance_db* pldmInstanceIdDb = nullptr;
-};
-
-} // namespace pldm
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index f58540e..da50615 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -1,8 +1,8 @@
 #include "common/flight_recorder.hpp"
+#include "common/instance_id.hpp"
 #include "common/utils.hpp"
 #include "dbus_impl_requester.hpp"
 #include "fw-update/manager.hpp"
-#include "instance_id.hpp"
 #include "invoker.hpp"
 #include "requester/handler.hpp"
 #include "requester/mctp_endpoint_discovery.hpp"