blob: 9275e9ff98e446689900014f32cf264678870f0b [file] [log] [blame]
Deepak Kodihalli8457f822016-11-29 06:05:39 -06001## This file is a template. The comment below is emitted
2## into the rendered file; feel free to edit this file.
3// WARNING: Generated header. Do not edit!
4
5
6#pragma once
7
8#include <map>
9#include <iostream>
10#include "defines.hpp"
11#include "store.hpp"
Deepak Kodihalli76794492017-02-16 23:48:18 -060012#include "types.hpp"
13#include "utils.hpp"
Deepak Kodihalli8457f822016-11-29 06:05:39 -060014
15namespace openpower
16{
17namespace vpd
18{
19namespace inventory
20{
21
Deepak Kodihalli8457f822016-11-29 06:05:39 -060022/** @brief API to write parsed VPD to inventory,
23 * for a specifc FRU
24 *
25 * @param [in] vpdStore - Store object containing
26 * parsed VPD
27 * @param [in] path - FRU object path
28 */
29template<Fru F>
30void writeFru(const Store& vpdStore, const std::string& path);
31
32% for key in fruDict.iterkeys():
33<%
34 fru = fruDict[key]
35%>\
36// Specialization of ${key}
37template<>
38void writeFru<Fru::${key}>(const Store& vpdStore,
39 const std::string& path)
40{
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060041 ObjectMap objects;
42 InterfaceMap interfaces;
Deepak Kodihalli8457f822016-11-29 06:05:39 -060043
44 // Inventory manager needs object path, list of interface names to be
45 // implemented, and property:value pairs contained in said interfaces
46
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060047 % for interface, properties in fru.iteritems():
Deepak Kodihalli8457f822016-11-29 06:05:39 -060048<%
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060049 names = interface.split(".")
50 intfName = names[0] + names[-1]
Deepak Kodihalli8457f822016-11-29 06:05:39 -060051%>\
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060052 PropertyMap ${intfName}Props;
Deepak Kodihalli8457f822016-11-29 06:05:39 -060053 % for name, value in properties.iteritems():
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060054 % if fru and interface and name and value:
Deepak Kodihalli8457f822016-11-29 06:05:39 -060055<%
56 record, keyword = value.split(",")
57%>\
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060058 ${intfName}Props["${name}"] =
Deepak Kodihalli8457f822016-11-29 06:05:39 -060059 vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
60 % endif
61 % endfor
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060062 interfaces.emplace("${interface}",
63 std::move(${intfName}Props));
Deepak Kodihalli8457f822016-11-29 06:05:39 -060064 % endfor
65
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060066 sdbusplus::message::object_path object(path);
67 objects.emplace(std::move(object), std::move(interfaces));
68
69 callPIM(std::move(objects));
Deepak Kodihalli8457f822016-11-29 06:05:39 -060070}
71
72% endfor
73} // namespace inventory
74} // namespace vpd
75} // namespace openpower