NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
exclude.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2013, Regents of the University of California
4  * Alexander Afanasyev
5  *
6  * BSD license, See the LICENSE file for more information
7  *
8  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
9  */
10 
11 #ifndef NDN_EXCLUDE_H
12 #define NDN_EXCLUDE_H
13 
14 #include <ns3/simple-ref-count.h>
15 
16 #include "name-component.h"
17 #include <map>
18 
19 NDN_NAMESPACE_BEGIN
20 
25 class Exclude : public SimpleRefCount<Exclude>
26 {
27 public:
28  typedef std::map< name::Component, bool /*any*/, std::greater<name::Component> > exclude_type;
29 
30  typedef exclude_type::iterator iterator;
31  typedef exclude_type::const_iterator const_iterator;
32  typedef exclude_type::reverse_iterator reverse_iterator;
33  typedef exclude_type::const_reverse_iterator const_reverse_iterator;
34 
38  Exclude ();
39 
40  // no need for explicit copy constructor
41 
46  bool
47  isExcluded (const name::Component &comp) const;
48 
54  Exclude &
55  excludeOne (const name::Component &comp);
56 
63  Exclude &
64  excludeRange (const name::Component &from, const name::Component &to);
65 
71  inline Exclude &
72  excludeBefore (const name::Component &to);
73 
79  Exclude &
80  excludeAfter (const name::Component &from);
81 
91  void
92  appendExclude (const name::Component &name, bool any);
93 
97  inline size_t
98  size () const;
99 
103  inline const_iterator
104  begin () const;
105 
109  inline const_iterator
110  end () const;
111 
115  inline const_reverse_iterator
116  rbegin () const;
117 
121  inline const_reverse_iterator
122  rend () const;
123 
124 private:
125  Exclude &
126  excludeRange (iterator fromLowerBound, iterator toLowerBound);
127 
128 private:
129  exclude_type m_exclude;
130 };
131 
132 std::ostream&
133 operator << (std::ostream &os, const Exclude &name);
134 
135 inline Exclude &
136 Exclude::excludeBefore (const name::Component &to)
137 {
138  return excludeRange (name::Component (), to);
139 }
140 
141 inline size_t
142 Exclude::size () const
143 {
144  return m_exclude.size ();
145 }
146 
147 inline Exclude::const_iterator
148 Exclude::begin () const
149 {
150  return m_exclude.begin ();
151 }
152 
153 inline Exclude::const_iterator
154 Exclude::end () const
155 {
156  return m_exclude.end ();
157 }
158 
159 inline Exclude::const_reverse_iterator
160 Exclude::rbegin () const
161 {
162  return m_exclude.rbegin ();
163 }
164 
165 inline Exclude::const_reverse_iterator
166 Exclude::rend () const
167 {
168  return m_exclude.rend ();
169 }
170 
171 NDN_NAMESPACE_END
172 
173 #endif // NDN_EXCLUDE_H
Class to represent Exclude component in NDN interests.
Definition: exclude.h:25
Class to representing binary blob of NDN name component.