PEL: Save registry callout JSON for later

When finding an entry in the PEL message registry, save the callout JSON
section, if there is one, in the returned Entry object.  This also adds
a constructor argument that lets one choose to do this or not, because
it isn't needed when used in peltool.

That JSON will be parsed at a later point.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I757509ced952ce8f07f12c28ab203e5eedf4fd32
diff --git a/extensions/openpower-pels/registry.cpp b/extensions/openpower-pels/registry.cpp
index 3c4e016..8b7ac18 100644
--- a/extensions/openpower-pels/registry.cpp
+++ b/extensions/openpower-pels/registry.cpp
@@ -376,6 +376,19 @@
                 entry.doc.messageArgSources = doc["MessageArgSources"];
             }
 
+            // If there are callouts defined, save the JSON for later
+            if (_loadCallouts)
+            {
+                if (e->contains("Callouts"))
+                {
+                    entry.callouts = (*e)["Callouts"];
+                }
+                else if (e->contains("CalloutsUsingAD"))
+                {
+                    entry.callouts = (*e)["CalloutsUsingAD"];
+                }
+            }
+
             return entry;
         }
         catch (std::exception& e)
diff --git a/extensions/openpower-pels/registry.hpp b/extensions/openpower-pels/registry.hpp
index 0a75d8e..09666f3 100644
--- a/extensions/openpower-pels/registry.hpp
+++ b/extensions/openpower-pels/registry.hpp
@@ -161,6 +161,11 @@
      * The Documentation related fields.
      */
     DOC doc;
+
+    /**
+     * @brief The callout JSON, if the entry has callouts.
+     */
+    std::optional<nlohmann::json> callouts;
 };
 
 /**
@@ -185,10 +190,30 @@
 
     /**
      * @brief Constructor
+     *
+     * Will load the callout JSON.
+     *
      * @param[in] registryFile - The path to the file.
      */
     explicit Registry(const std::filesystem::path& registryFile) :
-        _registryFile(registryFile)
+        Registry(registryFile, true)
+    {
+    }
+
+    /**
+     * @brief Constructor
+     *
+     * This version contains a parameter that allows the callout JSON
+     * to be saved in the Entry struct or not, as it isn't needed at
+     * all in some cases.
+     *
+     * @param[in] registryFile - The path to the file.
+     * @param[in] loadCallouts - If the callout JSON should be saved.
+     */
+    explicit Registry(const std::filesystem::path& registryFile,
+                      bool loadCallouts) :
+        _registryFile(registryFile),
+        _loadCallouts(loadCallouts)
     {
     }
 
@@ -229,6 +254,11 @@
      * @brief The full message registry object.
      */
     std::optional<nlohmann::json> _registry;
+
+    /**
+     * @brief If the callout JSON should be saved in the Entry on lookup.
+     */
+    bool _loadCallouts;
 };
 
 namespace helper
diff --git a/extensions/openpower-pels/tools/peltool.cpp b/extensions/openpower-pels/tools/peltool.cpp
index 61fb257..1be5953 100644
--- a/extensions/openpower-pels/tools/peltool.cpp
+++ b/extensions/openpower-pels/tools/peltool.cpp
@@ -40,8 +40,8 @@
 namespace pv = openpower::pels::pel_values;
 
 using PELFunc = std::function<void(const PEL&)>;
-message::Registry registry(getMessageRegistryPath() /
-                           message::registryFileName);
+message::Registry registry(getMessageRegistryPath() / message::registryFileName,
+                           false);
 namespace service
 {
 constexpr auto logging = "xyz.openbmc_project.Logging";