xref: /openbmc/phosphor-logging/elog_meta.cpp (revision 6f533669)
1 #include "config.h"
2 
3 #include "elog_meta.hpp"
4 
5 namespace phosphor
6 {
7 namespace logging
8 {
9 namespace metadata
10 {
11 namespace associations
12 {
13 
14 #if defined PROCESS_META
15 
16 template <>
17 void build<xyz::openbmc_project::common::callout::Device::CALLOUT_DEVICE_PATH>(
18     const std::string& match, const std::vector<std::string>& data,
19     AssociationList& list)
20 {
21     std::map<std::string, std::string> metadata;
22     parse(data, metadata);
23     auto iter = metadata.find(match);
24     if (metadata.end() != iter)
25     {
26         auto comp = [](const auto& first, const auto& second) {
27             return (std::strcmp(std::get<0>(first), second) < 0);
28         };
29         auto callout = std::lower_bound(callouts.begin(), callouts.end(),
30                                         (iter->second).c_str(), comp);
31         if ((callouts.end() != callout) &&
32             !std::strcmp((iter->second).c_str(), std::get<0>(*callout)))
33         {
34             list.emplace_back(std::make_tuple(
35                 CALLOUT_FWD_ASSOCIATION, CALLOUT_REV_ASSOCIATION,
36                 std::string(INVENTORY_ROOT) + std::get<1>(*callout)));
37         }
38     }
39 }
40 
41 template <>
42 void build<
43     xyz::openbmc_project::common::callout::Inventory::CALLOUT_INVENTORY_PATH>(
44     const std::string& match, const std::vector<std::string>& data,
45     AssociationList& list)
46 {
47     std::map<std::string, std::string> metadata;
48     parse(data, metadata);
49     auto iter = metadata.find(match);
50     if (metadata.end() != iter)
51     {
52         list.emplace_back(std::make_tuple(CALLOUT_FWD_ASSOCIATION,
53                                           CALLOUT_REV_ASSOCIATION,
54                                           std::string(iter->second.c_str())));
55     }
56 }
57 
58 #endif
59 
60 } // namespace associations
61 } // namespace metadata
62 } // namespace logging
63 } // namespace phosphor
64