NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
counting-policy.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef COUNTING_POLICY_H_
21 #define COUNTING_POLICY_H_
22 
24 
25 #include <boost/intrusive/options.hpp>
26 #include <boost/intrusive/list.hpp>
27 
28 namespace ns3 {
29 namespace ndn {
30 namespace ndnSIM {
31 
36 struct counting_policy_traits {
38  static std::string
39  GetName()
40  {
41  return "Counting";
42  }
43 
44  struct policy_hook_type : public boost::intrusive::list_member_hook<> {
45  };
46 
47  template<class Container>
48  struct container_hook {
49  // could be class/struct implementation
50  typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
51  type;
52  };
53 
54  template<class Base, class Container, class Hook>
55  struct policy {
56  typedef typename boost::intrusive::list<Container, Hook> policy_container;
57 
58  // could be just typedef
59  class type : public policy_container {
60  public:
61  typedef Container parent_trie;
62 
63  type(Base& base)
64  : base_(base)
65  {
66  }
67 
68  inline void
69  update(typename parent_trie::iterator item)
70  {
71  // do nothing
72  }
73 
74  inline bool
75  insert(typename parent_trie::iterator item)
76  {
77  policy_container::push_back(*item);
78  return true;
79  }
80 
81  inline void
82  lookup(typename parent_trie::iterator item)
83  {
84  // do nothing
85  }
86 
87  inline void
88  erase(typename parent_trie::iterator item)
89  {
90  policy_container::erase(policy_container::s_iterator_to(*item));
91  }
92 
93  inline void
94  clear()
95  {
96  policy_container::clear();
97  }
98 
99  private:
100  type()
101  : base_(*((Base*)0)){};
102 
103  private:
104  Base& base_;
105  };
106  };
107 };
108 
109 } // ndnSIM
110 } // ndn
111 } // ns3
112 
114 
115 #endif // COUNTING_POLICY_H_
Copyright (c) 2011-2015 Regents of the University of California.
Table::const_iterator iterator
Definition: cs-internal.hpp:41
Copyright (c) 2011-2015 Regents of the University of California.