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