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 | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 14 | #include "extra-properties-gen.hpp" |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 15 | |
| 16 | namespace openpower |
| 17 | { |
| 18 | namespace vpd |
| 19 | { |
| 20 | namespace inventory |
| 21 | { |
| 22 | |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 23 | /** @brief API to write parsed VPD to inventory, |
| 24 | * for a specifc 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 | { |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 42 | ObjectMap objects; |
| 43 | InterfaceMap interfaces; |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 44 | |
| 45 | // Inventory manager needs object path, list of interface names to be |
| 46 | // implemented, and property:value pairs contained in said interfaces |
| 47 | |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 48 | % for interface, properties in fru.iteritems(): |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 49 | <% |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 50 | names = interface.split(".") |
| 51 | intfName = names[0] + names[-1] |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 52 | %>\ |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 53 | PropertyMap ${intfName}Props; |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 54 | % for name, value in properties.iteritems(): |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 55 | % if fru and interface and name and value: |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 56 | <% |
| 57 | record, keyword = value.split(",") |
| 58 | %>\ |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 59 | ${intfName}Props["${name}"] = |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 60 | vpdStore.get<Record::${record}, record::Keyword::${keyword}>(); |
| 61 | % endif |
| 62 | % endfor |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 63 | interfaces.emplace("${interface}", |
| 64 | std::move(${intfName}Props)); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 65 | % endfor |
| 66 | |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 67 | sdbusplus::message::object_path object(path); |
Deepak Kodihalli | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 68 | // Check and update extra properties |
| 69 | if(extra::objects.end() != extra::objects.find(path)) |
| 70 | { |
| 71 | for(const auto& entry : extra::objects.at(path)) |
| 72 | { |
| 73 | interfaces.emplace(entry.first, entry.second); |
| 74 | } |
| 75 | } |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 76 | objects.emplace(std::move(object), std::move(interfaces)); |
| 77 | |
| 78 | callPIM(std::move(objects)); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | % endfor |
| 82 | } // namespace inventory |
| 83 | } // namespace vpd |
| 84 | } // namespace openpower |