utils/print-introspected-doxygen.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 09 Apr 2008 13:05:20 -0700
changeset 2931 5bee690ea6b6
parent 2693 56e28e34e109
child 2944 d8806baadedb
permissions -rw-r--r--
improve type linking behavior.
     1 #include <iostream>
     2 #include "ns3/object.h"
     3 
     4 using namespace ns3;
     5 
     6 void
     7 PrintAttributes (TypeId tid, std::ostream &os)
     8 {
     9   os << "<ul>"<<std::endl;
    10   for (uint32_t j = 0; j < tid.GetAttributeN (); j++)
    11     {
    12       os << "<li><b>" << tid.GetAttributeName (j) << "</b>: "
    13 		<< tid.GetAttributeHelp (j) << std::endl;
    14       Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (j);
    15       os << "  <ul>" << std::endl << "    <li>Type: \\ref " <<  checker->GetType ();
    16       if (checker->HasTypeConstraints ())
    17 	{
    18 	  os << " -> " << checker->GetTypeConstraints ();
    19 	}
    20       os << "</li>" << std::endl;
    21       uint32_t flags = tid.GetAttributeFlags (j);
    22       os << "<li>Flags: ";
    23       if (flags & TypeId::ATTR_SET)
    24 	{
    25 	  os << "write ";
    26 	}
    27       if (flags & TypeId::ATTR_GET)
    28 	{
    29 	  os << "read ";
    30 	}
    31       if (flags & TypeId::ATTR_CONSTRUCT)
    32 	{
    33 	  os << "construct ";
    34 	}
    35       os << "  </ul> " << std::endl;
    36       
    37     }
    38   os << "</ul>" << std::endl;
    39 }
    40 
    41 
    42 int main (int argc, char *argv[])
    43 {
    44 
    45   for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
    46     {
    47       std::cout << "/*!" << std::endl;
    48       TypeId tid = TypeId::GetRegistered (i);
    49       if (tid.MustHideFromDocumentation ())
    50 	{
    51 	  continue;
    52 	}
    53       std::cout << "\\fn static TypeId " << tid.GetName () << "::GetTypeId (void)" << std::endl;
    54       std::cout << "\\brief This method returns the TypeId associated to \\ref " << tid.GetName () << std::endl << std::endl;
    55       if (tid.GetAttributeN () == 0)
    56 	{
    57 	  std::cout << "No Attributes defined for this type." << std::endl;
    58 	}
    59       else
    60 	{
    61 	  std::cout << "Attributes defined for this type:" << std::endl;
    62 	  PrintAttributes (tid, std::cout);
    63 	}
    64       bool hasAttributesInParent = false;
    65       TypeId tmp = tid.GetParent ();
    66       while (tmp.GetParent () != tmp)
    67 	{
    68 	  if (tmp.GetAttributeN () != 0)
    69 	    {
    70 	      hasAttributesInParent = true;
    71 	    }
    72 	  tmp = tmp.GetParent ();
    73 	}
    74       if (hasAttributesInParent)
    75 	{
    76 	  std::cout << "Attributes defined in parent classes:<br>" << std::endl;
    77 	  tmp = tid.GetParent ();
    78 	  while (tmp.GetParent () != tmp)
    79 	    {
    80 	      if (tmp.GetAttributeN () != 0)
    81 		{
    82 		  std::cout << tmp.GetName () << std::endl;
    83 		  PrintAttributes (tmp, std::cout);
    84 		}
    85 	      tmp = tmp.GetParent ();
    86 	    }
    87 	}
    88       std::cout << "*/" << std::endl;
    89     }
    90 
    91 
    92   return 0;
    93 }