forked from openbmc/openpower-vpd-parser
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathwritefru.mako.hpp
executable file
·108 lines (97 loc) · 2.79 KB
/
writefru.mako.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
## This file is a template. The comment below is emitted
## into the rendered file; feel free to edit this file.
// WARNING: Generated header. Do not edit!
#pragma once
#include <map>
#include <iostream>
#include "defines.hpp"
#include "store.hpp"
#include "types.hpp"
#include "common_utility.hpp"
#include "extra-properties-gen.hpp"
namespace openpower
{
namespace vpd
{
namespace inventory
{
using namespace openpower::vpd::common::utility;
/** @brief API to write parsed VPD to inventory,
* for a specific FRU
*
* @param [in] vpdStore - Store object containing
* parsed VPD
* @param [in] path - FRU object path
*/
template<Fru F>
void writeFru(const Store& /*vpdStore*/, const std::string& /*path*/) {
throw std::runtime_error("Not implemented");
}
% for key in fruDict.keys():
<%
fru = fruDict[key]
%>\
// Specialization of ${key}
template<>
void writeFru<Fru::${key}>(const Store& vpdStore,
const std::string& path)
{
ObjectMap objects;
InterfaceMap interfaces;
auto iter = extra::objects.find(path);
// Inventory manager needs object path, list of interface names to be
// implemented, and property:value pairs contained in said interfaces
% for interface, properties in fru.items():
<%
names = interface.split(".")
intfName = names[0] + names[-1]
%>\
PropertyMap ${intfName}Props;
% if properties:
% for name, value in properties.items():
% if fru and interface and name and value:
<%
record, keyword = name.split(",")
%>\
if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>())
{
${intfName}Props["${value}"] =
vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
}
% endif
% endfor
% endif
// Check and update extra properties
if(extra::objects.end() != iter)
{
auto propIter = (iter->second).find("${interface}");
if((iter->second).end() != propIter)
{
for(const auto& map : propIter->second)
{
${intfName}Props[map.first] = map.second;
}
}
}
interfaces.emplace("${interface}",
std::move(${intfName}Props));
% endfor
sdbusplus::message::object_path object(path);
// Check and update extra properties
if(extra::objects.end() != iter)
{
for(const auto& entry : iter->second)
{
if(interfaces.end() == interfaces.find(entry.first))
{
interfaces.emplace(entry.first, entry.second);
}
}
}
objects.emplace(std::move(object), std::move(interfaces));
callPIM(std::move(objects));
}
% endfor
} // namespace inventory
} // namespace vpd
} // namespace openpower