blob: 1b8aaea512b59362283a62aea2b03060ab4c5d22 [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
Patrick Williamsa06b4c62024-11-21 11:43:39 -05005#include "util.hpp"
6
Deepak Kodihalli682326a2017-03-06 05:26:53 -06007namespace phosphor
8{
9namespace logging
10{
11namespace metadata
12{
13namespace associations
14{
15
16#if defined PROCESS_META
17
18template <>
Willy Tu6ddbf692023-09-05 10:54:16 -070019void build<xyz::openbmc_project::common::callout::Device::CALLOUT_DEVICE_PATH>(
Patrick Venturef18bf832018-10-26 18:14:00 -070020 const std::string& match, const std::vector<std::string>& data,
Deepak Kodihalli682326a2017-03-06 05:26:53 -060021 AssociationList& list)
22{
Patrick Williamsa06b4c62024-11-21 11:43:39 -050023 auto metadata = util::additional_data::parse(data);
Deepak Kodihalli682326a2017-03-06 05:26:53 -060024 auto iter = metadata.find(match);
Patrick Venturef18bf832018-10-26 18:14:00 -070025 if (metadata.end() != iter)
Deepak Kodihalli682326a2017-03-06 05:26:53 -060026 {
Patrick Venturef18bf832018-10-26 18:14:00 -070027 auto comp = [](const auto& first, const auto& second) {
Patrick Venture30047bf2018-11-01 18:52:15 -070028 return (std::strcmp(std::get<0>(first), second) < 0);
Deepak Kodihalli682326a2017-03-06 05:26:53 -060029 };
Patrick Venturef18bf832018-10-26 18:14:00 -070030 auto callout = std::lower_bound(callouts.begin(), callouts.end(),
31 (iter->second).c_str(), comp);
32 if ((callouts.end() != callout) &&
Patrick Venture30047bf2018-11-01 18:52:15 -070033 !std::strcmp((iter->second).c_str(), std::get<0>(*callout)))
Deepak Kodihalli682326a2017-03-06 05:26:53 -060034 {
Patrick Venturef18bf832018-10-26 18:14:00 -070035 list.emplace_back(std::make_tuple(
36 CALLOUT_FWD_ASSOCIATION, CALLOUT_REV_ASSOCIATION,
37 std::string(INVENTORY_ROOT) + std::get<1>(*callout)));
Deepak Kodihalli682326a2017-03-06 05:26:53 -060038 }
39 }
40}
41
Tom Joseph213aaf62017-07-25 00:02:09 +053042template <>
Patrick Venturef18bf832018-10-26 18:14:00 -070043void build<
Willy Tu6ddbf692023-09-05 10:54:16 -070044 xyz::openbmc_project::common::callout::Inventory::CALLOUT_INVENTORY_PATH>(
Patrick Venturef18bf832018-10-26 18:14:00 -070045 const std::string& match, const std::vector<std::string>& data,
Tom Joseph213aaf62017-07-25 00:02:09 +053046 AssociationList& list)
47{
Patrick Williamsa06b4c62024-11-21 11:43:39 -050048 auto metadata = util::additional_data::parse(data);
Tom Joseph213aaf62017-07-25 00:02:09 +053049 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