blob: 52cd1d6beb6debe189f94632e9d60819010ef251 [file] [log] [blame]
Deepak Kodihalli4de4d002019-11-11 02:41:43 -06001#include "instance_id.hpp"
2
3#include <stdexcept>
4
5namespace pldm
6{
7
8uint8_t InstanceId::next()
9{
10 uint8_t idx = 0;
11 while (idx < id.size() && id.test(idx))
12 {
13 ++idx;
14 }
15
16 if (idx == id.size())
17 {
18 throw std::runtime_error("No free instance ids");
19 }
20
21 id.set(idx);
22 return idx;
23}
24
25} // namespace pldm