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"
111std::map<std::string, ns3::TypeId::AttributeInformation>
114 std::map<std::string, ns3::TypeId::AttributeInformation> index;
118 index[info.
name] = info;
129std::map<std::string, ns3::TypeId::TraceSourceInformation>
132 std::map<std::string, ns3::TypeId::TraceSourceInformation> index;
136 index[info.
name] = info;
148BoldWithId(
const std::string
id,
const std::string displayText)
152 return displayText +
" ";
168 return displayText +
" ";
180SpanWithId(
const std::string
id,
const std::string displayText)
184 return displayText +
" ";
202 commentStart =
"===============================================================\n";
205 file =
"File: introspected-doxygen.txt";
306 void Print(std::ostream& os)
const;
313 std::vector<std::string>
Get(
TypeId tid)
const;
346 std::vector<std::pair<TypeId, std::string>>
m_output;
398 os << item.first.GetName() <<
" -> " << item.second << std::endl;
406 std::ostringstream oss;
435std::vector<std::string>
439 std::vector<std::string> paths;
442 if (item.first == tid)
444 paths.push_back(item.second);
469 std::sort(t.begin(), t.end());
470 t.erase(std::unique(t.begin(), t.end()), t.end());
473std::vector<std::string>
502 if (ptrChecker !=
nullptr)
504 TypeId pointee = ptrChecker->GetPointeeTypeId();
508 if (objectTypeId == pointee)
525 const auto vectorChecker =
527 if (vectorChecker !=
nullptr)
529 TypeId item = vectorChecker->GetItemTypeId();
543 std::string childName =
"$" + child.
GetName();
553 if (item.first == tid || item.second == tid)
556 if (item.first == tid)
560 if (item.second == tid)
564 std::string name =
"$" + other.
GetName();
584 static bool mapped =
false;
638typedef std::map<std::string, int32_t>
NameMap;
653 static bool mapped =
false;
678 std::transform(
name.begin(),
name.end(),
name.begin(), ::toupper);
686 for (
const auto& item : noTids)
707 static bool mapped =
false;
714 for (
const auto& item : nameMap)
727 groups[group].insert(tid);
771 os <<
SpanWithId(
"config-paths",
"Introspection did not find any typical Config paths")
776 os <<
HeadingWithId(
"config-paths",
"Config Paths") <<
"\n\n"
777 << tid.
GetName() <<
" is accessible through the following paths"
778 <<
" with Config::Set and Config::Connect:\n"
780 for (
const auto& path : paths)
804 for (
const auto& [
name, info] : index)
809 << info.checker->GetValueTypeName() <<
listLineStop <<
"\n";
811 std::string underType;
812 if (info.checker->HasUnderlyingTypeInformation())
816 std::string valType = info.checker->GetValueTypeName();
817 underType = info.checker->GetUnderlyingTypeInformation();
818 bool handled =
false;
819 if ((valType !=
"ns3::EnumValue") && (underType !=
"std::string"))
822 if (valType ==
"ns3::PointerValue")
824 const auto ptrChecker =
826 if (ptrChecker !=
nullptr)
829 <<
"< " <<
reference << ptrChecker->GetPointeeTypeId().GetName() <<
">";
833 else if (valType ==
"ns3::ObjectPtrContainerValue")
835 const auto ptrChecker =
837 if (ptrChecker !=
nullptr)
840 <<
"< " <<
reference << ptrChecker->GetItemTypeId().GetName() <<
">";
846 auto match = [&uType = std::as_const(underType)](
const std::string& s) {
847 return uType.rfind(s, 0) == 0;
850 if (match(
"bool") || match(
"double") || match(
"int8_t") || match(
"uint8_t") ||
851 match(
"int16_t") || match(
"uint16_t") || match(
"int32_t") ||
852 match(
"uint32_t") || match(
"int64_t") || match(
"uint64_t"))
866 std::string value = info.initialValue->SerializeToString(info.checker);
867 if (underType ==
"std::string" && value.empty())
873 bool moreFlags{
false};
879 std::string msg) ->
void {
880 if (myInfo.flags & flag && hasFunc)
919 os <<
HeadingWithId(
"attributes",
"Attributes") << std::endl;
953 for (
const auto& [
name, info] : index)
963 os <<
"Callback signature: " << info.callback <<
"\n" <<
listLineStop <<
"\n";
987 os <<
SpanWithId(
"trace-sources",
"No TraceSources are defined for this type") <<
breakBoth
992 os <<
HeadingWithId(
"trace-sources",
"TraceSources") << std::endl;
1023 std::size_t arch = (
sizeof(
void*) * CHAR_BIT);
1025 os <<
BoldWithId(
"size",
"Size") <<
"of this type is " << tid.
GetSize() <<
" bytes (on a "
1026 << arch <<
"-bit architecture)." <<
breakBoth << std::endl;
1077 for (
const auto& item : nameMap)
1080 if (item.second < 0)
1104 <<
"This is a list of all" <<
reference <<
"ns3::TypeId's.\n"
1105 <<
"For more information see the" <<
reference <<
"ns3::TypeId "
1106 <<
"section of this API documentation and the" <<
referenceNo <<
"TypeId section "
1107 <<
"in the Configuration and " <<
referenceNo <<
"Attributes chapter of the Manual.\n\n";
1114 for (
const auto& item : nameMap)
1117 if (item.second < 0)
1144 <<
"This is a list of all" <<
reference <<
"attributes classes. "
1145 <<
"For more information see the" <<
reference <<
"attributes "
1146 <<
"section of this API documentation and the Attributes sections "
1147 <<
"in the Tutorial and Manual.\n\n";
1152 for (
const auto& item : nameMap)
1155 if (item.second < 0)
1170 for (
const auto& [
name, info] : index)
1191 <<
"This is a list of all" <<
reference <<
"ns3::GlobalValue instances.\n"
1192 <<
"See ns3::GlobalValue for how to set these.\n";
1198 (*i)->GetValue(val);
1201 << (*i)->GetHelp() <<
". Default value: " << val.
Get() <<
"." <<
listLineStop <<
"\n";
1217 <<
"This is a list of all Object Groups.\n"
1218 <<
"Objects are added to groups by " <<
hrefStart <<
"ns3::TypeId::SetGroupName()" <<
hrefMid
1219 <<
"ns3::TypeId::SetGroupName" <<
hrefStop <<
"\n\n";
1223 for (
const auto& g : groups)
1228 for (
const auto& tid : g.second)
1248 <<
"This is a list of all" <<
reference <<
"ns3::LogComponent instances.\n\n";
1256 std::size_t widthL = std::string(
"Log Component").size();
1257 std::size_t widthR = std::string(
"file").size();
1258 for (
const auto& it : (*logs))
1260 widthL = std::max(widthL, it.first.size());
1261 std::string
file = it.second->File();
1264 while (
file.find(
"../") == 0)
1268 widthR = std::max(widthR,
file.size());
1270 const std::string tLeft(
"| ");
1271 const std::string tMid(
" | ");
1272 const std::string tRight(
" |");
1275 os << tLeft << std::setw(widthL) << std::left <<
"Log Component" << tMid << std::setw(widthR)
1276 << std::left <<
"File" << tRight <<
"\n"
1277 << tLeft <<
":" << std::string(widthL - 1,
'-') << tMid <<
":"
1278 << std::string(widthR - 1,
'-') << tRight <<
"\n";
1280 for (
const auto& it : (*logs))
1282 std::string
file = it.second->File();
1285 while (
file.find(
"../") == 0)
1290 os << tLeft << std::setw(widthL) << std::left << it.first << tMid << std::setw(widthR)
1291 <<
file << tRight <<
"\n";
1293 os << std::right <<
"\n" <<
commentStop << std::endl;
1309 <<
"This is a list of all" <<
reference <<
"tracing sources. "
1310 <<
"For more information see the " <<
reference <<
"tracing "
1311 <<
"section of this API documentation and the Tracing sections "
1312 <<
"in the Tutorial and Manual.\n\n";
1318 for (
const auto& item : nameMap)
1321 if (item.second < 0)
1338 for (
const auto& [
name, info] : index)
1370 std::string section =
"attribute_" +
name;
1376 <<
"AttributeValue implementation for " <<
name <<
"\n";
1397 const std::string&
name,
1398 const std::string& type,
1399 const std::string& header)
1406 std::string valClass =
name +
"Value";
1407 std::string qualClass =
" ns3::" + valClass;
1410 <<
classStart << qualClass <<
" \"" << header <<
"\"\n"
1411 <<
"AttributeValue implementation for " <<
name <<
".\n"
1412 <<
seeAlso <<
"ns3::AttributeValue\n"
1419 os <<
"(const " << type <<
" & value)\n"
1421 <<
argument <<
"[in] value The " <<
name <<
" value to use.\n";
1431 <<
"Access the " <<
name <<
" value as type " <<
codeWord <<
"T.\n"
1438 if (type !=
"Callback")
1442 <<
"Set the value.\n"
1443 <<
argument <<
"[in] value The value to adopt.\n"
1449 <<
"The stored " <<
name <<
" instance.\n"
1467 std::string make =
"ns3::Make" +
name +
"Accessor ";
1472 << make <<
"(T1 a1)\n"
1473 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1)\n"
1474 <<
seeAlso <<
"ns3::AttributeAccessor\n"
1481 << make <<
"(T1 a1, T2 a2)\n"
1482 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1,T2)\n"
1483 <<
seeAlso <<
"ns3::AttributeAccessor\n"
1502 std::string make =
"ns3::Make" +
name +
"Checker ";
1508 <<
" \"" << header <<
"\"\n"
1509 <<
"AttributeChecker implementation for " <<
name <<
"Value.\n"
1510 <<
seeAlso <<
"ns3::AttributeChecker\n"
1518 <<
returns <<
"The AttributeChecker.\n"
1519 <<
seeAlso <<
"ns3::AttributeChecker\n"
1566 {
"Address",
"Address",
true,
"address.h" },
1567 {
"Box",
"Box",
true,
"box.h" },
1568 {
"DataRate",
"DataRate",
true,
"data-rate.h" },
1569 {
"Length",
"Length",
true,
"length.h" },
1570 {
"Ipv4Address",
"Ipv4Address",
true,
"ipv4-address.h" },
1571 {
"Ipv4Mask",
"Ipv4Mask",
true,
"ipv4-address.h" },
1572 {
"Ipv6Address",
"Ipv6Address",
true,
"ipv6-address.h" },
1573 {
"Ipv6Prefix",
"Ipv6Prefix",
true,
"ipv6-address.h" },
1574 {
"Mac16Address",
"Mac16Address",
true,
"mac16-address.h" },
1575 {
"Mac48Address",
"Mac48Address",
true,
"mac48-address.h" },
1576 {
"Mac64Address",
"Mac64Address",
true,
"mac64-address.h" },
1577 {
"ObjectFactory",
"ObjectFactory",
true,
"object-factory.h" },
1578 {
"Priomap",
"Priomap",
true,
"prio-queue-disc.h" },
1579 {
"QueueSize",
"QueueSize",
true,
"queue-size.h" },
1580 {
"Rectangle",
"Rectangle",
true,
"rectangle.h" },
1581 {
"Ssid",
"Ssid",
true,
"ssid.h" },
1582 {
"TypeId",
"TypeId",
true,
"type-id.h" },
1583 {
"UanModesList",
"UanModesList",
true,
"uan-tx-mode.h" },
1584 {
"ValueClassTest",
"ValueClassTest",
false,
"attribute-test-suite.cc" },
1585 {
"Vector2D",
"Vector2D",
true,
"vector.h" },
1586 {
"Vector3D",
"Vector3D",
true,
"vector.h" },
1587 {
"Waypoint",
"Waypoint",
true,
"waypoint.h" },
1588 {
"WifiMode",
"WifiMode",
true,
"wifi-mode.h" },
1591 {
"Boolean",
"bool",
false,
"boolean.h" },
1592 {
"Callback",
"CallbackBase",
true,
"callback.h" },
1593 {
"Double",
"double",
false,
"double.h" },
1594 {
"Enum",
"T",
false,
"enum.h" },
1595 {
"Integer",
"int64_t",
false,
"integer.h" },
1596 {
"String",
"std::string",
false,
"string.h" },
1597 {
"Time",
"Time",
true,
"nstime.h" },
1598 {
"Uinteger",
"uint64_t",
false,
"uinteger.h" },
1599 {
"",
"",
false,
"last placeholder" }
1604 while (!attributes[i].m_name.empty())
1625main(
int argc,
char* argv[])
1632 cmd.Usage(
"Generate documentation for all ns-3 registered types, "
1633 "trace sources, attributes and global variables.");
1634 cmd.AddValue(
"output-text",
"format output as plain text",
outputText);
1635 cmd.AddValue(
"TypeId",
"Print docs for just the given TypeId", typeId);
1636 cmd.Parse(argc, argv);
1638 if (!typeId.empty())
1648 auto fqTypeId =
"ns3::" + typeId;
1652 std::cout <<
"\nFound fully qualified name " << fqTypeId <<
"\n\n";
1662 std::cerr <<
"Invalid TypeId name: " << typeId <<
"\n\n" <<
cmd << std::endl;
1676 <<
"Doxygen docs generated from the ns3::TypeId database.\n"
1677 <<
note <<
"This file is automatically generated by " <<
codeWord
1678 <<
"print-introspected-doxygen.cc. Do not edit this file! "
1679 <<
"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.
static TypeId GetTypeId()
Register this type.
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.
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 headingWithIdMid
middle of section heading with id (h3)
std::string functionStart
start of a method/function
std::string hrefStop
end of a link
std::string spanWithIdStop
end of span with id
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 headingWithIdStop
end of section heading with id (h3)
std::string HeadingWithId(const std::string id, const std::string displayText)
Generate heading (h3) markup with id if not generating text only.
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 spanWithIdStart
start of span with id
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 headingWithIdStart
start of section heading with id (h3)
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 hideCaller
hide caller graph
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 SpanWithId(const std::string id, const std::string displayText)
Generate span (span) HTML markup with id if not generating text only.
std::string brief
brief tag
std::string reference
reference tag
std::string flagSpanStop
end of Attribute flag value
std::string boldWithIdMid
middle of bold span with id
std::string boldWithIdStop
end of bold span with id
std::string BoldWithId(const std::string id, const std::string displayText)
Generate bold (b) HTML markup with id if not generating text only.
std::string boldWithIdStart
start of bold with id
std::string spanWithIdMid
middle of span with id
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.