A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-tx-mode.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Leonard Tracy <lentracy@gmail.com>
18 */
19
20#ifndef UAN_TX_MODE_H
21#define UAN_TX_MODE_H
22
23#include "ns3/object.h"
24
25#include <map>
26
27namespace ns3
28{
29
30class UanTxModeFactory;
31class UanTxMode;
32
33/**
34 * \ingroup uan
35 *
36 * Abstraction of packet modulation information.
37 *
38 * This contains a lightweight globally unique id for the mode.
39 * Mode details are held in the UanTxModeFactory. Attributes
40 * are set in by the UanTxModeFactory constructor.
41 */
43{
44 public:
45 UanTxMode(); //!< Constructor.
46 ~UanTxMode(); //!< Destructor.
47
48 /**
49 * Modulation type.
50 */
52 {
53 PSK, //!< Phase shift keying.
54 QAM, //!< Quadrature amplitude modulation.
55 FSK, //!< Frequency shift keying.
56 OTHER //!< Unspecified/undefined.
57 };
58
59 /**
60 * Get the modulation type of the mode.
61 *
62 * \return The modulation type.
63 */
65 /**
66 * Get the data rate of the transmit mode.
67 *
68 * \return Data rate of the TX mode, in bits per second.
69 */
71 /**
72 * Get the physical signaling rate.
73 *
74 * \return PHY rate in symbols per second.
75 */
76 uint32_t GetPhyRateSps() const;
77 /**
78 * Get the transmission center frequency.
79 *
80 * \return Center frequency, in Hz.
81 */
83 /**
84 * Get the transmission signal bandwidth.
85 *
86 * \return Bandwidth in Hz.
87 */
89 /**
90 * Get the number of constellation points in the modulation scheme.
91 *
92 * \return Number of constellation points.
93 */
95 /**
96 * Get the mode name.
97 *
98 * \return Name
99 */
100 std::string GetName() const;
101 /**
102 * Get a unique id for the mode.
103 *
104 * \return Unique ID.
105 */
106 uint32_t GetUid() const;
107
108 private:
109 friend class UanTxModeFactory;
110 friend std::ostream& operator<<(std::ostream& os, const UanTxMode& mode);
111 friend std::istream& operator>>(std::istream& is, UanTxMode& mode);
112
113 uint32_t m_uid; //!< Mode id
114
115}; // class UanTxMode
116
117/**
118 * Writes tx mode entry to stream os.
119 *
120 * \param os The output stream.
121 * \param mode The mode.
122 * \return The stream.
123 */
124std::ostream& operator<<(std::ostream& os, const UanTxMode& mode);
125/**
126 * Reads tx mode entry from stream is
127 *
128 * \param is The input stream.
129 * \param mode The mode.
130 * \return The stream.
131 */
132std::istream& operator>>(std::istream& is, UanTxMode& mode);
133
134/**
135 * \ingroup uan
136 *
137 * Global database of UanTxMode objects, retrievable by id or name.
138 */
140{
141 public:
142 UanTxModeFactory(); //!< Constructor.
143 ~UanTxModeFactory(); //!< Destructor.
144
145 /**
146 *
147 * \param type Modulation type.
148 * \param dataRateBps Data rate in BPS.
149 * \param phyRateSps Symbol rate in symbols per second.
150 * \param cfHz Center frequency in Hz.
151 * \param bwHz Bandwidth in Hz.
152 * \param constSize Modulation constellation size (2 for BPSK, 4 for QPSK).
153 * \param name Unique string name for this transmission mode.
154 *
155 * \return the transmit mode object
156 */
158 uint32_t dataRateBps,
159 uint32_t phyRateSps,
160 uint32_t cfHz,
161 uint32_t bwHz,
162 uint32_t constSize,
163 std::string name);
164
165 /**
166 * Get a mode by name.
167 *
168 * \param name String name of mode.
169 * \return Mode with given name.
170 */
171 static UanTxMode GetMode(std::string name);
172 /**
173 * Get a mode by id.
174 *
175 * \param uid Unique ID of mode.
176 * \return The mode with given uid.
177 */
178 static UanTxMode GetMode(uint32_t uid);
179
180 private:
181 friend class UanTxMode;
182 uint32_t m_nextUid; //!< next id number
183
184 /**
185 * \ingroup uan
186 * Container for the UanTxMode properties.
187 */
189 {
190 UanTxMode::ModulationType m_type; //!< Modulation type.
191 uint32_t m_cfHz; //!< Center frequency in Hz.
192 uint32_t m_bwHz; //!< Bandwidth in Hz.
193 uint32_t m_dataRateBps; //!< Data rate in BPS.
194 uint32_t m_phyRateSps; //!< Symbol rate in symbols per second.
195 uint32_t m_constSize; //!< Modulation constellation size (2 for BPSK, 4 for QPSK).
196 uint32_t m_uid; //!< Unique id.
197 std::string m_name; //!< Unique string name for this transmission mode.
198 };
199
200 /**
201 * Container for modes
202 *
203 * \internal
204 * Accessed internally by uid and name, so a multimap might be more
205 * appropriate. If name accesses are predominant, perhaps a map
206 * indexed by name, with a find for uid. If accesses by uid dominate
207 * then vector (since uid's are sequential), and find by name.
208 */
209 std::map<uint32_t, UanTxModeItem> m_modes;
210
211 /**
212 * Check if the mode \pname{name} already exists.
213 *
214 * \param name The mode name to test.
215 * \return True if \pname{name} exists.
216 */
217 bool NameUsed(std::string name);
218
219 /**
220 * Construct and get the static global factory instance.
221 *
222 * \return The global instance.
223 */
225
226 /**
227 * Get a mode by id.
228 *
229 * \param uid The unique id to find.
230 * \return The corresponding mode.
231 */
233
234 /**
235 * Get a mode by name.
236 * \param name The mode name to find.
237 * \return The corresponding mode.
238 */
239 UanTxModeItem& GetModeItem(std::string name);
240
241 /**
242 * Create a public UanTxMode from an internal UanTxModeItem.
243 *
244 * \param item The UanTxModeItem to reference.
245 * \return A public UanTxMode.
246 */
248
249}; // class UanTxModeFactory
250
251/**
252 * \ingroup uan
253 *
254 * Container for UanTxModes.
255 *
256 * \see attribute_UanModesList
257 */
259{
260 public:
261 UanModesList(); //!< Constructor
262 virtual ~UanModesList(); //!< Destructor
263
264 /**
265 * Add mode to this list.
266 * \param mode The mode to add.
267 */
268 void AppendMode(UanTxMode mode);
269 /**
270 * Delete the mode at given index.
271 * \param num Index of mode to delete.
272 */
273 void DeleteMode(uint32_t num);
274 /**
275 * Retrieve a mode by index.
276 *
277 * \param index Mode index.
278 * \return Mode at given index.
279 */
280 UanTxMode operator[](uint32_t index) const;
281 /**
282 * Get the number of modes in this list.
283 *
284 * \return Number of modes.
285 */
286 uint32_t GetNModes() const;
287
288 private:
289 /** The vector of modes in this list. */
290 std::vector<UanTxMode> m_modes;
291
292 friend std::ostream& operator<<(std::ostream& os, const UanModesList& ml);
293 friend std::istream& operator>>(std::istream& is, UanModesList& ml);
294
295}; // class UanModesList
296
297/**
298 * Write UanModesList to stream os
299 *
300 * \param os The output stream.
301 * \param ml The mode list.
302 * \return The stream.
303 */
304std::ostream& operator<<(std::ostream& os, const UanModesList& ml);
305/**
306 * Read UanModesList from stream is.
307 *
308 * \param is The input stream.
309 * \param ml The mode list to fill.
310 * \return The stream.
311 */
312std::istream& operator>>(std::istream& is, UanModesList& ml);
313
315
316} // namespace ns3
317
318#endif /* UAN_TX_MODE_H */
Container for UanTxModes.
Definition: uan-tx-mode.h:259
void DeleteMode(uint32_t num)
Delete the mode at given index.
Definition: uan-tx-mode.cc:236
UanModesList()
Constructor.
Definition: uan-tx-mode.cc:220
uint32_t GetNModes() const
Get the number of modes in this list.
Definition: uan-tx-mode.cc:256
friend std::istream & operator>>(std::istream &is, UanModesList &ml)
Read UanModesList from stream is.
Definition: uan-tx-mode.cc:274
void AppendMode(UanTxMode mode)
Add mode to this list.
Definition: uan-tx-mode.cc:230
UanTxMode operator[](uint32_t index) const
Retrieve a mode by index.
Definition: uan-tx-mode.cc:249
virtual ~UanModesList()
Destructor.
Definition: uan-tx-mode.cc:224
friend std::ostream & operator<<(std::ostream &os, const UanModesList &ml)
Write UanModesList to stream os.
Definition: uan-tx-mode.cc:262
std::vector< UanTxMode > m_modes
The vector of modes in this list.
Definition: uan-tx-mode.h:290
Global database of UanTxMode objects, retrievable by id or name.
Definition: uan-tx-mode.h:140
static UanTxMode CreateMode(UanTxMode::ModulationType type, uint32_t dataRateBps, uint32_t phyRateSps, uint32_t cfHz, uint32_t bwHz, uint32_t constSize, std::string name)
Definition: uan-tx-mode.cc:132
UanTxMode MakeModeFromItem(const UanTxModeItem &item)
Create a public UanTxMode from an internal UanTxModeItem.
Definition: uan-tx-mode.cc:206
UanTxModeFactory()
Constructor.
Definition: uan-tx-mode.cc:106
static UanTxModeFactory & GetFactory()
Construct and get the static global factory instance.
Definition: uan-tx-mode.cc:214
static UanTxMode GetMode(std::string name)
Get a mode by name.
Definition: uan-tx-mode.cc:192
std::map< uint32_t, UanTxModeItem > m_modes
Container for modes.
Definition: uan-tx-mode.h:209
~UanTxModeFactory()
Destructor.
Definition: uan-tx-mode.cc:111
bool NameUsed(std::string name)
Check if the mode name already exists.
Definition: uan-tx-mode.cc:117
uint32_t m_nextUid
next id number
Definition: uan-tx-mode.h:182
UanTxModeItem & GetModeItem(uint32_t uid)
Get a mode by id.
Definition: uan-tx-mode.cc:166
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:43
uint32_t GetUid() const
Get a unique id for the mode.
Definition: uan-tx-mode.cc:82
ModulationType
Modulation type.
Definition: uan-tx-mode.h:52
@ QAM
Quadrature amplitude modulation.
Definition: uan-tx-mode.h:54
@ OTHER
Unspecified/undefined.
Definition: uan-tx-mode.h:56
@ PSK
Phase shift keying.
Definition: uan-tx-mode.h:53
@ FSK
Frequency shift keying.
Definition: uan-tx-mode.h:55
friend std::ostream & operator<<(std::ostream &os, const UanTxMode &mode)
Writes tx mode entry to stream os.
Definition: uan-tx-mode.cc:88
friend std::istream & operator>>(std::istream &is, UanTxMode &mode)
Reads tx mode entry from stream is.
Definition: uan-tx-mode.cc:95
uint32_t GetConstellationSize() const
Get the number of constellation points in the modulation scheme.
Definition: uan-tx-mode.cc:70
uint32_t GetPhyRateSps() const
Get the physical signaling rate.
Definition: uan-tx-mode.cc:52
uint32_t GetDataRateBps() const
Get the data rate of the transmit mode.
Definition: uan-tx-mode.cc:46
~UanTxMode()
Destructor.
Definition: uan-tx-mode.cc:35
uint32_t GetBandwidthHz() const
Get the transmission signal bandwidth.
Definition: uan-tx-mode.cc:64
std::string GetName() const
Get the mode name.
Definition: uan-tx-mode.cc:76
UanTxMode()
Constructor.
Definition: uan-tx-mode.cc:31
uint32_t m_uid
Mode id.
Definition: uan-tx-mode.h:113
ModulationType GetModType() const
Get the modulation type of the mode.
Definition: uan-tx-mode.cc:40
uint32_t GetCenterFreqHz() const
Get the transmission center frequency.
Definition: uan-tx-mode.cc:58
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:183
Container for the UanTxMode properties.
Definition: uan-tx-mode.h:189
uint32_t m_constSize
Modulation constellation size (2 for BPSK, 4 for QPSK).
Definition: uan-tx-mode.h:195
uint32_t m_phyRateSps
Symbol rate in symbols per second.
Definition: uan-tx-mode.h:194
std::string m_name
Unique string name for this transmission mode.
Definition: uan-tx-mode.h:197
UanTxMode::ModulationType m_type
Modulation type.
Definition: uan-tx-mode.h:190
uint32_t m_bwHz
Bandwidth in Hz.
Definition: uan-tx-mode.h:192
uint32_t m_dataRateBps
Data rate in BPS.
Definition: uan-tx-mode.h:193
uint32_t m_cfHz
Center frequency in Hz.
Definition: uan-tx-mode.h:191