blob: 4f88c435e830c0f24b50b6f001c233e41c135e80 [file] [log] [blame]
Deepak Kodihalli4de4d002019-11-11 02:41:43 -06001#pragma once
2
3#include <bitset>
Andrew Jefferyda4b13c2023-04-28 12:56:20 +09304#include <cstdint>
Deepak Kodihalli4de4d002019-11-11 02:41:43 -06005
6namespace pldm
7{
8
9constexpr size_t maxInstanceIds = 32;
10
11/** @class InstanceId
12 * @brief Implementation of PLDM instance id as per DSP0240 v1.0.0
13 */
14class InstanceId
15{
16 public:
17 /** @brief Get next unused instance id
18 * @return - PLDM instance id
19 */
20 uint8_t next();
21
22 /** @brief Mark an instance id as unused
23 * @param[in] instanceId - PLDM instance id to be freed
24 */
25 void markFree(uint8_t instanceId)
26 {
27 id.set(instanceId, false);
28 }
29
30 private:
31 std::bitset<maxInstanceIds> id;
32};
33
34} // namespace pldm