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-2021 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_CXX_IMPL_INTEREST_FILTER_RECORD_HPP
23
#define NDN_CXX_IMPL_INTEREST_FILTER_RECORD_HPP
24
25
#include "
ndn-cxx/impl/pending-interest.hpp
"
26
#include "
ndn-cxx/impl/record-container.hpp
"
27
28
namespace
ndn
{
29
33
class
InterestFilterRecord
:
public
detail::RecordBase
<InterestFilterRecord>
34
{
35
public
:
42
InterestFilterRecord
(
const
InterestFilter
& filter,
const
InterestCallback
& callback)
43
: m_filter(filter)
44
, m_interestCallback(callback)
45
{
46
}
47
48
const
InterestFilter
&
49
getFilter
()
const
50
{
51
return
m_filter;
52
}
53
58
bool
59
doesMatch
(
const
PendingInterest
& entry)
const
60
{
61
return
(entry.
getOrigin
() ==
PendingInterestOrigin::FORWARDER
|| m_filter.
allowsLoopback
()) &&
62
m_filter.
doesMatch
(entry.
getInterest
()->getName());
63
}
64
69
void
70
invokeInterestCallback
(
const
Interest
& interest)
const
71
{
72
if
(m_interestCallback !=
nullptr
) {
73
m_interestCallback(m_filter, interest);
74
}
75
}
76
77
private
:
78
InterestFilter
m_filter;
79
InterestCallback
m_interestCallback;
80
};
81
82
}
// namespace ndn
83
84
#endif // NDN_CXX_IMPL_INTEREST_FILTER_RECORD_HPP
ndn::InterestFilterRecord::invokeInterestCallback
void invokeInterestCallback(const Interest &interest) const
invokes the InterestCallback
Definition:
interest-filter-record.hpp:70
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 &callback)
Construct an Interest filter record.
Definition:
interest-filter-record.hpp:42
ndn::PendingInterest::getInterest
shared_ptr< const Interest > getInterest() const
Definition:
pending-interest.hpp:90
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:49
ndn::InterestFilter::allowsLoopback
NDN_CXX_NODISCARD bool allowsLoopback() const
Get whether Interest loopback is allowed.
Definition:
interest-filter.hpp:127
ndn::InterestFilterRecord
Associates an InterestFilter with an Interest callback.
Definition:
interest-filter-record.hpp:33
ndn::InterestFilterRecord::doesMatch
bool doesMatch(const PendingInterest &entry) const
Check if Interest name matches the filter.
Definition:
interest-filter-record.hpp:59
ndn::Interest
Represents an Interest packet.
Definition:
interest.hpp:48
ndn::InterestFilter::doesMatch
bool doesMatch(const Name &name) const
Check if specified Interest name matches the filter.
Definition:
interest-filter.cpp:58
pending-interest.hpp
ndn::InterestCallback
function< void(const InterestFilter &, const Interest &)> InterestCallback
Callback invoked when an incoming Interest matches the specified InterestFilter.
Definition:
face.hpp:65
ndn::PendingInterestOrigin::FORWARDER
Interest was received from the forwarder via Transport.
ndn::PendingInterest::getOrigin
PendingInterestOrigin getOrigin() const
Definition:
pending-interest.hpp:96
record-container.hpp
ndn::PendingInterest
Stores a pending Interest and associated callbacks.
Definition:
pending-interest.hpp:58
ndn::detail::RecordBase
Template of PendingInterest, RegisteredPrefix, and InterestFilterRecord.
Definition:
record-container.hpp:42
ndnSIM
ndn-cxx
ndn-cxx
impl
interest-filter-record.hpp
Generated on Fri May 6 2022 12:34:12 for ndnSIM by
1.8.13