summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/failing_mtms.hpp
blob: 8f5cd441dbc153a515eb59b08b32c10e706c99dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once

#include "data_interface.hpp"
#include "mtms.hpp"
#include "section.hpp"
#include "stream.hpp"

namespace openpower
{
namespace pels
{

/**
 * @class FailingMTMS
 *
 * This represents the Failing Enclosure MTMS section in a PEL.
 * It is a required section.  In the BMC case, the enclosure is
 * the system enclosure.
 */
class FailingMTMS : public Section
{
  public:
    FailingMTMS() = delete;
    ~FailingMTMS() = default;
    FailingMTMS(const FailingMTMS&) = default;
    FailingMTMS& operator=(const FailingMTMS&) = default;
    FailingMTMS(FailingMTMS&&) = default;
    FailingMTMS& operator=(FailingMTMS&&) = default;

    /**
     * @brief Constructor
     *
     * @param[in] dataIface - The object to use to obtain
     *                        the MTM and SN.
     */
    explicit FailingMTMS(const DataInterfaceBase& dataIface);

    /**
     * @brief Constructor
     *
     * Fills in this class's data fields from the stream.
     *
     * @param[in] pel - the PEL data stream
     */
    explicit FailingMTMS(Stream& pel);

    /**
     * @brief Flatten the section into the stream
     *
     * @param[in] stream - The stream to write to
     */
    void flatten(Stream& stream) const override;

    /**
     * @brief Returns the size of this section when flattened into a PEL
     *
     * @return size_t - the size of the section
     */
    static constexpr size_t flattenedSize()
    {
        return Section::flattenedSize() + MTMS::flattenedSize();
    }

    /**
     * @brief Returns the machine type+model as a string
     *
     * @return std::string the MTM
     */
    std::string getMachineTypeModel() const
    {
        return _mtms.machineTypeAndModel();
    }

    /**
     * @brief Returns the machine serial number as a string
     *
     * @return std::string the serial number
     */
    std::string getMachineSerialNumber() const
    {
        return _mtms.machineSerialNumber();
    }

    /**
     * @brief Get section in JSON.
     * @return std::optional<std::string> - Failing MTMS section in JSON
     */
    std::optional<std::string> getJSON() const override;

  private:
    /**
     * @brief Validates the section contents
     *
     * Updates _valid (in Section) with the results.
     */
    void validate() override;

    /**
     * @brief Fills in the object from the stream data
     *
     * @param[in] stream - The stream to read from
     */
    void unflatten(Stream& stream);

    /**
     * @brief The structure that holds the TM and SN fields.
     *        This is also used in other places in the PEL.
     */
    MTMS _mtms;
};

} // namespace pels

} // namespace openpower
OpenPOWER on IntegriCloud