blob: e9cbeba6e3f065bc25e22706124aae27835e7843 [file] [log] [blame]
Deepak Kodihalli35c7fb12016-11-21 04:32:44 -06001#pragma once
2
3#include <string>
4#include <unordered_map>
5#include "defines.hpp"
6#include "types.hpp"
7
8namespace openpower
9{
10namespace vpd
11{
12
13/** @brief Parsed VPD is represented as a dictionary of records, where
14 * each record in itself is a dictionary of keywords */
15using Parsed =
16 std::unordered_map<std::string,
17 std::unordered_map<std::string, std::string>>;
18
19/** @class Store
20 * @brief Store for parsed OpenPOWER VPD
21 *
22 * A Store object stores parsed OpenPOWER VPD, and provides access
23 * to the VPD, specified by record and keyword. Parsed VPD is typically
24 * provided by the Parser class.
25 */
26class Store final
27{
28 public:
29 Store() = delete;
30 Store(const Store&) = delete;
31 Store& operator=(const Store&) = delete;
32 Store(Store&&) = default;
33 Store& operator=(Store&&) = default;
34 ~Store() = default;
35
36 /** @brief Construct a Store
37 *
38 * @param[in] vpdBuffer - A parsed VPD object
39 */
40 explicit Store(Parsed&& vpdBuffer): vpd(std::move(vpdBuffer)) {}
41
42 /** @brief Retrives VPD from Store
43 *
44 * @tparam R - VPD record
45 * @tparam K - VPD keyword
46 * @returns VPD stored in input record:keyword
47 */
48 template<Record R, record::Keyword K>
49 inline const std::string& get() const;
50
51 private:
52 /** @brief The store for parsed VPD */
53 Parsed vpd;
54};
55
56} // namespace vpd
57} // namespace openpower