Enable Cereal class versioning
Change-Id: Ib6d212e730d25eb14ceed5b5f3f222ee3b47b35c
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/configure.ac b/configure.ac
index fa69297..d2565d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,5 +83,9 @@
AC_DEFINE_UNQUOTED([ELOG_ID_PERSIST_PATH], ["$ELOG_ID_PERSIST_PATH"], \
[Path of file for storing elog id's, which have associated dumps])
+AC_ARG_VAR(CLASS_VERSION, [Class version to register with Cereal])
+AS_IF([test "x$CLASS_VERSION" == "x"], [CLASS_VERSION=1])
+AC_DEFINE_UNQUOTED([CLASS_VERSION], [$CLASS_VERSION], [Class version to register with Cereal])
+
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/elog_watch.cpp b/elog_watch.cpp
index 5ab65df..6cb7a0f 100644
--- a/elog_watch.cpp
+++ b/elog_watch.cpp
@@ -1,9 +1,14 @@
+#include <cereal/cereal.hpp>
#include <phosphor-logging/elog.hpp>
#include "elog_watch.hpp"
#include "dump_internal.hpp"
#include "xyz/openbmc_project/Dump/Create/error.hpp"
#include "dump_serialize.hpp"
+#include "config.h"
+
+// Register class version with Cereal
+CEREAL_CLASS_VERSION(phosphor::dump::elog::Watch, CLASS_VERSION);
namespace phosphor
{
diff --git a/elog_watch.hpp b/elog_watch.hpp
index 588ac34..4730311 100644
--- a/elog_watch.hpp
+++ b/elog_watch.hpp
@@ -47,11 +47,17 @@
/** @brief Function required by Cereal to perform serialization.
* @tparam Archive - Cereal archive type (binary in our case).
* @param[in] a - reference to Cereal archive.
+ * @param[in] version - Class version that enables handling
+ * a serialized data across code levels
*/
template<class Archive>
- void serialize(Archive& a)
+ void serialize(Archive& a, const std::uint32_t version)
{
a(elogList);
+
+ //TODO: openbmc/phosphor-debug-collector#1
+ // Split into load/save so that it enables
+ // version compare during serialization
}
/** @brief Callback function for error log add.