blob: 514296e9b13b977a14dedd9ac6386c8243538085 [file] [log] [blame]
Deepak Kodihalli682326a2017-03-06 05:26:53 -06001#include "config.h"
2#include "elog_meta.hpp"
3
4namespace phosphor
5{
6namespace logging
7{
8namespace metadata
9{
10namespace associations
11{
12
13#if defined PROCESS_META
14
15template <>
16void build<xyz::openbmc_project::Common::
17 Callout::Device::CALLOUT_DEVICE_PATH>(
Deepak Kodihallia5d8d152017-03-16 05:10:05 -050018 const std::string& match,
Deepak Kodihalli682326a2017-03-06 05:26:53 -060019 const std::vector<std::string>& data,
20 AssociationList& list)
21{
22 std::map<std::string, std::string> metadata;
23 parse(data, metadata);
24 auto iter = metadata.find(match);
25 if(metadata.end() != iter)
26 {
27 auto comp = [](const auto& first, const auto& second)
28 {
29 return (strcmp(std::get<0>(first), second) < 0);
30 };
31 auto callout = std::lower_bound(callouts.begin(),
32 callouts.end(),
33 (iter->second).c_str(),
34 comp);
35 if((callouts.end() != callout) &&
36 !strcmp((iter->second).c_str(), std::get<0>(*callout)))
37 {
38 list.emplace_back(std::make_tuple(CALLOUT_FWD_ASSOCIATION,
39 CALLOUT_REV_ASSOCIATION,
40 std::string(INVENTORY_ROOT) +
41 std::get<1>(*callout)));
42 }
43 }
44}
45
Tom Joseph213aaf62017-07-25 00:02:09 +053046template <>
47void build<xyz::openbmc_project::Common::
48 Callout::Inventory::CALLOUT_INVENTORY_PATH>(
49 const std::string& match,
50 const std::vector<std::string>& data,
51 AssociationList& list)
52{
53 std::map<std::string, std::string> metadata;
54 parse(data, metadata);
55 auto iter = metadata.find(match);
56 if (metadata.end() != iter)
57 {
58 list.emplace_back(std::make_tuple(CALLOUT_FWD_ASSOCIATION,
59 CALLOUT_REV_ASSOCIATION,
60 std::string(iter->second.c_str())));
61 }
62}
63
Deepak Kodihalli682326a2017-03-06 05:26:53 -060064#endif
65
66} // namespace associations
67} // namespace metadata
68} // namespace logging
69} // namespace phosphor