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" |
| 12 | |
| 13 | namespace openpower |
| 14 | { |
| 15 | namespace vpd |
| 16 | { |
| 17 | namespace inventory |
| 18 | { |
| 19 | |
| 20 | using Inner = Parsed::mapped_type; |
| 21 | using Outer = std::map<std::string, Inner>; |
| 22 | |
| 23 | // TODO: Remove once the call to inventory manager is added |
| 24 | auto print = [](Outer&& object, const std::string& path) |
| 25 | { |
| 26 | std::cout << "\n"; |
| 27 | std::cout << path << "\n"; |
| 28 | std::cout << "\n"; |
| 29 | for(const auto& o : object) |
| 30 | { |
| 31 | std::cout << o.first << "\n"; |
| 32 | for(const auto& i : o.second) |
| 33 | { |
| 34 | std::cout << i.first << " : " << i.second << "\n"; |
| 35 | } |
| 36 | std::cout << "\n"; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | /** @brief API to write parsed VPD to inventory, |
| 41 | * for a specifc FRU |
| 42 | * |
| 43 | * @param [in] vpdStore - Store object containing |
| 44 | * parsed VPD |
| 45 | * @param [in] path - FRU object path |
| 46 | */ |
| 47 | template<Fru F> |
| 48 | void writeFru(const Store& vpdStore, const std::string& path); |
| 49 | |
| 50 | % for key in fruDict.iterkeys(): |
| 51 | <% |
| 52 | fru = fruDict[key] |
| 53 | %>\ |
| 54 | // Specialization of ${key} |
| 55 | template<> |
| 56 | void writeFru<Fru::${key}>(const Store& vpdStore, |
| 57 | const std::string& path) |
| 58 | { |
| 59 | Outer object; |
| 60 | |
| 61 | // Inventory manager needs object path, list of interface names to be |
| 62 | // implemented, and property:value pairs contained in said interfaces |
| 63 | |
| 64 | % for interfaces, properties in fru.iteritems(): |
| 65 | <% |
| 66 | interface = interfaces.split(".") |
| 67 | intfName = interface[0] + interface[-1] |
| 68 | %>\ |
| 69 | Inner ${intfName}; |
| 70 | % for name, value in properties.iteritems(): |
| 71 | % if fru and interfaces and name and value: |
| 72 | <% |
| 73 | record, keyword = value.split(",") |
| 74 | %>\ |
| 75 | ${intfName}["${name}"] = |
| 76 | vpdStore.get<Record::${record}, record::Keyword::${keyword}>(); |
| 77 | % endif |
| 78 | % endfor |
| 79 | object.emplace("${interfaces}", |
| 80 | std::move(${intfName})); |
| 81 | % endfor |
| 82 | |
| 83 | // TODO: Need integration with inventory manager, print serialized dbus |
| 84 | // object for now. |
| 85 | print(std::move(object), path); |
| 86 | } |
| 87 | |
| 88 | % endfor |
| 89 | } // namespace inventory |
| 90 | } // namespace vpd |
| 91 | } // namespace openpower |