NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2
/*
3
* Copyright (c) 2013-2017 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_DETAIL_INTEREST_FILTER_RECORD_HPP
23
#define NDN_DETAIL_INTEREST_FILTER_RECORD_HPP
24
25
#include "
pending-interest.hpp
"
26
27
namespace
ndn
{
28
32
class
InterestFilterRecord
: noncopyable
33
{
34
public
:
41
InterestFilterRecord
(
const
InterestFilter
& filter,
42
const
InterestCallback
& interestCallback)
43
: m_filter(filter)
44
, m_interestCallback(interestCallback)
45
{
46
}
47
51
const
InterestFilter
&
52
getFilter
()
const
53
{
54
return
m_filter;
55
}
56
61
bool
62
doesMatch
(
const
PendingInterest
& entry)
const
63
{
64
return
(entry.
getOrigin
() ==
PendingInterestOrigin::FORWARDER
|| m_filter.
allowsLoopback
()) &&
65
m_filter.
doesMatch
(entry.
getInterest
()->getName());
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
93
class
MatchInterestFilterId
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
ndn::InterestFilterRecord::invokeInterestCallback
void invokeInterestCallback(const Interest &interest) const
invokes the InterestCallback
Definition:
interest-filter-record.hpp:73
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::InterestFilterRecord::InterestFilterRecord
InterestFilterRecord(const InterestFilter &filter, const InterestCallback &interestCallback)
Construct an Interest filter record.
Definition:
interest-filter-record.hpp:41
ndn::PendingInterest::getInterest
shared_ptr< const Interest > getInterest() const
Get the Interest.
Definition:
pending-interest.hpp:107
ndn::InterestFilter
declares the set of Interests a producer can serve, which starts with a name prefix, plus an optional regular expression
Definition:
interest-filter.hpp:35
ndn::InterestFilterRecord::getFilter
const InterestFilter & getFilter() const
Definition:
interest-filter-record.hpp:52
ndn::InterestFilterRecord
associates an InterestFilter with Interest callback
Definition:
interest-filter-record.hpp:32
ndn::InterestFilterRecord::doesMatch
bool doesMatch(const PendingInterest &entry) const
Check if Interest name matches the filter.
Definition:
interest-filter-record.hpp:62
ndn::Interest
represents an Interest packet
Definition:
interest.hpp:42
ndn::MatchInterestFilterId::MatchInterestFilterId
MatchInterestFilterId(const InterestFilterId *interestFilterId)
Definition:
interest-filter-record.hpp:97
ndn::InterestFilter::doesMatch
bool doesMatch(const Name &name) const
Check if specified Interest name matches the filter.
Definition:
interest-filter.cpp:58
ndn::MatchInterestFilterId
Functor to match InterestFilterId.
Definition:
interest-filter-record.hpp:93
pending-interest.hpp
ndn::InterestCallback
function< void(const InterestFilter &, const Interest &)> InterestCallback
Callback invoked when incoming Interest matches the specified InterestFilter.
Definition:
face.hpp:65
ndn::MatchInterestFilterId::operator()
bool operator()(const shared_ptr< InterestFilterRecord > &interestFilterId) const
Definition:
interest-filter-record.hpp:103
ndn::PendingInterestOrigin::FORWARDER
Interest was received from the forwarder via Transport.
ndn::InterestFilter::allowsLoopback
bool allowsLoopback() const
Get whether Interest loopback is allowed.
Definition:
interest-filter.hpp:131
ndn::PendingInterest::getOrigin
PendingInterestOrigin getOrigin() const
Definition:
pending-interest.hpp:113
ndn::PendingInterest
Stores a pending Interest and associated callbacks.
Definition:
pending-interest.hpp:57
ndnSIM
ndn-cxx
src
detail
interest-filter-record.hpp
Generated on Sun Feb 25 2018 13:27:04 for ndnSIM by
1.8.14