Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 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" |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 12 | #include "types.hpp" |
| 13 | #include "utils.hpp" |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 14 | |
| 15 | namespace openpower |
| 16 | { |
| 17 | namespace vpd |
| 18 | { |
| 19 | namespace inventory |
| 20 | { |
| 21 | |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 22 | /** @brief API to write parsed VPD to inventory, |
| 23 | * for a specifc FRU |
| 24 | * |
| 25 | * @param [in] vpdStore - Store object containing |
| 26 | * parsed VPD |
| 27 | * @param [in] path - FRU object path |
| 28 | */ |
| 29 | template<Fru F> |
| 30 | void writeFru(const Store& vpdStore, const std::string& path); |
| 31 | |
| 32 | % for key in fruDict.iterkeys(): |
| 33 | <% |
| 34 | fru = fruDict[key] |
| 35 | %>\ |
| 36 | // Specialization of ${key} |
| 37 | template<> |
| 38 | void writeFru<Fru::${key}>(const Store& vpdStore, |
| 39 | const std::string& path) |
| 40 | { |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 41 | ObjectMap objects; |
| 42 | InterfaceMap interfaces; |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 43 | |
| 44 | // Inventory manager needs object path, list of interface names to be |
| 45 | // implemented, and property:value pairs contained in said interfaces |
| 46 | |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 47 | % for interface, properties in fru.iteritems(): |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 48 | <% |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 49 | names = interface.split(".") |
| 50 | intfName = names[0] + names[-1] |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 51 | %>\ |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 52 | PropertyMap ${intfName}Props; |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 53 | % for name, value in properties.iteritems(): |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 54 | % if fru and interface and name and value: |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 55 | <% |
| 56 | record, keyword = value.split(",") |
| 57 | %>\ |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 58 | ${intfName}Props["${name}"] = |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 59 | vpdStore.get<Record::${record}, record::Keyword::${keyword}>(); |
| 60 | % endif |
| 61 | % endfor |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 62 | interfaces.emplace("${interface}", |
| 63 | std::move(${intfName}Props)); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 64 | % endfor |
| 65 | |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 66 | sdbusplus::message::object_path object(path); |
| 67 | objects.emplace(std::move(object), std::move(interfaces)); |
| 68 | |
| 69 | callPIM(std::move(objects)); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | % endfor |
| 73 | } // namespace inventory |
| 74 | } // namespace vpd |
| 75 | } // namespace openpower |