A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-transmit-filter.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 University of Washington
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 */
18
20
21#include "spectrum-phy.h"
23
24#include <ns3/log.h>
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("SpectrumTransmitFilter");
30
31NS_OBJECT_ENSURE_REGISTERED(SpectrumTransmitFilter);
32
33TypeId
35{
36 static TypeId tid =
37 TypeId("ns3::SpectrumTransmitFilter").SetParent<Object>().SetGroupName("Spectrum");
38 return tid;
39}
40
42{
43 NS_LOG_FUNCTION(this);
44}
45
46void
48{
49 NS_LOG_FUNCTION(this);
50 if (m_next)
51 {
52 m_next->Dispose();
53 }
54 m_next = nullptr;
56}
57
58void
60{
61 m_next = next;
62}
63
66{
67 return m_next;
68}
69
70bool
72 Ptr<const SpectrumPhy> receiverPhy)
73{
74 NS_LOG_FUNCTION(this << params << receiverPhy);
75 bool result = DoFilter(params, receiverPhy);
76 if (result)
77 {
78 return true;
79 }
80 else if (m_next)
81 {
82 return m_next->Filter(params, receiverPhy);
83 }
84 else
85 {
86 return false;
87 }
88}
89
90int64_t
92{
93 auto currentStream = stream;
94 currentStream += DoAssignStreams(stream);
95 if (m_next)
96 {
97 currentStream += m_next->AssignStreams(currentStream);
98 }
99 return (currentStream - stream);
100}
101
102} // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:444
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
bool Filter(Ptr< const SpectrumSignalParameters > params, Ptr< const SpectrumPhy > receiverPhy)
Evaluate whether the signal to be scheduled on the receiving Phy should instead be filtered (discarde...
int64_t AssignStreams(int64_t stream)
If this loss model uses objects of type RandomVariableStream, set the stream numbers to the integers ...
static TypeId GetTypeId()
Get the type ID.
virtual bool DoFilter(Ptr< const SpectrumSignalParameters > params, Ptr< const SpectrumPhy > receiverPhy)=0
Evaluate whether the signal to be scheduled on the receiving Phy should instead be filtered (discarde...
Ptr< const SpectrumTransmitFilter > GetNext() const
Return the next transmit filter in the chain.
virtual int64_t DoAssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
void SetNext(Ptr< SpectrumTransmitFilter > next)
Add a transmit filter to be consulted next if this filter does not filter the signal.
Ptr< SpectrumTransmitFilter > m_next
SpectrumTransmitFilter chained to this one.
void DoDispose() override
Destructor implementation.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.