1 #pragma once 2 3 #include "instance_id.hpp" 4 #include "xyz/openbmc_project/PLDM/Requester/server.hpp" 5 6 #include <sdbusplus/bus.hpp> 7 #include <sdbusplus/server/object.hpp> 8 9 #include <map> 10 11 namespace pldm 12 { 13 namespace dbus_api 14 { 15 16 using RequesterIntf = sdbusplus::server::object::object< 17 sdbusplus::xyz::openbmc_project::PLDM::server::Requester>; 18 19 /** @class Requester 20 * @brief OpenBMC PLDM.Requester implementation. 21 * @details A concrete implementation for the 22 * xyz.openbmc_project.PLDM.Requester DBus APIs. 23 */ 24 class Requester : public RequesterIntf 25 { 26 public: 27 Requester() = delete; 28 Requester(const Requester&) = delete; 29 Requester& operator=(const Requester&) = delete; 30 Requester(Requester&&) = delete; 31 Requester& operator=(Requester&&) = delete; 32 virtual ~Requester() = default; 33 34 /** @brief Constructor to put object onto bus at a dbus path. 35 * @param[in] bus - Bus to attach to. 36 * @param[in] path - Path to attach at. 37 */ 38 Requester(sdbusplus::bus::bus& bus, const std::string& path) : 39 RequesterIntf(bus, path.c_str()){}; 40 41 /** @brief Implementation for RequesterIntf.GetInstanceId */ 42 uint8_t getInstanceId(uint8_t eid) override; 43 44 /** @brief Mark an instance id as unused 45 * @param[in] eid - MCTP eid to which this instance id belongs 46 * @param[in] instanceId - PLDM instance id to be freed 47 * @note will throw std::out_of_range if instanceId > 31 48 */ 49 void markFree(uint8_t eid, uint8_t instanceId) 50 { 51 ids[eid].markFree(instanceId); 52 } 53 54 private: 55 /** @brief EID to PLDM Instance ID map */ 56 std::map<uint8_t, InstanceId> ids; 57 }; 58 59 } // namespace dbus_api 60 } // namespace pldm 61