20 #ifndef FRESHNESS_POLICY_H_    21 #define FRESHNESS_POLICY_H_    25 #include "ns3/ndnSIM/model/ndn-common.hpp"    27 #include <boost/intrusive/options.hpp>    28 #include <boost/intrusive/list.hpp>    30 #include <ns3/nstime.h>    31 #include <ns3/simulator.h>    32 #include <ns3/traced-callback.h>    41 struct freshness_policy_traits {
    49   struct policy_hook_type : 
public boost::intrusive::set_member_hook<> {
    50     Time timeWhenShouldExpire;
    53   template<
class Container>
    54   struct container_hook {
    55     typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
    59   template<
class Base, 
class Container, 
class Hook>
    64       return static_cast<typename policy_container::value_traits::hook_type*>(
    65                policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
    69     get_freshness(
typename Container::const_iterator item)
    71       return static_cast<const typename policy_container::value_traits::hook_type*>(
    72                policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
    76     struct MemberHookLess {
    78       operator()(
const Key& a, 
const Key& b)
 const    80         return get_freshness(&a) < get_freshness(&b);
    84     typedef boost::intrusive::multiset<Container,
    85                                        boost::intrusive::compare<MemberHookLess<Container>>,
    86                                        Hook> policy_container;
    88     class type : 
public policy_container {
    90       typedef policy policy_base; 
    91       typedef Container parent_trie;
   108         time::milliseconds freshness = item->payload()->GetData()->getFreshnessPeriod();
   109         if (freshness > time::milliseconds::zero()) {
   110           get_freshness(item) = Simulator::Now() + MilliSeconds(freshness.count());
   116           policy_container::insert(*item);
   131         time::milliseconds freshness = item->payload()->GetData()->getFreshnessPeriod();
   132         if (freshness > time::milliseconds::zero()) {
   134           policy_container::erase(policy_container::s_iterator_to(*item));
   141         policy_container::clear();
   145       set_max_size(
size_t max_size)
   147         max_size_ = max_size;
   158         : base_(*((Base*)0)){};
   173 #endif // LIFETIME_STATS_POLICY_H Copyright (c) 2011-2015 Regents of the University of California.
 
Table::const_iterator iterator
 
Copyright (c) 2011-2015 Regents of the University of California.