-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMeasurementQueue.hpp
More file actions
executable file
·147 lines (126 loc) · 3.71 KB
/
MeasurementQueue.hpp
File metadata and controls
executable file
·147 lines (126 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
// MeasurementQueue.hpp
// AggregationNS3
//
// Created by Alper Sinan Akyurek on 8/9/16.
// Copyright © 2016 Alper Sinan Akyurek. All rights reserved.
//
#ifndef MeasurementQueue_hpp
#define MeasurementQueue_hpp
#include <list>
#include "Measurement.hpp"
#include <ns3/core-module.h>
/**
A queue class containing measurements and provides simple modification methods.
**/
class MeasurementQueue : public ns3::SimpleRefCount< MeasurementQueue >
{
private:
/** Type of the underlying storage type **/
typedef std::list<TMeasurementPtr> TMeasurementQueue;
public:
/** Type for the size of the queue **/
typedef unsigned int TQueueSize;
/** Iterator type for the queue **/
typedef TMeasurementQueue::iterator TIterator;
/** Constant iterator type for the queue **/
typedef TMeasurementQueue::const_iterator TConstIterator;
private:
/** Underlying measurement storage element **/
TMeasurementQueue m_queue;
public:
/**
Adds a new measurement item
\param item New measurement
**/
void
Add( const TMeasurementPtr & item );
/**
Adds multiple measurement items at once
\param items The queue to be merged
**/
void
Add( MeasurementQueue & items );
/**
Empties the queue from all measurements.
**/
void
Empty( void );
/**
Prints the contents for information
**/
void
Print( void ) const;
/**
Returns the total size (bytes) of all measurements in the queue.
\return Size (bytes) of all measurements in the queue.
**/
TQueueSize
Size( void ) const
{
return ( ( TQueueSize )( this->m_queue.size() ) * Measurement::TotalSize );
}
/**
Returns the number of measurement in the queue.
\return Number of measurements in the queue.
**/
TQueueSize
Count( void ) const
{
return ( ( TQueueSize )( this->m_queue.size() ) );
}
/**
Reads from a buffer and creates measurements
\param buffer Address of the buffer
\param bufferSize Size of the buffer
\return Address of the end of the buffer
**/
void*
ReadFromBuffer( void* buffer, const unsigned int bufferSize );
/**
Writes to a buffer all measurements in the queue.
\param buffer Buffer to be written to.
\return Address of the end of the buffer.
**/
void*
WriteToBuffer( void* buffer );
/**
Beginning of the queue iterator.
\return Beginning iterator.
**/
TIterator
Begin( void )
{
return ( this->m_queue.begin() );
}
/**
Beginning of the queue iterator (constant).
\return Constant beginning iterator.
**/
TConstIterator
Begin( void ) const
{
return ( this->m_queue.begin() );
}
/**
End of the queue iterator
\return Ending iterator
**/
TIterator
End( void )
{
return ( this->m_queue.end() );
}
/**
End of the queue iterator (constant).
\return Ending iterator (constant).
**/
TConstIterator
End( void ) const
{
return ( this->m_queue.end() );
}
};
/** Type of a smart pointer to the measurement queue class **/
typedef ns3::Ptr<MeasurementQueue> TMeasurementQueuePtr;
#endif /* MeasurementQueue_hpp */