A Discrete-Event Network Simulator
API
uan-tx-mode.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_TX_MODE_H
22 #define UAN_TX_MODE_H
23 
24 #include "ns3/object.h"
25 #include <map>
26 
27 namespace ns3 {
28 
29 class UanTxModeFactory;
30 class UanTxMode;
31 
41 class UanTxMode
42 {
43 public:
44  UanTxMode ();
45  ~UanTxMode ();
46 
50  typedef enum {
51  PSK,
52  QAM,
53  FSK,
54  OTHER
61  ModulationType GetModType (void) const;
67  uint32_t GetDataRateBps (void) const;
73  uint32_t GetPhyRateSps (void) const;
79  uint32_t GetCenterFreqHz (void) const;
85  uint32_t GetBandwidthHz (void) const;
91  uint32_t GetConstellationSize (void) const;
97  std::string GetName (void) const;
103  uint32_t GetUid (void) const;
104 
105 private:
106  friend class UanTxModeFactory;
107  friend std::ostream &operator<< (std::ostream & os, const UanTxMode &mode);
108  friend std::istream &operator>> (std::istream & is, UanTxMode &mode);
109 
110 
111  uint32_t m_uid;
112 
113 }; // class UanTxMode
114 
115 
123 std::ostream & operator << (std::ostream & os, const UanTxMode &mode);
131 std::istream & operator >> (std::istream & is, UanTxMode &mode);
132 
139 {
140 public:
141  UanTxModeFactory ();
142  ~UanTxModeFactory ();
143 
157  uint32_t dataRateBps,
158  uint32_t phyRateSps,
159  uint32_t cfHz,
160  uint32_t bwHz,
161  uint32_t constSize,
162  std::string name);
163 
170  static UanTxMode GetMode (std::string name);
177  static UanTxMode GetMode (uint32_t uid);
178 
179 private:
180  friend class UanTxMode;
181  uint32_t m_nextUid;
182 
188  {
190  uint32_t m_cfHz;
191  uint32_t m_bwHz;
192  uint32_t m_dataRateBps;
193  uint32_t m_phyRateSps;
194  uint32_t m_constSize;
195  uint32_t m_uid;
196  std::string m_name;
197  };
198 
208  std::map<uint32_t, UanTxModeItem> m_modes;
209 
216  bool NameUsed (std::string name);
217 
223  static UanTxModeFactory &GetFactory (void);
224 
231  UanTxModeItem &GetModeItem (uint32_t uid);
232 
238  UanTxModeItem &GetModeItem (std::string name);
239 
247 
248 }; // class UanTxModeFactory
249 
258 {
259 public:
260  UanModesList ();
261  virtual ~UanModesList ();
262 
267  void AppendMode (UanTxMode mode);
272  void DeleteMode (uint32_t num);
279  UanTxMode operator[] (uint32_t index) const;
285  uint32_t GetNModes (void) const;
286 
287 
288 private:
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 
304 std::ostream &operator << (std::ostream &os, const UanModesList &ml);
312 std::istream &operator >> (std::istream &is, UanModesList &ml);
313 
315 
316 } // namespace ns3
317 
318 #endif /* UAN_TX_MODE_H */
ns3::UanTxModeFactory::m_nextUid
uint32_t m_nextUid
next id number
Definition: uan-tx-mode.h:181
ns3::UanTxModeFactory::GetMode
static UanTxMode GetMode(std::string name)
Get a mode by name.
Definition: uan-tx-mode.cc:194
ns3::UanTxModeFactory::m_modes
std::map< uint32_t, UanTxModeItem > m_modes
Container for modes.
Definition: uan-tx-mode.h:208
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UanModesList::DeleteMode
void DeleteMode(uint32_t num)
Delete the mode at given index.
Definition: uan-tx-mode.cc:238
ns3::UanTxModeFactory::UanTxModeItem::m_uid
uint32_t m_uid
Unique id.
Definition: uan-tx-mode.h:195
ns3::UanTxModeFactory::NameUsed
bool NameUsed(std::string name)
Check if the mode name already exists.
Definition: uan-tx-mode.cc:117
ns3::UanTxModeFactory::MakeModeFromItem
UanTxMode MakeModeFromItem(const UanTxModeItem &item)
Create a public UanTxMode from an internal UanTxModeItem.
Definition: uan-tx-mode.cc:208
ns3::UanTxMode::GetBandwidthHz
uint32_t GetBandwidthHz(void) const
Get the transmission signal bandwidth.
Definition: uan-tx-mode.cc:63
ns3::UanModesList::AppendMode
void AppendMode(UanTxMode mode)
Add mode to this list.
Definition: uan-tx-mode.cc:232
ns3::UanModesList
Container for UanTxModes.
Definition: uan-tx-mode.h:258
ns3::UanModesList::UanModesList
UanModesList()
Constructor.
Definition: uan-tx-mode.cc:222
ns3::UanTxMode::operator>>
friend std::istream & operator>>(std::istream &is, UanTxMode &mode)
Reads tx mode entry from stream is.
Definition: uan-tx-mode.cc:94
ns3::UanTxMode::~UanTxMode
~UanTxMode()
Destructor.
Definition: uan-tx-mode.cc:33
ns3::UanTxMode::operator<<
friend std::ostream & operator<<(std::ostream &os, const UanTxMode &mode)
Writes tx mode entry to stream os.
Definition: uan-tx-mode.cc:87
ns3::UanTxMode::m_uid
uint32_t m_uid
Mode id.
Definition: uan-tx-mode.h:111
ns3::UanModesList::~UanModesList
virtual ~UanModesList()
Destructor.
Definition: uan-tx-mode.cc:226
ns3::UanTxModeFactory::CreateMode
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
ns3::UanTxMode::GetCenterFreqHz
uint32_t GetCenterFreqHz(void) const
Get the transmission center frequency.
Definition: uan-tx-mode.cc:57
ns3::UanTxModeFactory::GetFactory
static UanTxModeFactory & GetFactory(void)
Construct and get the static global factory instance.
Definition: uan-tx-mode.cc:216
ns3::UanTxModeFactory::UanTxModeItem
Container for the UanTxMode properties.
Definition: uan-tx-mode.h:188
ns3::UanTxModeFactory::UanTxModeItem::m_name
std::string m_name
Unique string name for this transmission mode.
Definition: uan-tx-mode.h:196
ns3::UanModesList::GetNModes
uint32_t GetNModes(void) const
Get the number of modes in this list.
Definition: uan-tx-mode.cc:259
ns3::UanTxModeFactory::GetModeItem
UanTxModeItem & GetModeItem(uint32_t uid)
Get a mode by id.
Definition: uan-tx-mode.cc:167
ns3::UanModesList::operator>>
friend std::istream & operator>>(std::istream &is, UanModesList &ml)
Read UanModesList from stream is.
Definition: uan-tx-mode.cc:277
ns3::UanTxModeFactory::UanTxModeItem::m_constSize
uint32_t m_constSize
Modulation constellation size (2 for BPSK, 4 for QPSK).
Definition: uan-tx-mode.h:194
ns3::UanTxMode::PSK
@ PSK
Phase shift keying.
Definition: uan-tx-mode.h:51
ns3::UanTxMode::OTHER
@ OTHER
Unspecified/undefined.
Definition: uan-tx-mode.h:54
ns3::UanTxMode::GetConstellationSize
uint32_t GetConstellationSize(void) const
Get the number of constellation points in the modulation scheme.
Definition: uan-tx-mode.cc:69
ns3::UanTxMode
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:42
ns3::UanTxModeFactory::UanTxModeFactory
UanTxModeFactory()
Constructor.
Definition: uan-tx-mode.cc:107
ns3::UanTxMode::FSK
@ FSK
Frequency shift keying.
Definition: uan-tx-mode.h:53
ns3::UanTxMode::QAM
@ QAM
Quadrature amplitude modulation.
Definition: uan-tx-mode.h:52
ns3::UanTxModeFactory::UanTxModeItem::m_phyRateSps
uint32_t m_phyRateSps
Symbol rate in symbols per second.
Definition: uan-tx-mode.h:193
ns3::UanModesList::operator[]
UanTxMode operator[](uint32_t index) const
Retrieve a mode by index.
Definition: uan-tx-mode.cc:252
ns3::UanTxModeFactory::~UanTxModeFactory
~UanTxModeFactory()
Destructor.
Definition: uan-tx-mode.cc:112
ns3::UanTxMode::GetPhyRateSps
uint32_t GetPhyRateSps(void) const
Get the physical signaling rate.
Definition: uan-tx-mode.cc:51
ns3::UanModesList::m_modes
std::vector< UanTxMode > m_modes
The vector of modes in this list.
Definition: uan-tx-mode.h:290
ns3::UanModesList::operator<<
friend std::ostream & operator<<(std::ostream &os, const UanModesList &ml)
Write UanModesList to stream os.
Definition: uan-tx-mode.cc:265
ns3::UanTxMode::GetUid
uint32_t GetUid(void) const
Get a unique id for the mode.
Definition: uan-tx-mode.cc:81
ns3::UanTxMode::GetName
std::string GetName(void) const
Get the mode name.
Definition: uan-tx-mode.cc:75
ns3::UanTxMode::UanTxMode
UanTxMode()
Constructor.
Definition: uan-tx-mode.cc:29
ns3::UanTxMode::GetModType
ModulationType GetModType(void) const
Get the modulation type of the mode.
Definition: uan-tx-mode.cc:39
ns3::UanTxModeFactory::UanTxModeItem::m_cfHz
uint32_t m_cfHz
Center frequency in Hz.
Definition: uan-tx-mode.h:190
ns3::UanTxMode::ModulationType
ModulationType
Modulation type.
Definition: uan-tx-mode.h:50
ns3::UanTxMode::GetDataRateBps
uint32_t GetDataRateBps(void) const
Get the data rate of the transmit mode.
Definition: uan-tx-mode.cc:45
ns3::UanTxModeFactory
Global database of UanTxMode objects, retrievable by id or name.
Definition: uan-tx-mode.h:139
ns3::UanTxModeFactory::UanTxModeItem::m_type
UanTxMode::ModulationType m_type
Modulation type.
Definition: uan-tx-mode.h:189
ns3::UanTxModeFactory::UanTxModeItem::m_bwHz
uint32_t m_bwHz
Bandwidth in Hz.
Definition: uan-tx-mode.h:191
ns3::UanTxModeFactory::UanTxModeItem::m_dataRateBps
uint32_t m_dataRateBps
Data rate in BPS.
Definition: uan-tx-mode.h:192
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ATTRIBUTE_HELPER_HEADER
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Definition: attribute-helper.h:390
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:160