summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-09-29 22:53:53 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-09-30 00:08:23 +0530
commit2c4425e85328802325949a68787cc5f776d47842 (patch)
treeaaeab92bd91f666524c6c1967bd55424b5d18f47
parentfa23d704bd8f0f940ac2dbe055db1763c977005d (diff)
downloadphosphor-inventory-manager-2c4425e85328802325949a68787cc5f776d47842.tar.gz
phosphor-inventory-manager-2c4425e85328802325949a68787cc5f776d47842.zip
Enable Cereal class versioning
Change-Id: I0cb5a444fdd65138503d4360f03e66c5032f9870 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r--configure.ac4
-rw-r--r--gen_serialization.mako.hpp12
2 files changed, 14 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 27a6082..1429253 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,10 @@ AS_IF([test "x$PIM_PERSIST_PATH" == "x"], \
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 @@ namespace cereal
<% 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 @@ void save(Archive& a,
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:] + "()" %>\
OpenPOWER on IntegriCloud