NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 "../common.hpp"
26 #include "../name.hpp"
27 #include "../interest.hpp"
28 
29 namespace ndn {
30 
31 class InterestFilterRecord : noncopyable
32 {
33 public:
34  typedef function<void (const InterestFilter&, const Interest&)> InterestCallback;
35 
36  InterestFilterRecord(const InterestFilter& filter, const InterestCallback& afterInterest)
37  : m_filter(filter)
38  , m_afterInterest(afterInterest)
39  {
40  }
41 
46  bool
47  doesMatch(const Name& name) const
48  {
49  return m_filter.doesMatch(name);
50  }
51 
56  void
57  invokeInterestCallback(const Interest& interest) const
58  {
59  m_afterInterest(m_filter, interest);
60  }
61 
62  const InterestFilter&
63  getFilter() const
64  {
65  return m_filter;
66  }
67 
68 private:
69  InterestFilter m_filter;
70  InterestCallback m_afterInterest;
71 };
72 
73 
77 class InterestFilterId;
78 
83 {
84 public:
85  explicit
86  MatchInterestFilterId(const InterestFilterId* interestFilterId)
87  : m_id(interestFilterId)
88  {
89  }
90 
91  bool
92  operator()(const shared_ptr<InterestFilterRecord>& interestFilterId) const
93  {
94  return (reinterpret_cast<const InterestFilterId*>(interestFilterId.get()) == m_id);
95  }
96 private:
97  const InterestFilterId* m_id;
98 };
99 
100 } // namespace ndn
101 
102 #endif // NDN_DETAIL_INTEREST_FILTER_RECORD_HPP
void invokeInterestCallback(const Interest &interest) const
invokes the InterestCallback
Copyright (c) 2011-2015 Regents of the University of California.
const InterestFilter & getFilter() const
represents an Interest packet
Definition: interest.hpp:45
MatchInterestFilterId(const InterestFilterId *interestFilterId)
bool doesMatch(const Name &name) const
Check if specified name matches the filter.
function< void(const InterestFilter &, const Interest &)> InterestCallback
Functor to match InterestFilterId.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
bool operator()(const shared_ptr< InterestFilterRecord > &interestFilterId) const
InterestFilterRecord(const InterestFilter &filter, const InterestCallback &afterInterest)
bool doesMatch(const Name &name) const
Check if Interest name matches the filter.