Enable Cereal class versioning

Change-Id: I0cb5a444fdd65138503d4360f03e66c5032f9870
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/configure.ac b/configure.ac
index 27a6082..1429253 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,10 @@
 AC_DEFINE_UNQUOTED([PIM_PERSIST_PATH], ["$PIM_PERSIST_PATH"], \
     [Path of directory housing persisted inventory])
 
+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])
+
 # Create configured output
 AC_CONFIG_FILES([Makefile.extra],
     [${srcdir}/generate_makefile.sh $yaml > Makefile.extra],
diff --git a/gen_serialization.mako.hpp b/gen_serialization.mako.hpp
index f417917..5cf3c13 100644
--- a/gen_serialization.mako.hpp
+++ b/gen_serialization.mako.hpp
@@ -4,10 +4,16 @@
 
 #include <cereal/types/string.hpp>
 #include <cereal/types/vector.hpp>
+#include "config.h"
 % for iface in interfaces:
 #include <${iface.header()}>
 % endfor
 
+% for iface in interfaces:
+<% properties = interface_composite.names(str(iface)) %>\
+CEREAL_CLASS_VERSION(${iface.namespace()}, CLASS_VERSION);
+% endfor
+
 namespace cereal
 {
 
@@ -15,7 +21,8 @@
 <% properties = interface_composite.names(str(iface)) %>\
 template<class Archive>
 void save(Archive& a,
-          const ${iface.namespace()}& object)
+          const ${iface.namespace()}& object,
+          const std::uint32_t version)
 {
 <%
     props = ["object." + p[:1].lower() + p[1:] + "()" for p in properties]
@@ -27,7 +34,8 @@
 
 template<class Archive>
 void load(Archive& a,
-          ${iface.namespace()}& object)
+          ${iface.namespace()}& object,
+          const std::uint32_t version)
 {
 % for p in properties:
 <% t = "object." + p[:1].lower() + p[1:] + "()" %>\