A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
spectrum-model.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
3
/*
4
* Copyright (c) 2009 CTTC
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Author: Nicola Baldo <nbaldo@cttc.es>
20
*/
21
22
#include <cmath>
23
#include <cstddef>
24
#include <ns3/spectrum-model.h>
25
#include <ns3/log.h>
26
#include <ns3/assert.h>
27
28
29
30
NS_LOG_COMPONENT_DEFINE
(
"SpectrumModel"
);
31
32
33
34
namespace
ns3 {
35
36
37
bool
operator==
(
const
SpectrumModel
& lhs,
const
SpectrumModel
& rhs)
38
{
39
return
(lhs.
m_uid
== rhs.
m_uid
);
40
}
41
42
SpectrumModelUid_t
SpectrumModel::m_uidCount
= 0;
43
44
SpectrumModel::SpectrumModel
(std::vector<double> centerFreqs)
45
{
46
NS_ASSERT
(centerFreqs.size () > 1);
47
m_uid
= ++
m_uidCount
;
48
49
for
(std::vector<double>::const_iterator it = centerFreqs.begin ();
50
it != centerFreqs.end ();
51
++it)
52
{
53
BandInfo
e;
54
e.
fc
= *it;
55
if
(it == centerFreqs.begin ())
56
{
57
double
delta = ((*(it + 1)) - (*it)) / 2;
58
e.
fl
= *it - delta;
59
e.
fh
= *it + delta;
60
}
61
else
if
(it == centerFreqs.end () - 1 )
62
{
63
double
delta = ((*it) - (*(it - 1))) / 2;
64
e.
fl
= *it - delta;
65
e.
fh
= *it + delta;
66
}
67
else
68
{
69
e.
fl
= ((*it) + (*(it - 1))) / 2;
70
e.
fh
= ((*(it + 1)) + (*it)) / 2;
71
}
72
m_bands
.push_back (e);
73
}
74
}
75
76
SpectrumModel::SpectrumModel
(
Bands
bands)
77
{
78
m_uid
= ++
m_uidCount
;
79
NS_LOG_INFO
(
"creating new SpectrumModel, m_uid="
<<
m_uid
);
80
m_bands
= bands;
81
}
82
83
Bands::const_iterator
84
SpectrumModel::Begin
()
const
85
{
86
return
m_bands
.begin ();
87
}
88
89
Bands::const_iterator
90
SpectrumModel::End
()
const
91
{
92
return
m_bands
.end ();
93
}
94
95
size_t
96
SpectrumModel::GetNumBands
()
const
97
{
98
return
m_bands
.size ();
99
}
100
101
SpectrumModelUid_t
102
SpectrumModel::GetUid
()
const
103
{
104
return
m_uid
;
105
}
106
107
108
109
}
// namespace ns3
ns3::SpectrumModelUid_t
uint32_t SpectrumModelUid_t
Definition:
spectrum-model.h:54
ns3::SpectrumModel::GetNumBands
size_t GetNumBands() const
Definition:
spectrum-model.cc:96
ns3::SpectrumModel::m_uid
SpectrumModelUid_t m_uid
unique id for a given set of frequencies
Definition:
spectrum-model.h:112
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Definition:
log.h:298
ns3::SpectrumModel
Set of frequency values implementing the domain of the functions in the Function Space defined by Spe...
Definition:
spectrum-model.h:63
ns3::Bands
std::vector< BandInfo > Bands
Definition:
spectrum-model.h:53
ns3::SpectrumModel::End
Bands::const_iterator End() const
Definition:
spectrum-model.cc:90
ns3::SpectrumModel::GetUid
SpectrumModelUid_t GetUid() const
Definition:
spectrum-model.cc:102
ns3::BandInfo::fc
double fc
center frequency
Definition:
spectrum-model.h:48
ns3::SpectrumModel::m_uidCount
static SpectrumModelUid_t m_uidCount
counter to assign m_uids
Definition:
spectrum-model.h:113
ns3::BandInfo::fl
double fl
lower limit of subband
Definition:
spectrum-model.h:47
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("SpectrumModel")
ns3::SpectrumModel::m_bands
Bands m_bands
actual definition of frequency bands within this SpectrumModel
Definition:
spectrum-model.h:110
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition:
event-id.cc:89
ns3::SpectrumModel::Begin
Bands::const_iterator Begin() const
Definition:
spectrum-model.cc:84
ns3::BandInfo::fh
double fh
upper limit of subband
Definition:
spectrum-model.h:49
ns3::SpectrumModel::SpectrumModel
SpectrumModel(std::vector< double > centerFreqs)
This constructs a SpectrumModel based on a given set of frequencies, which is assumed to be sorted by...
Definition:
spectrum-model.cc:44
ns3::BandInfo
The building block of a SpectrumModel.
Definition:
spectrum-model.h:45
src
spectrum
model
spectrum-model.cc
Generated on Sat Apr 19 2014 14:07:08 for ns-3 by
1.8.6