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"
14*128512b2SDeepak 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;
448457f821SDeepak Kodihalli 
458457f821SDeepak Kodihalli     // Inventory manager needs object path, list of interface names to be
468457f821SDeepak Kodihalli     // implemented, and property:value pairs contained in said interfaces
478457f821SDeepak Kodihalli 
484cf89a10SDeepak Kodihalli     % for interface, properties in fru.iteritems():
498457f821SDeepak Kodihalli <%
504cf89a10SDeepak Kodihalli         names = interface.split(".")
514cf89a10SDeepak Kodihalli         intfName = names[0] + names[-1]
528457f821SDeepak Kodihalli %>\
534cf89a10SDeepak Kodihalli     PropertyMap ${intfName}Props;
548457f821SDeepak Kodihalli         % for name, value in properties.iteritems():
554cf89a10SDeepak Kodihalli             % if fru and interface and name and value:
568457f821SDeepak Kodihalli <%
578457f821SDeepak Kodihalli                 record, keyword = value.split(",")
588457f821SDeepak Kodihalli %>\
594cf89a10SDeepak Kodihalli     ${intfName}Props["${name}"] =
608457f821SDeepak Kodihalli         vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
618457f821SDeepak Kodihalli             % endif
628457f821SDeepak Kodihalli         % endfor
634cf89a10SDeepak Kodihalli     interfaces.emplace("${interface}",
644cf89a10SDeepak Kodihalli                        std::move(${intfName}Props));
658457f821SDeepak Kodihalli     % endfor
668457f821SDeepak Kodihalli 
674cf89a10SDeepak Kodihalli     sdbusplus::message::object_path object(path);
68*128512b2SDeepak Kodihalli     // Check and update extra properties
69*128512b2SDeepak Kodihalli     if(extra::objects.end() != extra::objects.find(path))
70*128512b2SDeepak Kodihalli     {
71*128512b2SDeepak Kodihalli         for(const auto& entry : extra::objects.at(path))
72*128512b2SDeepak Kodihalli         {
73*128512b2SDeepak Kodihalli             interfaces.emplace(entry.first, entry.second);
74*128512b2SDeepak Kodihalli         }
75*128512b2SDeepak Kodihalli     }
764cf89a10SDeepak Kodihalli     objects.emplace(std::move(object), std::move(interfaces));
774cf89a10SDeepak Kodihalli 
784cf89a10SDeepak Kodihalli     callPIM(std::move(objects));
798457f821SDeepak Kodihalli }
808457f821SDeepak Kodihalli 
818457f821SDeepak Kodihalli % endfor
828457f821SDeepak Kodihalli } // namespace inventory
838457f821SDeepak Kodihalli } // namespace vpd
848457f821SDeepak Kodihalli } // namespace openpower
85