utils/print-introspected-doxygen.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 27 Feb 2008 21:41:34 +0100
changeset 2502 50d0da37f02f
parent 2500 1fb9430f642d
child 2533 80cdc3eec057
permissions -rw-r--r--
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
     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 #include "ns3/string.h"
    11 
    12 using namespace ns3;
    13 
    14 void
    15 PrintSimpleText (const TraceResolver::SourceCollection *sources, std::ostream &os)
    16 {
    17   for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
    18     {
    19       os << "source=" << i->path << std::endl;
    20       os << "TraceContext=[";
    21       i->context.PrintAvailable (os, ",");
    22       os << "]" << std::endl;
    23       os << "help=\"" << i->doc.GetHelp () << "\"" << std::endl;
    24       os << "void TraceSinkCallback (const TraceContext &";
    25       for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
    26         {
    27           os << ", " << k->first;
    28         }
    29       os << ")" << std::endl;
    30       os << "argument 1  --  the trace context associated to the connected trace source." << std::endl;
    31       uint32_t k = 2;
    32       for (TraceDoc::Iterator j = i->doc.ArgsBegin (); j != i->doc.ArgsEnd (); j++)
    33         {
    34           os << "argument " << k << "  --  " << j->second << "." << std::endl;
    35           k++;
    36         }
    37       os << std::endl;
    38     }
    39 }
    40 static void
    41 PrintDoxygenText (const TraceResolver::SourceCollection *sources, std::ostream &os)
    42 {
    43   uint32_t z = 0;
    44   for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
    45     {
    46       os << "///" << std::endl;
    47       os << "/// \\ingroup TraceSourceList" << std::endl; 
    48       os << "/// \\brief " << i->doc.GetHelp () << std::endl;
    49       os << "/// \\param arg1 the trace context associated to the connected trace source." << std::endl;
    50       uint32_t j = 2;
    51       for (TraceDoc::Iterator l = i->doc.ArgsBegin (); l != i->doc.ArgsEnd (); l++)
    52         {
    53           os << "/// \\param arg" << j << " " << l->second << "." << std::endl;
    54           j++;
    55         }
    56       os << "///" << std::endl;
    57       os << "///" << std::endl;
    58       os << "/// The path to this trace source is: <b><tt>\"" << i->path << "\"</tt></b>." << std::endl;
    59       os << "///" << std::endl;
    60       if (i->context.Begin ().IsLast ())
    61         {
    62           os << "/// No data can be extracted from \\p arg1 with ns3::TraceContext::GetElement." << std::endl;
    63         }
    64       else
    65         {
    66           os << "/// The following classes can be extracted from \\p arg1 with " << std::endl;
    67           os << "/// ns3::TraceContext::GetElement:" << std::endl;
    68           for (TraceContext::Iterator m = i->context.Begin (); !m.IsLast (); m.Next ())
    69             {
    70               os << "///  - " << m.Get () << std::endl;
    71             }
    72         }
    73       os << "void TraceSinkCallback" << z << " (const TraceContext & arg1" ;
    74       j = 2;
    75       for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
    76         {
    77           os << ", " << k->first << " arg" << j;
    78           j++;
    79         }
    80       os << ");" << std::endl;
    81       os << std::endl;
    82       z++;
    83     }
    84 }
    85 
    86 static void
    87 PrintOneDefaultValue (DefaultValueBase *value, std::ostream &os)
    88 {
    89   os << "///  <li> \\anchor DefaultValue" << value->GetName ()
    90      << " " << value->GetName () << std::endl;
    91   os << "///    <ul>" << std::endl;
    92   os << "///         <li>Type: " << value->GetType () << "</td></tr>" << std::endl;
    93   os << "///         <li>Default value: " << value->GetDefaultValue () << "</td></tr>" << std::endl;
    94   os << "///         <li>Description: " << value->GetHelp () << "</td></tr>" << std::endl;
    95   os << "///    </ul>" << std::endl;
    96   os << "///  </li>" << std::endl;
    97 }
    98 
    99 static void
   100 PrintDefaultValuesDoxygen (std::ostream &os)
   101 {
   102   os << "/// \\page ListOfDefaultValues The list of default values" << 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 = CreateObject<InternetNode> ();
   121   node->AggregateObject (CreateObject<MobilityModelNotifier> ());
   122 
   123   Ptr<PointToPointNetDevice> p2p = CreateObjectWith<PointToPointNetDevice> ("Node", node, 
   124 									    "Address", Mac48Address::Allocate ());
   125   node->AddDevice (p2p);
   126   p2p->AddQueue (Queue::CreateDefault ());
   127   Ptr<CsmaNetDevice> csma = CreateObjectWith<CsmaNetDevice> ("Node", node, 
   128 							     "Address", Mac48Address::Allocate (),
   129 							     "EncapsulationMode", String ("Llc"));
   130   node->AddDevice (csma);
   131   csma->AddQueue (Queue::CreateDefault ());
   132 
   133   TraceResolver::SourceCollection collection;
   134   NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
   135   PrintDoxygenText (&collection, std::cout);
   136 
   137 
   138   PrintDefaultValuesDoxygen (std::cout);
   139 
   140   return 0;
   141 }