src/wifi/model/snr-tag.cc
changeset 9234 310d371059d5
child 10410 4d4eb8097fa3
equal deleted inserted replaced
9233:4a9feececbf3 9234:310d371059d5
       
     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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    21  * Author: Mirko Banchi <mk.banchi@gmail.com>
       
    22  * Author: 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 
       
    31 NS_OBJECT_ENSURE_REGISTERED (SnrTag);
       
    32 
       
    33 TypeId
       
    34 SnrTag::GetTypeId (void)
       
    35 {
       
    36   static TypeId tid = TypeId ("ns3::SnrTag")
       
    37     .SetParent<Tag> ()
       
    38     .AddConstructor<SnrTag> ()
       
    39     .AddAttribute ("Snr", "The snr of the last packet received",
       
    40                    DoubleValue (0.0),
       
    41                    MakeDoubleAccessor (&SnrTag::Get),
       
    42                    MakeDoubleChecker<double> ())
       
    43   ;
       
    44   return tid;
       
    45 }
       
    46 TypeId
       
    47 SnrTag::GetInstanceTypeId (void) const
       
    48 {
       
    49   return GetTypeId ();
       
    50 }
       
    51 
       
    52 SnrTag::SnrTag ()
       
    53   : m_snr (0)
       
    54 {
       
    55 }
       
    56 SnrTag::SnrTag (double snr)
       
    57   : m_snr (snr)
       
    58 {
       
    59 }
       
    60 
       
    61 
       
    62 uint32_t
       
    63 SnrTag::GetSerializedSize (void) const
       
    64 {
       
    65   return sizeof (double);
       
    66 }
       
    67 void
       
    68 SnrTag::Serialize (TagBuffer i) const
       
    69 {
       
    70   i.WriteDouble (m_snr);
       
    71 }
       
    72 void
       
    73 SnrTag::Deserialize (TagBuffer i)
       
    74 {
       
    75   m_snr = i.ReadDouble ();
       
    76 }
       
    77 void
       
    78 SnrTag::Print (std::ostream &os) const
       
    79 {
       
    80   os << "Snr=" << m_snr;
       
    81 }
       
    82 void
       
    83 SnrTag::Set (double snr)
       
    84 {
       
    85   m_snr = snr;
       
    86 }
       
    87 double
       
    88 SnrTag::Get (void) const
       
    89 {
       
    90   return m_snr;
       
    91 }
       
    92 
       
    93 
       
    94 }