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> 6 #include <cereal/types/tuple.hpp> 7 #include <cereal/types/vector.hpp> 8 #include <cereal/types/map.hpp> 9 #include "config.h" 10 % for iface in interfaces: 11 #include <${iface.header()}> 12 % endfor 13 14 % for iface in interfaces: 15 <% properties = interface_composite.names(str(iface)) %>\ 16 CEREAL_CLASS_VERSION(${iface.namespace()}, CLASS_VERSION); 17 % endfor 18 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; 23 namespace cereal 24 { 25 // The version we started using cereal NVP from 26 static constexpr size_t CLASS_VERSION_WITH_NVP = 2; 27 28 % for iface in interfaces: 29 <% properties = interface_composite.names(str(iface)) %>\ 30 template<class Archive> 31 void save(Archive& a, 32 const ${iface.namespace()}& object, 33 const std::uint32_t /* version */) 34 { 35 % for p in properties: 36 <% t = "cereal::make_nvp(\"" + p.CamelCase + "\", object." + p.camelCase + "())" 37 %>\ 38 a(${t}); 39 % endfor 40 } 41 42 template<class Archive> 43 void load(Archive& a, 44 ${iface.namespace()}& object, 45 const std::uint32_t version) 46 { 47 % for p in properties: 48 <% t = "object." + p.camelCase + "()" %>\ 49 decltype(${t}) ${p.CamelCase}{}; 50 % endfor 51 if (version < CLASS_VERSION_WITH_NVP) 52 { 53 <% 54 props = ', '.join([p.CamelCase for p in properties]) 55 %>\ 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 } 66 catch (const Exception &e) 67 { 68 // Ignore any exceptions, property value stays default 69 } 70 % endfor 71 } 72 % for p in properties: 73 <% t = "object." + p.camelCase + "(" + p.CamelCase + ", skipSignals)" %>\ 74 ${t}; 75 % endfor 76 } 77 78 % endfor 79 } // namespace cereal 80