utils/print-introspected-doxygen.cc
author Tom Henderson <tomh@tomh.org>
Thu, 10 Jan 2008 07:31:40 -0800
changeset 2217 0b4567d545de
parent 1855 ee15fef0cb62
child 2253 dfa0f692e38a
permissions -rw-r--r--
Doxygen organization
     1 #include "ns3/internet-node.h"
     2 #include "ns3/ptr.h"
     3 #include "ns3/trace-resolver.h"
     4 #include "ns3/node-list.h"
     5 #include "ns3/point-to-point-net-device.h"
     6 #include "ns3/csma-net-device.h"
     7 #include "ns3/queue.h"
     8 #include "ns3/mobility-model-notifier.h"
     9 #include "ns3/default-value.h"
    10 
    11 using namespace ns3;
    12 
    13 void
    14 PrintSimpleText (const TraceResolver::SourceCollection *sources, std::ostream &os)
    15 {
    16   for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
    17     {
    18       os << "source=" << i->path << std::endl;
    19       os << "TraceContext=[";
    20       i->context.PrintAvailable (os, ",");
    21       os << "]" << std::endl;
    22       os << "help=\"" << i->doc.GetHelp () << "\"" << std::endl;
    23       os << "void TraceSinkCallback (const TraceContext &";
    24       for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
    25         {
    26           os << ", " << k->first;
    27         }
    28       os << ")" << std::endl;
    29       os << "argument 1  --  the trace context associated to the connected trace source." << std::endl;
    30       uint32_t k = 2;
    31       for (TraceDoc::Iterator j = i->doc.ArgsBegin (); j != i->doc.ArgsEnd (); j++)
    32         {
    33           os << "argument " << k << "  --  " << j->second << "." << std::endl;
    34           k++;
    35         }
    36       os << std::endl;
    37     }
    38 }
    39 static void
    40 PrintDoxygenText (const TraceResolver::SourceCollection *sources, std::ostream &os)
    41 {
    42   uint32_t z = 0;
    43   for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
    44     {
    45       os << "///" << std::endl;
    46       os << "/// \\ingroup TraceSourceList" << std::endl; 
    47       os << "/// \\brief " << i->doc.GetHelp () << std::endl;
    48       os << "/// \\param arg1 the trace context associated to the connected trace source." << std::endl;
    49       uint32_t j = 2;
    50       for (TraceDoc::Iterator l = i->doc.ArgsBegin (); l != i->doc.ArgsEnd (); l++)
    51         {
    52           os << "/// \\param arg" << j << " " << l->second << "." << std::endl;
    53           j++;
    54         }
    55       os << "///" << std::endl;
    56       os << "///" << std::endl;
    57       os << "/// The path to this trace source is: <b><tt>\"" << i->path << "\"</tt></b>." << std::endl;
    58       os << "///" << std::endl;
    59       if (i->context.Begin ().IsLast ())
    60         {
    61           os << "/// No data can be extracted from \\p arg1 with ns3::TraceContext::GetElement." << std::endl;
    62         }
    63       else
    64         {
    65           os << "/// The following classes can be extracted from \\p arg1 with " << std::endl;
    66           os << "/// ns3::TraceContext::GetElement:" << std::endl;
    67           for (TraceContext::Iterator m = i->context.Begin (); !m.IsLast (); m.Next ())
    68             {
    69               os << "///  - " << m.Get () << std::endl;
    70             }
    71         }
    72       os << "void TraceSinkCallback" << z << " (const TraceContext & arg1" ;
    73       j = 2;
    74       for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
    75         {
    76           os << ", " << k->first << " arg" << j;
    77           j++;
    78         }
    79       os << ");" << std::endl;
    80       os << std::endl;
    81       z++;
    82     }
    83 }
    84 
    85 static void
    86 PrintOneDefaultValue (DefaultValueBase *value, std::ostream &os)
    87 {
    88   os << "///  <li> \\anchor DefaultValue" << value->GetName ()
    89      << " " << value->GetName () << std::endl;
    90   os << "///    <ul>" << std::endl;
    91   os << "///         <li>Type: " << value->GetType () << "</td></tr>" << std::endl;
    92   os << "///         <li>Default value: " << value->GetDefaultValue () << "</td></tr>" << std::endl;
    93   os << "///         <li>Description: " << value->GetHelp () << "</td></tr>" << std::endl;
    94   os << "///    </ul>" << std::endl;
    95   os << "///  </li>" << std::endl;
    96 }
    97 
    98 static void
    99 PrintDefaultValuesDoxygen (std::ostream &os)
   100 {
   101   os << "/// \\page ListOfDefaultValues The list of default values" << std::endl;
   102   os << "/// \\ingroup core" << std::endl;
   103   os << "/// \\defgroup ListOfDefaultValuesGroup The list of default values" << std::endl;
   104   os << "/// <ul>" << std::endl;
   105   for (DefaultValueList::Iterator i = DefaultValueList::Begin ();
   106        i != DefaultValueList::End (); i++)
   107     {
   108       if ((*i)->GetName () == "help")
   109 	{
   110 	  continue;
   111 	}
   112       PrintOneDefaultValue (*i, os);
   113     }
   114   os << "/// </ul>" << std::endl;
   115 }
   116 
   117 
   118 int main (int argc, char *argv[])
   119 {
   120   Ptr<Node> node = Create<InternetNode> ();
   121   node->AddInterface (Create<MobilityModelNotifier> ());
   122 
   123   Ptr<PointToPointNetDevice> p2p = Create<PointToPointNetDevice> (node);
   124   p2p->AddQueue (Queue::CreateDefault ());
   125   Ptr<CsmaNetDevice> csma = Create<CsmaNetDevice> (node);
   126   csma->AddQueue (Queue::CreateDefault ());
   127 
   128   TraceResolver::SourceCollection collection;
   129   NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
   130   PrintDoxygenText (&collection, std::cout);
   131 
   132 
   133   PrintDefaultValuesDoxygen (std::cout);
   134 
   135   return 0;
   136 }