blob: f7a2aa8e076746542f1013867ee090d9c7349fa7 [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"
12
13namespace openpower
14{
15namespace vpd
16{
17namespace inventory
18{
19
20using Inner = Parsed::mapped_type;
21using Outer = std::map<std::string, Inner>;
22
23// TODO: Remove once the call to inventory manager is added
24auto print = [](Outer&& object, const std::string& path)
25{
26 std::cout << "\n";
27 std::cout << path << "\n";
28 std::cout << "\n";
29 for(const auto& o : object)
30 {
31 std::cout << o.first << "\n";
32 for(const auto& i : o.second)
33 {
34 std::cout << i.first << " : " << i.second << "\n";
35 }
36 std::cout << "\n";
37 }
38};
39
40/** @brief API to write parsed VPD to inventory,
41 * for a specifc FRU
42 *
43 * @param [in] vpdStore - Store object containing
44 * parsed VPD
45 * @param [in] path - FRU object path
46 */
47template<Fru F>
48void writeFru(const Store& vpdStore, const std::string& path);
49
50% for key in fruDict.iterkeys():
51<%
52 fru = fruDict[key]
53%>\
54// Specialization of ${key}
55template<>
56void writeFru<Fru::${key}>(const Store& vpdStore,
57 const std::string& path)
58{
59 Outer object;
60
61 // Inventory manager needs object path, list of interface names to be
62 // implemented, and property:value pairs contained in said interfaces
63
64 % for interfaces, properties in fru.iteritems():
65<%
66 interface = interfaces.split(".")
67 intfName = interface[0] + interface[-1]
68%>\
69 Inner ${intfName};
70 % for name, value in properties.iteritems():
71 % if fru and interfaces and name and value:
72<%
73 record, keyword = value.split(",")
74%>\
75 ${intfName}["${name}"] =
76 vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
77 % endif
78 % endfor
79 object.emplace("${interfaces}",
80 std::move(${intfName}));
81 % endfor
82
83 // TODO: Need integration with inventory manager, print serialized dbus
84 // object for now.
85 print(std::move(object), path);
86}
87
88% endfor
89} // namespace inventory
90} // namespace vpd
91} // namespace openpower