1 ## 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 #include "types.hpp"
13 #include "utils.hpp"
14 #include "extra-properties-gen.hpp"
15 
16 namespace openpower
17 {
18 namespace vpd
19 {
20 namespace inventory
21 {
22 
23 /** @brief API to write parsed VPD to inventory,
24  *      for a specific FRU
25  *
26  *  @param [in] vpdStore - Store object containing
27  *      parsed VPD
28  *  @param [in] path - FRU object path
29  */
30 template<Fru F>
31 void writeFru(const Store& vpdStore, const std::string& path) {
32     throw std::runtime_error("Not implemented");
33 }
34 
35 % for key in fruDict.iterkeys():
36 <%
37     fru = fruDict[key]
38 %>\
39 // Specialization of ${key}
40 template<>
41 void writeFru<Fru::${key}>(const Store& vpdStore,
42                            const std::string& path)
43 {
44     ObjectMap objects;
45     InterfaceMap interfaces;
46     auto iter = extra::objects.find(path);
47 
48     // Inventory manager needs object path, list of interface names to be
49     // implemented, and property:value pairs contained in said interfaces
50 
51     % for interface, properties in fru.iteritems():
52 <%
53         names = interface.split(".")
54         intfName = names[0] + names[-1]
55 %>\
56     PropertyMap ${intfName}Props;
57         % if properties:
58             % for name, value in properties.iteritems():
59                 % if fru and interface and name and value:
60 <%
61                 record, keyword = name.split(",")
62 %>\
63     if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>())
64     {
65         ${intfName}Props["${value}"] =
66             vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
67     }
68                 % endif
69             % endfor
70         % endif
71     // Check and update extra properties
72     if(extra::objects.end() != iter)
73     {
74         auto propIter = (iter->second).find("${interface}");
75         if((iter->second).end() != propIter)
76         {
77             for(const auto& map : propIter->second)
78             {
79                 ${intfName}Props[map.first] = map.second;
80             }
81         }
82     }
83     interfaces.emplace("${interface}",
84                        std::move(${intfName}Props));
85     % endfor
86 
87     sdbusplus::message::object_path object(path);
88     // Check and update extra properties
89     if(extra::objects.end() != iter)
90     {
91         for(const auto& entry : iter->second)
92         {
93             if(interfaces.end() == interfaces.find(entry.first))
94             {
95                 interfaces.emplace(entry.first, entry.second);
96             }
97         }
98     }
99     objects.emplace(std::move(object), std::move(interfaces));
100 
101     callPIM(std::move(objects));
102 }
103 
104 % endfor
105 } // namespace inventory
106 } // namespace vpd
107 } // namespace openpower
108