1 #include "aggregate_update_manager.hpp"
2
3 namespace pldm::fw_update
4 {
5
handleRequest(mctp_eid_t eid,uint8_t command,const pldm_msg * request,size_t reqMsgLen)6 Response AggregateUpdateManager::handleRequest(
7 mctp_eid_t eid, uint8_t command, const pldm_msg* request, size_t reqMsgLen)
8 {
9 Response response;
10 response = UpdateManager::handleRequest(eid, command, request, reqMsgLen);
11 auto responseMsg = new (response.data()) pldm_msg;
12 if (responseMsg->payload[0] != PLDM_FWUP_COMMAND_NOT_EXPECTED)
13 {
14 return response;
15 }
16 for (auto& [_, updateManager] : updateManagers)
17 {
18 response =
19 updateManager->handleRequest(eid, command, request, reqMsgLen);
20 if (responseMsg->payload[0] != PLDM_FWUP_COMMAND_NOT_EXPECTED)
21 {
22 return response;
23 }
24 }
25 return response;
26 }
27
eraseUpdateManager(const SoftwareIdentifier & softwareIdentifier)28 void AggregateUpdateManager::eraseUpdateManager(
29 const SoftwareIdentifier& softwareIdentifier)
30 {
31 updateManagers.erase(softwareIdentifier);
32 descriptorMap.erase(softwareIdentifier);
33 componentInfoMap.erase(softwareIdentifier);
34 }
35
eraseUpdateManagerIf(std::function<bool (const SoftwareIdentifier &)> && predicate)36 void AggregateUpdateManager::eraseUpdateManagerIf(
37 std::function<bool(const SoftwareIdentifier&)>&& predicate)
38 {
39 for (auto it = updateManagers.begin(); it != updateManagers.end();)
40 {
41 if (predicate(it->first))
42 {
43 descriptorMap.erase(it->first);
44 componentInfoMap.erase(it->first);
45 it = updateManagers.erase(it);
46 }
47 else
48 {
49 ++it;
50 }
51 }
52 }
53
54 } // namespace pldm::fw_update
55