utils/print-introspected-doxygen.cc
changeset 2542 a9b88fdc09d6
parent 2540 4e9ba43f7b9e
child 2577 5b41cb5c3fcf
equal deleted inserted replaced
2541:91020a8d4264 2542:a9b88fdc09d6
     1 #include "ns3/internet-node.h"
     1 #include "ns3/internet-node.h"
     2 #include "ns3/ptr.h"
     2 #include "ns3/ptr.h"
     3 #include "ns3/trace-resolver.h"
       
     4 #include "ns3/node-list.h"
     3 #include "ns3/node-list.h"
     5 #include "ns3/point-to-point-net-device.h"
     4 #include "ns3/point-to-point-net-device.h"
     6 #include "ns3/csma-net-device.h"
     5 #include "ns3/csma-net-device.h"
     7 #include "ns3/queue.h"
     6 #include "ns3/queue.h"
     8 #include "ns3/drop-tail-queue.h"
     7 #include "ns3/drop-tail-queue.h"
    10 #include "ns3/default-value.h"
     9 #include "ns3/default-value.h"
    11 #include "ns3/string.h"
    10 #include "ns3/string.h"
    12 
    11 
    13 using namespace ns3;
    12 using namespace ns3;
    14 
    13 
    15 void
       
    16 PrintSimpleText (const TraceResolver::SourceCollection *sources, std::ostream &os)
       
    17 {
       
    18   for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
       
    19     {
       
    20       os << "source=" << i->path << std::endl;
       
    21       os << "TraceContext=[";
       
    22       i->context.PrintAvailable (os, ",");
       
    23       os << "]" << std::endl;
       
    24       os << "help=\"" << i->doc.GetHelp () << "\"" << std::endl;
       
    25       os << "void TraceSinkCallback (const TraceContext &";
       
    26       for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
       
    27         {
       
    28           os << ", " << k->first;
       
    29         }
       
    30       os << ")" << std::endl;
       
    31       os << "argument 1  --  the trace context associated to the connected trace source." << std::endl;
       
    32       uint32_t k = 2;
       
    33       for (TraceDoc::Iterator j = i->doc.ArgsBegin (); j != i->doc.ArgsEnd (); j++)
       
    34         {
       
    35           os << "argument " << k << "  --  " << j->second << "." << std::endl;
       
    36           k++;
       
    37         }
       
    38       os << std::endl;
       
    39     }
       
    40 }
       
    41 static void
       
    42 PrintDoxygenText (const TraceResolver::SourceCollection *sources, std::ostream &os)
       
    43 {
       
    44   uint32_t z = 0;
       
    45   for (TraceResolver::SourceCollection::Iterator i = sources->Begin (); i != sources->End (); i++)
       
    46     {
       
    47       os << "///" << std::endl;
       
    48       os << "/// \\ingroup TraceSourceList" << std::endl; 
       
    49       os << "/// \\brief " << i->doc.GetHelp () << std::endl;
       
    50       os << "/// \\param arg1 the trace context associated to the connected trace source." << std::endl;
       
    51       uint32_t j = 2;
       
    52       for (TraceDoc::Iterator l = i->doc.ArgsBegin (); l != i->doc.ArgsEnd (); l++)
       
    53         {
       
    54           os << "/// \\param arg" << j << " " << l->second << "." << std::endl;
       
    55           j++;
       
    56         }
       
    57       os << "///" << std::endl;
       
    58       os << "///" << std::endl;
       
    59       os << "/// The path to this trace source is: <b><tt>\"" << i->path << "\"</tt></b>." << std::endl;
       
    60       os << "///" << std::endl;
       
    61       if (i->context.Begin ().IsLast ())
       
    62         {
       
    63           os << "/// No data can be extracted from \\p arg1 with ns3::TraceContext::GetElement." << std::endl;
       
    64         }
       
    65       else
       
    66         {
       
    67           os << "/// The following classes can be extracted from \\p arg1 with " << std::endl;
       
    68           os << "/// ns3::TraceContext::GetElement:" << std::endl;
       
    69           for (TraceContext::Iterator m = i->context.Begin (); !m.IsLast (); m.Next ())
       
    70             {
       
    71               os << "///  - " << m.Get () << std::endl;
       
    72             }
       
    73         }
       
    74       os << "void TraceSinkCallback" << z << " (const TraceContext & arg1" ;
       
    75       j = 2;
       
    76       for (TraceDoc::Iterator k = i->doc.ArgsBegin (); k != i->doc.ArgsEnd (); k++)
       
    77         {
       
    78           os << ", " << k->first << " arg" << j;
       
    79           j++;
       
    80         }
       
    81       os << ");" << std::endl;
       
    82       os << std::endl;
       
    83       z++;
       
    84     }
       
    85 }
       
    86 
    14 
    87 static void
    15 static void
    88 PrintOneDefaultValue (DefaultValueBase *value, std::ostream &os)
    16 PrintOneDefaultValue (DefaultValueBase *value, std::ostream &os)
    89 {
    17 {
    90   os << "///  <li> \\anchor DefaultValue" << value->GetName ()
    18   os << "///  <li> \\anchor DefaultValue" << value->GetName ()
   129 							     "Address", Mac48Address::Allocate (),
    57 							     "Address", Mac48Address::Allocate (),
   130 							     "EncapsulationMode", String ("Llc"));
    58 							     "EncapsulationMode", String ("Llc"));
   131   node->AddDevice (csma);
    59   node->AddDevice (csma);
   132   csma->AddQueue (CreateObject<DropTailQueue> ());
    60   csma->AddQueue (CreateObject<DropTailQueue> ());
   133 
    61 
   134   TraceResolver::SourceCollection collection;
       
   135   //NodeList::GetTraceResolver ()->CollectSources ("", TraceContext (), &collection);
       
   136   PrintDoxygenText (&collection, std::cout);
       
   137 
       
   138 
    62 
   139   PrintDefaultValuesDoxygen (std::cout);
    63   PrintDefaultValuesDoxygen (std::cout);
   140 
    64 
   141   return 0;
    65   return 0;
   142 }
    66 }