A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
17
namespace
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
*/
41
struct
BandInfo
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
57
typedef
std::vector<BandInfo>
Bands
;
58
59
/// Uid for SpectrumModels
60
typedef
uint32_t
SpectrumModelUid_t
;
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
*/
69
class
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
*/
118
SpectrumModelUid_t
GetUid
()
const
;
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 */
ns3::SimpleRefCount< SpectrumModel >::SimpleRefCount
SimpleRefCount()
Definition
simple-ref-count.h:79
ns3::SpectrumModel::operator==
friend bool operator==(const SpectrumModel &lhs, const SpectrumModel &rhs)
Comparison operator.
Definition
spectrum-model.cc:25
ns3::SpectrumModel::InitModel
void InitModel()
Initialize internal variables.
Definition
spectrum-model.cc:78
ns3::SpectrumModel::IsOrthogonal
bool IsOrthogonal(const SpectrumModel &other) const
Check if another SpectrumModel has bands orthogonal to our bands.
Definition
spectrum-model.cc:138
ns3::SpectrumModel::m_uidCount
static SpectrumModelUid_t m_uidCount
counter to assign m_uids
Definition
spectrum-model.h:164
ns3::SpectrumModel::m_contiguousBands
bool m_contiguousBands
Whether the bands are contiguous (i.e., no gap between adjacent bands).
Definition
spectrum-model.h:160
ns3::SpectrumModel::m_uid
SpectrumModelUid_t m_uid
unique id for a given set of frequencies
Definition
spectrum-model.h:163
ns3::SpectrumModel::SpectrumModel
SpectrumModel(const std::vector< double > ¢erFreqs)
This constructs a SpectrumModel based on a given set of frequencies, which is assumed to be sorted by...
Definition
spectrum-model.cc:32
ns3::SpectrumModel::End
Bands::const_iterator End() const
Const Iterator to the model Bands container end, i.e.
Definition
spectrum-model.cc:120
ns3::SpectrumModel::GetNumBands
size_t GetNumBands() const
Definition
spectrum-model.cc:126
ns3::SpectrumModel::IsAligned
bool IsAligned(const SpectrumModel &other) const
Check if another SpectrumModel is aligned with our bands.
Definition
spectrum-model.cc:159
ns3::SpectrumModel::Begin
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start, i.e.
Definition
spectrum-model.cc:114
ns3::SpectrumModel::GetUid
SpectrumModelUid_t GetUid() const
Definition
spectrum-model.cc:132
ns3::SpectrumModel::m_uniqueBandSize
bool m_uniqueBandSize
Whether all bands have the same size.
Definition
spectrum-model.h:162
ns3::SpectrumModel::m_bands
Bands m_bands
Actual definition of frequency bands within this SpectrumModel.
Definition
spectrum-model.h:159
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Bands
std::vector< BandInfo > Bands
Container of BandInfo.
Definition
spectrum-model.h:57
ns3::SpectrumModelUid_t
uint32_t SpectrumModelUid_t
Uid for SpectrumModels.
Definition
spectrum-model.h:60
ns3::BandInfo
The building block of a SpectrumModel.
Definition
spectrum-model.h:42
ns3::BandInfo::fc
double fc
center frequency
Definition
spectrum-model.h:44
ns3::BandInfo::fl
double fl
lower limit of subband
Definition
spectrum-model.h:43
ns3::BandInfo::operator<=>
auto operator<=>(const BandInfo &rhs) const =default
Three-way comparison operator.
ns3::BandInfo::fh
double fh
upper limit of subband
Definition
spectrum-model.h:45
src
spectrum
model
spectrum-model.h
Generated on
for ns-3 by
1.16.1