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