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