Enable Cereal class versioning
Fixes openbmc/openbmc#2320
Change-Id: Iac2649cd5f4794e2049cbdd4eb2df874d26beaaa
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/configure.ac b/configure.ac
index 895ce17..ec6df59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,5 +41,9 @@
AC_DEFINE_UNQUOTED([SETTINGS_PERSIST_PATH], ["$SETTINGS_PERSIST_PATH"], \
[Path of directory housing persisted settings])
+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/settings_manager.mako.hpp b/settings_manager.mako.hpp
index 9e0b3fd..09a5a1f 100644
--- a/settings_manager.mako.hpp
+++ b/settings_manager.mako.hpp
@@ -216,7 +216,8 @@
template<class Archive>
void save(Archive& a,
- const Impl& setting)
+ const Impl& setting,
+ const std::uint32_t version)
{
<%
props = []
@@ -231,7 +232,8 @@
template<class Archive>
void load(Archive& a,
- Impl& setting)
+ Impl& setting,
+ const std::uint32_t version)
{
<% props = [] %>\
% for index, item in enumerate(settingsDict[object]):
@@ -349,3 +351,18 @@
} // namespace settings
} // namespace phosphor
+
+// Now register the class version with Cereal
+% for object in objects:
+<%
+ classname = "phosphor::settings"
+ ns = object.split('/')
+ ns.pop(0)
+%>\
+% for n in ns:
+<%
+ classname += "::" + n
+%>\
+% endfor
+CEREAL_CLASS_VERSION(${classname + "::Impl"}, CLASS_VERSION);
+% endfor