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