15#include "ns3/command-line.h"
16#include "ns3/config.h"
17#include "ns3/global-value.h"
19#include "ns3/node-container.h"
20#include "ns3/object-vector.h"
21#include "ns3/object.h"
22#include "ns3/pointer.h"
23#include "ns3/simple-channel.h"
24#include "ns3/string.h"
25#include "ns3/system-path.h"
97std::map<std::string, ns3::TypeId::AttributeInformation>
100 std::map<std::string, ns3::TypeId::AttributeInformation> index;
104 index[info.
name] = info;
115std::map<std::string, ns3::TypeId::TraceSourceInformation>
118 std::map<std::string, ns3::TypeId::TraceSourceInformation> index;
122 index[info.
name] = info;
149 commentStart =
"===============================================================\n";
152 file =
"File: introspected-doxygen.txt";
255 void Print(std::ostream& os)
const;
262 std::vector<std::string>
Get(
TypeId tid)
const;
295 std::vector<std::pair<TypeId, std::string>>
m_output;
346 os << item.first.GetName() <<
" -> " << item.second << std::endl;
354 std::ostringstream oss;
383std::vector<std::string>
387 std::vector<std::string> paths;
390 if (item.first == tid)
392 paths.push_back(item.second);
417 std::sort(t.begin(), t.end());
418 t.erase(std::unique(t.begin(), t.end()), t.end());
421std::vector<std::string>
450 if (ptrChecker !=
nullptr)
452 TypeId pointee = ptrChecker->GetPointeeTypeId();
456 TypeId objectTypeId =
object->GetTypeId();
457 if (objectTypeId == pointee)
474 const auto vectorChecker =
476 if (vectorChecker !=
nullptr)
478 TypeId item = vectorChecker->GetItemTypeId();
492 std::string childName =
"$" + child.
GetName();
502 if (item.first == tid || item.second == tid)
505 if (item.first == tid)
509 if (item.second == tid)
513 std::string name =
"$" + other.
GetName();
533 static bool mapped =
false;
587typedef std::map<std::string, int32_t>
NameMap;
602 static bool mapped =
false;
627 std::transform(
name.begin(),
name.end(),
name.begin(), ::toupper);
635 for (
const auto& item : noTids)
656 static bool mapped =
false;
663 for (
const auto& item : nameMap)
676 groups[group].insert(tid);
734 os <<
"Introspection did not find any typical Config paths." <<
breakBoth << std::endl;
740 os << tid.
GetName() <<
" is accessible through the following paths"
741 <<
" with Config::Set and Config::Connect:" << std::endl;
743 for (
const auto& path : paths)
768 for (
const auto& [
name, info] : index)
773 << info.checker->GetValueTypeName() <<
listLineStop << std::endl;
775 std::string underType;
776 if (info.checker->HasUnderlyingTypeInformation())
780 std::string valType = info.checker->GetValueTypeName();
781 underType = info.checker->GetUnderlyingTypeInformation();
782 bool handled =
false;
783 if ((valType !=
"ns3::EnumValue") && (underType !=
"std::string"))
786 if (valType ==
"ns3::PointerValue")
788 const auto ptrChecker =
790 if (ptrChecker !=
nullptr)
793 <<
"< " <<
reference << ptrChecker->GetPointeeTypeId().GetName() <<
">";
797 else if (valType ==
"ns3::ObjectPtrContainerValue")
799 const auto ptrChecker =
801 if (ptrChecker !=
nullptr)
804 <<
"< " <<
reference << ptrChecker->GetItemTypeId().GetName() <<
">";
810 auto match = [&uType = std::as_const(underType)](
const std::string& s) {
811 return uType.rfind(s, 0) == 0;
814 if (match(
"bool") || match(
"double") || match(
"int8_t") || match(
"uint8_t") ||
815 match(
"int16_t") || match(
"uint16_t") || match(
"int32_t") ||
816 match(
"uint32_t") || match(
"int64_t") || match(
"uint64_t"))
830 std::string value = info.initialValue->SerializeToString(info.checker);
831 if (underType ==
"std::string" && value.empty())
838 bool moreFlags{
false};
844 std::string msg) ->
void {
845 if (myInfo.flags & flag && hasFunc)
879 os <<
"No Attributes are defined for this type." <<
breakBoth << std::endl;
918 for (
const auto& [
name, info] : index)
928 os <<
"Callback signature: " << info.callback << std::endl;
953 os <<
"No TraceSources are defined for this type." <<
breakBoth << std::endl;
988 std::size_t arch = (
sizeof(
void*) * CHAR_BIT);
991 << arch <<
"-bit architecture)." << std::endl;
1041 for (
const auto& item : nameMap)
1044 if (item.second < 0)
1068 os <<
commentStart <<
page <<
"TypeIdList All ns3::TypeId's\n" << std::endl;
1069 os <<
"This is a list of all" <<
reference <<
"ns3::TypeId's.\n"
1070 <<
"For more information see the" <<
reference <<
"ns3::TypeId "
1071 <<
"section of this API documentation and the" <<
referenceNo <<
"TypeId section "
1072 <<
"in the Configuration and " <<
referenceNo <<
"Attributes chapter of the Manual.\n"
1080 for (
const auto& item : nameMap)
1083 if (item.second < 0)
1110 os <<
commentStart <<
page <<
"AttributeList All Attributes\n" << std::endl;
1111 os <<
"This is a list of all" <<
reference <<
"attributes classes. "
1112 <<
"For more information see the" <<
reference <<
"attributes "
1113 <<
"section of this API documentation and the Attributes sections "
1114 <<
"in the Tutorial and Manual.\n"
1120 for (
const auto& item : nameMap)
1123 if (item.second < 0)
1139 for (
const auto& [
name, info] : index)
1159 os <<
commentStart <<
page <<
"GlobalValueList All GlobalValues\n" << std::endl;
1160 os <<
"This is a list of all" <<
reference <<
"ns3::GlobalValue instances.\n"
1161 <<
"See ns3::GlobalValue for how to set these." << std::endl;
1167 (*i)->GetValue(val);
1170 << (*i)->GetHelp() <<
". Default value: " << val.
Get() <<
"." <<
listLineStop
1187 os <<
commentStart <<
page <<
"GroupsList All Object Groups\n" << std::endl;
1188 os <<
"This is a list of all Object Groups.\n"
1189 <<
"Objects are added to groups by " <<
hrefStart <<
"ns3::TypeId::SetGroupName()" <<
hrefMid
1190 <<
"ns3::TypeId::SetGroupName" <<
hrefStop <<
"\n"
1195 for (
const auto& g : groups)
1200 for (
const auto& tid : g.second)
1219 os <<
commentStart <<
page <<
"LogComponentList All LogComponents\n" << std::endl;
1220 os <<
"This is a list of all" <<
reference <<
"ns3::LogComponent instances.\n" << std::endl;
1228 std::size_t widthL = std::string(
"Log Component").size();
1229 std::size_t widthR = std::string(
"file").size();
1230 for (
const auto& it : (*logs))
1232 widthL = std::max(widthL, it.first.size());
1233 std::string
file = it.second->File();
1236 while (
file.find(
"../") == 0)
1240 widthR = std::max(widthR,
file.size());
1242 const std::string tLeft(
"| ");
1243 const std::string tMid(
" | ");
1244 const std::string tRight(
" |");
1247 os << tLeft << std::setw(widthL) << std::left <<
"Log Component" << tMid << std::setw(widthR)
1248 << std::left <<
"File" << tRight << std::endl;
1249 os << tLeft <<
":" << std::string(widthL - 1,
'-') << tMid <<
":"
1250 << std::string(widthR - 1,
'-') << tRight << std::endl;
1252 for (
const auto& it : (*logs))
1254 std::string
file = it.second->File();
1257 while (
file.find(
"../") == 0)
1262 os << tLeft << std::setw(widthL) << std::left << it.first << tMid << std::setw(widthR)
1263 <<
file << tRight << std::endl;
1265 os << std::right << std::endl;
1281 os <<
commentStart <<
page <<
"TraceSourceList All TraceSources\n" << std::endl;
1282 os <<
"This is a list of all" <<
reference <<
"tracing sources. "
1283 <<
"For more information see the " <<
reference <<
"tracing "
1284 <<
"section of this API documentation and the Tracing sections "
1285 <<
"in the Tutorial and Manual.\n"
1292 for (
const auto& item : nameMap)
1295 if (item.second < 0)
1312 for (
const auto& [
name, info] : index)
1344 std::string section =
"attribute_" +
name;
1350 <<
"AttributeValue implementation for " <<
name <<
"\n";
1371 const std::string&
name,
1372 const std::string& type,
1373 const std::string& header)
1380 std::string valClass =
name +
"Value";
1381 std::string qualClass =
" ns3::" + valClass;
1384 os <<
classStart << qualClass <<
" \"" << header <<
"\"" << std::endl;
1385 os <<
"AttributeValue implementation for " <<
name <<
"." << std::endl;
1386 os <<
seeAlso <<
"AttributeValue" << std::endl;
1392 os <<
"(const " << type <<
" & value)\n"
1394 <<
argument <<
"[in] value The " <<
name <<
" value to use.\n";
1404 <<
"Access the " <<
name <<
" value as type " <<
codeWord <<
"T.\n"
1411 if (type !=
"Callback")
1415 <<
"Set the value.\n"
1416 <<
argument <<
"[in] value The value to adopt.\n"
1422 <<
"The stored " <<
name <<
" instance.\n"
1440 std::string make =
"ns3::Make" +
name +
"Accessor ";
1445 << make <<
"(T1 a1)\n"
1446 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1)\n"
1447 <<
seeAlso <<
"AttributeAccessor\n"
1453 << make <<
"(T1 a1, T2 a2)\n"
1454 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1,T2)\n"
1455 <<
seeAlso <<
"AttributeAccessor\n"
1473 std::string make =
"ns3::Make" +
name +
"Checker ";
1479 <<
" \"" << header <<
"\"" << std::endl;
1480 os <<
"AttributeChecker implementation for " <<
name <<
"Value." << std::endl;
1481 os <<
seeAlso <<
"AttributeChecker" << std::endl;
1488 <<
returns <<
"The AttributeChecker.\n"
1489 <<
seeAlso <<
"AttributeChecker\n"
1535 {
"Address",
"Address",
true,
"address.h" },
1536 {
"Box",
"Box",
true,
"box.h" },
1537 {
"DataRate",
"DataRate",
true,
"data-rate.h" },
1538 {
"Length",
"Length",
true,
"length.h" },
1539 {
"Ipv4Address",
"Ipv4Address",
true,
"ipv4-address.h" },
1540 {
"Ipv4Mask",
"Ipv4Mask",
true,
"ipv4-address.h" },
1541 {
"Ipv6Address",
"Ipv6Address",
true,
"ipv6-address.h" },
1542 {
"Ipv6Prefix",
"Ipv6Prefix",
true,
"ipv6-address.h" },
1543 {
"Mac16Address",
"Mac16Address",
true,
"mac16-address.h" },
1544 {
"Mac48Address",
"Mac48Address",
true,
"mac48-address.h" },
1545 {
"Mac64Address",
"Mac64Address",
true,
"mac64-address.h" },
1546 {
"ObjectFactory",
"ObjectFactory",
true,
"object-factory.h" },
1547 {
"Priomap",
"Priomap",
true,
"prio-queue-disc.h" },
1548 {
"QueueSize",
"QueueSize",
true,
"queue-size.h" },
1549 {
"Rectangle",
"Rectangle",
true,
"rectangle.h" },
1550 {
"Ssid",
"Ssid",
true,
"ssid.h" },
1551 {
"TypeId",
"TypeId",
true,
"type-id.h" },
1552 {
"UanModesList",
"UanModesList",
true,
"uan-tx-mode.h" },
1553 {
"ValueClassTest",
"ValueClassTest",
false,
"attribute-test-suite.cc" },
1554 {
"Vector2D",
"Vector2D",
true,
"vector.h" },
1555 {
"Vector3D",
"Vector3D",
true,
"vector.h" },
1556 {
"Waypoint",
"Waypoint",
true,
"waypoint.h" },
1557 {
"WifiMode",
"WifiMode",
true,
"wifi-mode.h" },
1560 {
"Boolean",
"bool",
false,
"boolean.h" },
1561 {
"Callback",
"CallbackBase",
true,
"callback.h" },
1562 {
"Double",
"double",
false,
"double.h" },
1563 {
"Enum",
"T",
false,
"enum.h" },
1564 {
"Integer",
"int64_t",
false,
"integer.h" },
1565 {
"String",
"std::string",
false,
"string.h" },
1566 {
"Time",
"Time",
true,
"nstime.h" },
1567 {
"Uinteger",
"uint64_t",
false,
"uinteger.h" },
1568 {
"",
"",
false,
"last placeholder" }
1573 while (!attributes[i].m_name.empty())
1594main(
int argc,
char* argv[])
1601 cmd.Usage(
"Generate documentation for all ns-3 registered types, "
1602 "trace sources, attributes and global variables.");
1603 cmd.AddValue(
"output-text",
"format output as plain text",
outputText);
1604 cmd.AddValue(
"TypeId",
"Print docs for just the given TypeId", typeId);
1605 cmd.Parse(argc, argv);
1607 if (!typeId.empty())
1617 auto fqTypeId =
"ns3::" + typeId;
1621 std::cout <<
"\nFound fully qualified name " << fqTypeId <<
"\n\n";
1631 std::cerr <<
"Invalid TypeId name: " << typeId <<
"\n" << std::endl;
1643 std::cout << std::endl;
1646 <<
"Doxygen docs generated from the TypeId database.\n"
1647 <<
note <<
"This file is automatically generated by " <<
codeWord
1648 <<
"print-introspected-doxygen.cc. Do not edit this file! "
1649 <<
"Edit that file instead.\n"
Parse command-line arguments.
static Iterator Begin()
The Begin iterator.
static Iterator End()
The End iterator.
static ComponentList * GetComponentList()
Get the list of LogComponents.
std::unordered_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.
AttributeChecker implementation for ObjectPtrContainerValue.
AttributeChecker implementation for PointerValue.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
a unique identifier for an interface.
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
std::size_t GetTraceSourceN() const
Get the number of Trace sources.
bool MustHideFromDocumentation() const
Check if this TypeId should not be listed in documentation.
AttributeFlag
Flags describing when a given attribute can be read or written.
@ ATTR_GET
The attribute can be read.
@ ATTR_SET
The attribute can be written.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const
Get the trace source by index.
std::string GetGroupName() const
Get the group name.
static uint16_t GetRegisteredN()
Get the number of registered TypeIds.
std::size_t GetAttributeN() const
Get the number of attributes.
TypeId GetParent() const
Get the parent of this TypeId.
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
std::size_t GetSize() const
Get the size of this object.
TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
SupportLevel
The level of support or deprecation for attributes or trace sources.
@ SUPPORTED
Attribute or trace source is currently used.
@ OBSOLETE
Attribute or trace source is not used anymore; simulation fails.
@ DEPRECATED
Attribute or trace source is deprecated; user is warned.
std::string GetName() const
Get the 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()
#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 ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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::map< std::string, ns3::TypeId::TraceSourceInformation > SortedTraceSourceInfo(const TypeId tid)
Alphabetize the TraceSourceInformation for a TypeId by the TraceSource name.
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::map< std::string, ns3::TypeId::AttributeInformation > SortedAttributeInfo(const TypeId tid)
Alphabetize the AttributeInformation for a TypeId by the Attribute name.
bool outputText
Are we generating text or Doxygen?
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.
std::set< TypeId > GroupList_t
List of TypeIds for a group.
std::map< std::string, int32_t > NameMap
Map from TypeId name to tid.
void PrintMakeAccessors(std::ostream &os, const std::string &name)
Print the AttributeValue MakeAccessor documentation for a class.
void PrintAllTraceSources(std::ostream &os)
Print the list of all Trace sources.
void PrintAllLogComponents(std::ostream &os)
Print the list of all LogComponents.
void PrintAttributeHelper(std::ostream &os, const AttributeDescriptor &attr)
Print documentation corresponding to use of the ATTRIBUTE_HELPER_HEADER macro or ATTRIBUTE_VALUE_DEFI...
void PrintTypeIdBlock(std::ostream &os, const TypeId tid)
Print the doxy block for a single TypeId.
void PrintTypeIdBlocks(std::ostream &os)
Print the doxy block for each TypeId.
std::map< std::string, GroupList_t > GroupsList_t
Collection of group names with associated TypeIds.
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.
GroupsList_t GetGroupsList()
Get a sorted list of TypeId groups.
void PrintSupportLevel(std::ostream &os, TypeId::SupportLevel supportLevel, std::string supportMsg)
Print the support level for an Attribute or TraceSource.
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.
NameMap GetNameMap()
Create a map from the class names to their index in the vector of TypeId's so that the names will end...
void PrintTraceSources(std::ostream &os, const TypeId tid)
Print the Trace sources block for tid, including Trace sources declared in base classes.
void SetMarkup()
Initialize the markup strings, for either doxygen or text.
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 PrintAllGroups(std::ostream &os)
Print the list of all groups.
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.