NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2
/*
3
* Copyright (c) 2013-2018 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_IMPL_CONTAINER_WITH_ON_EMPTY_SIGNAL_HPP
23
#define NDN_IMPL_CONTAINER_WITH_ON_EMPTY_SIGNAL_HPP
24
25
#include "
ndn-cxx/detail/common.hpp
"
26
#include "
ndn-cxx/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_IMPL_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 container that emits onEmpty signal when it becomes empty.
Definition:
container-with-on-empty-signal.hpp:34
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition:
signal.hpp:51
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
common.hpp
import common constructs for ndn-cxx library internal use
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
signal.hpp
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
ndn-cxx
impl
container-with-on-empty-signal.hpp
Generated on Sun Feb 24 2019 22:16:05 for ndnSIM by
1.8.15