blob: f2759bef0183208a9d563684d6465a0812701067 [file] [log] [blame]
Ilya Moiseenko1a8be032012-01-18 12:51:09 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 */
20
21#include "ccnx-path-stretch-tag.h"
22
23namespace ns3 {
24
25WeightsPathStretchTag::WeightsPathStretchTag()
26 : m_weightPathStretch(0)
27{
28}
29
30WeightsPathStretchTag::WeightsPathStretchTag(const WeightsPathStretchTag &o)
31 : m_weightPathStretch(o.m_weightPathStretch)
32{
33}
34
35WeightsPathStretchTag &WeightsPathStretchTag::operator = (const WeightsPathStretchTag &o)
36{
37 if (this == &o)
38 return *this;
39
40 m_weightPathStretch = o.m_weightPathStretch;
41 return *this;
42}
43
44bool WeightsPathStretchTag::operator == (WeightsPathStretchTag const &o) const
45{
46 return (m_weightPathStretch == o.m_weightPathStretch);
47}
48
49TypeId WeightsPathStretchTag::GetTypeId(void)
50{
51 static TypeId tid = TypeId("ns3::WeightsPathStretchTag")
52 .SetParent<Tag>()
53 .AddConstructor<WeightsPathStretchTag>()
54 ;
55 return tid;
56}
57
58TypeId WeightsPathStretchTag::GetInstanceTypeId(void) const
59{
60 return GetTypeId();
61}
62
63uint32_t WeightsPathStretchTag::GetSerializedSize(void) const
64{
65 return sizeof(uint32_t);
66}
67
68void WeightsPathStretchTag::Serialize(TagBuffer i) const
69{
70 i.WriteU32(m_weightPathStretch);
71}
72
73void WeightsPathStretchTag::Deserialize(TagBuffer i)
74{
75 m_weightPathStretch = i.ReadU32();
76}
77
78void WeightsPathStretchTag::Print(std::ostream &os) const
79{
80 os << "Path Stretch (Weights) = " << m_weightPathStretch << std::endl;
81}
82
83void WeightsPathStretchTag::AddNewHop(uint32_t weight)
84{
85 m_weightPathStretch +=weight;
86}
87uint32_t WeightsPathStretchTag::GetValue()
88{
89 return m_weightPathStretch;
90}
91} // namespace ns3
92