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