#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;
/// 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