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