utils/print-introspected-doxygen.cc
changeset 1855 ee15fef0cb62
parent 1853 e2d7985a5938
child 2217 0b4567d545de
child 2230 9f13ac3291e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/utils/print-introspected-doxygen.cc	Thu Nov 15 10:35:55 2007 +0100
     1.3 @@ -0,0 +1,135 @@
     1.4 +#include "ns3/internet-node.h"
     1.5 +#include "ns3/ptr.h"
     1.6 +#include "ns3/trace-resolver.h"
     1.7 +#include "ns3/node-list.h"
     1.8 +#include "ns3/point-to-point-net-device.h"
     1.9 +#include "ns3/csma-net-device.h"
    1.10 +#include "ns3/queue.h"
    1.11 +#include "ns3/mobility-model-notifier.h"
    1.12 +#include "ns3/default-value.h"
    1.13 +
    1.14 +using namespace ns3;
    1.15 +
    1.16 +void
    1.17 +PrintSimpleText (const TraceResolver::SourceCollection *sources, std::ostream &os)
    1.18 +{
    1.19 +  for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
    1.20 +    {
    1.21 +      os << "source=" << i->path << std::endl;
    1.22 +      os << "TraceContext=[";
    1.23 +      i->context.PrintAvailable (os, ",");
    1.24 +      os << "]" << std::endl;
    1.25 +      os << "help=\"" << i->doc.GetHelp () << "\"" << std::endl;
    1.26 +      os << "void TraceSinkCallback (const TraceContext &";
    1.27 +      for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
    1.28 +        {
    1.29 +          os << ", " << k->first;
    1.30 +        }
    1.31 +      os << ")" << std::endl;
    1.32 +      os << "argument 1  --  the trace context associated to the connected trace source." << std::endl;
    1.33 +      uint32_t k = 2;
    1.34 +      for (TraceDoc::Iterator j = i->doc.ArgsBegin (); j != i->doc.ArgsEnd (); j++)
    1.35 +        {
    1.36 +          os << "argument " << k << "  --  " << j->second << "." << std::endl;
    1.37 +          k++;
    1.38 +        }
    1.39 +      os << std::endl;
    1.40 +    }
    1.41 +}
    1.42 +static void
    1.43 +PrintDoxygenText (const TraceResolver::SourceCollection *sources, std::ostream &os)
    1.44 +{
    1.45 +  uint32_t z = 0;
    1.46 +  for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
    1.47 +    {
    1.48 +      os << "///" << std::endl;
    1.49 +      os << "/// \\ingroup TraceSourceList" << std::endl; 
    1.50 +      os << "/// \\brief " << i->doc.GetHelp () << std::endl;
    1.51 +      os << "/// \\param arg1 the trace context associated to the connected trace source." << std::endl;
    1.52 +      uint32_t j = 2;
    1.53 +      for (TraceDoc::Iterator l = i->doc.ArgsBegin (); l != i->doc.ArgsEnd (); l++)
    1.54 +        {
    1.55 +          os << "/// \\param arg" << j << " " << l->second << "." << std::endl;
    1.56 +          j++;
    1.57 +        }
    1.58 +      os << "///" << std::endl;
    1.59 +      os << "///" << std::endl;
    1.60 +      os << "/// The path to this trace source is: <b><tt>\"" << i->path << "\"</tt></b>." << std::endl;
    1.61 +      os << "///" << std::endl;
    1.62 +      if (i->context.Begin ().IsLast ())
    1.63 +        {
    1.64 +          os << "/// No data can be extracted from \\p arg1 with ns3::TraceContext::GetElement." << std::endl;
    1.65 +        }
    1.66 +      else
    1.67 +        {
    1.68 +          os << "/// The following classes can be extracted from \\p arg1 with " << std::endl;
    1.69 +          os << "/// ns3::TraceContext::GetElement:" << std::endl;
    1.70 +          for (TraceContext::Iterator m = i->context.Begin (); !m.IsLast (); m.Next ())
    1.71 +            {
    1.72 +              os << "///  - " << m.Get () << std::endl;
    1.73 +            }
    1.74 +        }
    1.75 +      os << "void TraceSinkCallback" << z << " (const TraceContext & arg1" ;
    1.76 +      j = 2;
    1.77 +      for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
    1.78 +        {
    1.79 +          os << ", " << k->first << " arg" << j;
    1.80 +          j++;
    1.81 +        }
    1.82 +      os << ");" << std::endl;
    1.83 +      os << std::endl;
    1.84 +      z++;
    1.85 +    }
    1.86 +}
    1.87 +
    1.88 +static void
    1.89 +PrintOneDefaultValue (DefaultValueBase *value, std::ostream &os)
    1.90 +{
    1.91 +  os << "///  <li> \\anchor DefaultValue" << value->GetName ()
    1.92 +     << " " << value->GetName () << std::endl;
    1.93 +  os << "///    <ul>" << std::endl;
    1.94 +  os << "///         <li>Type: " << value->GetType () << "</td></tr>" << std::endl;
    1.95 +  os << "///         <li>Default value: " << value->GetDefaultValue () << "</td></tr>" << std::endl;
    1.96 +  os << "///         <li>Description: " << value->GetHelp () << "</td></tr>" << std::endl;
    1.97 +  os << "///    </ul>" << std::endl;
    1.98 +  os << "///  </li>" << std::endl;
    1.99 +}
   1.100 +
   1.101 +static void
   1.102 +PrintDefaultValuesDoxygen (std::ostream &os)
   1.103 +{
   1.104 +  os << "/// \\page ListOfDefaultValues The list of default values" << std::endl;
   1.105 +  os << "/// \\defgroup ListOfDefaultValuesGroup The list of default values" << std::endl;
   1.106 +  os << "/// <ul>" << std::endl;
   1.107 +  for (DefaultValueList::Iterator i = DefaultValueList::Begin ();
   1.108 +       i != DefaultValueList::End (); i++)
   1.109 +    {
   1.110 +      if ((*i)->GetName () == "help")
   1.111 +	{
   1.112 +	  continue;
   1.113 +	}
   1.114 +      PrintOneDefaultValue (*i, os);
   1.115 +    }
   1.116 +  os << "/// </ul>" << std::endl;
   1.117 +}
   1.118 +
   1.119 +
   1.120 +int main (int argc, char *argv[])
   1.121 +{
   1.122 +  Ptr<Node> node = Create<InternetNode> ();
   1.123 +  node->AddInterface (Create<MobilityModelNotifier> ());
   1.124 +
   1.125 +  Ptr<PointToPointNetDevice> p2p = Create<PointToPointNetDevice> (node);
   1.126 +  p2p->AddQueue (Queue::CreateDefault ());
   1.127 +  Ptr<CsmaNetDevice> csma = Create<CsmaNetDevice> (node);
   1.128 +  csma->AddQueue (Queue::CreateDefault ());
   1.129 +
   1.130 +  TraceResolver::SourceCollection collection;
   1.131 +  NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
   1.132 +  PrintDoxygenText (&collection, std::cout);
   1.133 +
   1.134 +
   1.135 +  PrintDefaultValuesDoxygen (std::cout);
   1.136 +
   1.137 +  return 0;
   1.138 +}