NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
counter.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#ifndef NFD_CORE_COUNTER_HPP
27
#define NFD_CORE_COUNTER_HPP
28
29
#include "common.hpp"
30
31
namespace
nfd
{
32
38
class
SimpleCounter
39
{
40
public
:
41
typedef
uint64_t
rep
;
42
43
constexpr
44
SimpleCounter
()
45
:
m_value
(0)
46
{
47
}
48
49
SimpleCounter
(
const
SimpleCounter
&) =
delete
;
50
51
SimpleCounter
&
52
operator=
(
const
SimpleCounter
&) =
delete
;
53
56
operator
rep
()
const
57
{
58
return
m_value
;
59
}
60
63
void
64
set
(rep value)
65
{
66
m_value
= value;
67
}
68
69
protected
:
70
rep
m_value
;
71
};
72
77
class
PacketCounter
:
public
SimpleCounter
78
{
79
public
:
82
PacketCounter
&
83
operator++
()
84
{
85
++
m_value
;
86
return
*
this
;
87
}
88
// postfix ++ operator is not provided because it's not needed
89
};
90
95
class
ByteCounter
:
public
SimpleCounter
96
{
97
public
:
100
ByteCounter
&
101
operator+=
(
rep
n)
102
{
103
m_value
+= n;
104
return
*
this
;
105
}
106
};
107
111
template
<
typename
T>
112
class
SizeCounter
113
{
114
public
:
115
typedef
size_t
rep
;
116
117
constexpr
118
SizeCounter
(
const
T& table)
119
: m_table(table)
120
{
121
}
122
123
SizeCounter
(
const
SizeCounter
&) =
delete
;
124
125
SizeCounter
&
126
operator=
(
const
SizeCounter
&) =
delete
;
127
130
operator
rep
()
const
131
{
132
return
m_table.size();
133
}
134
135
private
:
136
const
T& m_table;
137
};
138
139
}
// namespace nfd
140
141
#endif // NFD_CORE_COUNTER_HPP
nfd::SimpleCounter::m_value
rep m_value
Definition:
counter.hpp:70
nfd::PacketCounter
represents a counter of number of packets
Definition:
counter.hpp:77
nfd::SizeCounter::SizeCounter
constexpr SizeCounter(const T &table)
Definition:
counter.hpp:118
nfd::SizeCounter::rep
size_t rep
Definition:
counter.hpp:115
nfd::SimpleCounter::rep
uint64_t rep
Definition:
counter.hpp:41
nfd::ByteCounter
represents a counter of number of bytes
Definition:
counter.hpp:95
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::PacketCounter::operator++
PacketCounter & operator++()
increment the counter by one
Definition:
counter.hpp:83
nfd::SizeCounter
provides a counter that observes the size of a table
Definition:
counter.hpp:112
nfd::SimpleCounter::SimpleCounter
constexpr SimpleCounter()
Definition:
counter.hpp:44
nfd::SimpleCounter::operator=
SimpleCounter & operator=(const SimpleCounter &)=delete
nfd::SimpleCounter
represents a counter that encloses an integer value
Definition:
counter.hpp:38
nfd::ByteCounter::operator+=
ByteCounter & operator+=(rep n)
increase the counter
Definition:
counter.hpp:101
ndnSIM
NFD
core
counter.hpp
Generated on Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12