1682326a1SDeepak Kodihalli #include "config.h"
2f18bf836SPatrick Venture
3682326a1SDeepak Kodihalli #include "elog_meta.hpp"
4682326a1SDeepak Kodihalli
5*a06b4c6bSPatrick Williams #include "util.hpp"
6*a06b4c6bSPatrick Williams
7682326a1SDeepak Kodihalli namespace phosphor
8682326a1SDeepak Kodihalli {
9682326a1SDeepak Kodihalli namespace logging
10682326a1SDeepak Kodihalli {
11682326a1SDeepak Kodihalli namespace metadata
12682326a1SDeepak Kodihalli {
13682326a1SDeepak Kodihalli namespace associations
14682326a1SDeepak Kodihalli {
15682326a1SDeepak Kodihalli
16682326a1SDeepak Kodihalli #if defined PROCESS_META
17682326a1SDeepak Kodihalli
18682326a1SDeepak Kodihalli template <>
build(const std::string & match,const std::vector<std::string> & data,AssociationList & list)196ddbf69eSWilly Tu void build<xyz::openbmc_project::common::callout::Device::CALLOUT_DEVICE_PATH>(
20f18bf836SPatrick Venture const std::string& match, const std::vector<std::string>& data,
21682326a1SDeepak Kodihalli AssociationList& list)
22682326a1SDeepak Kodihalli {
23*a06b4c6bSPatrick Williams auto metadata = util::additional_data::parse(data);
24682326a1SDeepak Kodihalli auto iter = metadata.find(match);
25682326a1SDeepak Kodihalli if (metadata.end() != iter)
26682326a1SDeepak Kodihalli {
27f18bf836SPatrick Venture auto comp = [](const auto& first, const auto& second) {
2830047bf9SPatrick Venture return (std::strcmp(std::get<0>(first), second) < 0);
29682326a1SDeepak Kodihalli };
30f18bf836SPatrick Venture auto callout = std::lower_bound(callouts.begin(), callouts.end(),
31f18bf836SPatrick Venture (iter->second).c_str(), comp);
32682326a1SDeepak Kodihalli if ((callouts.end() != callout) &&
3330047bf9SPatrick Venture !std::strcmp((iter->second).c_str(), std::get<0>(*callout)))
34682326a1SDeepak Kodihalli {
35f18bf836SPatrick Venture list.emplace_back(std::make_tuple(
36f18bf836SPatrick Venture CALLOUT_FWD_ASSOCIATION, CALLOUT_REV_ASSOCIATION,
37f18bf836SPatrick Venture std::string(INVENTORY_ROOT) + std::get<1>(*callout)));
38682326a1SDeepak Kodihalli }
39682326a1SDeepak Kodihalli }
40682326a1SDeepak Kodihalli }
41682326a1SDeepak Kodihalli
42213aaf6fSTom Joseph template <>
build(const std::string & match,const std::vector<std::string> & data,AssociationList & list)43f18bf836SPatrick Venture void build<
446ddbf69eSWilly Tu xyz::openbmc_project::common::callout::Inventory::CALLOUT_INVENTORY_PATH>(
45f18bf836SPatrick Venture const std::string& match, const std::vector<std::string>& data,
46213aaf6fSTom Joseph AssociationList& list)
47213aaf6fSTom Joseph {
48*a06b4c6bSPatrick Williams auto metadata = util::additional_data::parse(data);
49213aaf6fSTom Joseph auto iter = metadata.find(match);
50213aaf6fSTom Joseph if (metadata.end() != iter)
51213aaf6fSTom Joseph {
52075c7923SPatrick Williams list.emplace_back(
53075c7923SPatrick Williams std::make_tuple(CALLOUT_FWD_ASSOCIATION, CALLOUT_REV_ASSOCIATION,
54213aaf6fSTom Joseph std::string(iter->second.c_str())));
55213aaf6fSTom Joseph }
56213aaf6fSTom Joseph }
57213aaf6fSTom Joseph
58682326a1SDeepak Kodihalli #endif
59682326a1SDeepak Kodihalli
60682326a1SDeepak Kodihalli } // namespace associations
61682326a1SDeepak Kodihalli } // namespace metadata
62682326a1SDeepak Kodihalli } // namespace logging
63682326a1SDeepak Kodihalli } // namespace phosphor
64