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
cs-entry-impl.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
cs-entry-impl.hpp
"
27
28
namespace
nfd
{
29
namespace
cs {
30
31
EntryImpl::EntryImpl
(
const
Name
&
name
)
32
: m_queryName(name)
33
{
34
BOOST_ASSERT(this->isQuery());
35
}
36
37
EntryImpl::EntryImpl
(shared_ptr<const Data> data,
bool
isUnsolicited
)
38
{
39
this->
setData
(data, isUnsolicited);
40
BOOST_ASSERT(!this->isQuery());
41
}
42
43
bool
44
EntryImpl::isQuery()
const
45
{
46
return
!this->
hasData
();
47
}
48
49
bool
50
EntryImpl::canStale
()
const
51
{
52
BOOST_ASSERT(!this->isQuery());
53
return
this->
getStaleTime
() < time::steady_clock::TimePoint::max();
54
}
55
56
void
57
EntryImpl::unsetUnsolicited
()
58
{
59
BOOST_ASSERT(!this->isQuery());
60
this->
setData
(this->
getData
(),
false
);
61
}
62
63
int
64
compareQueryWithData
(
const
Name
& queryName,
const
Data
& data)
65
{
66
bool
queryIsFullName = !queryName.
empty
() && queryName[-1].isImplicitSha256Digest();
67
68
int
cmp = queryIsFullName ?
69
queryName.
compare
(0, queryName.
size
() - 1, data.
getName
()) :
70
queryName.
compare
(data.
getName
());
71
72
if
(cmp != 0) {
// Name without digest differs
73
return
cmp;
74
}
75
76
if
(queryIsFullName) {
// Name without digest equals, compare digest
77
return
queryName[-1].
compare
(data.
getFullName
()[-1]);
78
}
79
else
{
// queryName is a proper prefix of Data fullName
80
return
-1;
81
}
82
}
83
84
int
85
compareDataWithData
(
const
Data
& lhs,
const
Data
& rhs)
86
{
87
int
cmp = lhs.
getName
().
compare
(rhs.
getName
());
88
if
(cmp != 0) {
89
return
cmp;
90
}
91
92
return
lhs.
getFullName
()[-1].
compare
(rhs.
getFullName
()[-1]);
93
}
94
95
bool
96
EntryImpl::operator<
(
const
EntryImpl
& other)
const
97
{
98
if
(this->isQuery()) {
99
if
(other.isQuery()) {
100
return
m_queryName < other.m_queryName;
101
}
102
else
{
103
return
compareQueryWithData
(m_queryName, other.
getData
()) < 0;
104
}
105
}
106
else
{
107
if
(other.isQuery()) {
108
return
compareQueryWithData
(other.m_queryName, this->getData()) > 0;
109
}
110
else
{
111
return
compareDataWithData
(this->
getData
(), other.
getData
()) < 0;
112
}
113
}
114
}
115
116
}
// namespace cs
117
}
// namespace nfd
nfd::cs::Entry::hasData
bool hasData() const
Definition:
cs-entry.hpp:107
nfd::cs::EntryImpl::canStale
bool canStale() const
Definition:
cs-entry-impl.cpp:50
nfd::cs::Entry::setData
void setData(shared_ptr< const Data > data, bool isUnsolicited)
replaces the stored Data
Definition:
cs-entry.cpp:32
nfd::cs::EntryImpl
an Entry in ContentStore implementation
Definition:
cs-entry-impl.hpp:42
ndn::Data::getName
const Name & getName() const
Get name of the Data packet.
Definition:
data.hpp:343
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:38
nfd::cs::Entry::getData
const Data & getData() const
Definition:
cs-entry.hpp:43
nfd::cs::Entry::isUnsolicited
bool isUnsolicited() const
Definition:
cs-entry.hpp:73
ndn::Name::size
size_t size() const
Get the number of components.
Definition:
name.hpp:408
ndn::Name
Name abstraction to represent an absolute name.
Definition:
name.hpp:46
nfd::cs::EntryImpl::operator<
bool operator<(const EntryImpl &other) const
Definition:
cs-entry-impl.cpp:96
ndn::Name::compare
int compare(const Name &other) const
Compare this to the other Name using NDN canonical ordering.
Definition:
name.hpp:474
ndn::Name::empty
bool empty() const
Check if name is emtpy.
Definition:
name.hpp:398
cs-entry-impl.hpp
nfd::cs::compareQueryWithData
int compareQueryWithData(const Name &queryName, const Data &data)
Definition:
cs-entry-impl.cpp:64
ndn::Data::getFullName
const Name & getFullName() const
Get full name of Data packet, including the implicit digest.
Definition:
data.cpp:179
nfd::cs::compareDataWithData
int compareDataWithData(const Data &lhs, const Data &rhs)
Definition:
cs-entry-impl.cpp:85
ndn::Data
represents a Data packet
Definition:
data.hpp:39
nfd::cs::EntryImpl::EntryImpl
EntryImpl(const Name &name)
construct Entry for query
Definition:
cs-entry-impl.cpp:31
ndn::name
Definition:
name-component.cpp:37
nfd::cs::Entry::getStaleTime
const time::steady_clock::TimePoint & getStaleTime() const
Definition:
cs-entry.hpp:84
nfd::cs::EntryImpl::unsetUnsolicited
void unsetUnsolicited()
Definition:
cs-entry-impl.cpp:57
ndnSIM
NFD
daemon
table
cs-entry-impl.cpp
Generated on Tue Feb 23 2016 22:18:44 for ndnSIM by
1.8.11