Splitted method serialize() into load() and save() as this is needed to introduce...
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 17 Jul 2013 14:57:57 +0000 (16:57 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 17 Jul 2013 14:57:57 +0000 (16:57 +0200)
src/service.hpp

index 7d71d97..289e629 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <boost/archive/text_oarchive.hpp>
 #include <boost/archive/text_iarchive.hpp>
+#include <boost/serialization/version.hpp>
+#include <boost/serialization/split_member.hpp>
 
 #include <boost/shared_ptr.hpp>
 #include <string>
@@ -47,7 +49,7 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version)
+    void save(Archive & ar, const unsigned int version) const
     {
         // protocol and hostname are the unique identifier for each service.
         ar & Protocol;
@@ -59,8 +61,29 @@ private:
         ar & MaxUpdatesWithinInterval;
         ar & MaxEqualUpdatesInSuccession;
         ar & DNSCacheTTL;
+
+        // Activated was introduced with version 1.
         ar & Activated;
     }
+    template<class Archive>
+    void load(Archive & ar, const unsigned int version)
+    {
+        // protocol and hostname are the unique identifier for each service.
+        ar & Protocol;
+        ar & Hostname;
+        // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service.
+        ar & LastUpdates;
+        ar & ActualIP;
+        ar & UpdateInterval;
+        ar & MaxUpdatesWithinInterval;
+        ar & MaxEqualUpdatesInSuccession;
+        ar & DNSCacheTTL;
+
+        // Activated was introduced with version 1.
+        if ( version >= 1 )
+            ar & Activated;
+    }
+    BOOST_SERIALIZATION_SPLIT_MEMBER()
 
     Logger::Ptr Log;
 
@@ -135,4 +158,6 @@ public:
     bool operator!= (const Service& other) const;
 };
 
+BOOST_CLASS_VERSION(Service,1)
+
 #endif