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