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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#ifndef SPECTRUM_MODEL_H
10#define SPECTRUM_MODEL_H
11
12#include "ns3/simple-ref-count.h"
13
14#include <cstddef>
15#include <vector>
16
17namespace ns3
18{
19
20/**
21 * @defgroup spectrum Spectrum Models
22 */
23
24/**
25 * @ingroup spectrum
26 * @ingroup tests
27 * @defgroup spectrum-tests Spectrum Models tests
28 */
29
30/**
31 * @ingroup spectrum
32 *
33 * The building block of a SpectrumModel. This struct models
34 * a frequency band defined by the frequency interval [fl, fc] and
35 * with center frequency fc. Typically, the center frequency will be
36 * used for stuff such as propagation modeling, while the interval
37 * boundaries will be used for bandwidth calculation and for
38 * conversion between different SpectrumRepresentations.
39 *
40 */
42{
43 double fl; //!< lower limit of subband
44 double fc; //!< center frequency
45 double fh; //!< upper limit of subband
46
47 /**
48 * Three-way comparison operator
49 *
50 * @param rhs right hand side
51 * @return deduced comparison type
52 */
53 auto operator<=>(const BandInfo& rhs) const = default;
54};
55
56/// Container of BandInfo
57typedef std::vector<BandInfo> Bands;
58
59/// Uid for SpectrumModels
61
62/**
63 * Set of frequency values implementing the domain of the functions in
64 * the Function Space defined by SpectrumValue. Frequency values are in
65 * Hz. It is intended that frequency values are non-negative, though
66 * this is not enforced.
67 *
68 */
69class SpectrumModel : public SimpleRefCount<SpectrumModel>
70{
71 public:
72 /**
73 * Comparison operator. Returns true if the two SpectrumModels are identical
74 * @param lhs left operand
75 * @param rhs right operand
76 * @returns true if the two operands are identical
77 */
78 friend bool operator==(const SpectrumModel& lhs, const SpectrumModel& rhs);
79
80 /**
81 * This constructs a SpectrumModel based on a given set of frequencies,
82 * which is assumed to be sorted by increasing frequency. The lower
83 * (resp. upper) frequency band limit is determined as the mean value
84 * between the center frequency of the considered band and the
85 * center frequency of the adjacent lower (resp. upper) band.
86 *
87 * @param centerFreqs the vector of center frequencies.
88 */
89 SpectrumModel(const std::vector<double>& centerFreqs);
90
91 /**
92 * This constructs a SpectrumModel based on the explicit values of
93 * center frequencies and boundaries of each subband.
94 *
95 * @param bands the vector of bands for this model
96 */
97 SpectrumModel(const Bands& bands);
98
99 /**
100 * This constructs a SpectrumModel based on the explicit values of
101 * center frequencies and boundaries of each subband. This is used
102 * if <i>bands</i> is an rvalue.
103 *
104 * @param bands the vector of bands for this model
105 */
106 SpectrumModel(Bands&& bands);
107
108 /**
109 *
110 * @return the number of frequencies in this SpectrumModel
111 */
112 size_t GetNumBands() const;
113
114 /**
115 *
116 * @return the unique id of this SpectrumModel
117 */
119
120 /**
121 * Const Iterator to the model Bands container start, i.e. to the band with lowest frequency.
122 *
123 * @return a const iterator to the start of the vector of bands
124 */
125 Bands::const_iterator Begin() const;
126
127 /**
128 * Const Iterator to the model Bands container end, i.e. after the band with highest frequency.
129 *
130 * @return a const iterator to past-the-end of the vector of bands
131 */
132 Bands::const_iterator End() const;
133
134 /**
135 * Check if another SpectrumModel has bands orthogonal to our bands.
136 *
137 * @param other another SpectrumModel
138 * @returns true if bands are orthogonal
139 */
140 bool IsOrthogonal(const SpectrumModel& other) const;
141
142 /**
143 * Check if another SpectrumModel is aligned with our bands.
144 * This means that both SpectrumModels have boundaries for each band that are common between the
145 * two models. In this case, the conversion between the two models is just a matter of copying
146 * values in the overlapping bands and setting to zero the values in the non-overlapping bands.
147 *
148 * @param other another SpectrumModel
149 * @returns true if bands are aligned
150 */
151 bool IsAligned(const SpectrumModel& other) const;
152
153 private:
154 /**
155 * Initialize internal variables
156 */
157 void InitModel();
158
159 Bands m_bands; //!< Actual definition of frequency bands within this SpectrumModel
160 bool m_contiguousBands; //!< Whether the bands are contiguous (i.e., no gap between adjacent
161 //!< bands)
162 bool m_uniqueBandSize; //!< Whether all bands have the same size
163 SpectrumModelUid_t m_uid; //!< unique id for a given set of frequencies
164 static SpectrumModelUid_t m_uidCount; //!< counter to assign m_uids
165};
166
167} // namespace ns3
168
169#endif /* SPECTRUM_MODEL_H */
friend bool operator==(const SpectrumModel &lhs, const SpectrumModel &rhs)
Comparison operator.
void InitModel()
Initialize internal variables.
bool IsOrthogonal(const SpectrumModel &other) const
Check if another SpectrumModel has bands orthogonal to our bands.
static SpectrumModelUid_t m_uidCount
counter to assign m_uids
bool m_contiguousBands
Whether the bands are contiguous (i.e., no gap between adjacent bands).
SpectrumModelUid_t m_uid
unique id for a given set of frequencies
SpectrumModel(const std::vector< double > &centerFreqs)
This constructs a SpectrumModel based on a given set of frequencies, which is assumed to be sorted by...
Bands::const_iterator End() const
Const Iterator to the model Bands container end, i.e.
size_t GetNumBands() const
bool IsAligned(const SpectrumModel &other) const
Check if another SpectrumModel is aligned with our bands.
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start, i.e.
SpectrumModelUid_t GetUid() const
bool m_uniqueBandSize
Whether all bands have the same size.
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
auto operator<=>(const BandInfo &rhs) const =default
Three-way comparison operator.
double fh
upper limit of subband