utils/print-introspected-doxygen.cc
changeset 2602 d9262bff6df2
parent 2600 6c389d0c717d
child 2693 56e28e34e109
equal deleted inserted replaced
2601:4297e8c61615 2602:d9262bff6df2
     1 #include "ns3/internet-node.h"
     1 #include <iostream>
     2 #include "ns3/ptr.h"
     2 #include "ns3/object.h"
     3 #include "ns3/node-list.h"
       
     4 #include "ns3/point-to-point-net-device.h"
       
     5 #include "ns3/csma-net-device.h"
       
     6 #include "ns3/queue.h"
       
     7 #include "ns3/drop-tail-queue.h"
       
     8 #include "ns3/mobility-model-notifier.h"
       
     9 #include "ns3/string.h"
       
    10 
     3 
    11 using namespace ns3;
     4 using namespace ns3;
    12 
     5 
       
     6 void
       
     7 PrintAttributes (TypeId tid, std::ostream &os)
       
     8 {
       
     9   os << "<ul>"<<std::endl;
       
    10   for (uint32_t j = 0; j < tid.GetAttributeListN (); 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: " <<  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 }
    13 
    40 
    14 
    41 
    15 int main (int argc, char *argv[])
    42 int main (int argc, char *argv[])
    16 {
    43 {
    17   Ptr<Node> node = CreateObject<InternetNode> ();
       
    18   node->AggregateObject (CreateObject<MobilityModelNotifier> ());
       
    19 
    44 
    20   Ptr<PointToPointNetDevice> p2p = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ());
    45   for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
    21   node->AddDevice (p2p);
    46     {
    22   p2p->AddQueue (CreateObject<DropTailQueue> ());
    47       std::cout << "/*!" << std::endl;
    23   Ptr<CsmaNetDevice> csma = CreateObject<CsmaNetDevice> ("Address", Mac48Address::Allocate (),
    48       TypeId tid = TypeId::GetRegistered (i);
    24 							 "EncapsulationMode", String ("Llc"));
    49       if (tid.MustHideFromDocumentation ())
    25   node->AddDevice (csma);
    50 	{
    26   csma->AddQueue (CreateObject<DropTailQueue> ());
    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.GetAttributeListN () == 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.GetAttributeListN () != 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.GetAttributeListN () != 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     }
    27 
    90 
    28 
    91 
    29   return 0;
    92   return 0;
    30 }
    93 }