A Discrete-Event Network Simulator
API
snr-tag.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  * Copyright (c) 2013 University of Surrey
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation;
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21  * Mirko Banchi <mk.banchi@gmail.com>
22  * Konstantinos Katsaros <dinos.katsaros@gmail.com>
23  */
24 
25 #include "snr-tag.h"
26 #include "ns3/tag.h"
27 #include "ns3/double.h"
28 
29 namespace ns3 {
30 
32 
33 TypeId
35 {
36  static TypeId tid = TypeId ("ns3::SnrTag")
37  .SetParent<Tag> ()
38  .SetGroupName ("Wifi")
39  .AddConstructor<SnrTag> ()
40  .AddAttribute ("Snr", "The snr of the last packet received",
41  DoubleValue (0.0),
43  MakeDoubleChecker<double> ())
44  ;
45  return tid;
46 }
47 
48 TypeId
50 {
51  return GetTypeId ();
52 }
53 
55  : m_snr (0)
56 {
57 }
58 
59 SnrTag::SnrTag (double snr)
60  : m_snr (snr)
61 {
62 }
63 
64 uint32_t
66 {
67  return sizeof (double);
68 }
69 
70 void
72 {
73  i.WriteDouble (m_snr);
74 }
75 
76 void
78 {
79  m_snr = i.ReadDouble ();
80 }
81 
82 void
83 SnrTag::Print (std::ostream &os) const
84 {
85  os << "Snr=" << m_snr;
86 }
87 
88 void
89 SnrTag::Set (double snr)
90 {
91  m_snr = snr;
92 }
93 
94 double
95 SnrTag::Get (void) const
96 {
97  return m_snr;
98 }
99 
100 }
void Set(double snr)
Set the SNR to the given value.
Definition: snr-tag.cc:89
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
static TypeId GetTypeId(void)
Definition: snr-tag.cc:34
void WriteDouble(double v)
Definition: tag-buffer.cc:115
virtual void Print(std::ostream &os) const
Definition: snr-tag.cc:83
virtual uint32_t GetSerializedSize(void) const
Definition: snr-tag.cc:65
double ReadDouble(void)
Definition: tag-buffer.cc:164
SnrTag()
Create a SnrTag with the default snr 0.
Definition: snr-tag.cc:54
virtual void Serialize(TagBuffer i) const
Definition: snr-tag.cc:71
double Get(void) const
Return the SNR value.
Definition: snr-tag.cc:95
virtual void Deserialize(TagBuffer i)
Definition: snr-tag.cc:77
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: snr-tag.cc:49
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
read and write tag data
Definition: tag-buffer.h:51
double m_snr
SNR value.
Definition: snr-tag.h:71
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
Introspection did not find any typical Config paths.
Definition: snr-tag.h:34