Bug 105: Queue getter methods should be const
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Thu, 15 Nov 2007 11:41:42 +0000
changeset 1860 cb17b9a8625b
parent 1859 7f78a53adb33
child 1861 5bc0b0d8d620
Bug 105: Queue getter methods should be const
src/node/drop-tail-queue.cc
src/node/drop-tail-queue.h
src/node/queue.cc
src/node/queue.h
--- a/src/node/drop-tail-queue.cc	Wed Nov 21 09:08:32 2007 +0100
+++ b/src/node/drop-tail-queue.cc	Thu Nov 15 11:41:42 2007 +0000
@@ -95,7 +95,7 @@
 }
 
 bool
-DropTailQueue::DoPeek (Packet& p)
+DropTailQueue::DoPeek (Packet& p) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_PARAMS (this << &p);
--- a/src/node/drop-tail-queue.h	Wed Nov 21 09:08:32 2007 +0100
+++ b/src/node/drop-tail-queue.h	Thu Nov 15 11:41:42 2007 +0000
@@ -59,7 +59,7 @@
 private:
   virtual bool DoEnqueue (const Packet& p);
   virtual bool DoDequeue (Packet &p);
-  virtual bool DoPeek (Packet &p);
+  virtual bool DoPeek (Packet &p) const;
 
 private:
   std::queue<Packet> m_packets;
--- a/src/node/queue.cc	Wed Nov 21 09:08:32 2007 +0100
+++ b/src/node/queue.cc	Thu Nov 15 11:41:42 2007 +0000
@@ -186,7 +186,7 @@
 }
 
 bool
-Queue::Peek (Packet &p)
+Queue::Peek (Packet &p) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_PARAMS (this << &p);
@@ -195,7 +195,7 @@
 
 
 uint32_t 
-Queue::GetNPackets (void)
+Queue::GetNPackets (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC ("returns " << m_nPackets);
@@ -203,7 +203,7 @@
 }
 
 uint32_t
-Queue::GetNBytes (void)
+Queue::GetNBytes (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC (" returns " << m_nBytes);
@@ -211,7 +211,7 @@
 }
 
 bool
-Queue::IsEmpty (void)
+Queue::IsEmpty (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC ("returns " << (m_nPackets == 0));
@@ -219,7 +219,7 @@
 }
 
 uint32_t
-Queue::GetTotalReceivedBytes (void)
+Queue::GetTotalReceivedBytes (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC("returns " << m_nTotalReceivedBytes);
@@ -227,7 +227,7 @@
 }
 
 uint32_t
-Queue::GetTotalReceivedPackets (void)
+Queue::GetTotalReceivedPackets (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC ("returns " << m_nTotalReceivedPackets);
@@ -235,7 +235,7 @@
 }
 
 uint32_t
-Queue:: GetTotalDroppedBytes (void)
+Queue:: GetTotalDroppedBytes (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC ("returns " << m_nTotalDroppedBytes);
@@ -243,7 +243,7 @@
 }
 
 uint32_t
-Queue::GetTotalDroppedPackets (void)
+Queue::GetTotalDroppedPackets (void) const
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC("returns " << m_nTotalDroppedPackets);
--- a/src/node/queue.h	Wed Nov 21 09:08:32 2007 +0100
+++ b/src/node/queue.h	Thu Nov 15 11:41:42 2007 +0000
@@ -86,7 +86,7 @@
   /**
    * \return true if the queue is empty; false otherwise
    */
-  bool IsEmpty (void);
+  bool IsEmpty (void) const;
   /**
    * Place a packet into the rear of the Queue
    * \return True if the operation was successful; false otherwise
@@ -101,7 +101,7 @@
    * Get a copy of the item at the front of the queue without removing it
    * \return True if the operation was successful; false otherwise
    */
-  bool Peek (Packet &p);
+  bool Peek (Packet &p) const;
 
   /**
    * XXX Doesn't do anything right now, think its supposed to flush the queue
@@ -110,11 +110,11 @@
   /**
    * \return The number of packets currently stored in the Queue
    */
-  uint32_t GetNPackets (void);
+  uint32_t GetNPackets (void) const;
   /**
    * \return The number of bytes currently occupied by the packets in the Queue
    */
-  uint32_t GetNBytes (void);
+  uint32_t GetNBytes (void) const;
 
   /**
    * \return The total number of bytes recieved by this Queue since the
@@ -122,25 +122,25 @@
    * whichever happened more recently
    * 
    */
-  uint32_t GetTotalReceivedBytes (void);
+  uint32_t GetTotalReceivedBytes (void) const;
   /**
    * \return The total number of packets recieved by this Queue since the
    * simulation began, or since ResetStatistics was called, according to 
    * whichever happened more recently
    */
-  uint32_t GetTotalReceivedPackets (void);
+  uint32_t GetTotalReceivedPackets (void) const;
   /**
    * \return The total number of bytes dropped by this Queue since the
    * simulation began, or since ResetStatistics was called, according to 
    * whichever happened more recently
    */
-  uint32_t GetTotalDroppedBytes (void);
+  uint32_t GetTotalDroppedBytes (void) const;
   /**
    * \return The total number of bytes dropped by this Queue since the
    * simulation began, or since ResetStatistics was called, according to 
    * whichever happened more recently
    */
-  uint32_t GetTotalDroppedPackets (void);
+  uint32_t GetTotalDroppedPackets (void) const;
   /**
    * Resets the counts for dropped packets, dropped bytes, recieved packets, and
    * recieved bytes.
@@ -175,7 +175,7 @@
 
   virtual bool DoEnqueue (const Packet& p) = 0;
   virtual bool DoDequeue (Packet &p) = 0;
-  virtual bool DoPeek (Packet &p) = 0;
+  virtual bool DoPeek (Packet &p) const = 0;
 
 protected:
   Ptr<TraceResolver> GetTraceResolver (void) const;