NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
interest-filter-record.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_DETAIL_INTEREST_FILTER_RECORD_HPP
23 #define NDN_DETAIL_INTEREST_FILTER_RECORD_HPP
24 
25 #include "../name.hpp"
26 #include "../interest.hpp"
27 
28 namespace ndn {
29 
33 class InterestFilterRecord : noncopyable
34 {
35 public:
43  const InterestCallback& interestCallback)
44  : m_filter(filter)
45  , m_interestCallback(interestCallback)
46  {
47  }
48 
52  const InterestFilter&
53  getFilter() const
54  {
55  return m_filter;
56  }
57 
62  bool
63  doesMatch(const Name& name) const
64  {
65  return m_filter.doesMatch(name);
66  }
67 
72  void
73  invokeInterestCallback(const Interest& interest) const
74  {
75  if (m_interestCallback != nullptr) {
76  m_interestCallback(m_filter, interest);
77  }
78  }
79 
80 private:
81  InterestFilter m_filter;
82  InterestCallback m_interestCallback;
83 };
84 
88 class InterestFilterId;
89 
94 {
95 public:
96  explicit
97  MatchInterestFilterId(const InterestFilterId* interestFilterId)
98  : m_id(interestFilterId)
99  {
100  }
101 
102  bool
103  operator()(const shared_ptr<InterestFilterRecord>& interestFilterId) const
104  {
105  return reinterpret_cast<const InterestFilterId*>(interestFilterId.get()) == m_id;
106  }
107 
108 private:
109  const InterestFilterId* m_id;
110 };
111 
112 } // namespace ndn
113 
114 #endif // NDN_DETAIL_INTEREST_FILTER_RECORD_HPP
Copyright (c) 2011-2015 Regents of the University of California.
bool doesMatch(const Name &name) const
Check if specified Interest name matches the filter.
InterestFilterRecord(const InterestFilter &filter, const InterestCallback &interestCallback)
Construct an Interest filter record.
void invokeInterestCallback(const Interest &interest) const
invokes the InterestCallback
declares the set of Interests a producer can serve, which starts with a name prefix, plus an optional regular expression
associates an InterestFilter with Interest callback
represents an Interest packet
Definition: interest.hpp:42
MatchInterestFilterId(const InterestFilterId *interestFilterId)
const InterestFilter & getFilter() const
Functor to match InterestFilterId.
bool doesMatch(const Name &name) const
Check if Interest name matches the filter.
Represents an absolute name.
Definition: name.hpp:42
function< void(const InterestFilter &, const Interest &)> InterestCallback
Callback invoked when incoming Interest matches the specified InterestFilter.
Definition: face.hpp:70
bool operator()(const shared_ptr< InterestFilterRecord > &interestFilterId) const