blob: df29dd486caeae87cf208d8241aed50b03ef0341 [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
5#include <cereal/types/string.hpp>
Brad Bishop1f4c70a2019-04-12 19:17:11 +00006#include <cereal/types/tuple.hpp>
Deepak Kodihallif7b03992017-08-04 11:25:41 -05007#include <cereal/types/vector.hpp>
Patrick Williams84b99d92020-10-14 10:09:31 -05008#include <cereal/types/map.hpp>
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +05309#include "config.h"
Deepak Kodihallif7b03992017-08-04 11:25:41 -050010% for iface in interfaces:
11#include <${iface.header()}>
12% endfor
13
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +053014% for iface in interfaces:
15<% properties = interface_composite.names(str(iface)) %>\
16CEREAL_CLASS_VERSION(${iface.namespace()}, CLASS_VERSION);
17% endfor
18
Brad Bishop23a8d932020-12-06 19:40:13 -050019// Emitting signals prior to claiming a well known DBus service name causes
20// un-necessary DBus traffic and wakeups. De-serialization only happens prior
21// to claiming a well known name, so don't emit signals.
22static constexpr auto skipSignals = true;
Deepak Kodihallif7b03992017-08-04 11:25:41 -050023namespace cereal
24{
Santosh Puranik903b0de2021-06-09 18:58:45 +053025// The version we started using cereal NVP from
26static constexpr size_t CLASS_VERSION_WITH_NVP = 2;
Deepak Kodihallif7b03992017-08-04 11:25:41 -050027
28% for iface in interfaces:
29<% properties = interface_composite.names(str(iface)) %>\
30template<class Archive>
31void save(Archive& a,
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +053032 const ${iface.namespace()}& object,
33 const std::uint32_t version)
Deepak Kodihallif7b03992017-08-04 11:25:41 -050034{
Santosh Puranik903b0de2021-06-09 18:58:45 +053035% for p in properties:
36<% t = "cereal::make_nvp(\"" + p.CamelCase + "\", object." + p.camelCase + "())"
Deepak Kodihallif7b03992017-08-04 11:25:41 -050037%>\
Santosh Puranik903b0de2021-06-09 18:58:45 +053038 a(${t});
39% endfor
Deepak Kodihallif7b03992017-08-04 11:25:41 -050040}
41
Deepak Kodihallif7b03992017-08-04 11:25:41 -050042template<class Archive>
43void load(Archive& a,
Vishwanatha Subbanna2c4425e2017-09-29 22:53:53 +053044 ${iface.namespace()}& object,
45 const std::uint32_t version)
Deepak Kodihallif7b03992017-08-04 11:25:41 -050046{
47% for p in properties:
Brad Bishop38646592019-04-12 18:05:45 +000048<% t = "object." + p.camelCase + "()" %>\
49 decltype(${t}) ${p.CamelCase}{};
Deepak Kodihallif7b03992017-08-04 11:25:41 -050050% endfor
Santosh Puranik903b0de2021-06-09 18:58:45 +053051 if (version < CLASS_VERSION_WITH_NVP)
52 {
Deepak Kodihallif7b03992017-08-04 11:25:41 -050053<%
Brad Bishop38646592019-04-12 18:05:45 +000054 props = ', '.join([p.CamelCase for p in properties])
Deepak Kodihallif7b03992017-08-04 11:25:41 -050055%>\
Santosh Puranik903b0de2021-06-09 18:58:45 +053056 a(${props});
57 }
58 else
59 {
60% for p in properties:
61<% t = "cereal::make_nvp(\"" + p.CamelCase + "\", " + p.CamelCase + ")" %>\
62 try
63 {
64 a(${t});
65 }
Patrick Williams3e2d9642021-10-06 12:35:04 -050066 catch (const Exception &e)
Santosh Puranik903b0de2021-06-09 18:58:45 +053067 {
68 // Ignore any exceptions, property value stays default
69 }
70% endfor
71 }
Deepak Kodihallif7b03992017-08-04 11:25:41 -050072% for p in properties:
Brad Bishop23a8d932020-12-06 19:40:13 -050073<% t = "object." + p.camelCase + "(" + p.CamelCase + ", skipSignals)" %>\
Deepak Kodihallif7b03992017-08-04 11:25:41 -050074 ${t};
75% endfor
76}
77
78% endfor
79} // namespace cereal