NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
interest-filter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_INTEREST_FILTER_HPP
23 #define NDN_INTEREST_FILTER_HPP
24 
25 #include "name.hpp"
26 
27 namespace ndn {
28 
29 class RegexPatternListMatcher;
30 
32 {
33 public:
34  class Error : public std::runtime_error
35  {
36  public:
37  explicit
38  Error(const std::string& what)
39  : std::runtime_error(what)
40  {
41  }
42  };
43 
51  InterestFilter(const Name& prefix);
52 
60  InterestFilter(const char* prefixUri);
61 
69  InterestFilter(const std::string& prefixUri);
70 
89  InterestFilter(const Name& prefix, const std::string& regexFilter);
90 
94  operator const Name&() const
95  {
96  if (static_cast<bool>(m_regexFilter)) {
97  BOOST_THROW_EXCEPTION(Error("Please update OnInterest callback to accept const "
98  "InterestFilter& (non-trivial Interest filter is being used)"));
99  }
100  return m_prefix;
101  }
102 
106  bool
107  doesMatch(const Name& name) const;
108 
109  const Name&
110  getPrefix() const
111  {
112  return m_prefix;
113  }
114 
115  bool
117  {
118  return static_cast<bool>(m_regexFilter);
119  }
120 
123  {
124  return *m_regexFilter;
125  }
126 
127 private:
128  Name m_prefix;
129  shared_ptr<RegexPatternListMatcher> m_regexFilter;
130 };
131 
132 std::ostream&
133 operator<<(std::ostream& os, const InterestFilter& filter);
134 
135 
136 inline
138  : m_prefix(prefix)
139 {
140 }
141 
142 inline
143 InterestFilter::InterestFilter(const char* prefixUri)
144  : m_prefix(prefixUri)
145 {
146 }
147 
148 inline
149 InterestFilter::InterestFilter(const std::string& prefixUri)
150  : m_prefix(prefixUri)
151 {
152 }
153 
154 } // namespace ndn
155 
156 #endif // NDN_INTEREST_FILTER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
bool doesMatch(const Name &name) const
Check if specified name matches the filter.
const RegexPatternListMatcher & getRegexFilter() const
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:340
STL namespace.
Error(const std::string &what)
const Name & getPrefix() const
Name abstraction to represent an absolute name.
Definition: name.hpp:46
InterestFilter(const Name &prefix)
Create an Interest filter to match Interests by prefix.
bool hasRegexFilter() const