replace static const Interface iid; with static InterfaceId iid (void);
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 02 Jan 2008 10:33:39 +0100
changeset 2232 9abd038ee588
parent 2231 a5b898c1ee2c
child 2233 b359c83c5fbe
replace static const Interface iid; with static InterfaceId iid (void);
samples/main-component-manager.cc
samples/main-object.cc
samples/main-query-interface.cc
src/common/error-model.cc
src/common/error-model.h
src/core/component-manager.cc
src/core/component-manager.h
src/core/object.cc
src/core/object.h
src/internet-node/arp-l3-protocol.cc
src/internet-node/arp-l3-protocol.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/grid-topology.cc
src/mobility/hierarchical-mobility-model.cc
src/mobility/hierarchical-mobility-model.h
src/mobility/mobility-model-notifier.cc
src/mobility/mobility-model-notifier.h
src/mobility/mobility-model.cc
src/mobility/mobility-model.h
src/mobility/random-direction-2d-mobility-model.cc
src/mobility/random-position.cc
src/mobility/random-position.h
src/mobility/random-topology.cc
src/mobility/random-walk-2d-mobility-model.cc
src/mobility/random-waypoint-mobility-model.cc
src/mobility/static-mobility-model.cc
src/mobility/static-speed-mobility-model.cc
src/mobility/static-speed-mobility-model.h
src/node/channel.cc
src/node/channel.h
src/node/drop-tail-queue.cc
src/node/ipv4.cc
src/node/ipv4.h
src/node/net-device.cc
src/node/net-device.h
src/node/node.cc
src/node/node.h
src/node/packet-socket-factory.cc
src/node/packet-socket-factory.h
src/node/queue.cc
src/node/queue.h
src/node/socket-factory.cc
src/node/socket-factory.h
src/node/udp.cc
src/node/udp.h
src/routing/global-routing/global-router-interface.cc
src/routing/global-routing/global-router-interface.h
src/routing/olsr/olsr-agent-impl.cc
src/routing/olsr/olsr-agent.cc
src/routing/olsr/olsr-agent.h
utils/bench-object.cc
--- a/samples/main-component-manager.cc	Wed Jan 02 09:25:31 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#include "ns3/object.h"
-#include "ns3/component-manager.h"
-
-using namespace ns3;
-
-class AnObject : public Object
-{
-public:
-  static const InterfaceId iid;
-  static const ClassId cid;
-  AnObject (int a, double b);
-protected:
-  virtual void DoDispose (void);
-};
-
-const InterfaceId AnObject::iid = MakeInterfaceId ("AnObject", Object::iid);
-const ClassId AnObject::cid = MakeClassId<AnObject, int, double> ("AnObject", AnObject::iid);
-
-AnObject::AnObject (int a, double b)
-{}
-void
-AnObject::DoDispose (void)
-{
-  // Do your work here.
-  // chain up
-  Object::DoDispose ();
-}
-
-
-int main (int argc, char *argv[])
-{
-  Ptr<AnObject> anObject = ComponentManager::Create<AnObject,int,double> (AnObject::cid, AnObject::iid, 10, 20.0);
-  NS_ASSERT (anObject != 0);
-  return 0;
-}
--- a/samples/main-object.cc	Wed Jan 02 09:25:31 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-#include "ns3/object.h"
-
-using namespace ns3;
-
-class AnObject : public Object
-{
-public:
-  static const InterfaceId iid;
-  AnObject ();
-protected:
-  virtual void DoDispose (void);
-};
-
-const InterfaceId AnObject::iid = MakeInterfaceId ("AnObject", Object::iid);
-
-AnObject::AnObject ()
-{}
-void
-AnObject::DoDispose (void)
-{
-  // Do your work here.
-  // chain up
-  Object::DoDispose ();
-}
-
-class AnotherObject : public Object
-{
-public:
-  static const InterfaceId iid;
-  AnotherObject (int a);
-private:
-  virtual void DoDispose (void);
-};
-
-const InterfaceId AnotherObject::iid = MakeInterfaceId ("AnotherObject", Object::iid);
-
-AnotherObject::AnotherObject (int a)
-{
-  // enable our interface
-  SetInterfaceId (AnotherObject::iid);
-}
-void
-AnotherObject::DoDispose (void)
-{
-  // Do your work here.
-  // chain up
-  Object::DoDispose ();
-}
-
-
-
-class YetAnotherObject : public Object
-{
-public:
-  static const InterfaceId iid;
-  YetAnotherObject (int a);
-private:
-  virtual void DoDispose (void);
-};
-
-const InterfaceId YetAnotherObject::iid = MakeInterfaceId ("YetAnotherObject", Object::iid);
-
-YetAnotherObject::YetAnotherObject (int a)
-{
-  // enable our interface
-  SetInterfaceId (YetAnotherObject::iid);
-  // aggregated directly to another object.
-  AddInterface (CreateObject<AnObject> ());
-}
-void
-YetAnotherObject::DoDispose (void)
-{
-  // Do your work here.
-  // chain up
-  Object::DoDispose ();
-}
-
-
-
-int main (int argc, char *argv[])
-{
-  Ptr<Object> p;
-  Ptr<AnObject> anObject;
-  Ptr<AnotherObject> anotherObject;
-  Ptr<YetAnotherObject> yetAnotherObject;
-
-  p = CreateObject<AnObject> ();
-  // p gives you access to AnObject's interface
-  anObject = p->QueryInterface<AnObject> (AnObject::iid);
-  NS_ASSERT (anObject != 0);
-  // p does not give you access to AnotherObject's interface
-  anotherObject = p->QueryInterface<AnotherObject> (AnotherObject::iid);
-  NS_ASSERT (anotherObject == 0);
-
-  anotherObject = CreateObject<AnotherObject> (1);
-  // AnotherObject does not give you access to AnObject's interface
-  anObject = anotherObject->QueryInterface<AnObject> (AnObject::iid);
-  NS_ASSERT (anObject == 0);
-
-  // aggregate the two objects
-  p->AddInterface (anotherObject);
-  // p gives you access to AnObject's interface
-  anObject = p->QueryInterface<AnObject> (AnObject::iid);
-  NS_ASSERT (anObject != 0);
-  // p gives you access to AnotherObject's interface
-  anotherObject = p->QueryInterface<AnotherObject> (AnotherObject::iid);
-  NS_ASSERT (anotherObject != 0);
-
-
-  yetAnotherObject = CreateObject<YetAnotherObject> (2);
-  // gives you acess to AnObject interface too.
-  anObject = yetAnotherObject->QueryInterface<AnObject> (AnObject::iid);
-  NS_ASSERT (anObject != 0);
-
-
-  return 0;
-}
-
--- a/samples/main-query-interface.cc	Wed Jan 02 09:25:31 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,280 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 University of Washington
- * Authors:  Tom Henderson, Craig Dowell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "ns3/log.h"
-#include "ns3/object.h"
-#include "ns3/component-manager.h"
-
-using namespace ns3;
-
-//
-// This sample file shows examples of how to use QueryInterface.
-//
-// QueryInterface is a templated method of class Object, defined in 
-// src/core/object.h.  ns-3 objects that derive from class Object
-// can have QueryInterface invoked on them.
-//
-// QueryInterface is a type-safe way to ask an object, at run-time, 
-// "Do you support the interface identified by the given InterfaceId?"  
-// It avoids deprecated techniques of having to downcast pointers to 
-// an object to ask questions about its type.  One or more interfaces
-// may be associated with a given object.
-// 
-// QueryInterface is of most use when working with base class
-// pointers of objects that may be subclassed.  For instance,
-// one may have a pointer to a Node, but not know whether it has
-// an IPv4 stack.  Another example might be to determine whether
-// a Node has an EnergyModel, to which calls to decrement energy
-// from the node's battery might be made.
-//
-
-
-//
-// Object is the base class for ns-3 node-related objects used at 
-// the public API.  Object provides reference counting implementations
-// and the QueryInterface.
-// 
-// A common design paradigm for an ns-3 node object, such as a Queue,
-// is that we provide an abstract base class that inherits from
-// Object.  This class is assigned an interface ID (iid) and 
-// contains the basic API for objects in this class and subclasses.
-// This base class is specialized to provide implementations of
-// the object in question (such as a DropTailQueue).
-// 
-// The design pattern commonly used is known as the "non-virtual
-// public interface" pattern, whereby the public API for this
-// object is a set of public non-virtual functions that forward
-// to private virtual functions.  The forwarding functions can
-// impose pre- and post-conditions on the forwarding call at
-// the base class level.
-// 
-// We'll call this base class "AnInterface" in the example below.
-//
-// 
-class AnInterface : public Object
-{
-public:
-  static const InterfaceId iid;
-  void methodA (void);
-private:
-  virtual void domethodA (void) = 0;
-};
-
-void
-AnInterface::methodA (void)
-{
-  NS_LOG_FUNCTION;
-  // pre-dispatch asserts
-  NS_LOG_LOGIC ("pre-condition");
-  domethodA ();
-  NS_LOG_LOGIC ("post-condition");
-  // post-dispatch asserts
-}
-
-//
-// The below assignment assigns the InterfaceId of the class AnInterface,
-// and declares that the parent iid is that of class Object.
-//
-const InterfaceId AnInterface::iid = MakeInterfaceId ("AnInterface", Object::iid);
-
-//
-// AnImplementation is an implementation of the abstract base class
-// defined above. It provides implementation for the virtual functions 
-// in the base class.  It defines one ClassId for each constructor, 
-// and can also provide an interface itself (in this example, 
-// a methodImpl is available)
-// 
-class AnImplementation : public AnInterface
-{
-public:
-  static const InterfaceId iid;
-  static const ClassId cid;
-
-  AnImplementation ();
-  void methodImpl (void);
-private:
-  virtual void domethodA (void);
-};
-
-void
-AnImplementation::methodImpl (void)
-{
-  NS_LOG_FUNCTION;
-}
-
-
-AnImplementation::AnImplementation (void)
-{
-  NS_LOG_FUNCTION;
-}
-
-void
-AnImplementation::domethodA () 
-{
-  NS_LOG_FUNCTION;
-}
-
-//
-// The below assignment assigns the InterfaceId of the class AnImplementation,
-// and declares that the parent iid is that of class Object.
-//
-const InterfaceId AnImplementation::iid = 
-  MakeInterfaceId ("AnImplementation", AnInterface::iid);
-
-//
-// The next few lines are used by the component manager.  They
-// state that the component manager can create a new object 
-// AnImplementation and return an interface corresponding to 
-// the AnImplementation iid.
-//
-const ClassId AnImplementation::cid = 
-  MakeClassId<AnImplementation> 
-  ("AnImplementation", AnImplementation::iid);
-
-
-//
-// Extending interfaces
-// ==================
-// What if AnInterface doesn't provide enough API for your
-// object type?
-// - if you aren't concerned about backward compatibility and
-//   don't mind recompiling, you just add new methods to AnInterface
-//   and recompile.
-// - if you want to address backward compatibiliy, or allow part
-//   of the system to use the old interface, you have to do more.
-//   You have to declare a new interface with the new functionality.
-//
-
-class AnExtendedInterface : public AnInterface
-{
-public:
-  static const InterfaceId iid;
-  void methodB (void);
-private:
-  virtual void domethodB (void) = 0;
-};
-
-const InterfaceId AnExtendedInterface::iid = 
-  MakeInterfaceId ("AnExtendedInterface", AnInterface::iid);
-
-//
-// Then you need provide an implementation for the virtual 
-// methods.  If you are providing a new implementation for 
-// everything, the answer is straightforward
-//
-
-class ANewImplementation : public AnExtendedInterface
-{
-public:
-  static const InterfaceId iid;
-  static const ClassId cid;
-
-  ANewImplementation ();
-  void methodImpl (void);
-private:
-  virtual void domethodA (void) { /* new-implementation-behavior ();  */}
-  virtual void domethodB (void) { /* new-implementation-behavior (); */}
-};
-
-ANewImplementation::ANewImplementation (void)
-{
-  // enable our interface
-  SetInterfaceId (ANewImplementation::iid);
-}
-
-void
-ANewImplementation::methodImpl (void)
-{
-  NS_LOG_FUNCTION;
-}
-
-const InterfaceId ANewImplementation::iid = 
-  MakeInterfaceId ("ANewImplementation", AnExtendedInterface::iid);
-
-//
-// If you want to extend an existing implementation, you can use 
-// the existing class to instantiate an implementation of its 
-// methods (hasa) and do the following if you can use stuff from 
-// the existing class.
-//
-
-class AnExtendedImplementation : public AnExtendedInterface
-{
-public:
-  static const InterfaceId iid;
-  static const ClassId cid;
-
-  AnExtendedImplementation ();
-  void methodImpl (void) { /* pImpl->methodImpl (); */ }
-  void methodExtendedImpl (void);
-private:
-  virtual void domethodA (void) { /* new-implementation-behavior (); */}
-  virtual void domethodB (void) { /* new-implementation-behavior (); */}
-  Ptr<AnImplementation> pImpl;
-};
-
-AnExtendedImplementation::AnExtendedImplementation (void)
-{
-  pImpl = CreateObject<AnImplementation> (); 
-  SetInterfaceId (AnExtendedImplementation::iid);
-}
-
-void
-AnExtendedImplementation::methodExtendedImpl (void)
-{
-  NS_LOG_FUNCTION;
-}
-
-const InterfaceId AnExtendedImplementation::iid = 
-  MakeInterfaceId ("AnExtendedImplementation", AnExtendedInterface::iid);
-
-//
-// Inheriting from an existing implementation (isa) and an extended
-// interface is tricky, because of the diamond multiple inheritance
-// problem.  If the pImpl method above is not desirable, it may
-// be that the implementation extension could be aggregated.
-// 
-// The extension will not have access to the base implementation,
-// so this design pattern may be more appropriate if the extension
-// is very modular (e.g., add an EnergyModel to a wireless interface)
-//
-// EXAMPLE NOT YET PROVIDED
-
-int main (int argc, char *argv[])
-{
-
-  Ptr<AnInterface> aBase = ComponentManager::Create<AnImplementation> 
-    (AnImplementation::cid, AnInterface::iid);
-  NS_ASSERT (aBase != 0);
-
-  aBase->methodA ();
-  //aBase->methodImpl (); // XXX won't compile, aBase not right ptr type
-  
-  Ptr<AnImplementation> aBaseImplPtr = 
-    aBase-> QueryInterface<AnImplementation> (AnImplementation::iid);
-  aBaseImplPtr->methodImpl ();
-  aBaseImplPtr->methodA();
-
-  // Test symmetric property of QueryInterface 
-  Ptr<AnInterface> aBase2 = 
-    aBaseImplPtr-> QueryInterface<AnInterface> (AnInterface::iid);
-  aBase2->methodA ();
-
-  return 0;
-}
--- a/src/common/error-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/common/error-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -34,10 +34,14 @@
 namespace ns3 {
 
 static ClassIdDefaultValue g_classIdErrorModelDefaultValue ("ErrorModel",
-  "Error Model", ErrorModel::iid, "RateErrorModel");
+                                                            "Error Model", ErrorModel::iid (), 
+                                                            "RateErrorModel");
 
-const InterfaceId ErrorModel::iid = 
-  MakeInterfaceId ("ErrorModel", Object::iid);
+InterfaceId ErrorModel::iid (void)
+{ 
+  static InterfaceId iid = MakeInterfaceId ("ErrorModel", Object::iid ());
+  return iid;
+}
 
 ErrorModel::ErrorModel () :
   m_enable (true) 
@@ -55,8 +59,7 @@
 { 
   NS_LOG_FUNCTION;
   ClassId classId = g_classIdErrorModelDefaultValue.GetValue ();
-  Ptr<ErrorModel> em = ComponentManager::Create<ErrorModel> (classId, 
-    ErrorModel::iid);
+  Ptr<ErrorModel> em = ComponentManager::Create<ErrorModel> (classId);
   return em;
 }
 
@@ -103,12 +106,10 @@
 // RateErrorModel
 //
 
-const InterfaceId RateErrorModel::iid = 
-  MakeInterfaceId ("RateErrorModel", ErrorModel::iid);
 
 const ClassId RateErrorModel::cid =
-  MakeClassId<RateErrorModel> ("RateErrorModel", ErrorModel::iid,
-  RateErrorModel::iid);
+  MakeClassId<RateErrorModel> ("RateErrorModel", ErrorModel::iid (),
+                               RateErrorModel::iid ());
 
 // Defaults for rate/size
 static NumericDefaultValue<double> g_defaultRateErrorModelErrorRate
@@ -122,6 +123,13 @@
     EU_BIT, "EU_BIT", 
     0, (void*)0);
 
+InterfaceId RateErrorModel::iid (void)
+{ 
+  static InterfaceId iid = MakeInterfaceId ("RateErrorModel", ErrorModel::iid ());
+  return iid;
+}
+
+
 RateErrorModel::RateErrorModel () : 
   m_unit (g_defaultRateErrorModelErrorUnit.GetValue() ),
   m_rate (g_defaultRateErrorModelErrorRate.GetValue() )
@@ -232,12 +240,15 @@
 // ListErrorModel
 //
 
-const InterfaceId ListErrorModel::iid = 
-  MakeInterfaceId ("ListErrorModel", ErrorModel::iid);
+const ClassId ListErrorModel::cid =
+  MakeClassId<ListErrorModel> ("ListErrorModel", ErrorModel::iid (),
+                               ListErrorModel::iid ());
 
-const ClassId ListErrorModel::cid =
-  MakeClassId<ListErrorModel> ("ListErrorModel", ErrorModel::iid,
-  ListErrorModel::iid);
+InterfaceId ListErrorModel::iid (void)
+{ 
+  static InterfaceId iid = MakeInterfaceId ("ListErrorModel", ErrorModel::iid ());
+  return iid;
+}
 
 ListErrorModel::ListErrorModel ()  
 {
--- a/src/common/error-model.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/common/error-model.h	Wed Jan 02 10:33:39 2008 +0100
@@ -67,7 +67,7 @@
 class ErrorModel : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   /**
    * A factory method to generate a preconfigured default ErrorModel for use
    * \return an ErrorModel smart pointer that is the default ErrorModel 
@@ -137,7 +137,7 @@
 class RateErrorModel : public ErrorModel
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   static const ClassId cid;
 
   RateErrorModel ();
@@ -204,7 +204,7 @@
 class ListErrorModel : public ErrorModel
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   static const ClassId cid;
   ListErrorModel ();
   virtual ~ListErrorModel ();
--- a/src/core/component-manager.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/core/component-manager.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -100,10 +100,10 @@
   List *list = Singleton<List>::Get ();
   for (List::const_iterator i = list->begin (); i != list->end (); i++)
     {
-      for (std::vector<const InterfaceId *>::const_iterator j = i->m_supportedInterfaces.begin ();
+      for (std::vector<InterfaceId>::const_iterator j = i->m_supportedInterfaces.begin ();
            j != i->m_supportedInterfaces.end (); j++)
         {
-          if (*(*j) == iid)
+          if (*j == iid)
             {
               classIdList.push_back (i->m_classId);
               break;
@@ -116,30 +116,30 @@
 
 void
 ComponentManager::Register (ClassId classId, CallbackBase *callback, 
-                            std::vector<const InterfaceId *> supportedInterfaces)
+                            std::vector<InterfaceId> supportedInterfaces)
 {
   List *list = Singleton<List>::Get ();
   struct ClassIdEntry entry = ClassIdEntry (classId);
   entry.m_callback = callback;
   bool foundObject = false;
-  for (std::vector<const InterfaceId *>::iterator i = supportedInterfaces.begin ();
+  for (std::vector<InterfaceId>::iterator i = supportedInterfaces.begin ();
        i != supportedInterfaces.end (); i++)
     {
-      if (*i == &Object::iid)
+      if (*i == Object::iid ())
         {
           foundObject = true;
         }
     }
   if (!foundObject)
     {
-      supportedInterfaces.push_back (&Object::iid);
+      supportedInterfaces.push_back (Object::iid ());
     }
   entry.m_supportedInterfaces = supportedInterfaces;
   list->push_back (entry);
 }
 
 void
-RegisterCallback (ClassId classId, CallbackBase *callback, std::vector<const InterfaceId *> supportedInterfaces)
+RegisterCallback (ClassId classId, CallbackBase *callback, std::vector<InterfaceId> supportedInterfaces)
 {
   return ComponentManager::Register (classId, callback, supportedInterfaces);
 }
@@ -147,12 +147,12 @@
 
 ClassIdDefaultValue::ClassIdDefaultValue (std::string name, 
                                           std::string help,
-                                          const InterfaceId &iid,
+                                          InterfaceId iid,
                                           std::string defaultValue)
   : DefaultValueBase (name, help),
     m_defaultName (defaultValue),
     m_name (defaultValue),
-    m_interfaceId (&iid)
+    m_interfaceId (iid)
 {
   DefaultValueList::Add (this);
 }
@@ -180,7 +180,7 @@
     {
       return false;
     }
-  std::vector<ClassId> classIdList = ComponentManager::LookupByInterfaceId (*m_interfaceId);
+  std::vector<ClassId> classIdList = ComponentManager::LookupByInterfaceId (m_interfaceId);
   for (std::vector<ClassId>::const_iterator i = classIdList.begin ();
        i != classIdList.end (); i++)
     {
@@ -196,7 +196,7 @@
 std::string 
 ClassIdDefaultValue::DoGetType (void) const
 {
-  std::vector<ClassId> classIdList = ComponentManager::LookupByInterfaceId (*m_interfaceId);
+  std::vector<ClassId> classIdList = ComponentManager::LookupByInterfaceId (m_interfaceId);
   std::ostringstream oss;
   oss << "(";
   for (std::vector<ClassId>::const_iterator i = classIdList.begin ();
@@ -234,12 +234,14 @@
 class B : public ns3::Object
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("B", Object::iid ());
+    return iid;
+  }
+
   B ();
 };
 
-const ns3::InterfaceId B::iid = MakeInterfaceId ("B", Object::iid);
-
 B::B ()
 {}
 
@@ -251,7 +253,11 @@
   static const ns3::ClassId cidOneBool;
   static const ns3::ClassId cidOneUi32;
   static const ns3::ClassId cidOther;
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("A", Object::iid ());
+    return iid;
+  }
+
 
   A ();
   A (bool);
@@ -265,10 +271,9 @@
   int m_ui32;
 };
 
-const ns3::ClassId A::cidZero = ns3::MakeClassId<A> ("A", A::iid);
-const ns3::ClassId A::cidOneBool = ns3::MakeClassId <A,bool> ("ABool", A::iid);
-const ns3::ClassId A::cidOneUi32 = ns3::MakeClassId <A,uint32_t> ("AUi32", A::iid);
-const ns3::InterfaceId A::iid = ns3::MakeInterfaceId ("A", Object::iid);
+const ns3::ClassId A::cidZero = ns3::MakeClassId<A> ("A", A::iid ());
+const ns3::ClassId A::cidOneBool = ns3::MakeClassId <A,bool> ("ABool", A::iid ());
+const ns3::ClassId A::cidOneUi32 = ns3::MakeClassId <A,uint32_t> ("AUi32", A::iid ());
 
 A::A ()
   : m_zeroInvoked (true),
@@ -302,24 +307,31 @@
 class X : public A
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("X", A::iid ());
+    return iid;
+  }
+
 };
 class C : public X
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("C", X::iid ());
+    return iid;
+  }
 };
 class D : public C
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("D", C::iid ());
+    return iid;
+  }
   static const ns3::ClassId cid;
 };
 
-const ns3::InterfaceId X::iid = ns3::MakeInterfaceId ("X", A::iid);
-const ns3::InterfaceId C::iid = ns3::MakeInterfaceId ("C", X::iid);
-const ns3::InterfaceId D::iid = ns3::MakeInterfaceId ("D", C::iid);
-const ns3::ClassId D::cid = ns3::MakeClassId<D> ("D", A::iid, X::iid, C::iid, D::iid);
+const ns3::ClassId D::cid = ns3::MakeClassId<D> ("D", A::iid (), X::iid (), C::iid (), D::iid ());
 
 }
 
--- a/src/core/component-manager.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/core/component-manager.h	Wed Jan 02 10:33:39 2008 +0100
@@ -91,7 +91,7 @@
    * as a supported interface.
    */
   MakeClassId (std::string name, 
-               const InterfaceId &iid);
+               InterfaceId iid);
   /**
    * \param name name of ClassId
    * \param iid0 interface id
@@ -101,8 +101,8 @@
    * as supported interfaces.
    */
   MakeClassId (std::string name, 
-               const InterfaceId &iid0, 
-               const InterfaceId iid1);
+               InterfaceId iid0, 
+               InterfaceId iid1);
   /**
    * \param name name of ClassId
    * \param iid0 interface id
@@ -113,9 +113,9 @@
    * and iid2 as supported interfaces.
    */
   MakeClassId (std::string name, 
-               const InterfaceId &iid0, 
-               const InterfaceId &iid1,
-               const InterfaceId &iid2);
+               InterfaceId iid0, 
+               InterfaceId iid1,
+               InterfaceId iid2);
   /**
    * \param name name of ClassId
    * \param iid0 interface id
@@ -127,10 +127,10 @@
    * iid2, and iid3 as supported interfaces.
    */
   MakeClassId (std::string name, 
-               const InterfaceId &iid0, 
-               const InterfaceId &iid1,
-               const InterfaceId &iid2,
-               const InterfaceId &iid3);
+               InterfaceId iid0, 
+               InterfaceId iid1,
+               InterfaceId iid2,
+               InterfaceId iid3);
   /**
    * \param name name of ClassId
    * \param iid0 interface id
@@ -143,15 +143,15 @@
    * iid2, iid3, and iid4 as supported interfaces.
    */
   MakeClassId (std::string name, 
-               const InterfaceId &iid0, 
-               const InterfaceId &iid1,
-               const InterfaceId &iid2,
-               const InterfaceId &iid3,
-               const InterfaceId &iid4);
+               InterfaceId iid0, 
+               InterfaceId iid1,
+               InterfaceId iid2,
+               InterfaceId iid3,
+               InterfaceId iid4);
 private:
   typedef ObjectMaker<T,T1,T2,T3,T4,T5> MakerType;
   static Callback<Ptr<Object>,T1,T2,T3,T4,T5> m_callback;
-  void Register (const InterfaceId *array [], uint32_t n);
+  void Register (InterfaceId array [], uint32_t n);
 };
 
 
@@ -345,9 +345,9 @@
 
 private:
   friend void RegisterCallback (ClassId classId, CallbackBase *callback, 
-                                std::vector<const InterfaceId *> supportedInterfaces);
+                                std::vector<InterfaceId> supportedInterfaces);
   static void Register (ClassId classId, CallbackBase *callback, 
-                        std::vector<const InterfaceId *> supportedInterfaces);
+                        std::vector<InterfaceId> supportedInterfaces);
 
   template <typename T1, typename T2,
             typename T3, typename T4,
@@ -358,7 +358,7 @@
     ClassIdEntry (ClassId classId);
     ClassId m_classId;
     CallbackBase *m_callback;
-    std::vector<const InterfaceId *> m_supportedInterfaces;
+    std::vector<InterfaceId> m_supportedInterfaces;
   };
 
   typedef std::vector<struct ClassIdEntry> List;
@@ -386,7 +386,7 @@
    */
   ClassIdDefaultValue (std::string name, 
                        std::string help,
-                       const InterfaceId &iid,
+                       InterfaceId iid,
                        std::string defaultValue);
   /**
    * \returns the ClassId of the object selected by the user.
@@ -410,7 +410,7 @@
   virtual std::string DoGetDefaultValue (void) const;
   std::string m_defaultName;
   std::string m_name;
-  const InterfaceId *m_interfaceId;
+  InterfaceId m_interfaceId;
 };
 
 } // namespace ns3 
@@ -473,16 +473,16 @@
 namespace ns3 {
   
 void RegisterCallback (ClassId classId, ns3::CallbackBase *callback, 
-                       std::vector<const InterfaceId *> supportedInterfaces);
+                       std::vector<InterfaceId> supportedInterfaces);
 
 
 
 template <typename T, typename T1, typename T2,
           typename T3, typename T4, typename T5>
 void 
-MakeClassId<T,T1,T2,T3,T4,T5>::Register (const InterfaceId *array [], uint32_t n) 
+MakeClassId<T,T1,T2,T3,T4,T5>::Register (InterfaceId array [], uint32_t n) 
 {
-  std::vector<const InterfaceId *> supportedInterfaces;
+  std::vector<InterfaceId> supportedInterfaces;
   for (uint32_t i = 0; i < n; i++)
     {
       supportedInterfaces.push_back (array[i]);
@@ -495,63 +495,63 @@
 MakeClassId<T,T1,T2,T3,T4,T5>::MakeClassId (std::string name) 
   : ClassId (name) 
 {
-  const InterfaceId *array[] = {};
-  Register (array, sizeof (array)/sizeof(InterfaceId *));
+  InterfaceId array[] = {};
+  Register (array, sizeof (array)/sizeof(InterfaceId));
 }
 template <typename T, typename T1, typename T2,
           typename T3, typename T4, typename T5>
 MakeClassId<T,T1,T2,T3,T4,T5>::MakeClassId (std::string name, 
-                                   const InterfaceId &iid) 
+                                            InterfaceId iid) 
   : ClassId (name) 
 {
-  const InterfaceId *array[] = {&iid};
-  Register (array, sizeof (array)/sizeof(InterfaceId *));
+  InterfaceId array[] = {iid};
+  Register (array, sizeof (array)/sizeof(InterfaceId));
 }
 template <typename T, typename T1, typename T2,
           typename T3, typename T4, typename T5>
 MakeClassId<T,T1,T2,T3,T4,T5>::MakeClassId (std::string name, 
-                                   const InterfaceId &iid0, 
-                                   const InterfaceId iid1) 
+                                            InterfaceId iid0, 
+                                            InterfaceId iid1) 
   : ClassId (name) 
 {
-  const InterfaceId *array[] = {&iid0, &iid1};
-  Register (array, sizeof (array)/sizeof(InterfaceId *));
+  InterfaceId array[] = {iid0, iid1};
+  Register (array, sizeof (array)/sizeof(InterfaceId));
 }
 template <typename T, typename T1, typename T2,
           typename T3, typename T4, typename T5>
 MakeClassId<T,T1,T2,T3,T4,T5>::MakeClassId (std::string name, 
-                                   const InterfaceId &iid0, 
-                                   const InterfaceId &iid1,
-                                   const InterfaceId &iid2)
+                                            InterfaceId iid0, 
+                                            InterfaceId iid1,
+                                            InterfaceId iid2)
   : ClassId (name) 
 {
-  const InterfaceId *array[] = {&iid0, &iid1, &iid2};
-  Register (array, sizeof (array)/sizeof(InterfaceId *));
+  InterfaceId array[] = {iid0, iid1, iid2};
+  Register (array, sizeof (array)/sizeof(InterfaceId));
 }
 template <typename T, typename T1, typename T2,
           typename T3, typename T4, typename T5>
 MakeClassId<T,T1,T2,T3,T4,T5>::MakeClassId (std::string name, 
-                                   const InterfaceId &iid0, 
-                                   const InterfaceId &iid1,
-                                   const InterfaceId &iid2,
-                                   const InterfaceId &iid3)
+                                            InterfaceId iid0, 
+                                            InterfaceId iid1,
+                                            InterfaceId iid2,
+                                            InterfaceId iid3)
   : ClassId (name) 
 {
-  const InterfaceId *array[] = {&iid0, &iid1, &iid2, &iid3};
-  Register (array, sizeof (array)/sizeof(InterfaceId *));
+  InterfaceId array[] = {iid0, iid1, iid2, iid3};
+  Register (array, sizeof (array)/sizeof(InterfaceId));
 }
 template <typename T, typename T1, typename T2,
           typename T3, typename T4, typename T5>
 MakeClassId<T,T1,T2,T3,T4,T5>::MakeClassId (std::string name, 
-                                   const InterfaceId &iid0, 
-                                   const InterfaceId &iid1,
-                                   const InterfaceId &iid2,
-                                   const InterfaceId &iid3,
-                                   const InterfaceId &iid4)
+                                            InterfaceId iid0, 
+                                            InterfaceId iid1,
+                                            InterfaceId iid2,
+                                            InterfaceId iid3,
+                                            InterfaceId iid4)
   : ClassId (name) 
 {
-  const InterfaceId *array[] = {&iid0, &iid1, iid2, &iid3, &iid4};
-  Register (array, sizeof (array)/sizeof(InterfaceId *));
+  InterfaceId array[] = {iid0, iid1, iid2, iid3, iid4};
+  Register (array, sizeof (array)/sizeof(InterfaceId));
 }
 
 template <typename T, typename T1, typename T2,
--- a/src/core/object.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/core/object.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -175,12 +175,17 @@
 }
 
 
-const InterfaceId Object::iid = MakeObjectInterfaceId ();
+InterfaceId 
+Object::iid (void)
+{
+  static InterfaceId iid = MakeObjectInterfaceId ();
+  return iid;
+}
 
 
 Object::Object ()
   : m_count (1),
-    m_iid (Object::iid),
+    m_iid (Object::iid ()),
     m_disposed (false),
     m_collecting (false),
     m_next (this)
@@ -197,7 +202,7 @@
   do {
     NS_ASSERT (currentObject != 0);
     InterfaceId cur = currentObject->m_iid;
-    while (cur != iid && cur != Object::iid)
+    while (cur != iid && cur != Object::iid ())
       {
         cur = InterfaceId::LookupParent (cur);
       }
@@ -349,7 +354,7 @@
       NS_ASSERT (current != 0);
       NS_LOG_LOGIC ("collect current=" << current);
       InterfaceId cur = current->m_iid;
-      while (cur != Object::iid)
+      while (cur != Object::iid ())
         {
           std::string name = cur.GetName ();
           std::string fullpath = path;
@@ -404,7 +409,10 @@
 class BaseA : public ns3::Object
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("BaseA", Object::iid ());
+    return iid;
+  }
   BaseA ()
   {}
   void BaseGenerateTrace (int16_t v)
@@ -424,7 +432,10 @@
 class DerivedA : public BaseA
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("DerivedA", BaseA::iid ());
+    return iid;
+  }
   DerivedA (int v)
   {}
   void DerivedGenerateTrace (int16_t v)
@@ -443,15 +454,13 @@
   ns3::SVTraceSource<int16_t> m_sourceDerived;
 };
 
-const ns3::InterfaceId BaseA::iid = 
-  ns3::MakeInterfaceId ("BaseA", Object::iid);
-const ns3::InterfaceId DerivedA::iid = 
-  ns3::MakeInterfaceId ("DerivedA", BaseA::iid);;
-
 class BaseB : public ns3::Object
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("BaseB", Object::iid ());
+    return iid;
+  }
   BaseB ()
   {}
   void BaseGenerateTrace (int16_t v)
@@ -471,7 +480,10 @@
 class DerivedB : public BaseB
 {
 public:
-  static const ns3::InterfaceId iid;
+  static ns3::InterfaceId iid (void) {
+    static ns3::InterfaceId iid = ns3::MakeInterfaceId ("DerivedB", BaseB::iid ());
+    return iid;
+  }
   DerivedB (int v)
   {}
   void DerivedGenerateTrace (int16_t v)
@@ -490,11 +502,6 @@
   ns3::SVTraceSource<int16_t> m_sourceDerived;
 };
 
-const ns3::InterfaceId BaseB::iid = 
-  ns3::MakeInterfaceId ("BaseB", Object::iid);
-const ns3::InterfaceId DerivedB::iid = 
-  ns3::MakeInterfaceId ("DerivedB", BaseB::iid);;
-
 } // namespace anonymous
 
 namespace ns3 {
@@ -547,11 +554,11 @@
 
   Ptr<BaseA> baseA = CreateObject<BaseA> ();
   NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (), baseA);
-  NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid), 0);
+  NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid ()), 0);
   NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<DerivedA> (), 0);
   baseA = CreateObject<DerivedA> (10);
   NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (), baseA);
-  NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid), baseA);
+  NS_TEST_ASSERT_EQUAL (baseA->QueryInterface<BaseA> (DerivedA::iid ()), baseA);
   NS_TEST_ASSERT_UNEQUAL (baseA->QueryInterface<DerivedA> (), 0);
 
   baseA = CreateObject<BaseA> ();
--- a/src/core/object.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/core/object.h	Wed Jan 02 10:33:39 2008 +0100
@@ -98,7 +98,7 @@
 class Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   Object ();
   virtual ~Object ();
@@ -265,7 +265,7 @@
 Ptr<T> 
 Object::QueryInterface () const
 {
-  Ptr<Object> found = DoQueryInterface (T::iid);
+  Ptr<Object> found = DoQueryInterface (T::iid ());
   if (found != 0)
     {
       return Ptr<T> (dynamic_cast<T *> (PeekPointer (found)));
@@ -289,7 +289,7 @@
 Ptr<T> CreateObject (void)
 {
   Ptr<T> p = Ptr<T> (new T (), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -297,7 +297,7 @@
 Ptr<T> CreateObject (T1 a1)
 {
   Ptr<T> p = Ptr<T> (new T (a1), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -305,7 +305,7 @@
 Ptr<T> CreateObject (T1 a1, T2 a2)
 {
   Ptr<T> p = Ptr<T> (new T (a1, a2), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -313,7 +313,7 @@
 Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3)
 {
   Ptr<T> p = Ptr<T> (new T (a1, a2, a3), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -321,7 +321,7 @@
 Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4)
 {
   Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -329,7 +329,7 @@
 Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
 {
   Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4, a5), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -337,7 +337,7 @@
 Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
 {
   Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4, a5, a6), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
@@ -345,7 +345,7 @@
 Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7)
 {
   Ptr<T> p = Ptr<T> (new T (a1, a2, a3, a4, a5, a6, a7), false);
-  p->SetInterfaceId (T::iid);
+  p->SetInterfaceId (T::iid ());
   return p;
 }
 
--- a/src/internet-node/arp-l3-protocol.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/internet-node/arp-l3-protocol.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -33,9 +33,15 @@
 
 namespace ns3 {
 
-const InterfaceId ArpL3Protocol::iid = MakeInterfaceId ("ArpL3Protocol", Object::iid);
 const uint16_t ArpL3Protocol::PROT_NUMBER = 0x0806;
 
+InterfaceId 
+ArpL3Protocol::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("ArpL3Protocol", Object::iid ());
+  return iid;
+}
+
 ArpL3Protocol::ArpL3Protocol (Ptr<Node> node)
   : m_node (node)
 {
--- a/src/internet-node/arp-l3-protocol.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/internet-node/arp-l3-protocol.h	Wed Jan 02 10:33:39 2008 +0100
@@ -40,7 +40,7 @@
 class ArpL3Protocol : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   static const uint16_t PROT_NUMBER;
   /**
    * \brief Constructor
--- a/src/internet-node/ipv4-l3-protocol.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/internet-node/ipv4-l3-protocol.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -40,9 +40,15 @@
 
 namespace ns3 {
 
-const InterfaceId Ipv4L3Protocol::iid = MakeInterfaceId ("Ipv4L3Protocol", Object::iid);
 const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800;
 
+InterfaceId 
+Ipv4L3Protocol::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Ipv4L3Protocol", Object::iid ());
+  return iid;
+}
+
 Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement ()
   : m_type (TX)
 {
--- a/src/internet-node/ipv4-l3-protocol.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/internet-node/ipv4-l3-protocol.h	Wed Jan 02 10:33:39 2008 +0100
@@ -99,7 +99,7 @@
 class Ipv4L3Protocol : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   static const uint16_t PROT_NUMBER;
 
   Ipv4L3Protocol(Ptr<Node> node);
--- a/src/internet-node/ipv4-l4-demux.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/internet-node/ipv4-l4-demux.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -30,8 +30,6 @@
 
 namespace ns3 {
 
-const InterfaceId Ipv4L4Demux::iid = MakeInterfaceId ("Ipv4L4Demux", Object::iid);
-
 Ipv4L4ProtocolTraceContextElement::Ipv4L4ProtocolTraceContextElement ()
   : m_protocolNumber (0)
 {}
@@ -60,6 +58,12 @@
   return "ns3::Ipv4L4ProtocolTraceContextElement";
 }
 
+InterfaceId 
+Ipv4L4Demux::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Ipv4L4Demux", Object::iid ());
+  return iid;
+}
 
 Ipv4L4Demux::Ipv4L4Demux (Ptr<Node> node)
   : m_node (node)
--- a/src/internet-node/ipv4-l4-demux.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/internet-node/ipv4-l4-demux.h	Wed Jan 02 10:33:39 2008 +0100
@@ -62,7 +62,7 @@
 class Ipv4L4Demux : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   Ipv4L4Demux (Ptr<Node> node);
   virtual ~Ipv4L4Demux();
 
--- a/src/mobility/grid-topology.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/grid-topology.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -43,8 +43,7 @@
   double x, y;
   x = m_xMin + m_deltaX * (i % m_n);
   y = m_yMin + m_deltaY * (i / m_n);
-  Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_positionClassId,
-                                                                         MobilityModel::iid);
+  Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_positionClassId);
   object->AddInterface (mobility);
   mobility->SetPosition (Vector (x, y, 0.0));
 }
@@ -55,8 +54,7 @@
   double x, y;
   x = m_xMin + m_deltaX * (i / m_n);
   y = m_yMin + m_deltaY * (i % m_n);
-  Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_positionClassId, 
-                                                                         MobilityModel::iid);
+  Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_positionClassId);
   object->AddInterface (mobility);
   mobility->SetPosition (Vector (x, y, 0.0));
 }
--- a/src/mobility/hierarchical-mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/hierarchical-mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -22,6 +22,13 @@
 
 namespace ns3 {
 
+InterfaceId 
+HierarchicalMobilityModel::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("HierarchicalMobilityModel", MobilityModel::iid ());
+  return iid;
+}
+
 HierarchicalMobilityModel::HierarchicalMobilityModel (Ptr<MobilityModel> child, Ptr<MobilityModel> parent)
   : m_child (child),
     m_parent (parent)
--- a/src/mobility/hierarchical-mobility-model.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/hierarchical-mobility-model.h	Wed Jan 02 10:33:39 2008 +0100
@@ -33,7 +33,7 @@
 class HierarchicalMobilityModel : public MobilityModel
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   /**
    * \param child the "relative" mobility model
--- a/src/mobility/mobility-model-notifier.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/mobility-model-notifier.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -23,10 +23,15 @@
 
 namespace ns3 {
 
-const InterfaceId MobilityModelNotifier::iid = MakeInterfaceId ("MobilityModelNotifier", Object::iid);
 const ClassId MobilityModelNotifier::cid = 
   MakeClassId<MobilityModelNotifier> ("MobilityModelNotifier", 
-				    MobilityModelNotifier::iid);
+                                      MobilityModelNotifier::iid ());
+InterfaceId 
+MobilityModelNotifier::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("MobilityModelNotifier", Object::iid ());
+  return iid;
+}
 
 MobilityModelNotifier::MobilityModelNotifier ()
 {}
--- a/src/mobility/mobility-model-notifier.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/mobility-model-notifier.h	Wed Jan 02 10:33:39 2008 +0100
@@ -34,8 +34,8 @@
 class MobilityModelNotifier : public Object
 {
 public:
-  static const InterfaceId iid;
   static const ClassId cid;
+  static InterfaceId iid (void);
 
   /**
    * Create a new position notifier
--- a/src/mobility/mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -23,7 +23,12 @@
 
 namespace ns3 {
 
-const InterfaceId MobilityModel::iid = MakeInterfaceId ("MobilityModel", Object::iid);
+InterfaceId 
+MobilityModel::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("MobilityModel", Object::iid ());
+  return iid;
+}
 
 MobilityModel::MobilityModel ()
 {}
--- a/src/mobility/mobility-model.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/mobility-model.h	Wed Jan 02 10:33:39 2008 +0100
@@ -35,7 +35,7 @@
 class MobilityModel : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   MobilityModel ();
   virtual ~MobilityModel () = 0;
 
--- a/src/mobility/random-direction-2d-mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/random-direction-2d-mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -33,7 +33,7 @@
 const double RandomDirection2dMobilityModel::PI = 3.14159265358979323846;
 const ClassId RandomDirection2dMobilityModel::cid = 
   MakeClassId<RandomDirection2dMobilityModel> ("RandomDirection2dMobilityModel",
-                                               MobilityModel::iid);
+                                               MobilityModel::iid ());
 
 
 static RandomVariableDefaultValue 
--- a/src/mobility/random-position.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/random-position.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -58,14 +58,19 @@
 	 "The y coordinate of the center of the random position disc.",
 	 0.0);
 
-const InterfaceId RandomPosition::iid = MakeInterfaceId ("RandomPosition", Object::iid);
+InterfaceId 
+RandomPosition::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("RandomPosition", Object::iid ());
+  return iid;
+}
 
 const ClassId RandomRectanglePosition::cid = 
   MakeClassId<RandomRectanglePosition> ("RandomRectanglePosition", 
-					RandomPosition::iid);
+					RandomPosition::iid ());
 const ClassId RandomDiscPosition::cid = 
   MakeClassId<RandomDiscPosition> ("RandomDiscPosition", 
-				   RandomPosition::iid);
+				   RandomPosition::iid ());
 
 RandomPosition::RandomPosition ()
 {
--- a/src/mobility/random-position.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/random-position.h	Wed Jan 02 10:33:39 2008 +0100
@@ -36,7 +36,7 @@
 class RandomPosition : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   RandomPosition ();
   virtual ~RandomPosition ();
   /**
--- a/src/mobility/random-topology.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/random-topology.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -28,20 +28,19 @@
 static ClassIdDefaultValue
 g_position ("RandomTopologyPositionType",
             "The type of initial random position in a 3d topology.",
-            RandomPosition::iid,
+            RandomPosition::iid (),
             "RandomRectanglePosition");
 
 static ClassIdDefaultValue
 g_mobility ("RandomTopologyMobilityType",
             "The type of mobility model attached to an object in a 3d topology.",
-            MobilityModel::iid,
+            MobilityModel::iid (),
             "StaticMobilityModel");
 
 RandomTopology::RandomTopology ()
   : m_mobilityModel (g_mobility.GetValue ())
 {
-  m_positionModel = ComponentManager::Create<RandomPosition> (g_position.GetValue (), 
-                                                              RandomPosition::iid);
+  m_positionModel = ComponentManager::Create<RandomPosition> (g_position.GetValue ());
 }
 RandomTopology::RandomTopology (Ptr<RandomPosition> positionModel, ClassId mobilityModel)
   : m_positionModel (positionModel),
@@ -67,8 +66,7 @@
 void 
 RandomTopology::LayoutOne (Ptr<Object> object)
 {
-  Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_mobilityModel, 
-                                                                         MobilityModel::iid);
+  Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_mobilityModel);
   object->AddInterface (mobility);
   Vector position = m_positionModel->Get ();
   mobility->SetPosition (position);
--- a/src/mobility/random-walk-2d-mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/random-walk-2d-mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -32,7 +32,7 @@
 namespace ns3 {
 
 const ClassId RandomWalk2dMobilityModel::cid = 
-  MakeClassId<RandomWalk2dMobilityModel> ("RandomWalk2dMobilityModel", RandomWalk2dMobilityModel::iid);
+  MakeClassId<RandomWalk2dMobilityModel> ("RandomWalk2dMobilityModel", RandomWalk2dMobilityModel::iid ());
 
 
 static EnumDefaultValue<RandomWalk2dMobilityModelParameters::Mode> 
--- a/src/mobility/random-waypoint-mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/random-waypoint-mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -40,18 +40,17 @@
 static ClassIdDefaultValue
 g_position ("RandomWaypointPosition",
 	    "A random position model used to pick the next waypoint position.",
-	    RandomPosition::iid,
+	    RandomPosition::iid (),
 	    "RandomRectanglePosition");
 
 const ClassId RandomWaypointMobilityModel::cid = 
-  MakeClassId<RandomWaypointMobilityModel> ("RandomWaypointMobilityModel", MobilityModel::iid);
+  MakeClassId<RandomWaypointMobilityModel> ("RandomWaypointMobilityModel", MobilityModel::iid ());
 
 RandomWaypointMobilityModelParameters::RandomWaypointMobilityModelParameters ()
   : m_speed (g_speed.GetCopy ()),
     m_pause (g_pause.GetCopy ())
 {
-  m_position = ComponentManager::Create<RandomPosition> (g_position.GetValue (), 
-							 RandomPosition::iid);
+  m_position = ComponentManager::Create<RandomPosition> (g_position.GetValue ());
 }
 RandomWaypointMobilityModelParameters::RandomWaypointMobilityModelParameters (Ptr<RandomPosition> randomPosition,
 									      const RandomVariable &speed,
--- a/src/mobility/static-mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/static-mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -22,7 +22,7 @@
 namespace ns3 {
 
 const ClassId StaticMobilityModel::cid = MakeClassId<StaticMobilityModel> ("StaticMobilityModel", 
-                                                                           MobilityModel::iid);
+                                                                           MobilityModel::iid ());
   
 StaticMobilityModel::StaticMobilityModel ()
 {}
--- a/src/mobility/static-speed-mobility-model.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/static-speed-mobility-model.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -22,12 +22,14 @@
 
 namespace ns3 {
 
-const InterfaceId StaticSpeedMobilityModel::iid = 
-  MakeInterfaceId ("StaticSpeedMobilityModel", MobilityModel::iid);
 const ClassId StaticSpeedMobilityModel::cid = 
   MakeClassId<StaticSpeedMobilityModel> ("StaticSpeedMobilityModel", 
-                                         StaticSpeedMobilityModel::iid);
-
+                                         StaticSpeedMobilityModel::iid ());
+InterfaceId StaticSpeedMobilityModel::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("StaticSpeedMobilityModel", MobilityModel::iid ());
+  return iid;
+}
 
 StaticSpeedMobilityModel::StaticSpeedMobilityModel ()
 {}
--- a/src/mobility/static-speed-mobility-model.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/mobility/static-speed-mobility-model.h	Wed Jan 02 10:33:39 2008 +0100
@@ -36,8 +36,8 @@
 class StaticSpeedMobilityModel : public MobilityModel 
 {
 public:
-  static const InterfaceId iid;
   static const ClassId cid;
+  static InterfaceId iid (void);
   /**
    * Create position located at coordinates (0,0,0) with
    * speed (0,0,0).
--- a/src/node/channel.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/channel.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -24,7 +24,12 @@
 
 namespace ns3 {
 
-const InterfaceId Channel::iid = MakeInterfaceId ("Channel", Object::iid);
+InterfaceId 
+Channel::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Channel", Object::iid ());
+  return iid;
+}
 
 Channel::Channel ()
   : m_name("Channel")
--- a/src/node/channel.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/channel.h	Wed Jan 02 10:33:39 2008 +0100
@@ -35,7 +35,7 @@
 class Channel : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   Channel ();
   Channel (std::string name);
--- a/src/node/drop-tail-queue.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/drop-tail-queue.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -25,7 +25,7 @@
 namespace ns3 {
 
 const ClassId DropTailQueue::cid = 
-  MakeClassId<DropTailQueue> ("DropTailQueue", Queue::iid);
+  MakeClassId<DropTailQueue> ("DropTailQueue", Queue::iid ());
 
 
 DropTailQueue::DropTailQueue () :
--- a/src/node/ipv4.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/ipv4.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -25,7 +25,12 @@
 
 namespace ns3 {
 
-const InterfaceId Ipv4::iid = MakeInterfaceId ("Ipv4", Object::iid);
+InterfaceId 
+Ipv4::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Ipv4", Object::iid ());
+  return iid;
+}
 
 Ipv4::Ipv4 ()
 {}
--- a/src/node/ipv4.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/ipv4.h	Wed Jan 02 10:33:39 2008 +0100
@@ -157,7 +157,7 @@
 class Ipv4 : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   Ipv4 ();
   virtual ~Ipv4 ();
 
--- a/src/node/net-device.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/net-device.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -33,7 +33,11 @@
 
 namespace ns3 {
 
-const InterfaceId NetDevice::iid = MakeInterfaceId ("NetDevice", Object::iid);
+InterfaceId NetDevice::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("NetDevice", Object::iid ());
+  return iid;
+}
 
 NetDevice::NetDevice(Ptr<Node> node, const Address& addr) : 
   m_node (node), 
--- a/src/node/net-device.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/net-device.h	Wed Jan 02 10:33:39 2008 +0100
@@ -60,7 +60,7 @@
 class NetDevice : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   virtual ~NetDevice();
 
 
--- a/src/node/node.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/node.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -29,7 +29,12 @@
 
 namespace ns3{
 
-const InterfaceId Node::iid = MakeInterfaceId ("Node", Object::iid);
+InterfaceId 
+Node::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Node", Object::iid ());
+  return iid;
+}
 
 NodeNetDeviceIndex::NodeNetDeviceIndex ()
   : m_index (0)
--- a/src/node/node.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/node.h	Wed Jan 02 10:33:39 2008 +0100
@@ -96,7 +96,7 @@
 class Node : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   /**
    * Must be invoked by subclasses only.
--- a/src/node/packet-socket-factory.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/packet-socket-factory.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -24,8 +24,13 @@
 
 namespace ns3 {
 
-const InterfaceId PacketSocketFactory::iid = MakeInterfaceId ("Packet", 
-                                                              SocketFactory::iid);
+InterfaceId 
+PacketSocketFactory::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Packet", 
+                                            SocketFactory::iid ());
+  return iid;
+}
 
 PacketSocketFactory::PacketSocketFactory ()
 {}
--- a/src/node/packet-socket-factory.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/packet-socket-factory.h	Wed Jan 02 10:33:39 2008 +0100
@@ -34,7 +34,7 @@
 class PacketSocketFactory : public SocketFactory
 {
 public:
-  static const InterfaceId iid; /// Interface identifier
+  static InterfaceId iid (void);
 
   PacketSocketFactory ();
 
--- a/src/node/queue.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/queue.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -27,9 +27,8 @@
 
 namespace ns3 {
 
-const InterfaceId Queue::iid = MakeInterfaceId ("Queue", Object::iid);
 static ClassIdDefaultValue g_classIdDefaultValue ("Queue", "Packet Queue",
-                                                  Queue::iid, "DropTailQueue");
+                                                  Queue::iid (), "DropTailQueue");
 
 
 std::string 
@@ -97,6 +96,13 @@
   }
 }
 
+InterfaceId 
+Queue::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Queue", Object::iid ());
+  return iid;
+}
+
 Queue::Queue() : 
   m_nBytes(0), 
   m_nTotalReceivedBytes(0),
@@ -275,7 +281,7 @@
 {
   NS_LOG_FUNCTION;
   ClassId classId = g_classIdDefaultValue.GetValue ();
-  Ptr<Queue> queue = ComponentManager::Create<Queue> (classId, Queue::iid);
+  Ptr<Queue> queue = ComponentManager::Create<Queue> (classId);
   return queue;
 }
 
--- a/src/node/queue.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/queue.h	Wed Jan 02 10:33:39 2008 +0100
@@ -78,7 +78,7 @@
 class Queue : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   Queue ();
   virtual ~Queue ();
--- a/src/node/socket-factory.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/socket-factory.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -22,7 +22,11 @@
 
 namespace ns3 {
 
-const InterfaceId SocketFactory::iid = MakeInterfaceId ("SocketFactory", Object::iid);
+InterfaceId SocketFactory::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("SocketFactory", Object::iid ());
+  return iid;
+}
 
 SocketFactory::SocketFactory ()
 {}
--- a/src/node/socket-factory.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/socket-factory.h	Wed Jan 02 10:33:39 2008 +0100
@@ -47,7 +47,7 @@
 class SocketFactory : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   SocketFactory ();
 
--- a/src/node/udp.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/udp.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -22,7 +22,11 @@
 
 namespace ns3 {
 
-const InterfaceId Udp::iid = MakeInterfaceId ("Udp", SocketFactory::iid);
+InterfaceId Udp::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("Udp", SocketFactory::iid ());
+  return iid;
+}
 
 Udp::Udp ()
 {}
--- a/src/node/udp.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/node/udp.h	Wed Jan 02 10:33:39 2008 +0100
@@ -43,7 +43,7 @@
 class Udp : public SocketFactory
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
   Udp ();
 
--- a/src/routing/global-routing/global-router-interface.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/routing/global-routing/global-router-interface.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -431,8 +431,12 @@
 //
 // ---------------------------------------------------------------------------
 
-const InterfaceId GlobalRouter::iid = 
-  MakeInterfaceId ("GlobalRouter", Object::iid);
+InterfaceId 
+GlobalRouter::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("GlobalRouter", Object::iid ());
+  return iid;
+}
 
 GlobalRouter::GlobalRouter ()
   : m_LSAs()
--- a/src/routing/global-routing/global-router-interface.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/routing/global-routing/global-router-interface.h	Wed Jan 02 10:33:39 2008 +0100
@@ -560,7 +560,7 @@
  *
  * @see Object::QueryInterface ()
  */
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
 
 /**
  * @brief Create a Global Router class 
--- a/src/routing/olsr/olsr-agent-impl.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/routing/olsr/olsr-agent-impl.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -178,7 +178,7 @@
   m_ipv4 = node->QueryInterface<Ipv4> ();
   NS_ASSERT (m_ipv4);
 
-  Ptr<SocketFactory> socketFactory = node->QueryInterface<SocketFactory> (Udp::iid);
+  Ptr<SocketFactory> socketFactory = node->QueryInterface<SocketFactory> (Udp::iid ());
 
   m_receiveSocket = socketFactory->CreateSocket ();
   if (m_receiveSocket->Bind (InetSocketAddress (OLSR_PORT_NUMBER)))
--- a/src/routing/olsr/olsr-agent.cc	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/routing/olsr/olsr-agent.cc	Wed Jan 02 10:33:39 2008 +0100
@@ -24,7 +24,14 @@
 namespace ns3 {
 namespace olsr {
 
-const InterfaceId Agent::iid = MakeInterfaceId ("OlsrAgent", Object::iid);
-const ClassId Agent::cid = MakeClassId< AgentImpl, Ptr<Node> > ("OlsrAgent", Agent::iid);
+const ClassId Agent::cid = MakeClassId< AgentImpl, Ptr<Node> > ("OlsrAgent", Agent::iid ());
+
+InterfaceId 
+Agent::iid (void)
+{
+  static InterfaceId iid = MakeInterfaceId ("OlsrAgent", Object::iid ());
+  return iid;
+}
+
 
 }}
--- a/src/routing/olsr/olsr-agent.h	Wed Jan 02 09:25:31 2008 +0100
+++ b/src/routing/olsr/olsr-agent.h	Wed Jan 02 10:33:39 2008 +0100
@@ -46,7 +46,7 @@
 class Agent : public Object
 {
 public:
-  static const InterfaceId iid;
+  static InterfaceId iid (void);
   static const ClassId cid;
 
   /**
--- a/utils/bench-object.cc	Wed Jan 02 09:25:31 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-#include <vector>
-#include <stdlib.h>
-#include "ns3/object.h"
-
-using namespace ns3;
-
-class BaseA : public ns3::Object
-{
-public:
-  static const ns3::InterfaceId iid;
-  BaseA ()
-  {
-    SetInterfaceId (BaseA::iid);
-  }
-  virtual void Dispose (void) {}
-};
-
-const ns3::InterfaceId BaseA::iid = 
-ns3::MakeInterfaceId ("BaseABench", Object::iid);
-
-
-
-int main (int argc, char *argv[])
-{
-  int nobjects = atoi (argv[1]);
-  int nswaps = atoi (argv[2]);
-
-  std::vector< Ptr<BaseA> > objlist;
-
-  for (int i = 0; i < nobjects; ++i)
-    objlist.push_back (CreateObject<BaseA> ());
-
-  for (int swapCounter = nswaps; swapCounter; --swapCounter)
-    {
-      int x1 = swapCounter % nobjects;
-      int x2 = (swapCounter+1) % nobjects;
-      Ptr<BaseA> obj1 = objlist[x1];
-      Ptr<BaseA> obj2 = objlist[x2];
-      objlist[x2] = obj1;
-      objlist[x1] = obj2;
-    }
-}
-