PEL: Create PEL from parameters

Add a constructor to the PEL class so it can be built from the message
registry entry for that error along with the event log properties.

When support for new sections are added, they will be created here as
well along with the PrivateHeader and UserHeader section classes.

Eventually, this constructor will be called from the Manager class after
it is told a new event log has been created and after it looks up that
error's PEL message registry entry.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2d8ca550736aab45a30ac3db9861723b33e6cd32
diff --git a/extensions/openpower-pels/pel.hpp b/extensions/openpower-pels/pel.hpp
index 564fe33..ff45acb 100644
--- a/extensions/openpower-pels/pel.hpp
+++ b/extensions/openpower-pels/pel.hpp
@@ -1,6 +1,8 @@
 #pragma once
 
+#include "additional_data.hpp"
 #include "private_header.hpp"
+#include "registry.hpp"
 #include "user_header.hpp"
 
 #include <memory>
@@ -33,6 +35,12 @@
  * - PEL(const std::vector<uint8_t>& data) - build this object out of a fully
  *   formed flattened PEL.
  *
+ * - PEL(const openpower::pels::message::Entry& entry,
+ *       uint32_t obmcLogID,
+ *       uint64_t timestamp,
+ *       phosphor::logging::Entry::Level severity)
+ *      - build this object from an OpenBMC event log.
+ *
  * The data() method allows one to retrieve the PEL as a vector<uint8_t>.  This
  * is the format in which it is stored and transmitted.
  */
@@ -66,6 +74,20 @@
     PEL(const std::vector<uint8_t>& data, uint32_t obmcLogID);
 
     /**
+     * @brief Constructor
+     *
+     * Creates a PEL from an OpenBMC event log and its message
+     * registry entry.
+     *
+     * @param[in] entry - The message registry entry for this error
+     * @param[in] obmcLogID - ID of corresponding OpenBMC event log
+     * @param[in] timestamp - Timestamp from the event log
+     * @param[in] severity - Severity from the event log
+     */
+    PEL(const openpower::pels::message::Entry& entry, uint32_t obmcLogID,
+        uint64_t timestamp, phosphor::logging::Entry::Level severity);
+
+    /**
      * @brief Convenience function to return the log ID field from the
      *        Private Header section.
      *
@@ -198,6 +220,11 @@
      * then there will be no need to keep around the data anymore.
      */
     std::vector<uint8_t> _rawPEL;
+
+    /**
+     * @brief If the PEL came from a flattened data stream.
+     */
+    bool _fromStream = false;
 };
 
 } // namespace pels