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