Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 1 | ## 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 Bishop | 1f4c70a | 2019-04-12 19:17:11 +0000 | [diff] [blame] | 6 | #include <cereal/types/tuple.hpp> |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 7 | #include <cereal/types/vector.hpp> |
Patrick Williams | 84b99d9 | 2020-10-14 10:09:31 -0500 | [diff] [blame] | 8 | #include <cereal/types/map.hpp> |
Vishwanatha Subbanna | 2c4425e | 2017-09-29 22:53:53 +0530 | [diff] [blame] | 9 | #include "config.h" |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 10 | % for iface in interfaces: |
| 11 | #include <${iface.header()}> |
| 12 | % endfor |
| 13 | |
Vishwanatha Subbanna | 2c4425e | 2017-09-29 22:53:53 +0530 | [diff] [blame] | 14 | % for iface in interfaces: |
| 15 | <% properties = interface_composite.names(str(iface)) %>\ |
| 16 | CEREAL_CLASS_VERSION(${iface.namespace()}, CLASS_VERSION); |
| 17 | % endfor |
| 18 | |
Brad Bishop | 23a8d93 | 2020-12-06 19:40:13 -0500 | [diff] [blame] | 19 | // 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. |
| 22 | static constexpr auto skipSignals = true; |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 23 | namespace cereal |
| 24 | { |
Santosh Puranik | 903b0de | 2021-06-09 18:58:45 +0530 | [diff] [blame] | 25 | // The version we started using cereal NVP from |
| 26 | static constexpr size_t CLASS_VERSION_WITH_NVP = 2; |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 27 | |
| 28 | % for iface in interfaces: |
| 29 | <% properties = interface_composite.names(str(iface)) %>\ |
| 30 | template<class Archive> |
| 31 | void save(Archive& a, |
Vishwanatha Subbanna | 2c4425e | 2017-09-29 22:53:53 +0530 | [diff] [blame] | 32 | const ${iface.namespace()}& object, |
| 33 | const std::uint32_t version) |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 34 | { |
Santosh Puranik | 903b0de | 2021-06-09 18:58:45 +0530 | [diff] [blame] | 35 | % for p in properties: |
| 36 | <% t = "cereal::make_nvp(\"" + p.CamelCase + "\", object." + p.camelCase + "())" |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 37 | %>\ |
Santosh Puranik | 903b0de | 2021-06-09 18:58:45 +0530 | [diff] [blame] | 38 | a(${t}); |
| 39 | % endfor |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 40 | } |
| 41 | |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 42 | template<class Archive> |
| 43 | void load(Archive& a, |
Vishwanatha Subbanna | 2c4425e | 2017-09-29 22:53:53 +0530 | [diff] [blame] | 44 | ${iface.namespace()}& object, |
| 45 | const std::uint32_t version) |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 46 | { |
| 47 | % for p in properties: |
Brad Bishop | 3864659 | 2019-04-12 18:05:45 +0000 | [diff] [blame] | 48 | <% t = "object." + p.camelCase + "()" %>\ |
| 49 | decltype(${t}) ${p.CamelCase}{}; |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 50 | % endfor |
Santosh Puranik | 903b0de | 2021-06-09 18:58:45 +0530 | [diff] [blame] | 51 | if (version < CLASS_VERSION_WITH_NVP) |
| 52 | { |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 53 | <% |
Brad Bishop | 3864659 | 2019-04-12 18:05:45 +0000 | [diff] [blame] | 54 | props = ', '.join([p.CamelCase for p in properties]) |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 55 | %>\ |
Santosh Puranik | 903b0de | 2021-06-09 18:58:45 +0530 | [diff] [blame] | 56 | 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 Williams | 3e2d964 | 2021-10-06 12:35:04 -0500 | [diff] [blame^] | 66 | catch (const Exception &e) |
Santosh Puranik | 903b0de | 2021-06-09 18:58:45 +0530 | [diff] [blame] | 67 | { |
| 68 | // Ignore any exceptions, property value stays default |
| 69 | } |
| 70 | % endfor |
| 71 | } |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 72 | % for p in properties: |
Brad Bishop | 23a8d93 | 2020-12-06 19:40:13 -0500 | [diff] [blame] | 73 | <% t = "object." + p.camelCase + "(" + p.CamelCase + ", skipSignals)" %>\ |
Deepak Kodihalli | f7b0399 | 2017-08-04 11:25:41 -0500 | [diff] [blame] | 74 | ${t}; |
| 75 | % endfor |
| 76 | } |
| 77 | |
| 78 | % endfor |
| 79 | } // namespace cereal |