18457f821SDeepak Kodihalli ## This file is a template.  The comment below is emitted
28457f821SDeepak Kodihalli ## into the rendered file; feel free to edit this file.
38457f821SDeepak Kodihalli // WARNING: Generated header. Do not edit!
48457f821SDeepak Kodihalli 
58457f821SDeepak Kodihalli 
68457f821SDeepak Kodihalli #pragma once
78457f821SDeepak Kodihalli 
88457f821SDeepak Kodihalli #include <map>
98457f821SDeepak Kodihalli #include <iostream>
108457f821SDeepak Kodihalli #include "defines.hpp"
118457f821SDeepak Kodihalli #include "store.hpp"
1276794495SDeepak Kodihalli #include "types.hpp"
1376794495SDeepak Kodihalli #include "utils.hpp"
14128512b2SDeepak Kodihalli #include "extra-properties-gen.hpp"
158457f821SDeepak Kodihalli 
168457f821SDeepak Kodihalli namespace openpower
178457f821SDeepak Kodihalli {
188457f821SDeepak Kodihalli namespace vpd
198457f821SDeepak Kodihalli {
208457f821SDeepak Kodihalli namespace inventory
218457f821SDeepak Kodihalli {
228457f821SDeepak Kodihalli 
238457f821SDeepak Kodihalli /** @brief API to write parsed VPD to inventory,
248457f821SDeepak Kodihalli  *      for a specifc FRU
258457f821SDeepak Kodihalli  *
268457f821SDeepak Kodihalli  *  @param [in] vpdStore - Store object containing
278457f821SDeepak Kodihalli  *      parsed VPD
288457f821SDeepak Kodihalli  *  @param [in] path - FRU object path
298457f821SDeepak Kodihalli  */
308457f821SDeepak Kodihalli template<Fru F>
318457f821SDeepak Kodihalli void writeFru(const Store& vpdStore, const std::string& path);
328457f821SDeepak Kodihalli 
338457f821SDeepak Kodihalli % for key in fruDict.iterkeys():
348457f821SDeepak Kodihalli <%
358457f821SDeepak Kodihalli     fru = fruDict[key]
368457f821SDeepak Kodihalli %>\
378457f821SDeepak Kodihalli // Specialization of ${key}
388457f821SDeepak Kodihalli template<>
398457f821SDeepak Kodihalli void writeFru<Fru::${key}>(const Store& vpdStore,
408457f821SDeepak Kodihalli                            const std::string& path)
418457f821SDeepak Kodihalli {
424cf89a10SDeepak Kodihalli     ObjectMap objects;
434cf89a10SDeepak Kodihalli     InterfaceMap interfaces;
44*0cc20121SDeepak Kodihalli     auto iter = extra::objects.find(path);
458457f821SDeepak Kodihalli 
468457f821SDeepak Kodihalli     // Inventory manager needs object path, list of interface names to be
478457f821SDeepak Kodihalli     // implemented, and property:value pairs contained in said interfaces
488457f821SDeepak Kodihalli 
494cf89a10SDeepak Kodihalli     % for interface, properties in fru.iteritems():
508457f821SDeepak Kodihalli <%
514cf89a10SDeepak Kodihalli         names = interface.split(".")
524cf89a10SDeepak Kodihalli         intfName = names[0] + names[-1]
538457f821SDeepak Kodihalli %>\
544cf89a10SDeepak Kodihalli     PropertyMap ${intfName}Props;
558457f821SDeepak Kodihalli         % for name, value in properties.iteritems():
564cf89a10SDeepak Kodihalli             % if fru and interface and name and value:
578457f821SDeepak Kodihalli <%
588457f821SDeepak Kodihalli                 record, keyword = value.split(",")
598457f821SDeepak Kodihalli %>\
604cf89a10SDeepak Kodihalli     ${intfName}Props["${name}"] =
618457f821SDeepak Kodihalli         vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
628457f821SDeepak Kodihalli             % endif
638457f821SDeepak Kodihalli         % endfor
64*0cc20121SDeepak Kodihalli     // Check and update extra properties
65*0cc20121SDeepak Kodihalli     if(extra::objects.end() != iter)
66*0cc20121SDeepak Kodihalli     {
67*0cc20121SDeepak Kodihalli         auto propIter = (iter->second).find("${interface}");
68*0cc20121SDeepak Kodihalli         if((iter->second).end() != propIter)
69*0cc20121SDeepak Kodihalli         {
70*0cc20121SDeepak Kodihalli             for(const auto& map : propIter->second)
71*0cc20121SDeepak Kodihalli             {
72*0cc20121SDeepak Kodihalli                 ${intfName}Props[map.first] = map.second;
73*0cc20121SDeepak Kodihalli             }
74*0cc20121SDeepak Kodihalli         }
75*0cc20121SDeepak Kodihalli     }
764cf89a10SDeepak Kodihalli     interfaces.emplace("${interface}",
774cf89a10SDeepak Kodihalli                        std::move(${intfName}Props));
788457f821SDeepak Kodihalli     % endfor
798457f821SDeepak Kodihalli 
804cf89a10SDeepak Kodihalli     sdbusplus::message::object_path object(path);
81128512b2SDeepak Kodihalli     // Check and update extra properties
82*0cc20121SDeepak Kodihalli     if(extra::objects.end() != iter)
83128512b2SDeepak Kodihalli     {
84*0cc20121SDeepak Kodihalli         for(const auto& entry : iter->second)
85*0cc20121SDeepak Kodihalli         {
86*0cc20121SDeepak Kodihalli             if(interfaces.end() == interfaces.find(entry.first))
87128512b2SDeepak Kodihalli             {
88128512b2SDeepak Kodihalli                 interfaces.emplace(entry.first, entry.second);
89128512b2SDeepak Kodihalli             }
90128512b2SDeepak Kodihalli         }
91*0cc20121SDeepak Kodihalli     }
924cf89a10SDeepak Kodihalli     objects.emplace(std::move(object), std::move(interfaces));
934cf89a10SDeepak Kodihalli 
944cf89a10SDeepak Kodihalli     callPIM(std::move(objects));
958457f821SDeepak Kodihalli }
968457f821SDeepak Kodihalli 
978457f821SDeepak Kodihalli % endfor
988457f821SDeepak Kodihalli } // namespace inventory
998457f821SDeepak Kodihalli } // namespace vpd
1008457f821SDeepak Kodihalli } // namespace openpower
101