A Discrete-Event Network Simulator
API
spectrum-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 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_HELPER_H
21#define SPECTRUM_HELPER_H
22
23#include <ns3/attribute.h>
24#include <ns3/net-device-container.h>
25#include <ns3/node-container.h>
26#include <ns3/object-factory.h>
27#include <ns3/propagation-loss-model.h>
28#include <ns3/spectrum-propagation-loss-model.h>
29
30#include <string>
31
32namespace ns3
33{
34
35class SpectrumPhy;
36class SpectrumChannel;
37class Node;
38class NetDevice;
39
45{
46 public:
56
62 template <typename... Ts>
63 void SetChannel(std::string type, Ts&&... args);
71 template <typename... Ts>
72 void AddPropagationLoss(std::string name, Ts&&... args);
73
80
88 template <typename... Ts>
89 void AddSpectrumPropagationLoss(std::string name, Ts&&... args);
90
97
105 template <typename... Ts>
106 void SetPropagationDelay(std::string name, Ts&&... args);
107
114
115 private:
121};
122
129{
130 public:
136 template <typename... Ts>
137 void SetPhy(std::string name, Ts&&... args);
138
145
151 void SetChannel(std::string channelName);
152
159 void SetPhyAttribute(std::string name, const AttributeValue& v);
160
169
170 private:
173};
174
175/***************************************************************
176 * Implementation of the templates declared above.
177 ***************************************************************/
178
179template <typename... Ts>
180void
182{
184 m_channel.Set(std::forward<Ts>(args)...);
185}
186
187template <typename... Ts>
188void
190{
191 ObjectFactory factory(name, std::forward<Ts>(args)...);
194}
195
196template <typename... Ts>
197void
199{
200 ObjectFactory factory(name, std::forward<Ts>(args)...);
203}
204
205template <typename... Ts>
206void
208{
209 m_propagationDelay = ObjectFactory(name, std::forward<Ts>(args)...);
210}
211
212template <typename... Ts>
213void
214SpectrumPhyHelper::SetPhy(std::string name, Ts&&... args)
215{
216 m_phy.SetTypeId(name);
217 m_phy.Set(std::forward<Ts>(args)...);
218}
219
220} // namespace ns3
221
222#endif /* SPECTRUM_HELPER_H */
Hold a value for an Attribute.
Definition: attribute.h:70
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Models the propagation loss through a transmission medium.
Setup a SpectrumChannel.
ObjectFactory m_propagationDelay
Propagation delay.
ObjectFactory m_channel
Channel.
Ptr< SpectrumChannel > Create() const
void AddPropagationLoss(std::string name, Ts &&... args)
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
void AddSpectrumPropagationLoss(std::string name, Ts &&... args)
void SetPropagationDelay(std::string name, Ts &&... args)
void SetChannel(std::string type, Ts &&... args)
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLossModel
Spectrum propagation loss model.
Ptr< PropagationLossModel > m_propagationLossModel
Propagation loss model.
Create and configure several SpectrumPhy instances and connect them to a channel.
void SetChannel(Ptr< SpectrumChannel > channel)
set the channel that will be used by SpectrumPhy instances created by this helper
Ptr< SpectrumChannel > m_channel
Channel.
ObjectFactory m_phy
Object factory for the phy objects.
void SetPhyAttribute(std::string name, const AttributeValue &v)
Ptr< SpectrumPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
void SetPhy(std::string name, Ts &&... args)
spectrum-aware propagation loss model
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:81