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/// Container of BandInfo
49typedef std::vector<BandInfo> Bands;
50
51/// Uid for SpectrumModels
53
54/**
55 * Set of frequency values implementing the domain of the functions in
56 * the Function Space defined by SpectrumValue. Frequency values are in
57 * Hz. It is intended that frequency values are non-negative, though
58 * this is not enforced.
59 *
60 */
61class SpectrumModel : public SimpleRefCount<SpectrumModel>
62{
63 public:
64 /**
65 * Comparison operator. Returns true if the two SpectrumModels are identical
66 * \param lhs left operand
67 * \param rhs right operand
68 * \returns true if the two operands are identical
69 */
70 friend bool operator==(const SpectrumModel& lhs, const SpectrumModel& rhs);
71
72 /**
73 * This constructs a SpectrumModel based on a given set of frequencies,
74 * which is assumed to be sorted by increasing frequency. The lower
75 * (resp. upper) frequency band limit is determined as the mean value
76 * between the center frequency of the considered band and the
77 * center frequency of the adjacent lower (resp. upper) band.
78 *
79 * @param centerFreqs the vector of center frequencies.
80 */
81 SpectrumModel(const std::vector<double>& centerFreqs);
82
83 /**
84 * This constructs a SpectrumModel based on the explicit values of
85 * center frequencies and boundaries of each subband.
86 *
87 * @param bands the vector of bands for this model
88 */
89 SpectrumModel(const Bands& bands);
90
91 /**
92 * This constructs a SpectrumModel based on the explicit values of
93 * center frequencies and boundaries of each subband. This is used
94 * if <i>bands</i> is an rvalue.
95 *
96 * @param bands the vector of bands for this model
97 */
98 SpectrumModel(Bands&& bands);
99
100 /**
101 *
102 * @return the number of frequencies in this SpectrumModel
103 */
104 size_t GetNumBands() const;
105
106 /**
107 *
108 * @return the unique id of this SpectrumModel
109 */
111
112 /**
113 * Const Iterator to the model Bands container start.
114 *
115 * @return a const iterator to the start of the vector of bands
116 */
117 Bands::const_iterator Begin() const;
118 /**
119 * Const Iterator to the model Bands container end.
120 *
121 * @return a const iterator to past-the-end of the vector of bands
122 */
123 Bands::const_iterator End() const;
124
125 /**
126 * Check if another SpectrumModels has bands orthogonal to our bands.
127 *
128 * \param other another SpectrumModel
129 * \returns true if bands are orthogonal
130 */
131 bool IsOrthogonal(const SpectrumModel& other) const;
132
133 private:
134 Bands m_bands; //!< Actual definition of frequency bands within this SpectrumModel
135 SpectrumModelUid_t m_uid; //!< unique id for a given set of frequencies
136 static SpectrumModelUid_t m_uidCount; //!< counter to assign m_uids
137};
138
139} // namespace ns3
140
141#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
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.
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