blob: 9a68ca9cfcad7e6d4866f886edf59b8eb73997b4 [file] [log] [blame]
George Liue53193f2020-02-24 09:23:26 +08001#include "pdr.hpp"
2
3namespace pldm
4{
5
6namespace responder
7{
8
9namespace pdr_utils
10{
11
Deepak Kodihallic682fe22020-03-04 00:42:54 -060012pldm_pdr* Repo::getPdr() const
George Liue53193f2020-02-24 09:23:26 +080013{
14 return repo;
15}
16
17RecordHandle Repo::addRecord(const PdrEntry& pdrEntry)
18{
19 return pldm_pdr_add(repo, pdrEntry.data, pdrEntry.size,
20 pdrEntry.handle.recordHandle);
21}
22
23const pldm_pdr_record* Repo::getFirstRecord(PdrEntry& pdrEntry)
24{
25 constexpr uint32_t firstNum = 0;
26 uint8_t* pdrData = nullptr;
27 auto record =
28 pldm_pdr_find_record(getPdr(), firstNum, &pdrData, &pdrEntry.size,
29 &pdrEntry.handle.nextRecordHandle);
30 if (record)
31 {
32 pdrEntry.data = pdrData;
33 }
34
35 return record;
36}
37
38const pldm_pdr_record* Repo::getNextRecord(const pldm_pdr_record* currRecord,
39 PdrEntry& pdrEntry)
40{
41 uint8_t* pdrData = nullptr;
42 auto record =
43 pldm_pdr_get_next_record(getPdr(), currRecord, &pdrData, &pdrEntry.size,
44 &pdrEntry.handle.nextRecordHandle);
45 if (record)
46 {
47 pdrEntry.data = pdrData;
48 }
49
50 return record;
51}
52
Deepak Kodihallic682fe22020-03-04 00:42:54 -060053uint32_t Repo::getRecordHandle(const pldm_pdr_record* record) const
George Liue53193f2020-02-24 09:23:26 +080054{
55 return pldm_pdr_get_record_handle(getPdr(), record);
56}
57
58uint32_t Repo::getRecordCount()
59{
60 return pldm_pdr_get_record_count(getPdr());
61}
62
63bool Repo::empty()
64{
65 return !getRecordCount();
66}
67
68} // namespace pdr_utils
69} // namespace responder
70} // namespace pldm