PEL: Add FailingMTMS PEL section class

This PEL section contains the Machine Type-Model and Serial number of
the enclosure and is required for BMC PELs.  In the constructor that
creates the section from scratch, it gets those values from the
DataInterface class.

This commit doesn't hook this section into the PEL class as there are
some prerequisites that still need to be done first.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I24d679b57751afb00539691defef180191ea8fc7
diff --git a/extensions/openpower-pels/failing_mtms.hpp b/extensions/openpower-pels/failing_mtms.hpp
new file mode 100644
index 0000000..209eaa9
--- /dev/null
+++ b/extensions/openpower-pels/failing_mtms.hpp
@@ -0,0 +1,102 @@
+#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) 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();
+
+    /**
+     * @brief Returns the machine serial number as a string
+     *
+     * @return std::string the serial number
+     */
+    std::string getMachineSerialNumber();
+
+  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