NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
a
b
c
d
e
f
g
h
i
k
n
o
p
q
r
s
t
u
v
Enumerations
a
b
c
d
f
i
k
l
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
a
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Enumerations
_
a
c
e
i
r
s
t
v
Enumerator
a
c
d
e
f
i
k
l
m
n
p
r
s
u
v
w
Related Functions
b
c
d
e
f
g
i
k
l
m
n
o
p
s
v
Files
File List
File Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
c
f
h
m
r
s
u
w
Variables
a
b
c
d
f
g
i
k
l
m
n
p
r
s
t
Typedefs
Macros
a
d
e
f
i
l
m
n
o
p
r
s
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
cs-policy.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2014-2019, Regents of the University of California,
4
* Arizona Board of Regents,
5
* Colorado State University,
6
* University Pierre & Marie Curie, Sorbonne University,
7
* Washington University in St. Louis,
8
* Beijing Institute of Technology,
9
* The University of Memphis.
10
*
11
* This file is part of NFD (Named Data Networking Forwarding Daemon).
12
* See AUTHORS.md for complete list of NFD authors and contributors.
13
*
14
* NFD is free software: you can redistribute it and/or modify it under the terms
15
* of the GNU General Public License as published by the Free Software Foundation,
16
* either version 3 of the License, or (at your option) any later version.
17
*
18
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20
* PURPOSE. See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License along with
23
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24
*/
25
26
#ifndef NFD_DAEMON_TABLE_CS_POLICY_HPP
27
#define NFD_DAEMON_TABLE_CS_POLICY_HPP
28
29
#include "
cs-entry.hpp
"
30
31
namespace
nfd
{
32
namespace
cs {
33
34
class
Cs;
35
38
class
Policy
: noncopyable
39
{
40
public
:
// registry
41
template
<
typename
P>
42
static
void
43
registerPolicy
(
const
std::string& policyName = P::POLICY_NAME)
44
{
45
Registry& registry = getRegistry();
46
BOOST_ASSERT(registry.count(policyName) == 0);
47
registry[policyName] = [] {
return
make_unique<P>(); };
48
}
49
53
static
unique_ptr<Policy>
54
create
(
const
std::string& policyName);
55
58
static
std::set<std::string>
59
getPolicyNames
();
60
61
public
:
62
explicit
63
Policy
(
const
std::string& policyName);
64
65
virtual
66
~Policy
() =
default
;
67
68
const
std::string&
69
getName
()
const
70
{
71
return
m_policyName;
72
}
73
76
Cs
*
77
getCs
()
const
78
{
79
return
m_cs;
80
}
81
84
void
85
setCs
(
Cs
* cs)
86
{
87
m_cs = cs;
88
}
89
92
size_t
93
getLimit
()
const
94
{
95
return
m_limit;
96
}
97
104
void
105
setLimit
(
size_t
nMaxEntries);
106
107
public
:
111
using
EntryRef
= Table::const_iterator;
112
118
signal::Signal<Policy, EntryRef>
beforeEvict
;
119
126
void
127
afterInsert
(
EntryRef
i);
128
133
void
134
afterRefresh
(
EntryRef
i);
135
139
void
140
beforeErase
(
EntryRef
i);
141
146
void
147
beforeUse
(
EntryRef
i);
148
149
protected
:
158
virtual
void
159
doAfterInsert
(
EntryRef
i) = 0;
160
166
virtual
void
167
doAfterRefresh
(
EntryRef
i) = 0;
168
175
virtual
void
176
doBeforeErase
(
EntryRef
i) = 0;
177
183
virtual
void
184
doBeforeUse
(
EntryRef
i) = 0;
185
189
virtual
void
190
evictEntries
() = 0;
191
192
protected
:
193
DECLARE_SIGNAL_EMIT
(
beforeEvict
)
194
195
private
:
// registry
196
using
CreateFunc = std::function<unique_ptr<Policy>()>;
197
using
Registry = std::map<std::string, CreateFunc>;
// indexed by policy name
198
199
static
Registry&
200
getRegistry();
201
202
private
:
203
std::string m_policyName;
204
size_t
m_limit;
205
Cs
* m_cs;
206
};
207
208
}
// namespace cs
209
}
// namespace nfd
210
214
#define NFD_REGISTER_CS_POLICY(P) \
215
static class NfdAuto ## P ## CsPolicyRegistrationClass \
216
{ \
217
public: \
218
NfdAuto ## P ## CsPolicyRegistrationClass() \
219
{ \
220
::nfd::cs::Policy::registerPolicy<P>(); \
221
} \
222
} g_nfdAuto ## P ## CsPolicyRegistrationVariable
223
224
#endif // NFD_DAEMON_TABLE_CS_POLICY_HPP
cs-entry.hpp
nfd::cs::Policy::registerPolicy
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
Definition:
cs-policy.hpp:43
nfd::cs::Policy::beforeUse
void beforeUse(EntryRef i)
invoked by CS before an entry is used to match a lookup
Definition:
cs-policy.cpp:97
nfd::cs::Policy
represents a CS replacement policy
Definition:
cs-policy.hpp:39
nfd::cs::Cs
implements the Content Store
Definition:
cs.hpp:45
nfd::cs::Policy::setLimit
void setLimit(size_t nMaxEntries)
sets hard limit (in number of entries)
Definition:
cs-policy.cpp:68
nfd::cs::Policy::EntryRef
Table::const_iterator EntryRef
a reference to an CS entry
Definition:
cs-policy.hpp:111
nfd::cs::Policy::~Policy
virtual ~Policy()=default
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition:
signal.hpp:52
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::cs::Policy::afterRefresh
void afterRefresh(EntryRef i)
invoked by CS after an existing entry is refreshed by same Data
Definition:
cs-policy.cpp:83
nfd::cs::Policy::beforeEvict
signal::Signal< Policy, EntryRef > beforeEvict
emits when an entry is being evicted
Definition:
cs-policy.hpp:118
nfd::cs::Policy::doBeforeErase
virtual void doBeforeErase(EntryRef i)=0
invoked before an entry is erased due to management command
nfd::cs::Policy::doAfterRefresh
virtual void doAfterRefresh(EntryRef i)=0
invoked after an existing entry is refreshed by same Data
nfd::cs::Policy::evictEntries
virtual void evictEntries()=0
evicts zero or more entries
nfd::cs::Policy::beforeErase
void beforeErase(EntryRef i)
invoked by CS before an entry is erased due to management command
Definition:
cs-policy.cpp:90
nfd::cs::Policy::Policy
Policy(const std::string &policyName)
Definition:
cs-policy.cpp:62
nfd::cs::Policy::create
static unique_ptr< Policy > create(const std::string &policyName)
Definition:
cs-policy.cpp:46
nfd::cs::Policy::afterInsert
void afterInsert(EntryRef i)
invoked by CS after a new entry is inserted
Definition:
cs-policy.cpp:76
nfd::cs::Policy::getCs
Cs * getCs() const
gets cs
Definition:
cs-policy.hpp:77
DECLARE_SIGNAL_EMIT
#define DECLARE_SIGNAL_EMIT(signalName)
(implementation detail) declares a 'emit_signalName' method
Definition:
emit.hpp:59
nfd::cs::Policy::doAfterInsert
virtual void doAfterInsert(EntryRef i)=0
invoked after a new entry is created in CS
nfd::cs::Policy::getName
const std::string & getName() const
Definition:
cs-policy.hpp:69
nfd::cs::Policy::getLimit
size_t getLimit() const
gets hard limit (in number of entries)
Definition:
cs-policy.hpp:93
nfd::cs::Policy::getPolicyNames
static std::set< std::string > getPolicyNames()
Definition:
cs-policy.cpp:54
nfd::cs::Policy::setCs
void setCs(Cs *cs)
sets cs
Definition:
cs-policy.hpp:85
nfd::cs::Policy::doBeforeUse
virtual void doBeforeUse(EntryRef i)=0
invoked before an entry is used to match a lookup
ndnSIM
NFD
daemon
table
cs-policy.hpp
Generated on Mon Jun 1 2020 22:32:16 for ndnSIM by
1.8.18