NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ndnSIM
ndnSIM documentation
All Attributes
All GlobalValues
All LogComponents
All TraceSources
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
strategy-choice.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2014-2017, 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_STRATEGY_CHOICE_HPP
27
#define NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP
28
29
#include "
strategy-choice-entry.hpp
"
30
#include "
name-tree.hpp
"
31
32
#include <boost/range/adaptor/transformed.hpp>
33
34
namespace
nfd
{
35
36
class
Forwarder
;
37
38
namespace
strategy_choice {
39
51
class
StrategyChoice
: noncopyable
52
{
53
public
:
54
explicit
55
StrategyChoice
(
Forwarder
& forwarder);
56
57
size_t
58
size
()
const
59
{
60
return
m_nItems;
61
}
62
67
void
68
setDefaultStrategy
(
const
Name
& strategyName);
69
70
public
:
// Strategy Choice table
71
class
InsertResult
72
{
73
public
:
74
explicit
75
operator
bool()
const
76
{
77
return
m_status == OK;
78
}
79
80
bool
81
isRegistered
()
const
82
{
83
return
m_status == OK || m_status == EXCEPTION;
84
}
85
86
private
:
87
enum
Status {
88
OK,
89
NOT_REGISTERED,
90
EXCEPTION,
91
DEPTH_EXCEEDED
92
};
93
94
// implicitly constructible from Status
95
InsertResult
(Status status,
const
std::string& exceptionMessage =
""
);
96
97
private
:
98
Status m_status;
99
std::string m_exceptionMessage;
100
101
friend
class
StrategyChoice
;
102
friend
std::ostream&
operator<<
(std::ostream&,
const
InsertResult
&);
103
};
104
111
InsertResult
112
insert
(
const
Name
& prefix,
const
Name
& strategyName);
113
118
void
119
erase
(
const
Name
& prefix);
120
124
std::pair<bool, Name>
125
get
(
const
Name
& prefix)
const
;
126
127
public
:
// effective strategy
130
fw::Strategy
&
131
findEffectiveStrategy
(
const
Name
& prefix)
const
;
132
137
fw::Strategy
&
138
findEffectiveStrategy
(
const
pit::Entry
& pitEntry)
const
;
139
144
fw::Strategy
&
145
findEffectiveStrategy
(
const
measurements::Entry
& measurementsEntry)
const
;
146
147
public
:
// enumeration
148
typedef
boost::transformed_range<name_tree::GetTableEntry<Entry>,
const
name_tree::Range
>
Range
;
149
typedef
boost::range_iterator<Range>::type
const_iterator
;
150
156
const_iterator
157
begin
()
const
158
{
159
return
this->getRange().begin();
160
}
161
165
const_iterator
166
end
()
const
167
{
168
return
this->getRange().end();
169
}
170
171
private
:
172
void
173
changeStrategy(
Entry
& entry,
174
fw::Strategy
& oldStrategy,
175
fw::Strategy
& newStrategy);
176
179
template
<
typename
K>
180
fw::Strategy
&
181
findEffectiveStrategyImpl(
const
K& key)
const
;
182
183
Range
184
getRange()
const
;
185
186
private
:
187
Forwarder
& m_forwarder;
188
NameTree
& m_nameTree;
189
size_t
m_nItems;
190
};
191
192
std::ostream&
193
operator<<
(std::ostream& os,
const
StrategyChoice::InsertResult
& res);
194
195
}
// namespace strategy_choice
196
197
using
strategy_choice::StrategyChoice
;
198
199
}
// namespace nfd
200
201
#endif // NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP
nfd::strategy_choice::StrategyChoice::const_iterator
boost::range_iterator< Range >::type const_iterator
Definition:
strategy-choice.hpp:149
nfd::strategy_choice::StrategyChoice::size
size_t size() const
Definition:
strategy-choice.hpp:58
nfd::strategy_choice::StrategyChoice::findEffectiveStrategy
fw::Strategy & findEffectiveStrategy(const Name &prefix) const
get effective strategy for prefix
Definition:
strategy-choice.cpp:190
nfd::strategy_choice::StrategyChoice::end
const_iterator end() const
Definition:
strategy-choice.hpp:166
nfd::strategy_choice::StrategyChoice::erase
void erase(const Name &prefix)
make prefix to inherit strategy from its parent
Definition:
strategy-choice.cpp:140
nfd::name_tree::NameTree
NameTree
Definition:
name-tree.cpp:36
nfd::Forwarder
main class of NFD
Definition:
forwarder.hpp:54
nfd::strategy_choice::StrategyChoice
StrategyChoice
Definition:
strategy-choice.cpp:40
nfd::strategy_choice::StrategyChoice::StrategyChoice
StrategyChoice(Forwarder &forwarder)
Definition:
strategy-choice.cpp:48
nfd::strategy_choice::StrategyChoice::InsertResult
Definition:
strategy-choice.hpp:71
nfd::strategy_choice::StrategyChoice::insert
InsertResult insert(const Name &prefix, const Name &strategyName)
set strategy of prefix to be strategyName
Definition:
strategy-choice.cpp:70
nfd::measurements::Entry
represents a Measurements entry
Definition:
measurements-entry.hpp:42
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::pit::Entry
an Interest table entry
Definition:
pit-entry.hpp:57
nfd::strategy_choice::StrategyChoice::InsertResult::isRegistered
bool isRegistered() const
Definition:
strategy-choice.hpp:81
ndn::Name
Represents an absolute name.
Definition:
name.hpp:42
nfd::strategy_choice::StrategyChoice::setDefaultStrategy
void setDefaultStrategy(const Name &strategyName)
set the default strategy
Definition:
strategy-choice.cpp:56
nfd::Forwarder
Forwarder
Definition:
forwarder.cpp:38
nfd::strategy_choice::StrategyChoice::InsertResult::operator<<
friend std::ostream & operator<<(std::ostream &, const InsertResult &)
Definition:
strategy-choice.cpp:123
nfd::strategy_choice::Entry
represents a Strategy Choice entry
Definition:
strategy-choice-entry.hpp:45
nfd::fw::Strategy
represents a forwarding strategy
Definition:
strategy.hpp:37
nfd::strategy_choice::StrategyChoice::Range
boost::transformed_range< name_tree::GetTableEntry< Entry >, const name_tree::Range > Range
Definition:
strategy-choice.hpp:148
strategy-choice-entry.hpp
nfd::strategy_choice::StrategyChoice
represents the Strategy Choice table
Definition:
strategy-choice.hpp:51
nfd::strategy_choice::StrategyChoice::begin
const_iterator begin() const
Definition:
strategy-choice.hpp:157
nfd::name_tree::Range
boost::iterator_range< Iterator > Range
a Forward Range of name tree entries
Definition:
name-tree-iterator.hpp:206
name-tree.hpp
ndnSIM
NFD
daemon
table
strategy-choice.hpp
Generated on Thu Nov 2 2017 03:30:29 for ndnSIM by
1.8.11