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