A Discrete-Event Network Simulator
API
nix-vector.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 The Georgia Institute of Technology
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  * Authors: Josh Pelkey <jpelkey@gatech.edu>
19  */
20 
21 #ifndef NIX_VECTOR_H
22 #define NIX_VECTOR_H
23 
24 #include "ns3/ptr.h"
25 #include "ns3/simple-ref-count.h"
26 #include "ns3/buffer.h"
27 
28 namespace ns3 {
29 
63 class NixVector : public SimpleRefCount<NixVector>
64 {
65 public:
66  NixVector ();
67  ~NixVector ();
71  Ptr<NixVector> Copy (void) const;
76  NixVector (const NixVector &o);
83  NixVector &operator = (const NixVector &o);
96  void AddNeighborIndex (uint32_t newBits, uint32_t numberOfBits);
110  uint32_t ExtractNeighborIndex (uint32_t numberOfBits);
115  uint32_t GetRemainingBits (void);
119  uint32_t GetSerializedSize (void) const;
130  uint32_t Serialize (uint32_t* buffer, uint32_t maxSize) const;
141  uint32_t Deserialize (const uint32_t* buffer, uint32_t size);
151  uint32_t BitCount (uint32_t numberOfNeighbors) const;
152 
153 
154 private:
156  typedef std::vector<uint32_t> NixBits_t;
157 
163  /* for printing of nix-vector */
164  void DumpNixVector (std::ostream &os) const;
165 
173  friend std::ostream & operator << ( std::ostream &os, const NixVector &nix);
174 
176  uint32_t m_used;
177 
185 
190  uint32_t m_totalBitSize;
191 
198  void PrintDec2BinNixFill (uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const;
199 
206  void PrintDec2BinNix (uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const;
207 };
208 } // namespace ns3
209 
210 #endif /* NIX_VECTOR_H */
Neighbor-index data structure for nix-vector routing.
Definition: nix-vector.h:63
NixVector & operator=(const NixVector &o)
Definition: nix-vector.cc:57
void PrintDec2BinNix(uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const
Internal for pretty printing of nix-vector (no fill)
Definition: nix-vector.cc:388
uint32_t m_totalBitSize
A counter of how total bits are in the nix-vector.
Definition: nix-vector.h:190
uint32_t GetRemainingBits(void)
Definition: nix-vector.cc:357
uint32_t ExtractNeighborIndex(uint32_t numberOfBits)
Definition: nix-vector.cc:160
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
Definition: nix-vector.cc:225
NixBits_t m_nixVector
the actual nix-vector
Definition: nix-vector.h:175
uint32_t GetSerializedSize(void) const
Definition: nix-vector.cc:214
std::vector< uint32_t > NixBits_t
Typedef: the NixVector bits storage.
Definition: nix-vector.h:156
void DumpNixVector(std::ostream &os) const
Print the NixVector.
Definition: nix-vector.cc:319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
friend std::ostream & operator<<(std::ostream &os, const NixVector &nix)
Stream insertion operator.
Definition: nix-vector.cc:81
Ptr< NixVector > Copy(void) const
Definition: nix-vector.cc:71
uint32_t BitCount(uint32_t numberOfNeighbors) const
Definition: nix-vector.cc:365
void PrintDec2BinNixFill(uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const
Internal for pretty printing of nix-vector (fill)
Definition: nix-vector.cc:415
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Definition: nix-vector.cc:282
uint32_t m_used
For tracking where we are in the nix-vector.
Definition: nix-vector.h:176
void AddNeighborIndex(uint32_t newBits, uint32_t numberOfBits)
Definition: nix-vector.cc:88
uint32_t m_currentVectorBitSize
For tracking how many bits we have used in the current vector entry.
Definition: nix-vector.h:184
A template-based reference counting class.