blob: f7e19fc2a05c766c4f40ea0dc830d7dfc6506b70 [file] [log] [blame]
Deepak Kodihallif7b03992017-08-04 11:25:41 -05001## This file is a template. The comment below is emitted
2## into the rendered file; feel free to edit this file.
3// This file was auto generated. Do not edit.
4
Santosh Puranikb11abf22023-11-29 18:54:07 +05305#include "config.h"
6
7#include <cereal/types/map.hpp>
8#include <cereal/types/set.hpp>
Deepak Kodihallif7b03992017-08-04 11:25:41 -05009#include <cereal/types/string.hpp>
Brad Bishop1f4c70a2019-04-12 19:17:11 +000010#include <cereal/types/tuple.hpp>
Deepak Kodihallif7b03992017-08-04 11:25:41 -050011#include <cereal/types/vector.hpp>
12% for iface in interfaces:
13#include <${iface.header()}>
14% endfor
15
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +053016% for iface in interfaces:
17<% properties = interface_composite.names(str(iface)) %>\
18CEREAL_CLASS_VERSION(${iface.namespace()}, CLASS_VERSION);
19% endfor
20
Brad Bishop23a8d932020-12-06 19:40:13 -050021// Emitting signals prior to claiming a well known DBus service name causes
22// un-necessary DBus traffic and wakeups. De-serialization only happens prior
23// to claiming a well known name, so don't emit signals.
24static constexpr auto skipSignals = true;
Deepak Kodihallif7b03992017-08-04 11:25:41 -050025namespace cereal
26{
Santosh Puranik903b0de2021-06-09 18:58:45 +053027// The version we started using cereal NVP from
28static constexpr size_t CLASS_VERSION_WITH_NVP = 2;
Deepak Kodihallif7b03992017-08-04 11:25:41 -050029
30% for iface in interfaces:
31<% properties = interface_composite.names(str(iface)) %>\
32template<class Archive>
33void save(Archive& a,
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +053034 const ${iface.namespace()}& object,
George Liu23314a52022-04-13 18:26:03 +080035 const std::uint32_t /* version */)
Deepak Kodihallif7b03992017-08-04 11:25:41 -050036{
Santosh Puranik903b0de2021-06-09 18:58:45 +053037% for p in properties:
38<% t = "cereal::make_nvp(\"" + p.CamelCase + "\", object." + p.camelCase + "())"
Deepak Kodihallif7b03992017-08-04 11:25:41 -050039%>\
Santosh Puranik903b0de2021-06-09 18:58:45 +053040 a(${t});
41% endfor
Deepak Kodihallif7b03992017-08-04 11:25:41 -050042}
43
Deepak Kodihallif7b03992017-08-04 11:25:41 -050044template<class Archive>
45void load(Archive& a,
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +053046 ${iface.namespace()}& object,
47 const std::uint32_t version)
Deepak Kodihallif7b03992017-08-04 11:25:41 -050048{
49% for p in properties:
Brad Bishop38646592019-04-12 18:05:45 +000050<% t = "object." + p.camelCase + "()" %>\
51 decltype(${t}) ${p.CamelCase}{};
Deepak Kodihallif7b03992017-08-04 11:25:41 -050052% endfor
Santosh Puranik903b0de2021-06-09 18:58:45 +053053 if (version < CLASS_VERSION_WITH_NVP)
54 {
Deepak Kodihallif7b03992017-08-04 11:25:41 -050055<%
Brad Bishop38646592019-04-12 18:05:45 +000056 props = ', '.join([p.CamelCase for p in properties])
Deepak Kodihallif7b03992017-08-04 11:25:41 -050057%>\
Santosh Puranik903b0de2021-06-09 18:58:45 +053058 a(${props});
59 }
60 else
61 {
62% for p in properties:
63<% t = "cereal::make_nvp(\"" + p.CamelCase + "\", " + p.CamelCase + ")" %>\
64 try
65 {
66 a(${t});
67 }
Patrick Williams3e2d9642021-10-06 12:35:04 -050068 catch (const Exception &e)
Santosh Puranik903b0de2021-06-09 18:58:45 +053069 {
70 // Ignore any exceptions, property value stays default
71 }
72% endfor
73 }
Deepak Kodihallif7b03992017-08-04 11:25:41 -050074% for p in properties:
Brad Bishop23a8d932020-12-06 19:40:13 -050075<% t = "object." + p.camelCase + "(" + p.CamelCase + ", skipSignals)" %>\
Deepak Kodihallif7b03992017-08-04 11:25:41 -050076 ${t};
77% endfor
78}
79
80% endfor
81} // namespace cereal