platform-mc: Added Terminus/TerminusManager class

Added requester::sendRecvPldmMsg awaiter type to be able to send and
receive PLDM message by coroutine.
Added TerminusManager to discover terminus from EID list updated by
MCTPDiscovery class. The TerminusManager will initialize TID.

Signed-off-by: Gilbert Chen <gilbert.chen@arm.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: Ifa5bdfff50648f1d7fba8710e160de662e8f9e06
diff --git a/platform-mc/manager.hpp b/platform-mc/manager.hpp
new file mode 100644
index 0000000..7636e94
--- /dev/null
+++ b/platform-mc/manager.hpp
@@ -0,0 +1,82 @@
+#pragma once
+
+#include "libpldm/pldm.h"
+
+#include "common/instance_id.hpp"
+#include "common/types.hpp"
+#include "platform_manager.hpp"
+#include "requester/handler.hpp"
+#include "requester/mctp_endpoint_discovery.hpp"
+#include "terminus_manager.hpp"
+
+namespace pldm
+{
+namespace platform_mc
+{
+
+/**
+ * @brief Manager
+ *
+ * This class handles all the aspect of the PLDM Platform Monitoring and Control
+ * specification for the MCTP devices
+ */
+class Manager : public pldm::MctpDiscoveryHandlerIntf
+{
+  public:
+    Manager() = delete;
+    Manager(const Manager&) = delete;
+    Manager(Manager&&) = delete;
+    Manager& operator=(const Manager&) = delete;
+    Manager& operator=(Manager&&) = delete;
+    ~Manager() = default;
+
+    explicit Manager(sdeventplus::Event& event, RequesterHandler& handler,
+                     pldm::InstanceIdDb& instanceIdDb) :
+        terminusManager(event, handler, instanceIdDb, termini, this),
+        platformManager(terminusManager, termini)
+    {}
+
+    /** @brief Helper function to do the actions before discovering terminus
+     *
+     *  @return coroutine return_value - PLDM completion code
+     */
+    exec::task<int> beforeDiscoverTerminus();
+
+    /** @brief Helper function to do the actions after discovering terminus
+     *
+     *  @return coroutine return_value - PLDM completion code
+     */
+    exec::task<int> afterDiscoverTerminus();
+
+    /** @brief Helper function to invoke registered handlers for
+     *         the added MCTP endpoints
+     *
+     *  @param[in] mctpInfos - list information of the MCTP endpoints
+     */
+    void handleMctpEndpoints(const MctpInfos& mctpInfos)
+    {
+        terminusManager.discoverMctpTerminus(mctpInfos);
+    }
+
+    /** @brief Helper function to invoke registered handlers for
+     *         the removed MCTP endpoints
+     *
+     *  @param[in] mctpInfos - list information of the MCTP endpoints
+     */
+    void handleRemovedMctpEndpoints(const MctpInfos& mctpInfos)
+    {
+        terminusManager.removeMctpTerminus(mctpInfos);
+    }
+
+  private:
+    /** @brief List of discovered termini */
+    TerminiMapper termini{};
+
+    /** @brief Terminus interface for calling the hook functions */
+    TerminusManager terminusManager;
+
+    /** @brief Platform interface for calling the hook functions */
+    PlatformManager platformManager;
+};
+} // namespace platform_mc
+} // namespace pldm