33 #include "ns3/command-line.h"
34 #include "ns3/config.h"
35 #include "ns3/global-value.h"
37 #include "ns3/object-vector.h"
38 #include "ns3/object.h"
39 #include "ns3/pointer.h"
40 #include "ns3/string.h"
41 #include "ns3/node-container.h"
42 #include "ns3/simple-channel.h"
43 #include "ns3/system-path.h"
124 commentStart =
"===============================================================\n";
220 void RecordAggregationInfo (std::string a, std::string b);
230 void Print (
void)
const;
237 std::vector<std::string> Get (
TypeId tid)
const;
242 std::vector<std::string> GetNoTypeIds (
void)
const;
248 std::string GetCurrentPath (
void)
const;
254 void DoGather (
TypeId tid);
260 void RecordOutput (
TypeId tid);
266 bool HasAlreadyBeenProcessed (
TypeId tid)
const;
270 std::vector<std::pair<TypeId,std::string> >
m_output;
302 m_noTids.push_back (a);
309 m_noTids.push_back (b);
313 m_aggregates.push_back (std::make_pair (aTid, bTid));
321 for (
auto item : m_output)
323 std::cout << item.first.GetName () <<
" -> " << item.second << std::endl;
332 std::ostringstream oss;
333 for (
auto item : m_currentPath)
345 m_output.push_back (std::make_pair (tid, GetCurrentPath ()));
353 for (
auto it : m_alreadyProcessed)
364 std::vector<std::string>
368 std::vector<std::string> paths;
369 for (
auto item : m_output)
371 if (item.first == tid)
373 paths.push_back (item.second);
394 template <
typename T>
398 std::sort (t.begin (), t.end ());
399 t.erase (std::unique (t.begin (), t.end ()), t.end ());
402 std::vector<std::string>
424 if (HasAlreadyBeenProcessed (tid))
439 TypeId objectTypeId =
object->GetTypeId ();
440 if (objectTypeId == pointee)
449 m_currentPath.push_back (info.
name);
450 m_alreadyProcessed.push_back (tid);
452 m_alreadyProcessed.pop_back ();
453 m_currentPath.pop_back ();
458 if (vectorChecker != 0)
461 m_currentPath.push_back (info.
name +
"/[i]");
462 m_alreadyProcessed.push_back (tid);
464 m_alreadyProcessed.pop_back ();
465 m_currentPath.pop_back ();
474 std::string childName =
"$" + child.
GetName ();
475 m_currentPath.push_back (childName);
476 m_alreadyProcessed.push_back (tid);
478 m_alreadyProcessed.pop_back ();
479 m_currentPath.pop_back ();
482 for (
auto item : m_aggregates)
484 if (item.first == tid || item.second == tid)
487 if (item.first == tid)
491 if (item.second == tid)
495 std::string name =
"$" + other.
GetName ();
496 m_currentPath.push_back (name);
497 m_alreadyProcessed.push_back (tid);
499 m_alreadyProcessed.pop_back ();
500 m_currentPath.pop_back ();
515 static bool mapped =
false;
556 simpleChannel = CreateObject<SimpleChannel> ();
570 typedef std::map< std::string, int32_t>
NameMap;
586 static bool mapped =
false;
610 std::string name = tid.
GetName ();
611 std::transform (name.begin (), name.end (), name.begin (), ::toupper);
619 for (
auto item : noTids)
646 os <<
"Introspection did not find any typical Config paths."
658 <<
" is accessible through the following paths"
659 <<
" with Config::Set and Config::Connect:"
662 for (
auto path : paths)
665 <<
"\"" << path <<
"\""
700 << info.
checker->GetValueTypeName ()
703 if (info.
checker->HasUnderlyingTypeInformation ())
707 <<
"Underlying type: ";
709 std::string valType = info.
checker->GetValueTypeName ();
710 std::string underType = info.
checker->GetUnderlyingTypeInformation ();
711 if ((valType !=
"ns3::EnumValue") && (underType !=
"std::string"))
714 bool handled =
false;
716 if (valType ==
"ns3::PointerValue")
728 else if (valType ==
"ns3::ObjectPtrContainerValue")
741 class StringBeginMatcher
744 StringBeginMatcher (
const std::string s)
746 bool operator () (
const std::string t)
748 std::size_t pos = m_string.find (t);
752 std::string m_string;
754 StringBeginMatcher match (underType);
756 if ( match (
"bool") || match (
"double") ||
757 match (
"int8_t") || match (
"uint8_t") ||
758 match (
"int16_t") || match (
"uint16_t") ||
759 match (
"int32_t") || match (
"uint32_t") ||
760 match (
"int64_t") || match (
"uint64_t")
821 os <<
"No Attributes are defined for this type."
841 <<
"Attributes defined in parent class "
873 <<
"%Callback signature: "
898 os <<
"No TraceSources are defined for this type."
917 <<
"TraceSources defined in parent class "
938 std::size_t arch = (
sizeof (
void *) * CHAR_BIT);
941 <<
" of this type is " << tid.
GetSize ()
942 <<
" bytes (on a " << arch <<
"-bit architecture)."
961 for (
auto item : nameMap)
970 std::string name = tid.
GetName ();
975 std::cout << std::endl;
1003 os <<
"This is a list of all" <<
reference <<
"ns3::TypeId's.\n"
1004 <<
"For more information see the" <<
reference <<
"ns3::TypeId "
1005 <<
"section of this API documentation and the"
1007 <<
"in the Configuration and "
1008 <<
referenceNo <<
"Attributes chapter of the Manual.\n"
1016 for (
auto item : nameMap)
1019 if (item.second < 0)
1055 os <<
"This is a list of all" <<
reference <<
"ns3::Attributes by class. "
1056 <<
"For more information see the" <<
reference <<
"ns3:Attributes "
1057 <<
"section of this API documentation and the Attributes sections "
1058 <<
"in the Tutorial and Manual.\n"
1064 for (
auto item: nameMap)
1067 if (item.second < 0)
1087 <<
": " << info.
help
1109 os <<
"This is a list of all" <<
reference <<
"ns3::GlobalValue instances.\n"
1110 <<
"See ns3::GlobalValue for how to set these."
1119 (*i)->GetValue (val);
1124 <<
hrefMid <<
"GlobalValue" << (*i)->GetName ()
1127 <<
": " << (*i)->GetHelp ()
1128 <<
". Default value: " << val.
Get () <<
". "
1149 os <<
"This is a list of all" <<
reference <<
"ns3::LogComponent instances.\n"
1158 std::size_t widthL = std::string (
"Log Component").size ();
1159 std::size_t widthR = std::string (
"file").size ();
1160 for (
auto it : (*logs))
1162 widthL =
std::max (widthL, it.first.size ());
1163 std::string
file = it.second->File ();
1166 while (
file.find (
"../") == 0)
1172 const std::string sep (
" | ");
1174 os << std::setw (widthL) << std::left <<
"Log Component" << sep
1176 << std::setw (widthR) << std::left <<
"File " << std::endl;
1177 os <<
":" << std::string (widthL - 1,
'-') << sep
1178 <<
":" << std::string (widthR - 1,
'-') << std::endl;
1180 LogComponent::ComponentList::const_iterator it;
1181 for (
auto it : (*logs))
1183 std::string
file = it.second->File ();
1186 while (
file.find (
"../") == 0)
1191 os << std::setw (widthL) << std::left << it.first << sep <<
file << std::endl;
1193 os << std::right << std::endl;
1212 os <<
"This is a list of all" <<
reference <<
"tracing sources. "
1213 <<
"For more information see the " <<
reference <<
"tracing "
1214 <<
"section of this API documentation and the Tracing sections "
1215 <<
"in the Tutorial and Manual.\n"
1222 for (
auto item : nameMap)
1225 if (item.second < 0)
1245 <<
": " << info.
help
1276 const std::string & name,
1277 const bool seeBase =
true)
1280 std::string section =
"attribute_" + name;
1286 << name <<
" Attribute\n"
1287 <<
"Attribute implementation for " << name <<
"\n";
1291 if (name !=
"IeMeshId")
1293 os <<
seeAlso <<
"ns3::" << name <<
"\n";
1297 os <<
seeAlso <<
"ns3::dot11s::" << name <<
"\n";
1317 const std::string & name,
1318 const std::string & type,
1319 const std::string & header)
1322 std::string sectAttr =
sectionStart +
"attribute_" + name;
1326 std::string valClass = name +
"Value";
1327 std::string qualClass =
" ns3::" + valClass;
1330 os <<
classStart << qualClass <<
" \"" << header <<
"\"" << std::endl;
1331 os <<
"AttributeValue implementation for " << name <<
"." << std::endl;
1332 os <<
seeAlso <<
"AttributeValue" << std::endl;
1338 << qualClass <<
"::" << valClass;
1339 if ( (name ==
"EmptyAttribute") ||
1340 (name ==
"ObjectPtrContainer") )
1348 os <<
"(const " << type <<
" & value)\n"
1349 <<
"Copy constructor.\n"
1350 <<
argument <<
"[in] value The " << name <<
" value to copy.\n";
1357 << qualClass <<
"::Get (void) const\n"
1358 <<
returns <<
"The " << name <<
" value.\n"
1364 << qualClass <<
"::GetAccessor (T & value) const\n"
1365 <<
"Access the " << name <<
" value as type " <<
codeWord <<
"T.\n"
1367 <<
argument <<
"[out] value The " << name <<
" value, as type "
1373 if (type !=
"Callback")
1377 << qualClass <<
"::Set (const " << type <<
" & value)\n"
1378 <<
"Set the value.\n"
1379 <<
argument <<
"[in] value The value to adopt.\n"
1386 << qualClass <<
"::m_value\n"
1387 <<
"The stored " << name <<
" instance.\n"
1406 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
1407 std::string make =
"ns3::Make" + name +
"Accessor ";
1412 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeAccessor> "
1413 << make <<
"(T1 a1)\n"
1414 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1)\n"
1415 <<
seeAlso <<
"AttributeAccessor\n"
1421 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeAccessor> "
1422 << make <<
"(T1 a1, T2 a2)\n"
1423 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1,T2)\n"
1424 <<
seeAlso <<
"AttributeAccessor\n"
1440 const std::string & name,
1441 const std::string & header)
1444 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
1445 std::string make =
"ns3::Make" + name +
"Checker ";
1450 os <<
classStart <<
" ns3::" << name <<
"Checker"
1451 <<
" \"" << header <<
"\"" << std::endl;
1452 os <<
"AttributeChecker implementation for " << name <<
"Value." << std::endl;
1453 os <<
seeAlso <<
"AttributeChecker" << std::endl;
1459 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeChecker> "
1460 << make <<
"(void)\n"
1461 <<
returns <<
"The AttributeChecker.\n"
1462 <<
seeAlso <<
"AttributeChecker\n"
1511 {
"Address",
"Address",
true,
"address.h" },
1512 {
"Box",
"Box",
true,
"box.h" },
1513 {
"DataRate",
"DataRate",
true,
"data-rate.h" },
1514 {
"Length",
"Length",
true,
"length.h" },
1515 {
"IeMeshId",
"IeMeshId",
true,
"ie-dot11s-id.h" },
1516 {
"Ipv4Address",
"Ipv4Address",
true,
"ipv4-address.h" },
1517 {
"Ipv4Mask",
"Ipv4Mask",
true,
"ipv4-address.h" },
1518 {
"Ipv6Address",
"Ipv6Address",
true,
"ipv6-address.h" },
1519 {
"Ipv6Prefix",
"Ipv6Prefix",
true,
"ipv6-address.h" },
1520 {
"Mac16Address",
"Mac16Address",
true,
"mac16-address.h" },
1521 {
"Mac48Address",
"Mac48Address",
true,
"mac48-address.h" },
1522 {
"Mac64Address",
"Mac64Address",
true,
"mac64-address.h" },
1523 {
"ObjectFactory",
"ObjectFactory",
true,
"object-factory.h" },
1524 {
"OrganizationIdentifier",
1525 "OrganizationIdentifier",
1526 true,
"vendor-specific-action.h" },
1527 {
"Rectangle",
"Rectangle",
true,
"rectangle.h" },
1528 {
"Ssid",
"Ssid",
true,
"ssid.h" },
1529 {
"TypeId",
"TypeId",
true,
"type-id.h" },
1530 {
"UanModesList",
"UanModesList",
true,
"uan-tx-mode.h" },
1532 {
"Vector",
"Vector",
true,
"vector.h" },
1533 {
"Vector2D",
"Vector2D",
true,
"vector.h" },
1534 {
"Vector3D",
"Vector3D",
true,
"vector.h" },
1535 {
"Waypoint",
"Waypoint",
true,
"waypoint.h" },
1536 {
"WifiMode",
"WifiMode",
true,
"wifi-mode.h" },
1539 {
"Boolean",
"bool",
false,
"boolean.h" },
1540 {
"Callback",
"Callback",
true,
"callback.h" },
1541 {
"Double",
"double",
false,
"double.h" },
1542 {
"Enum",
"int",
false,
"enum.h" },
1543 {
"Integer",
"int64_t",
false,
"integer.h" },
1544 {
"Pointer",
"Pointer",
false,
"pointer.h" },
1545 {
"String",
"std::string",
false,
"string.h" },
1546 {
"Time",
"Time",
true,
"nstime.h" },
1547 {
"Uinteger",
"uint64_t",
false,
"uinteger.h" },
1548 {
"",
"",
false,
"last placeholder" }
1552 while (attributes[i].m_name !=
"")
1589 int main (
int argc,
char *argv[])
1592 bool outputText =
false;
1595 cmd.Usage (
"Generate documentation for all ns-3 registered types, "
1596 "trace sources, attributes and global variables.");
1597 cmd.AddValue (
"output-text",
"format output as plain text", outputText);
1598 cmd.Parse (argc, argv);
1610 std::cout <<
"/* -*- Mode:C++; c-file-style:\"gnu\"; "
1611 "indent-tabs-mode:nil; -*- */\n"
1616 std::cout << std::endl;
1620 <<
"Doxygen docs generated from the TypeId database.\n"
1621 <<
note <<
"This file is automatically generated by "
1622 <<
codeWord <<
"print-introspected-doxygen.cc. Do not edit this file! "
1623 <<
"Edit that file instead.\n"
Parse command-line arguments.
Vector::const_iterator Iterator
Iterator type for the list of all global values.
static Iterator End(void)
The End iterator.
static Iterator Begin(void)
The Begin iterator.
static ComponentList * GetComponentList(void)
Get the list of LogComponnents.
std::map< std::string, LogComponent * > ComponentList
LogComponent name map.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
AttributeChecker implementation for ObjectPtrContainerValue.
virtual TypeId GetItemTypeId(void) const =0
Get the TypeId of the container class type.
AttributeChecker implementation for PointerValue.
virtual TypeId GetPointeeTypeId(void) const =0
Get the TypeId of the base type.
Hold variables of type string.
std::string Get(void) const
a unique identifier for an interface.
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
std::size_t GetTraceSourceN(void) const
Get the number of Trace sources.
std::size_t GetAttributeN(void) const
Get the number of attributes.
struct TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const
Get the trace source by index.
@ ATTR_GET
The attribute can be read.
@ ATTR_SET
The attribute can be written.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
static uint16_t GetRegisteredN(void)
Get the number of registered TypeIds.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
bool MustHideFromDocumentation(void) const
Check if this TypeId should not be listed in documentation.
TypeId GetParent(void) const
Get the parent of this TypeId.
std::string GetName(void) const
Get the name.
std::size_t GetSize(void) const
Get the size of this object.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< Object > GetRootNamespaceObject(uint32_t i)
std::size_t GetRootNamespaceObjectN(void)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void Print(ComponentCarrier cc)
std::string functionStart
start of a method/function
std::string hrefStop
end of a link
std::string referenceNo
block automatic references
std::string anchor
Markup tokens.
std::string argument
function argument
std::string functionStop
end of a method/function
std::string headingStart
start of section heading (h3)
std::string headingStop
end of section heading (h3)
std::string copyDoc
copy (or refer) to docs elsewhere
std::string breakBoth
linebreak
std::string listLineStart
start unordered list item
std::string templateArgument
template argument
std::string returns
the return value
std::string breakHtmlOnly
linebreak for html output only
std::string templArgExplicit
template argument required
std::string hrefStart
start of a link
std::string subSectionStart
start a new subsection
std::string hrefMid
middle part of a link
std::string commentStart
start of code comment
std::string page
start a separate page
std::string seeAlso
Reference to other docs.
std::string commentStop
end of code comment
std::string indentHtmlOnly
small indent
std::string codeWord
format next word as source code
std::string note
start a note section
std::string listLineStop
end unordered list item
std::string listStop
end unordered list
std::string classStop
end of a class
std::string breakTextOnly
linebreak for text output only
std::string brief
brief tag
std::string reference
reference tag
std::string flagSpanStop
end of Attribute flag value
std::string variable
variable or class member
std::string boldStart
start of bold span
std::string boldStop
end of bold span
std::string classStart
start of a class
std::string sectionStart
start of a section or group
std::string listStart
start unordered list
std::string flagSpanStart
start of Attribute flag value
std::string templArgDeduced
template argument deduced from function
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
StaticInformation GetTypicalAggregations()
Register aggregation relationships that are not automatically detected by this introspection program.
void PrintTraceSourcesTid(std::ostream &os, const TypeId tid)
Print direct Trace sources for this TypeId.
void PrintMakeAccessors(std::ostream &os, const std::string &name)
Print the AttributeValue MakeAccessor documentation for a class.
NameMap GetNameMap(void)
Create a map from the class names to their index in the vector of TypeId's so that the names will end...
void PrintAllTraceSources(std::ostream &os)
Print the list of all Trace sources.
void PrintAllLogComponents(std::ostream &os)
Print the list of all LogComponents.
void SetMarkup(bool outputText)
Initialize the markup strings, for either doxygen or text.
void PrintAttributeHelper(std::ostream &os, const AttributeDescriptor &attr)
Print documentation corresponding to use of the ATTRIBUTE_HELPER_HEADER macro or ATTRIBUTE_VALUE_DEFI...
void PrintTypeIdBlocks(std::ostream &os)
Print the doxy block for each TypeId.
void PrintAllAttributes(std::ostream &os)
Print the list of all Attributes.
void PrintAttributeValueWithName(std::ostream &os, const std::string &name, const std::string &type, const std::string &header)
Print the AttributeValue documentation for a class.
std::map< std::string, int32_t > NameMap
Map from TypeId name to tid.
void PrintSize(std::ostream &os, const TypeId tid)
Print the size of the type represented by this tid.
void Uniquefy(T t)
Helper to keep only the unique items in a container.
void PrintAttributeImplementations(std::ostream &os)
Print documentation for Attribute implementations.
void PrintTraceSources(std::ostream &os, const TypeId tid)
Print the Trace sources block for tid, including Trace sources declared in base classes.
NameMap::const_iterator NameMapIterator
NameMap iterator.
void PrintConfigPaths(std::ostream &os, const TypeId tid)
Print config paths.
void PrintAllTypeIds(std::ostream &os)
Print the list of all TypeIds.
void PrintAttributes(std::ostream &os, const TypeId tid)
Print the Attributes block for tid, including Attributes declared in base classes.
void PrintAllGlobals(std::ostream &os)
Print the list of all global variables.
void PrintMakeChecker(std::ostream &os, const std::string &name, const std::string &header)
Print the AttributeValue MakeChecker documentation for a class.
void PrintAttributeValueSection(std::ostream &os, const std::string &name, const bool seeBase=true)
Print the section definition for an AttributeValue.
void PrintAttributesTid(std::ostream &os, const TypeId tid)
Print direct Attributes for this TypeId.
Descriptor for an AttributeValue.
const std::string m_header
The header file name.
const std::string m_type
The name of the underlying type.
const std::string m_name
The base name of the resulting AttributeValue type.
const bool m_seeBase
Print a "see also" pointing to the base class.