utils/print-introspected-doxygen.cc
changeset 2602 d9262bff6df2
parent 2600 6c389d0c717d
child 2693 56e28e34e109
     1.1 --- a/utils/print-introspected-doxygen.cc	Thu Mar 13 11:10:38 2008 -0700
     1.2 +++ b/utils/print-introspected-doxygen.cc	Thu Mar 13 12:56:49 2008 -0700
     1.3 @@ -1,29 +1,92 @@
     1.4 -#include "ns3/internet-node.h"
     1.5 -#include "ns3/ptr.h"
     1.6 -#include "ns3/node-list.h"
     1.7 -#include "ns3/point-to-point-net-device.h"
     1.8 -#include "ns3/csma-net-device.h"
     1.9 -#include "ns3/queue.h"
    1.10 -#include "ns3/drop-tail-queue.h"
    1.11 -#include "ns3/mobility-model-notifier.h"
    1.12 -#include "ns3/string.h"
    1.13 +#include <iostream>
    1.14 +#include "ns3/object.h"
    1.15  
    1.16  using namespace ns3;
    1.17  
    1.18 +void
    1.19 +PrintAttributes (TypeId tid, std::ostream &os)
    1.20 +{
    1.21 +  os << "<ul>"<<std::endl;
    1.22 +  for (uint32_t j = 0; j < tid.GetAttributeListN (); j++)
    1.23 +    {
    1.24 +      os << "<li><b>" << tid.GetAttributeName (j) << "</b>: "
    1.25 +		<< tid.GetAttributeHelp (j) << std::endl;
    1.26 +      Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (j);
    1.27 +      os << "  <ul>" << std::endl << "    <li>Type: " <<  checker->GetType ();
    1.28 +      if (checker->HasTypeConstraints ())
    1.29 +	{
    1.30 +	  os << " -> " << checker->GetTypeConstraints ();
    1.31 +	}
    1.32 +      os << "</li>" << std::endl;
    1.33 +      uint32_t flags = tid.GetAttributeFlags (j);
    1.34 +      os << "<li>Flags: ";
    1.35 +      if (flags & TypeId::ATTR_SET)
    1.36 +	{
    1.37 +	  os << "write ";
    1.38 +	}
    1.39 +      if (flags & TypeId::ATTR_GET)
    1.40 +	{
    1.41 +	  os << "read ";
    1.42 +	}
    1.43 +      if (flags & TypeId::ATTR_CONSTRUCT)
    1.44 +	{
    1.45 +	  os << "construct ";
    1.46 +	}
    1.47 +      os << "  </ul> " << std::endl;
    1.48 +      
    1.49 +    }
    1.50 +  os << "</ul>" << std::endl;
    1.51 +}
    1.52  
    1.53  
    1.54  int main (int argc, char *argv[])
    1.55  {
    1.56 -  Ptr<Node> node = CreateObject<InternetNode> ();
    1.57 -  node->AggregateObject (CreateObject<MobilityModelNotifier> ());
    1.58  
    1.59 -  Ptr<PointToPointNetDevice> p2p = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ());
    1.60 -  node->AddDevice (p2p);
    1.61 -  p2p->AddQueue (CreateObject<DropTailQueue> ());
    1.62 -  Ptr<CsmaNetDevice> csma = CreateObject<CsmaNetDevice> ("Address", Mac48Address::Allocate (),
    1.63 -							 "EncapsulationMode", String ("Llc"));
    1.64 -  node->AddDevice (csma);
    1.65 -  csma->AddQueue (CreateObject<DropTailQueue> ());
    1.66 +  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
    1.67 +    {
    1.68 +      std::cout << "/*!" << std::endl;
    1.69 +      TypeId tid = TypeId::GetRegistered (i);
    1.70 +      if (tid.MustHideFromDocumentation ())
    1.71 +	{
    1.72 +	  continue;
    1.73 +	}
    1.74 +      std::cout << "\\fn static TypeId " << tid.GetName () << "::GetTypeId (void)" << std::endl;
    1.75 +      std::cout << "\\brief This method returns the TypeId associated to \\ref " << tid.GetName () << std::endl << std::endl;
    1.76 +      if (tid.GetAttributeListN () == 0)
    1.77 +	{
    1.78 +	  std::cout << "No Attributes defined for this type." << std::endl;
    1.79 +	}
    1.80 +      else
    1.81 +	{
    1.82 +	  std::cout << "Attributes defined for this type:" << std::endl;
    1.83 +	  PrintAttributes (tid, std::cout);
    1.84 +	}
    1.85 +      bool hasAttributesInParent = false;
    1.86 +      TypeId tmp = tid.GetParent ();
    1.87 +      while (tmp.GetParent () != tmp)
    1.88 +	{
    1.89 +	  if (tmp.GetAttributeListN () != 0)
    1.90 +	    {
    1.91 +	      hasAttributesInParent = true;
    1.92 +	    }
    1.93 +	  tmp = tmp.GetParent ();
    1.94 +	}
    1.95 +      if (hasAttributesInParent)
    1.96 +	{
    1.97 +	  std::cout << "Attributes defined in parent classes:<br>" << std::endl;
    1.98 +	  tmp = tid.GetParent ();
    1.99 +	  while (tmp.GetParent () != tmp)
   1.100 +	    {
   1.101 +	      if (tmp.GetAttributeListN () != 0)
   1.102 +		{
   1.103 +		  std::cout << tmp.GetName () << std::endl;
   1.104 +		  PrintAttributes (tmp, std::cout);
   1.105 +		}
   1.106 +	      tmp = tmp.GetParent ();
   1.107 +	    }
   1.108 +	}
   1.109 +      std::cout << "*/" << std::endl;
   1.110 +    }
   1.111  
   1.112  
   1.113    return 0;