finished self-implementation of DNS resolver recursion; will now remove all that!
[pingcheck] / src / dns / timetolive.h
index e56d9eb..f1162dd 100644 (file)
@@ -23,7 +23,10 @@ on this file might be covered by the GNU General Public License.
 #include <stdint.h>
 
 #include <boost/asio.hpp>
-//#include "dns/hostaddress.h"
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/nvp.hpp>
+#include <boost/serialization/split_member.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 
 // forward declaration
 class HostAddress;
@@ -57,6 +60,32 @@ private:
     /// the time when the time-to-live was set, so it is possible to know the
     /// elapsed time
     boost::posix_time::ptime TtlSetTime;
+
+    // serialization
+    friend class boost::serialization::access;
+    template<class Archive>
+    void save(Archive & ar, const unsigned int version) const
+    {
+        std::string ttl_creation_time = boost::posix_time::to_iso_string(
+                                                                    TtlSetTime);
+        ar & BOOST_SERIALIZATION_NVP(Ttl);
+        ar & BOOST_SERIALIZATION_NVP(ttl_creation_time);
+    }
+
+    template<class Archive>
+    void load(Archive & ar, const unsigned int version)
+    {
+        uint32_t ttl_seconds;
+        std::string ttl_creation_time;
+        ar & BOOST_SERIALIZATION_NVP(ttl_seconds);
+        ar & BOOST_SERIALIZATION_NVP(ttl_creation_time);
+
+        // now convert to Ip and Ttl
+        Ttl = ttl_seconds;
+        TtlSetTime = boost::posix_time::from_iso_string(ttl_creation_time);
+    }
+
+    BOOST_SERIALIZATION_SPLIT_MEMBER()
 };
 
 #endif // TIME_TO_LIVE_H