NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
container-with-on-empty-signal.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_DETAIL_CONTAINER_WITH_ON_EMPTY_SIGNAL_HPP
23
#define NDN_DETAIL_CONTAINER_WITH_ON_EMPTY_SIGNAL_HPP
24
25
#include "../common.hpp"
26
#include "../util/signal.hpp"
27
28
namespace
ndn
{
29
33
template
<
class
T>
34
class
ContainerWithOnEmptySignal
35
{
36
public
:
37
typedef
std::list<T>
Base
;
38
typedef
typename
Base::value_type
value_type
;
39
typedef
typename
Base::iterator
iterator
;
40
41
iterator
42
begin
()
43
{
44
return
m_container
.begin();
45
}
46
47
iterator
48
end
()
49
{
50
return
m_container
.end();
51
}
52
53
size_t
54
size
()
55
{
56
return
m_container
.size();
57
}
58
59
bool
60
empty
()
61
{
62
return
m_container
.empty();
63
}
64
65
iterator
66
erase
(iterator item)
67
{
68
iterator next =
m_container
.erase(item);
69
if
(
empty
()) {
70
this->
onEmpty
();
71
}
72
return
next;
73
}
74
75
void
76
clear
()
77
{
78
m_container
.clear();
79
this->
onEmpty
();
80
}
81
82
std::pair<iterator, bool>
83
insert
(
const
value_type& value)
84
{
85
return
{
m_container
.insert(
end
(), value),
true
};
86
}
87
88
template
<
class
Predicate>
89
void
remove_if
(Predicate p)
90
{
91
m_container
.remove_if(p);
92
if
(
empty
()) {
93
this->
onEmpty
();
94
}
95
}
96
97
public
:
98
Base
m_container
;
99
103
util::Signal<ContainerWithOnEmptySignal<T>
>
onEmpty
;
104
};
105
106
}
// namespace ndn
107
108
#endif // NDN_DETAIL_CONTAINER_WITH_ON_EMPTY_SIGNAL_HPP
ndn::ContainerWithOnEmptySignal::erase
iterator erase(iterator item)
Definition:
container-with-on-empty-signal.hpp:66
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::ContainerWithOnEmptySignal
A simple container that will fire up onEmpty signal when there are no entries left.
Definition:
container-with-on-empty-signal.hpp:34
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition:
signal-signal.hpp:50
ndn::ContainerWithOnEmptySignal::clear
void clear()
Definition:
container-with-on-empty-signal.hpp:76
ndn::ContainerWithOnEmptySignal::Base
std::list< T > Base
Definition:
container-with-on-empty-signal.hpp:37
ndn::ContainerWithOnEmptySignal::value_type
Base::value_type value_type
Definition:
container-with-on-empty-signal.hpp:38
nfd::cs::iterator
Table::const_iterator iterator
Definition:
cs-internal.hpp:41
ndn::ContainerWithOnEmptySignal::empty
bool empty()
Definition:
container-with-on-empty-signal.hpp:60
ndn::ContainerWithOnEmptySignal::insert
std::pair< iterator, bool > insert(const value_type &value)
Definition:
container-with-on-empty-signal.hpp:83
ndn::ContainerWithOnEmptySignal::size
size_t size()
Definition:
container-with-on-empty-signal.hpp:54
ndn::ContainerWithOnEmptySignal::begin
iterator begin()
Definition:
container-with-on-empty-signal.hpp:42
ndn::ContainerWithOnEmptySignal::onEmpty
util::Signal< ContainerWithOnEmptySignal< T > > onEmpty
Signal to be fired when container becomes empty.
Definition:
container-with-on-empty-signal.hpp:103
ndn::ContainerWithOnEmptySignal::iterator
Base::iterator iterator
Definition:
container-with-on-empty-signal.hpp:39
ndn::ContainerWithOnEmptySignal::m_container
Base m_container
Definition:
container-with-on-empty-signal.hpp:98
ndn::ContainerWithOnEmptySignal::end
iterator end()
Definition:
container-with-on-empty-signal.hpp:48
ndn::ContainerWithOnEmptySignal::remove_if
void remove_if(Predicate p)
Definition:
container-with-on-empty-signal.hpp:89
ndnSIM
ndn-cxx
src
detail
container-with-on-empty-signal.hpp
Generated on Sat Nov 12 2016 16:02:52 for ndnSIM by
1.8.12