Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <bitset> |
Andrew Jeffery | da4b13c | 2023-04-28 12:56:20 +0930 | [diff] [blame^] | 4 | #include <cstdint> |
Deepak Kodihalli | 4de4d00 | 2019-11-11 02:41:43 -0600 | [diff] [blame] | 5 | |
| 6 | namespace pldm |
| 7 | { |
| 8 | |
| 9 | constexpr size_t maxInstanceIds = 32; |
| 10 | |
| 11 | /** @class InstanceId |
| 12 | * @brief Implementation of PLDM instance id as per DSP0240 v1.0.0 |
| 13 | */ |
| 14 | class 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 |