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