utils/print-introspected-doxygen.cc
changeset 2602 d9262bff6df2
parent 2600 6c389d0c717d
child 2693 56e28e34e109
--- a/utils/print-introspected-doxygen.cc	Thu Mar 13 11:21:12 2008 -0700
+++ b/utils/print-introspected-doxygen.cc	Thu Mar 13 12:56:49 2008 -0700
@@ -1,29 +1,92 @@
-#include "ns3/internet-node.h"
-#include "ns3/ptr.h"
-#include "ns3/node-list.h"
-#include "ns3/point-to-point-net-device.h"
-#include "ns3/csma-net-device.h"
-#include "ns3/queue.h"
-#include "ns3/drop-tail-queue.h"
-#include "ns3/mobility-model-notifier.h"
-#include "ns3/string.h"
+#include <iostream>
+#include "ns3/object.h"
 
 using namespace ns3;
 
+void
+PrintAttributes (TypeId tid, std::ostream &os)
+{
+  os << "<ul>"<<std::endl;
+  for (uint32_t j = 0; j < tid.GetAttributeListN (); j++)
+    {
+      os << "<li><b>" << tid.GetAttributeName (j) << "</b>: "
+		<< tid.GetAttributeHelp (j) << std::endl;
+      Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (j);
+      os << "  <ul>" << std::endl << "    <li>Type: " <<  checker->GetType ();
+      if (checker->HasTypeConstraints ())
+	{
+	  os << " -> " << checker->GetTypeConstraints ();
+	}
+      os << "</li>" << std::endl;
+      uint32_t flags = tid.GetAttributeFlags (j);
+      os << "<li>Flags: ";
+      if (flags & TypeId::ATTR_SET)
+	{
+	  os << "write ";
+	}
+      if (flags & TypeId::ATTR_GET)
+	{
+	  os << "read ";
+	}
+      if (flags & TypeId::ATTR_CONSTRUCT)
+	{
+	  os << "construct ";
+	}
+      os << "  </ul> " << std::endl;
+      
+    }
+  os << "</ul>" << std::endl;
+}
 
 
 int main (int argc, char *argv[])
 {
-  Ptr<Node> node = CreateObject<InternetNode> ();
-  node->AggregateObject (CreateObject<MobilityModelNotifier> ());
 
-  Ptr<PointToPointNetDevice> p2p = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ());
-  node->AddDevice (p2p);
-  p2p->AddQueue (CreateObject<DropTailQueue> ());
-  Ptr<CsmaNetDevice> csma = CreateObject<CsmaNetDevice> ("Address", Mac48Address::Allocate (),
-							 "EncapsulationMode", String ("Llc"));
-  node->AddDevice (csma);
-  csma->AddQueue (CreateObject<DropTailQueue> ());
+  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
+    {
+      std::cout << "/*!" << std::endl;
+      TypeId tid = TypeId::GetRegistered (i);
+      if (tid.MustHideFromDocumentation ())
+	{
+	  continue;
+	}
+      std::cout << "\\fn static TypeId " << tid.GetName () << "::GetTypeId (void)" << std::endl;
+      std::cout << "\\brief This method returns the TypeId associated to \\ref " << tid.GetName () << std::endl << std::endl;
+      if (tid.GetAttributeListN () == 0)
+	{
+	  std::cout << "No Attributes defined for this type." << std::endl;
+	}
+      else
+	{
+	  std::cout << "Attributes defined for this type:" << std::endl;
+	  PrintAttributes (tid, std::cout);
+	}
+      bool hasAttributesInParent = false;
+      TypeId tmp = tid.GetParent ();
+      while (tmp.GetParent () != tmp)
+	{
+	  if (tmp.GetAttributeListN () != 0)
+	    {
+	      hasAttributesInParent = true;
+	    }
+	  tmp = tmp.GetParent ();
+	}
+      if (hasAttributesInParent)
+	{
+	  std::cout << "Attributes defined in parent classes:<br>" << std::endl;
+	  tmp = tid.GetParent ();
+	  while (tmp.GetParent () != tmp)
+	    {
+	      if (tmp.GetAttributeListN () != 0)
+		{
+		  std::cout << tmp.GetName () << std::endl;
+		  PrintAttributes (tmp, std::cout);
+		}
+	      tmp = tmp.GetParent ();
+	    }
+	}
+      std::cout << "*/" << std::endl;
+    }
 
 
   return 0;