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