add TraceContextElement::GetName method
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 27 Aug 2007 14:59:50 +0200
changeset 1364 7866d4dd9e64
parent 1363 849b30d0ea86
child 1365 4ae411ac425f
add TraceContextElement::GetName method
src/core/composite-trace-resolver.cc
src/core/trace-context-element.cc
src/core/trace-context-element.h
src/devices/csma-cd/csma-cd-net-device.cc
src/devices/csma-cd/csma-cd-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/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/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	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/core/composite-trace-resolver.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -273,6 +273,7 @@
     else if (m_sources == DOUBLEB) {os << "doubleB";}
     else if (m_sources == UINT16_T) {os << "uint16_t";}
   }
+  std::string GetName (void) {return "TraceSourceTest";}
   TraceSourceTest () : m_sources (TraceSourceTest::DOUBLEA) {}
   TraceSourceTest (enum Sources sources) :m_sources (sources) {}
   bool IsDoubleA (void) const {return m_sources == TraceSourceTest::DOUBLEA;}
@@ -292,6 +293,7 @@
   {static uint16_t uid = AllocateUid<SubTraceSourceTest> ("SubTraceSourceTest"); return uid;}
   void Print (std::ostream &os)
   {os << "subtracesource=int";}
+  std::string GetName (void) const {return "SubTraceSourceTest";}
   SubTraceSourceTest () : m_sources (SubTraceSourceTest::INT) {}
   SubTraceSourceTest (enum Sources sources) : m_sources (sources) {}
 private:
--- a/src/core/trace-context-element.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/core/trace-context-element.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -2,6 +2,13 @@
 
 namespace ns3 {
 
+std::string 
+ElementRegistry::GetName (uint16_t uid)
+{
+  InfoVector *vec = GetInfoVector ();
+  struct Info info = (*vec)[uid - 1];
+  return info.getName ();
+}
 uint32_t 
 ElementRegistry::GetSize (uint16_t uid)
 {
--- a/src/core/trace-context-element.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/core/trace-context-element.h	Mon Aug 27 14:59:50 2007 +0200
@@ -115,19 +115,24 @@
 
   static uint32_t GetSize (uint16_t uid);
   static void Print (uint16_t uid, uint8_t *instance, std::ostream &os);
+  static std::string GetName (uint16_t uid);
   static void Destroy (uint16_t uid, uint8_t *instance);
 private:
+  typedef std::string (*GetNameCb) (void);
   typedef void (*PrintCb) (uint8_t *instance, std::ostream &os);
   typedef void (*DestroyCb) (uint8_t *instance);
   struct Info {
     uint32_t size;
     std::string uidString;
+    GetNameCb getName;
     PrintCb print;
     DestroyCb destroy;
   };
   typedef std::vector<struct Info> InfoVector;
   static InfoVector *GetInfoVector (void);
   template <typename T>
+  static std::string DoGetName (void);
+  template <typename T>
   static void DoPrint (uint8_t *instance, std::ostream &os);
   template <typename T>
   static void DoDestroy (uint8_t *instance);  
@@ -143,6 +148,13 @@
   obj.Print (os);
 }
 template <typename T>
+std::string
+ElementRegistry::DoGetName (void)
+{
+  static T obj;
+  return obj.GetName ();
+}
+template <typename T>
 void 
 ElementRegistry::DoDestroy (uint8_t *instance)
 {
@@ -169,6 +181,7 @@
   struct Info info;
   info.size = sizeof (T);
   info.uidString = name;
+  info.getName = &ElementRegistry::DoGetName<T>;
   info.print = &ElementRegistry::DoPrint<T>;
   info.destroy = &ElementRegistry::DoDestroy<T>;
   vec->push_back (info);
--- a/src/devices/csma-cd/csma-cd-net-device.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/devices/csma-cd/csma-cd-net-device.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -59,6 +59,11 @@
   static uint16_t uid = AllocateUid<CsmaCdTraceType> ("CsmaCdTraceType");
   return uid;
 }
+std::string 
+CsmaCdTraceType::GetName (void) const
+{
+  return "CsmaCdTraceType";
+}
 
 
 CsmaCdNetDevice::CsmaCdNetDevice (Ptr<Node> node)
--- a/src/devices/csma-cd/csma-cd-net-device.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/devices/csma-cd/csma-cd-net-device.h	Mon Aug 27 14:59:50 2007 +0200
@@ -52,6 +52,7 @@
   CsmaCdTraceType ();
   void Print (std::ostream &os) const;
   static uint16_t GetUid (void);
+  std::string GetName (void) const;
 private:
   enum Type m_type;
 };
--- a/src/devices/point-to-point/point-to-point-net-device.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -53,6 +53,11 @@
   static uint16_t uid = AllocateUid<PointToPointTraceType> ("PointToPointTraceType");
   return uid;
 }
+std::string 
+PointToPointTraceType::GetName (void) const
+{
+  return "PointToPointTraceType";
+}
 
 
 PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node,
--- a/src/devices/point-to-point/point-to-point-net-device.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.h	Mon Aug 27 14:59:50 2007 +0200
@@ -44,6 +44,7 @@
   PointToPointTraceType ();
   void Print (std::ostream &os) const;
   static uint16_t GetUid (void);
+  std::string GetName (void) const;
 };
 
 /**
--- a/src/internet-node/ipv4-l3-protocol.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -87,6 +87,11 @@
   static uint16_t uid = AllocateUid<Ipv4L3ProtocolTraceContextElement> ("Ipv4L3ProtocolTraceContextElement");
   return uid;
 }
+std::string 
+Ipv4L3ProtocolTraceContextElement::GetName (void) const
+{
+  return "Ipv4L3ProtocolTraceContextElement";
+}
 
 
 Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex ()
@@ -111,6 +116,11 @@
   static uint16_t uid = AllocateUid<Ipv4L3ProtocolInterfaceIndex> ("Ipv4L3ProtocolInterfaceIndex");
   return uid;
 }
+std::string
+Ipv4L3ProtocolInterfaceIndex::GetName (void) const
+{
+  return "Ipv4L3ProtocolInterfaceIndex";
+}
 
 
 Ipv4L3Protocol::Ipv4L3Protocol(Ptr<Node> node)
--- a/src/internet-node/ipv4-l3-protocol.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.h	Mon Aug 27 14:59:50 2007 +0200
@@ -59,6 +59,7 @@
   bool IsDrop (void) const;
   void Print (std::ostream &os) const;
   static uint16_t GetUid (void);
+  std::string GetName (void) const;
 private:
   enum Type m_type;
 };
@@ -71,6 +72,7 @@
   uint32_t Get (void) const;
   void Print (std::ostream &os) const;
   static uint16_t GetUid (void);
+  std::string GetName (void) const;
 private:
   uint32_t m_index;
 };
--- a/src/internet-node/ipv4-l4-demux.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -54,6 +54,11 @@
   static uint16_t uid = AllocateUid<Ipv4L4ProtocolTraceContextElement> ("Ipv4L4ProtocolTraceContextElement");
   return uid;
 }
+std::string 
+Ipv4L4ProtocolTraceContextElement::GetName (void) const
+{
+  return "Ipv4L4ProtocolTraceContextElement";
+}
 
 
 Ipv4L4Demux::Ipv4L4Demux (Ptr<Node> node)
--- a/src/internet-node/ipv4-l4-demux.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.h	Mon Aug 27 14:59:50 2007 +0200
@@ -45,6 +45,7 @@
   int Get (void) const;
   void Print (std::ostream &os) const;
   static uint16_t GetUid (void);
+  std::string GetName (void) const;
 private:
   int m_protocolNumber;
 };
--- a/src/node/node-list.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/node/node-list.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -50,6 +50,11 @@
 {
   return m_index;
 }
+std::string 
+NodeListIndex::GetName (void) const
+{
+  return "NodeListIndex";
+}
 
 
 /**
--- a/src/node/node-list.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/node/node-list.h	Mon Aug 27 14:59:50 2007 +0200
@@ -39,6 +39,7 @@
   void Print (std::ostream &os);
   static uint16_t GetUid (void);
   uint32_t Get (void) const;
+  std::string GetName (void) const;
 private:
   uint32_t m_index;
 };
--- a/src/node/node.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/node/node.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -52,6 +52,11 @@
   static uint16_t uid = AllocateUid<NodeNetDeviceIndex> ("NodeNetDeviceIndex");
   return uid;
 }
+std::string 
+NodeNetDeviceIndex::GetName (void) const
+{
+  return "NodeNetDeviceIndex";
+}
 
 
 
--- a/src/node/node.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/node/node.h	Mon Aug 27 14:59:50 2007 +0200
@@ -44,6 +44,7 @@
   NodeNetDeviceIndex (uint32_t index);
   uint32_t Get (void) const;
   void Print (std::ostream &os) const;
+  std::string GetName (void) const;
   static uint16_t GetUid (void);
 private:
   uint32_t m_index;
--- a/src/node/queue.cc	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/node/queue.cc	Mon Aug 27 14:59:50 2007 +0200
@@ -32,6 +32,11 @@
                                                   Queue::iid, "DropTailQueue");
 
 
+std::string 
+QueueTraceType::GetName (void) const
+{
+  return "QueueTraceType";
+}
 uint16_t 
 QueueTraceType::GetUid (void)
 {
--- a/src/node/queue.h	Mon Aug 27 14:06:11 2007 +0200
+++ b/src/node/queue.h	Mon Aug 27 14:59:50 2007 +0200
@@ -52,6 +52,7 @@
   bool IsDequeue (void) const;
   bool IsDrop (void) const;
   void Print (std::ostream &os) const;
+  std::string GetName (void) const;
 private:
   enum Type m_type;
 };