20 #include "uan-tx-mode.h"
29 UanTxMode::UanTxMode ()
33 UanTxMode::~UanTxMode ()
41 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_type;
47 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_dataRateBps;
53 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_phyRateSps;
59 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_cfHz;
65 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_bwHz;
71 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_constSize;
77 return UanTxModeFactory::GetFactory ().GetModeItem (m_uid).m_name;
94 operator>> (std::istream & is, UanTxMode &mode)
107 UanTxModeFactory::UanTxModeFactory ()
112 UanTxModeFactory::~UanTxModeFactory ()
117 UanTxModeFactory::NameUsed (std::string name)
119 std::map<uint32_t, UanTxModeItem>::iterator it = m_modes.begin ();
121 for (; it != m_modes.end (); it++)
123 if ((*it).second.m_name == name)
133 uint32_t dataRateBps,
145 if (factory.NameUsed (name))
147 NS_LOG_WARN (
"Redefining UanTxMode with name \"" << name <<
"\"");
148 item = &factory.GetModeItem (name);
152 item = &factory.m_modes[factory.m_nextUid];
153 item->m_uid = factory.m_nextUid++;
157 item->m_dataRateBps = dataRateBps;
158 item->m_phyRateSps = phyRateSps;
161 item->m_constSize = constSize;
163 return factory.MakeModeFromItem (*item);
167 UanTxModeFactory::GetModeItem (uint32_t uid)
169 if (uid >= m_nextUid)
172 << uid <<
", >= m_nextUid");
178 UanTxModeFactory::UanTxModeItem &
179 UanTxModeFactory::GetModeItem (std::string name)
181 std::map<uint32_t, UanTxModeItem>::iterator it = m_modes.begin ();
182 for (; it != m_modes.end (); it++)
184 if ((*it).second.m_name == name)
189 NS_FATAL_ERROR (
"Unknown mode, \"" << name <<
"\", requested from mode factory");
194 UanTxModeFactory::GetMode (std::string name)
197 return factory.MakeModeFromItem (factory.GetModeItem (name));
201 UanTxModeFactory::GetMode (uint32_t uid)
204 return factory.MakeModeFromItem (factory.GetModeItem (uid));
208 UanTxModeFactory::MakeModeFromItem (
const UanTxModeItem &item)
211 mode.m_uid = item.m_uid;
216 UanTxModeFactory::GetFactory (
void)
218 static UanTxModeFactory factory;
222 UanModesList::UanModesList (
void)
226 UanModesList::~UanModesList (
void)
234 m_modes.push_back (newMode);
238 UanModesList::DeleteMode (uint32_t modeNum)
243 std::vector<UanTxMode>::iterator it = m_modes.begin ();
244 for (uint32_t i = 0; i < modeNum; i++)
248 it = m_modes.erase (it);
252 UanModesList::operator[] (uint32_t i)
const
259 UanModesList::GetNModes (
void)
const
261 return m_modes.size ();
270 for (uint32_t i = 0; i < ml.m_modes.size (); i++)
286 is.setstate (std::ios_base::failbit);
289 ml.m_modes.resize (numModes);
291 for (
int i = 0; i < numModes; i++)
293 is >> ml.m_modes[i] >> c;
296 is.setstate (std::ios_base::failbit);
std::istream & operator>>(std::istream &is, Angles &a)
uint32_t GetNModes(void) const
std::string GetName(void) const
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
Container for UanTxModes.
ModulationType GetModType(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
uint32_t GetDataRateBps(void) const
Abstraction of packet modulation information.
std::ostream & operator<<(std::ostream &os, const Angles &a)
uint32_t GetCenterFreqHz(void) const
#define ATTRIBUTE_HELPER_CPP(type)
uint32_t GetPhyRateSps(void) const
uint32_t GetConstellationSize(void) const
uint32_t GetBandwidthHz(void) const
uint32_t GetUid(void) const