blob: 0131c2f2a8d0d76a1f1ef618fa9bf0cf8700b43a [file] [log] [blame]
Deepak Kodihalli682326a2017-03-06 05:26:53 -06001#include "config.h"
Patrick Venturef18bf832018-10-26 18:14:00 -07002
Deepak Kodihalli682326a2017-03-06 05:26:53 -06003#include "elog_meta.hpp"
4
5namespace phosphor
6{
7namespace logging
8{
9namespace metadata
10{
11namespace associations
12{
13
14#if defined PROCESS_META
15
16template <>
Willy Tu6ddbf692023-09-05 10:54:16 -070017void build<xyz::openbmc_project::common::callout::Device::CALLOUT_DEVICE_PATH>(
Patrick Venturef18bf832018-10-26 18:14:00 -070018 const std::string& match, const std::vector<std::string>& data,
Deepak Kodihalli682326a2017-03-06 05:26:53 -060019 AssociationList& list)
20{
21 std::map<std::string, std::string> metadata;
22 parse(data, metadata);
23 auto iter = metadata.find(match);
Patrick Venturef18bf832018-10-26 18:14:00 -070024 if (metadata.end() != iter)
Deepak Kodihalli682326a2017-03-06 05:26:53 -060025 {
Patrick Venturef18bf832018-10-26 18:14:00 -070026 auto comp = [](const auto& first, const auto& second) {
Patrick Venture30047bf2018-11-01 18:52:15 -070027 return (std::strcmp(std::get<0>(first), second) < 0);
Deepak Kodihalli682326a2017-03-06 05:26:53 -060028 };
Patrick Venturef18bf832018-10-26 18:14:00 -070029 auto callout = std::lower_bound(callouts.begin(), callouts.end(),
30 (iter->second).c_str(), comp);
31 if ((callouts.end() != callout) &&
Patrick Venture30047bf2018-11-01 18:52:15 -070032 !std::strcmp((iter->second).c_str(), std::get<0>(*callout)))
Deepak Kodihalli682326a2017-03-06 05:26:53 -060033 {
Patrick Venturef18bf832018-10-26 18:14:00 -070034 list.emplace_back(std::make_tuple(
35 CALLOUT_FWD_ASSOCIATION, CALLOUT_REV_ASSOCIATION,
36 std::string(INVENTORY_ROOT) + std::get<1>(*callout)));
Deepak Kodihalli682326a2017-03-06 05:26:53 -060037 }
38 }
39}
40
Tom Joseph213aaf62017-07-25 00:02:09 +053041template <>
Patrick Venturef18bf832018-10-26 18:14:00 -070042void build<
Willy Tu6ddbf692023-09-05 10:54:16 -070043 xyz::openbmc_project::common::callout::Inventory::CALLOUT_INVENTORY_PATH>(
Patrick Venturef18bf832018-10-26 18:14:00 -070044 const std::string& match, const std::vector<std::string>& data,
Tom Joseph213aaf62017-07-25 00:02:09 +053045 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 {
Patrick Williams075c7922024-08-16 15:19:49 -040052 list.emplace_back(
53 std::make_tuple(CALLOUT_FWD_ASSOCIATION, CALLOUT_REV_ASSOCIATION,
54 std::string(iter->second.c_str())));
Tom Joseph213aaf62017-07-25 00:02:09 +053055 }
56}
57
Deepak Kodihalli682326a2017-03-06 05:26:53 -060058#endif
59
60} // namespace associations
61} // namespace metadata
62} // namespace logging
63} // namespace phosphor