-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApplication.hpp
executable file
·157 lines (129 loc) · 5.45 KB
/
Application.hpp
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
148
149
150
151
152
153
154
155
156
157
//
// Application.hpp
// AggregationNS3
//
// Created by Alper Sinan Akyurek on 8/8/16.
// Copyright © 2016 Alper Sinan Akyurek. All rights reserved.
//
#ifndef Application_hpp
#define Application_hpp
#include <map>
#include "MeasurementQueue.hpp"
#include "GainFunction.hpp"
/**
\brief Describes an application that generates data with associated deadlines.
Each application is also assigned a gain function for optimization.
*/
class Application : public ns3::SimpleRefCount< Application >
{
public:
/** Generation process pointer **/
typedef GainFunction::TGenerationPtr TGenerationPtr;
/** Deadline process pointer **/
typedef GainFunction::TDeadlinePtr TDeadlinePtr;
/** Pointer to the gain function **/
typedef ns3::Ptr< GainFunction > TGainFunctionPtr;
private:
/** Each application is assigned an ID for identification **/
typedef Measurement::TId TApplicationId;
/** A key-value store to map IDs to Application pointers **/
typedef std::map< TApplicationId, Application* > TApplicationMap;
private:
/** Global Application ID counter for unique assignment **/
static TApplicationId globalIdCounter;
/** Global Application mapping from ID to Application pointers **/
static TApplicationMap globalApplicationMap;
private:
/** Unique ID of this Application **/
TApplicationId m_id;
/** The generation process for data generation **/
TGenerationPtr m_generationProcess;
/** The deadline process for deadline assignment **/
TDeadlinePtr m_deadlineProcess;
/** The queue holding the measurements to be sent **/
TMeasurementQueuePtr m_measurementQueue;
/** Pointer to the data stream gain function **/
TGainFunctionPtr m_gainFunction;
public:
/**
Constructor without a gain function definition.
\param generation The generation process.
\param deadline The deadline process.
**/
Application( TGenerationPtr generation, TDeadlinePtr deadline );
/**
Constructor with all the necessary elements.
\param generation The generation process.
\param deadline The deadline process.
\param gainFunction The Gain Function of the Application.
**/
Application( TGenerationPtr generation, TDeadlinePtr deadline, const TGainFunctionPtr & gainFunction );
/**
Template constructor for the cases of Gain function type mismatch.
\param generation The generation process.
\param deadline The deadline process.
\param gainFunction Gain function of the application.
\tparam GainFunctionType The template type of the gain function.
**/
template <typename GainFunctionType>
Application( TGenerationPtr generation,
TDeadlinePtr deadline,
const ns3::Ptr<GainFunctionType> & gainFunction ) : Application( generation,
deadline,
ns3::DynamicCast< GainFunction >( gainFunction ) )
{
}
/** Prints Application and its queue for information **/
void
Print( void ) const;
/**
Sets the Application's gain function .
\param gainFunction New Gain Function of the application.
**/
void
SetMeasurementGainFunction( const TGainFunctionPtr & gainFunction );
/**
Returns the value of the Gain function for a given transmission time.
\param x The queried transmission time.
\return Returns the Gain value of the Application.
**/
GainFunction::TGain
GetMeasurementGain( const GainFunction::TTransmissionTime & x ) const;
/**
Return the derivative value of the Gain function for a given
transmission time.
\param x The queried transmission time.
\return Returns the Derivative of the Gain function of the Application.
**/
GainFunction::TGain
GetMeasurementGainDerivative( const GainFunction::TTransmissionTime & x ) const;
/**
Moves all measurements into the given queue.
\param measurementQueue The queue to be moved into.
**/
void
GetAllMeasurements( TMeasurementQueuePtr & measurementQueue );
/**
Static function that returns the generation prcess of an Application.
\param id ID to be queried.
\return Returns the generation process of the application.
**/
static TGenerationPtr
GetGenerationProcess( const TApplicationId id );
/**
Static function that returns the deadline process of an Application.
\param id ID to be queried.
\return Returns the deadline process of the application.
**/
static TGenerationPtr
GetDeadlineProcess( const TApplicationId id );
/**
Returns the number of measurements queued.
\return Number of measurements in the queue.
**/
MeasurementQueue::TQueueSize
GetNumberOfQueuedMeasurements( void ) const;
};
/** Smart Pointer to an Application **/
typedef ns3::Ptr<Application> TApplicationPtr;
#endif /* Application_hpp */