A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#ifndef SPECTRUM_MODEL_H
21#define SPECTRUM_MODEL_H
22
23#include <ns3/simple-ref-count.h>
24
25#include <cstddef>
26#include <vector>
27
28namespace ns3
29{
30
31/**
32 * \defgroup spectrum Spectrum Models
33 */
34
35/**
36 * \ingroup spectrum
37 * \ingroup tests
38 * \defgroup spectrum-tests Spectrum Models tests
39 */
40
41/**
42 * \ingroup spectrum
43 *
44 * The building block of a SpectrumModel. This struct models
45 * a frequency band defined by the frequency interval [fl, fc] and
46 * with center frequency fc. Typically, the center frequency will be
47 * used for stuff such as propagation modeling, while the interval
48 * boundaries will be used for bandwidth calculation and for
49 * conversion between different SpectrumRepresentations.
50 *
51 */
53{
54 double fl; //!< lower limit of subband
55 double fc; //!< center frequency
56 double fh; //!< upper limit of subband
57};
58
59/// Container of BandInfo
60typedef std::vector<BandInfo> Bands;
61
62/// Uid for SpectrumModels
64
65/**
66 * Set of frequency values implementing the domain of the functions in
67 * the Function Space defined by SpectrumValue. Frequency values are in
68 * Hz. It is intended that frequency values are non-negative, though
69 * this is not enforced.
70 *
71 */
72class SpectrumModel : public SimpleRefCount<SpectrumModel>
73{
74 public:
75 /**
76 * Comparison operator. Returns true if the two SpectrumModels are identical
77 * \param lhs left operand
78 * \param rhs right operand
79 * \returns true if the two operands are identical
80 */
81 friend bool operator==(const SpectrumModel& lhs, const SpectrumModel& rhs);
82
83 /**
84 * This constructs a SpectrumModel based on a given set of frequencies,
85 * which is assumed to be sorted by increasing frequency. The lower
86 * (resp. upper) frequency band limit is determined as the mean value
87 * between the center frequency of the considered band and the
88 * center frequency of the adjacent lower (resp. upper) band.
89 *
90 * @param centerFreqs the vector of center frequencies.
91 */
92 SpectrumModel(const std::vector<double>& centerFreqs);
93
94 /**
95 * This constructs a SpectrumModel based on the explicit values of
96 * center frequencies and boundaries of each subband.
97 *
98 * @param bands the vector of bands for this model
99 */
100 SpectrumModel(const Bands& bands);
101
102 /**
103 * This constructs a SpectrumModel based on the explicit values of
104 * center frequencies and boundaries of each subband. This is used
105 * if <i>bands</i> is an rvalue.
106 *
107 * @param bands the vector of bands for this model
108 */
109 SpectrumModel(Bands&& bands);
110
111 /**
112 *
113 * @return the number of frequencies in this SpectrumModel
114 */
115 size_t GetNumBands() const;
116
117 /**
118 *
119 * @return the unique id of this SpectrumModel
120 */
122
123 /**
124 * Const Iterator to the model Bands container start.
125 *
126 * @return a const iterator to the start of the vector of bands
127 */
128 Bands::const_iterator Begin() const;
129 /**
130 * Const Iterator to the model Bands container end.
131 *
132 * @return a const iterator to past-the-end of the vector of bands
133 */
134 Bands::const_iterator End() const;
135
136 /**
137 * Check if another SpectrumModels has bands orthogonal to our bands.
138 *
139 * \param other another SpectrumModel
140 * \returns true if bands are orthogonal
141 */
142 bool IsOrthogonal(const SpectrumModel& other) const;
143
144 private:
145 Bands m_bands; //!< Actual definition of frequency bands within this SpectrumModel
146 SpectrumModelUid_t m_uid; //!< unique id for a given set of frequencies
147 static SpectrumModelUid_t m_uidCount; //!< counter to assign m_uids
148};
149
150} // namespace ns3
151
152#endif /* SPECTRUM_MODEL_H */
A template-based reference counting class.
Set of frequency values implementing the domain of the functions in the Function Space defined by Spe...
friend bool operator==(const SpectrumModel &lhs, const SpectrumModel &rhs)
Comparison operator.
bool IsOrthogonal(const SpectrumModel &other) const
Check if another SpectrumModels has bands orthogonal to our bands.
static SpectrumModelUid_t m_uidCount
counter to assign m_uids
SpectrumModelUid_t m_uid
unique id for a given set of frequencies
Bands::const_iterator End() const
Const Iterator to the model Bands container end.
size_t GetNumBands() const
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
SpectrumModelUid_t GetUid() const
Bands m_bands
Actual definition of frequency bands within this SpectrumModel.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< BandInfo > Bands
Container of BandInfo.
uint32_t SpectrumModelUid_t
Uid for SpectrumModels.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband