constify
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 28 Aug 2007 14:33:53 +0200
changeset 1383 12f30b7defb4
parent 1382 61584c0c60f6
child 1384 a500f1a7c01d
constify
src/core/composite-trace-resolver.cc
src/core/composite-trace-resolver.h
src/core/object.cc
src/core/object.h
src/devices/csma/csma-net-device.cc
src/devices/csma/csma-net-device.h
src/devices/point-to-point/point-to-point-net-device.cc
src/devices/point-to-point/point-to-point-net-device.h
src/internet-node/arp-ipv4-interface.cc
src/internet-node/arp-ipv4-interface.h
src/internet-node/internet-node.cc
src/internet-node/internet-node.h
src/internet-node/ipv4-l3-protocol.cc
src/internet-node/ipv4-l3-protocol.h
src/internet-node/ipv4-l4-demux.cc
src/internet-node/ipv4-l4-demux.h
src/mobility/mobility-model-notifier.cc
src/mobility/mobility-model-notifier.h
src/node/node-list.cc
src/node/node-list.h
src/node/node.cc
src/node/node.h
src/node/queue.cc
src/node/queue.h
--- a/src/core/composite-trace-resolver.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/core/composite-trace-resolver.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -74,7 +74,7 @@
 void 
 CompositeTraceResolver::AddSource (std::string name,
                                    const TraceDoc &doc,
-                                   TraceSource &trace)
+                                   const TraceSource &trace)
 {
   DoAddSource (name, doc, trace, TraceContext ());
 }
@@ -82,7 +82,7 @@
 void 
 CompositeTraceResolver::DoAddSource (std::string name,
                                      const TraceDoc &doc,
-                                     TraceSource &trace, 
+                                     const TraceSource &trace, 
                                      const TraceContext &context)
 {
   class SourceCompositeItem : public CompositeItem
@@ -106,7 +106,7 @@
   } *item = new SourceCompositeItem ();
   item->name = name;
   item->context = context;
-  item->trace = &trace;
+  item->trace = const_cast<TraceSource *> (&trace);
   item->doc = doc;
   AddItem (item);
 }
--- a/src/core/composite-trace-resolver.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/core/composite-trace-resolver.h	Tue Aug 28 14:33:53 2007 +0200
@@ -55,7 +55,7 @@
    */
   template <typename T>
   void AddSource (std::string name, const TraceDoc &doc,
-                  TraceSource &trace, T const &context);
+                  const TraceSource &trace, T const &context);
   /**
    * \param name name of trace source
    * \param trace a callback trace source
@@ -66,7 +66,7 @@
    */
   void AddSource (std::string name,
                   const TraceDoc &doc,
-                  TraceSource &trace);
+                  const TraceSource &trace);
 
   void AddChild (std::string name, Ptr<Object> child);
 
@@ -116,7 +116,7 @@
   void DoAddChild (std::string name, Ptr<Object> child, const TraceContext &context);
   void DoAddSource (std::string name,
                     const TraceDoc &doc,
-                    TraceSource &trace,
+                    const TraceSource &trace,
                     const TraceContext &context);
   void Add (std::string name, 
             Callback<Ptr<TraceResolver> > createResolver);
@@ -136,7 +136,7 @@
 void 
 CompositeTraceResolver::AddSource (std::string name,
                                    const TraceDoc &doc,
-                                   TraceSource &trace, 
+                                   const TraceSource &trace, 
                                    T const &context)
 {
   TraceContext ctx;
--- a/src/core/object.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/core/object.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -63,20 +63,20 @@
 class InterfaceIdTraceResolver : public TraceResolver
 {
 public:
-  InterfaceIdTraceResolver (Ptr<Object> aggregate);
+  InterfaceIdTraceResolver (Ptr<const Object> aggregate);
   virtual void Connect (std::string path, CallbackBase const &cb, const TraceContext &context);
   virtual void Disconnect (std::string path, CallbackBase const &cb);
   virtual void CollectSources (std::string path, const TraceContext &context, 
                                SourceCollection *collection);
 private:
-  Ptr<Object> ParseForInterface (std::string path);
-  Ptr<Object> m_aggregate;
+  Ptr<const Object> ParseForInterface (std::string path);
+  Ptr<const Object> m_aggregate;
 };
 
-InterfaceIdTraceResolver::InterfaceIdTraceResolver (Ptr<Object> aggregate)
+InterfaceIdTraceResolver::InterfaceIdTraceResolver (Ptr<const Object> aggregate)
   : m_aggregate (aggregate)
 {}
-Ptr<Object>
+Ptr<const Object>
 InterfaceIdTraceResolver::ParseForInterface (std::string path)
 {
   std::string element = GetElement (path);
@@ -93,7 +93,7 @@
 void 
 InterfaceIdTraceResolver::Connect (std::string path, CallbackBase const &cb, const TraceContext &context)
 {
-  Ptr<Object> interface = ParseForInterface (path);
+  Ptr<const Object> interface = ParseForInterface (path);
   if (interface != 0)
     {
       interface->GetTraceResolver ()->Connect (GetSubpath (path), cb, context);
@@ -102,7 +102,7 @@
 void 
 InterfaceIdTraceResolver::Disconnect (std::string path, CallbackBase const &cb)
 {
-  Ptr<Object> interface = ParseForInterface (path);
+  Ptr<const Object> interface = ParseForInterface (path);
   if (interface != 0)
     {
       interface->TraceDisconnect (GetSubpath (path), cb);
@@ -232,12 +232,12 @@
 }
 
 void 
-Object::TraceConnect (std::string path, const CallbackBase &cb)
+Object::TraceConnect (std::string path, const CallbackBase &cb) const
 {
   GetTraceResolver ()->Connect (path, cb, TraceContext ());
 }
 void 
-Object::TraceDisconnect (std::string path, const CallbackBase &cb)
+Object::TraceDisconnect (std::string path, const CallbackBase &cb) const
 {
   GetTraceResolver ()->Disconnect (path, cb);
 }
@@ -256,7 +256,7 @@
 }
 
 Ptr<TraceResolver>
-Object::GetTraceResolver (void)
+Object::GetTraceResolver (void) const
 {
   Ptr<InterfaceIdTraceResolver> resolver =
     Create<InterfaceIdTraceResolver> (this);
@@ -298,9 +298,9 @@
 
 void 
 Object::DoCollectSources (std::string path, const TraceContext &context, 
-                          TraceResolver::SourceCollection *collection)
+                          TraceResolver::SourceCollection *collection) const
 {
-  Object *current;
+  const Object *current;
   current = this;
   do {
     if (current->m_collecting)
--- a/src/core/object.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/core/object.h	Tue Aug 28 14:33:53 2007 +0200
@@ -149,7 +149,7 @@
    * match the input path.
    *
    */
-  void TraceConnect (std::string path, const CallbackBase &cb);
+  void TraceConnect (std::string path, const CallbackBase &cb) const;
   /**
    * \param path the path to match for the callback
    * \param cb callback to disconnect
@@ -157,13 +157,13 @@
    * Disconnect the input callback from all trace sources which
    * match the input path.
    */
-  void TraceDisconnect (std::string path, const CallbackBase &cb);
+  void TraceDisconnect (std::string path, const CallbackBase &cb) const;
   /**
    * \returns the trace resolver associated to this object.
    *
    * This method should be rarely called by users.
    */
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 protected:
   /**
    * \param iid an InterfaceId
@@ -183,13 +183,13 @@
   friend class InterfaceIdTraceResolver;
   Ptr<Object> DoQueryInterface (InterfaceId iid) const;
   void DoCollectSources (std::string path, const TraceContext &context, 
-                         TraceResolver::SourceCollection *collection);
+                         TraceResolver::SourceCollection *collection) const;
   bool Check (void) const;
   void MaybeDelete (void) const;
   mutable uint32_t m_count;
   InterfaceId m_iid;
   bool m_disposed;
-  bool m_collecting;
+  mutable bool m_collecting;
   Object *m_next;
 };
 
--- a/src/devices/csma/csma-net-device.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/devices/csma/csma-net-device.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -458,7 +458,7 @@
 }
 
 Ptr<TraceResolver>
-CsmaNetDevice::GetTraceResolver (void)
+CsmaNetDevice::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddChild ("queue", m_queue);
--- a/src/devices/csma/csma-net-device.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/devices/csma/csma-net-device.h	Tue Aug 28 14:33:53 2007 +0200
@@ -212,7 +212,7 @@
    * (NOT TESTED)
    * @see class TraceResolver
    */
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 
   /**
    * Get a copy of the attached Queue.
--- a/src/devices/point-to-point/point-to-point-net-device.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -195,7 +195,7 @@
 }
 
 Ptr<TraceResolver> 
-PointToPointNetDevice::GetTraceResolver (void)
+PointToPointNetDevice::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddChild ("queue", m_queue);
--- a/src/devices/point-to-point/point-to-point-net-device.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.h	Tue Aug 28 14:33:53 2007 +0200
@@ -158,7 +158,7 @@
    *
    * @see class TraceResolver
    */
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
   virtual void DoDispose (void);
   /**
    * Get a copy of the attached Queue.
--- a/src/internet-node/arp-ipv4-interface.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/arp-ipv4-interface.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -41,7 +41,7 @@
 {}
 
 Ptr<TraceResolver>
-ArpIpv4Interface::GetTraceResolver (void)
+ArpIpv4Interface::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   if (GetDevice () != 0)
--- a/src/internet-node/arp-ipv4-interface.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/arp-ipv4-interface.h	Tue Aug 28 14:33:53 2007 +0200
@@ -43,7 +43,7 @@
   virtual ~ArpIpv4Interface ();
 
 protected:
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 private:
   virtual void SendTo (Packet p, Ipv4Address dest);
   Ptr<Node> m_node;
--- a/src/internet-node/internet-node.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/internet-node.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -75,7 +75,7 @@
 }
 
 Ptr<TraceResolver>
-InternetNode::GetTraceResolver ()
+InternetNode::GetTraceResolver () const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   Ptr<Ipv4L3Protocol> ipv4 = QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
--- a/src/internet-node/internet-node.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/internet-node.h	Tue Aug 28 14:33:53 2007 +0200
@@ -42,7 +42,7 @@
 
 protected:
   virtual void DoDispose(void);
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 private:
   bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const;
   void Construct (void);
--- a/src/internet-node/ipv4-l3-protocol.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -159,7 +159,7 @@
 }
 
 Ptr<TraceResolver>
-Ipv4L3Protocol::GetTraceResolver (void)
+Ipv4L3Protocol::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddSource ("tx", 
--- a/src/internet-node/ipv4-l3-protocol.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.h	Tue Aug 28 14:33:53 2007 +0200
@@ -171,7 +171,7 @@
 protected:
 
   virtual void DoDispose (void);
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 
 private:
 
--- a/src/internet-node/ipv4-l4-demux.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -84,7 +84,7 @@
 }
 
 Ptr<TraceResolver>
-Ipv4L4Demux::GetTraceResolver (void)
+Ipv4L4Demux::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
--- a/src/internet-node/ipv4-l4-demux.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.h	Tue Aug 28 14:33:53 2007 +0200
@@ -89,7 +89,7 @@
    */
   void Remove (Ptr<Ipv4L4Protocol> protocol);
 protected:
-  Ptr<TraceResolver> GetTraceResolver (void);
+  Ptr<TraceResolver> GetTraceResolver (void) const;
   virtual void DoDispose (void);
 private:
   typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t;
--- a/src/mobility/mobility-model-notifier.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/mobility/mobility-model-notifier.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -41,7 +41,7 @@
 }
 
 Ptr<TraceResolver> 
-MobilityModelNotifier::GetTraceResolver (void)
+MobilityModelNotifier::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = 
     Create<CompositeTraceResolver> ();
--- a/src/mobility/mobility-model-notifier.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/mobility/mobility-model-notifier.h	Tue Aug 28 14:33:53 2007 +0200
@@ -48,7 +48,7 @@
    */
   void Notify (Ptr<const MobilityModel> position) const;
 protected:
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 private:
   CallbackTraceSource<Ptr<const MobilityModel> > m_trace;
 };
--- a/src/node/node-list.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/node/node-list.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -67,9 +67,9 @@
   ~NodeListPriv ();
 
   uint32_t Add (Ptr<Node> node);
-  NodeList::Iterator Begin (void);
-  NodeList::Iterator End (void);
-  Ptr<TraceResolver> GetTraceResolver (void);
+  NodeList::Iterator Begin (void) const;
+  NodeList::Iterator End (void) const;
+  Ptr<TraceResolver> GetTraceResolver (void) const;
   Ptr<Node> GetNode (uint32_t n);
   uint32_t GetNNodes (void);
 
@@ -101,12 +101,12 @@
   
 }
 NodeList::Iterator 
-NodeListPriv::Begin (void)
+NodeListPriv::Begin (void) const
 {
   return m_nodes.begin ();
 }
 NodeList::Iterator 
-NodeListPriv::End (void)
+NodeListPriv::End (void) const
 {
   return m_nodes.end ();
 }
@@ -124,7 +124,7 @@
 
 
 Ptr<TraceResolver>
-NodeListPriv::GetTraceResolver (void)
+NodeListPriv::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddArray ("nodes", Begin (), End (), NodeListIndex ());
--- a/src/node/node-list.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/node/node-list.h	Tue Aug 28 14:33:53 2007 +0200
@@ -54,7 +54,7 @@
 class NodeList
 {
 public:
-  typedef std::vector< Ptr<Node> >::iterator Iterator;
+  typedef std::vector< Ptr<Node> >::const_iterator Iterator;
 
   /**
    * \param node node to add
--- a/src/node/node.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/node/node.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -87,7 +87,7 @@
 {}
 
 Ptr<TraceResolver>
-Node::GetTraceResolver (void)
+Node::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddArray ("devices", m_devices.begin (), m_devices.end (), NodeNetDeviceIndex ());
--- a/src/node/node.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/node/node.h	Tue Aug 28 14:33:53 2007 +0200
@@ -173,7 +173,7 @@
   void UnregisterProtocolHandler (ProtocolHandler handler);
 
 protected:
-  virtual Ptr<TraceResolver> GetTraceResolver (void);
+  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
   /**
    * The dispose method. Subclasses must override this method
    * and must chain up to it by calling Node::DoDispose at the
--- a/src/node/queue.cc	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/node/queue.cc	Tue Aug 28 14:33:53 2007 +0200
@@ -100,7 +100,7 @@
 }
 
 Ptr<TraceResolver>
-Queue::GetTraceResolver (void)
+Queue::GetTraceResolver (void) const
 {
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddSource ("enqueue", 
--- a/src/node/queue.h	Tue Aug 28 14:32:44 2007 +0200
+++ b/src/node/queue.h	Tue Aug 28 14:33:53 2007 +0200
@@ -166,7 +166,7 @@
   virtual bool DoPeek (Packet &p) = 0;
 
 protected:
-  Ptr<TraceResolver> GetTraceResolver (void);
+  Ptr<TraceResolver> GetTraceResolver (void) const;
   // called by subclasses to notify parent of packet drops.
   void Drop (const Packet& p);