NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
strategy-info-host.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#ifndef NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP
27
#define NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP
28
29
#include "
fw/strategy-info.hpp
"
30
31
namespace
nfd
{
32
35
class
StrategyInfoHost
36
{
37
public
:
42
template
<
typename
T>
43
T*
44
getStrategyInfo
()
const
45
{
46
static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
47
"T must inherit from StrategyInfo"
);
48
49
auto
it = m_items.find(T::getTypeId());
50
if
(it == m_items.end()) {
51
return
nullptr
;
52
}
53
return
static_cast<
T*
>
(it->second.get());
54
}
55
61
template
<
typename
T,
typename
...A>
62
std::pair<T*, bool>
63
insertStrategyInfo
(A&&... args)
64
{
65
static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
66
"T must inherit from StrategyInfo"
);
67
68
unique_ptr<fw::StrategyInfo>& item = m_items[T::getTypeId()];
69
bool
isNew = (item ==
nullptr
);
70
if
(isNew) {
71
item.reset(
new
T(std::forward<A>(args)...));
72
}
73
return
{
static_cast<
T*
>
(item.get()), isNew};
74
}
75
80
template
<
typename
T>
81
size_t
82
eraseStrategyInfo
()
83
{
84
static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
85
"T must inherit from StrategyInfo"
);
86
87
return
m_items.erase(T::getTypeId());
88
}
89
92
void
93
clearStrategyInfo
();
94
95
private
:
96
std::unordered_map<int, unique_ptr<fw::StrategyInfo>> m_items;
97
};
98
99
}
// namespace nfd
100
101
#endif // NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP
nfd::StrategyInfoHost::eraseStrategyInfo
size_t eraseStrategyInfo()
erase a StrategyInfo item
Definition:
strategy-info-host.hpp:82
nfd::StrategyInfoHost
base class for an entity onto which StrategyInfo items may be placed
Definition:
strategy-info-host.hpp:35
strategy-info.hpp
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::StrategyInfoHost::clearStrategyInfo
void clearStrategyInfo()
clear all StrategyInfo items
Definition:
strategy-info-host.cpp:31
nfd::StrategyInfoHost::insertStrategyInfo
std::pair< T *, bool > insertStrategyInfo(A &&... args)
insert a StrategyInfo item
Definition:
strategy-info-host.hpp:63
nfd::StrategyInfoHost::getStrategyInfo
T * getStrategyInfo() const
get a StrategyInfo item
Definition:
strategy-info-host.hpp:44
ndnSIM
NFD
daemon
table
strategy-info-host.hpp
Generated on Sun Feb 25 2018 13:27:06 for ndnSIM by
1.8.14