NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
interest-filter.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
interest-filter.hpp
"
23
24
#include "
util/regex/regex-pattern-list-matcher.hpp
"
25
26
namespace
ndn
{
27
28
InterestFilter::InterestFilter
(
const
Name
& prefix,
const
std::string& regexFilter)
29
: m_prefix(prefix)
30
, m_regexFilter(
ndn
::make_shared<
RegexPatternListMatcher
>(regexFilter,
31
shared_ptr<
RegexBackrefManager
>()))
32
{
33
}
34
35
bool
36
InterestFilter::doesMatch
(
const
Name
&
name
)
const
37
{
38
if
(name.
size
() < m_prefix.
size
())
39
return
false
;
40
41
if
(
hasRegexFilter
()) {
42
// perform prefix match and regular expression match for the remaining components
43
bool
isMatch = m_prefix.
isPrefixOf
(name);
44
45
if
(!isMatch)
46
return
false
;
47
48
return
m_regexFilter->match(name, m_prefix.
size
(), name.
size
() - m_prefix.
size
());
49
}
50
else
{
51
// perform just prefix match
52
53
return
m_prefix.
isPrefixOf
(name);
54
}
55
}
56
57
std::ostream&
58
operator<<
(std::ostream& os,
const
InterestFilter
& filter)
59
{
60
os << filter.
getPrefix
();
61
if
(filter.
hasRegexFilter
()) {
62
os <<
"?regex="
<< filter.
getRegexFilter
();
63
}
64
return
os;
65
}
66
67
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::InterestFilter::doesMatch
bool doesMatch(const Name &name) const
Check if specified name matches the filter.
Definition:
interest-filter.cpp:36
ndn::InterestFilter::getRegexFilter
const RegexPatternListMatcher & getRegexFilter() const
Definition:
interest-filter.hpp:122
ndn::RegexPatternListMatcher
Definition:
regex-pattern-list-matcher.hpp:35
ndn::operator<<
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition:
data.cpp:340
ndn::InterestFilter
Definition:
interest-filter.hpp:31
ndn::InterestFilter::getPrefix
const Name & getPrefix() const
Definition:
interest-filter.hpp:110
ndn::Name::size
size_t size() const
Get the number of components.
Definition:
name.hpp:408
ndn::RegexBackrefManager
Definition:
regex-backref-manager.hpp:35
ndn::Name
Name abstraction to represent an absolute name.
Definition:
name.hpp:46
ndn::InterestFilter::InterestFilter
InterestFilter(const Name &prefix)
Create an Interest filter to match Interests by prefix.
Definition:
interest-filter.hpp:137
ndn::Name::isPrefixOf
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...
Definition:
name.cpp:320
regex-pattern-list-matcher.hpp
ndn::name
Definition:
name-component.cpp:37
interest-filter.hpp
ndn::InterestFilter::hasRegexFilter
bool hasRegexFilter() const
Definition:
interest-filter.hpp:116
ndnSIM
ndn-cxx
src
interest-filter.cpp
Generated on Tue Feb 23 2016 22:18:43 for ndnSIM by
1.8.11