1 #include "pdr.hpp" 2 3 namespace pldm 4 { 5 6 namespace responder 7 { 8 9 namespace pdr_utils 10 { 11 12 pldm_pdr* Repo::getPdr() const 13 { 14 return repo; 15 } 16 17 RecordHandle Repo::addRecord(const PdrEntry& pdrEntry) 18 { 19 return pldm_pdr_add(repo, pdrEntry.data, pdrEntry.size, 20 pdrEntry.handle.recordHandle); 21 } 22 23 const 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 38 const 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 53 uint32_t Repo::getRecordHandle(const pldm_pdr_record* record) const 54 { 55 return pldm_pdr_get_record_handle(getPdr(), record); 56 } 57 58 uint32_t Repo::getRecordCount() 59 { 60 return pldm_pdr_get_record_count(getPdr()); 61 } 62 63 bool Repo::empty() 64 { 65 return !getRecordCount(); 66 } 67 68 } // namespace pdr_utils 69 } // namespace responder 70 } // namespace pldm 71