26#include "ns3/command-line.h"
27#include "ns3/config.h"
28#include "ns3/global-value.h"
30#include "ns3/node-container.h"
31#include "ns3/object-vector.h"
32#include "ns3/object.h"
33#include "ns3/pointer.h"
34#include "ns3/simple-channel.h"
35#include "ns3/string.h"
36#include "ns3/system-path.h"
125 commentStart =
"===============================================================\n";
128 file =
"File: introspected-doxygen.txt";
237 std::vector<std::string>
Get(
TypeId tid)
const;
270 std::vector<std::pair<TypeId, std::string>>
m_output;
298 bool found = TypeId::LookupByNameFailSafe(a, &aTid);
305 found = TypeId::LookupByNameFailSafe(b, &bTid);
321 std::cout << item.first.GetName() <<
" -> " << item.second << std::endl;
329 std::ostringstream oss;
358std::vector<std::string>
362 std::vector<std::string> paths;
365 if (item.first == tid)
367 paths.push_back(item.second);
392 std::sort(t.begin(), t.end());
393 t.erase(std::unique(t.begin(), t.end()), t.end());
396std::vector<std::string>
426 if (ptrChecker !=
nullptr)
432 TypeId objectTypeId =
object->GetTypeId();
433 if (objectTypeId == pointee)
452 if (vectorChecker !=
nullptr)
463 for (
uint32_t j = 0; j < TypeId::GetRegisteredN(); j++)
465 TypeId child = TypeId::GetRegistered(j);
468 std::string childName =
"$" + child.
GetName();
478 if (item.first == tid || item.second == tid)
481 if (item.first == tid)
485 if (item.second == tid)
489 std::string name =
"$" + other.
GetName();
509 static bool mapped =
false;
550 simpleChannel = CreateObject<SimpleChannel>();
563typedef std::map<std::string, int32_t>
NameMap;
578 static bool mapped =
false;
592 for (
uint32_t i = 0; i < TypeId::GetRegisteredN(); i++)
594 TypeId tid = TypeId::GetRegistered(i);
602 std::string name = tid.
GetName();
603 std::transform(name.begin(), name.end(), name.begin(), ::toupper);
611 for (
const auto& item : noTids)
637 os <<
"Introspection did not find any typical Config paths." <<
breakBoth << std::endl;
643 os << tid.
GetName() <<
" is accessible through the following paths"
644 <<
" with Config::Set and Config::Connect:" << std::endl;
646 for (
const auto&
path : paths)
676 std::string underType;
677 if (info.
checker->HasUnderlyingTypeInformation())
681 std::string valType = info.
checker->GetValueTypeName();
682 underType = info.
checker->GetUnderlyingTypeInformation();
683 bool handled =
false;
684 if ((valType !=
"ns3::EnumValue") && (underType !=
"std::string"))
687 if (valType ==
"ns3::PointerValue")
691 if (ptrChecker !=
nullptr)
698 else if (valType ==
"ns3::ObjectPtrContainerValue")
702 if (ptrChecker !=
nullptr)
711 class StringBeginMatcher
714 StringBeginMatcher(
const std::string s)
717 bool operator()(
const std::string t)
719 std::size_t pos = m_string.find(t);
724 std::string m_string;
727 StringBeginMatcher match(underType);
729 if (match(
"bool") || match(
"double") || match(
"int8_t") || match(
"uint8_t") ||
730 match(
"int16_t") || match(
"uint16_t") || match(
"int32_t") ||
731 match(
"uint32_t") || match(
"int64_t") || match(
"uint64_t"))
743 if (info.
flags & TypeId::ATTR_CONSTRUCT && info.
accessor->HasSetter())
746 if (underType ==
"std::string" &&
value ==
"")
753 bool moreFlags{
false};
755 if (info.
flags & TypeId::ATTR_CONSTRUCT && info.
accessor->HasSetter())
760 if (info.
flags & TypeId::ATTR_SET && info.
accessor->HasSetter())
765 if (info.
flags & TypeId::ATTR_GET && info.
accessor->HasGetter())
792 os <<
"No Attributes are defined for this type." <<
breakBoth << std::endl;
837 os <<
"Callback signature: " << info.
callback << std::endl;
859 os <<
"No TraceSources are defined for this type." <<
breakBoth << std::endl;
894 std::size_t arch = (
sizeof(
void*) * CHAR_BIT);
897 << arch <<
"-bit architecture)." << std::endl;
914 for (
const auto& item : nameMap)
922 TypeId tid = TypeId::GetRegistered(item.second);
923 std::string name = tid.
GetName();
928 std::cout << std::endl;
953 os <<
commentStart <<
page <<
"TypeIdList All ns3::TypeId's\n" << std::endl;
954 os <<
"This is a list of all" <<
reference <<
"ns3::TypeId's.\n"
955 <<
"For more information see the" <<
reference <<
"ns3::TypeId "
956 <<
"section of this API documentation and the" <<
referenceNo <<
"TypeId section "
957 <<
"in the Configuration and " <<
referenceNo <<
"Attributes chapter of the Manual.\n"
965 for (
const auto& item : nameMap)
973 TypeId tid = TypeId::GetRegistered(item.second);
995 os <<
commentStart <<
page <<
"AttributeList All Attributes\n" << std::endl;
996 os <<
"This is a list of all" <<
reference <<
"attributes classes. "
997 <<
"For more information see the" <<
reference <<
"attributes "
998 <<
"section of this API documentation and the Attributes sections "
999 <<
"in the Tutorial and Manual.\n"
1005 for (
const auto& item : nameMap)
1008 if (item.second < 0)
1013 TypeId tid = TypeId::GetRegistered(item.second);
1043 os <<
commentStart <<
page <<
"GlobalValueList All GlobalValues\n" << std::endl;
1044 os <<
"This is a list of all" <<
reference <<
"ns3::GlobalValue instances.\n"
1045 <<
"See ns3::GlobalValue for how to set these." << std::endl;
1051 (*i)->GetValue(val);
1054 << (*i)->GetHelp() <<
". Default value: " << val.
Get() <<
"." <<
listLineStop
1071 os <<
commentStart <<
page <<
"LogComponentList All LogComponents\n" << std::endl;
1072 os <<
"This is a list of all" <<
reference <<
"ns3::LogComponent instances.\n" << std::endl;
1080 std::size_t widthL = std::string(
"Log Component").size();
1081 std::size_t widthR = std::string(
"file").size();
1082 for (
const auto& it : (*logs))
1084 widthL =
std::max(widthL, it.first.size());
1085 std::string
file = it.second->File();
1088 while (
file.find(
"../") == 0)
1094 const std::string tLeft(
"| ");
1095 const std::string tMid(
" | ");
1096 const std::string tRight(
" |");
1099 os << tLeft << std::setw(widthL) << std::left <<
"Log Component" << tMid << std::setw(widthR)
1100 << std::left <<
"File" << tRight << std::endl;
1101 os << tLeft <<
":" << std::string(widthL - 1,
'-') << tMid <<
":"
1102 << std::string(widthR - 1,
'-') << tRight << std::endl;
1104 LogComponent::ComponentList::const_iterator it;
1105 for (
const auto& it : (*logs))
1107 std::string
file = it.second->File();
1110 while (
file.find(
"../") == 0)
1115 os << tLeft << std::setw(widthL) << std::left << it.first << tMid << std::setw(widthR)
1116 <<
file << tRight << std::endl;
1118 os << std::right << std::endl;
1134 os <<
commentStart <<
page <<
"TraceSourceList All TraceSources\n" << std::endl;
1135 os <<
"This is a list of all" <<
reference <<
"tracing sources. "
1136 <<
"For more information see the " <<
reference <<
"tracing "
1137 <<
"section of this API documentation and the Tracing sections "
1138 <<
"in the Tutorial and Manual.\n"
1145 for (
const auto& item : nameMap)
1148 if (item.second < 0)
1153 TypeId tid = TypeId::GetRegistered(item.second);
1195 std::string section =
"attribute_" + name;
1200 <<
subSectionStart <<
"attribute_" << name <<
" " << name <<
" Attribute\n"
1201 <<
"AttributeValue implementation for " << name <<
"\n";
1205 if (name !=
"IeMeshId")
1207 os <<
seeAlso <<
"ns3::" << name <<
"\n";
1211 os <<
seeAlso <<
"ns3::dot11s::" << name <<
"\n";
1230 const std::string& name,
1231 const std::string&
type,
1232 const std::string& header)
1235 std::string sectAttr =
sectionStart +
"attribute_" + name;
1239 std::string valClass = name +
"Value";
1240 std::string qualClass =
" ns3::" + valClass;
1243 os <<
classStart << qualClass <<
" \"" << header <<
"\"" << std::endl;
1244 os <<
"AttributeValue implementation for " << name <<
"." << std::endl;
1245 os <<
seeAlso <<
"AttributeValue" << std::endl;
1250 if ((name ==
"EmptyAttribute") || (name ==
"ObjectPtrContainer"))
1258 os <<
"(const " <<
type <<
" & value)\n"
1259 <<
"Copy constructor.\n"
1260 <<
argument <<
"[in] value The " << name <<
" value to copy.\n";
1266 <<
returns <<
"The " << name <<
" value.\n"
1271 <<
"::GetAccessor (T & value) const\n"
1272 <<
"Access the " << name <<
" value as type " <<
codeWord <<
"T.\n"
1274 <<
argument <<
"[out] value The " << name <<
" value, as type " <<
codeWord <<
"T.\n"
1279 if (
type !=
"Callback")
1283 <<
"Set the value.\n"
1284 <<
argument <<
"[in] value The value to adopt.\n"
1290 <<
"The stored " << name <<
" instance.\n"
1307 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
1308 std::string make =
"ns3::Make" + name +
"Accessor ";
1313 << make <<
"(T1 a1)\n"
1314 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1)\n"
1315 <<
seeAlso <<
"AttributeAccessor\n"
1321 << make <<
"(T1 a1, T2 a2)\n"
1322 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1,T2)\n"
1323 <<
seeAlso <<
"AttributeAccessor\n"
1340 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
1341 std::string make =
"ns3::Make" + name +
"Checker ";
1346 os <<
classStart <<
" ns3::" << name <<
"Checker"
1347 <<
" \"" << header <<
"\"" << std::endl;
1348 os <<
"AttributeChecker implementation for " << name <<
"Value." << std::endl;
1349 os <<
seeAlso <<
"AttributeChecker" << std::endl;
1356 <<
returns <<
"The AttributeChecker.\n"
1357 <<
seeAlso <<
"AttributeChecker\n"
1403 {
"Address",
"Address",
true,
"address.h" },
1404 {
"Box",
"Box",
true,
"box.h" },
1405 {
"DataRate",
"DataRate",
true,
"data-rate.h" },
1406 {
"Length",
"Length",
true,
"length.h" },
1407 {
"IeMeshId",
"IeMeshId",
true,
"ie-dot11s-id.h" },
1408 {
"Ipv4Address",
"Ipv4Address",
true,
"ipv4-address.h" },
1409 {
"Ipv4Mask",
"Ipv4Mask",
true,
"ipv4-address.h" },
1410 {
"Ipv6Address",
"Ipv6Address",
true,
"ipv6-address.h" },
1411 {
"Ipv6Prefix",
"Ipv6Prefix",
true,
"ipv6-address.h" },
1412 {
"Mac16Address",
"Mac16Address",
true,
"mac16-address.h" },
1413 {
"Mac48Address",
"Mac48Address",
true,
"mac48-address.h" },
1414 {
"Mac64Address",
"Mac64Address",
true,
"mac64-address.h" },
1415 {
"ObjectFactory",
"ObjectFactory",
true,
"object-factory.h" },
1416 {
"OrganizationIdentifier",
1417 "OrganizationIdentifier",
1418 true,
"vendor-specific-action.h" },
1419 {
"Priomap",
"Priomap",
true,
"prio-queue-disc.h" },
1420 {
"QueueSize",
"QueueSize",
true,
"queue-size.h" },
1421 {
"Rectangle",
"Rectangle",
true,
"rectangle.h" },
1422 {
"Ssid",
"Ssid",
true,
"ssid.h" },
1423 {
"TypeId",
"TypeId",
true,
"type-id.h" },
1424 {
"UanModesList",
"UanModesList",
true,
"uan-tx-mode.h" },
1425 {
"ValueClassTest",
"ValueClassTest",
false,
"attribute-test-suite.cc" },
1426 {
"Vector",
"Vector",
true,
"vector.h" },
1427 {
"Vector2D",
"Vector2D",
true,
"vector.h" },
1428 {
"Vector3D",
"Vector3D",
true,
"vector.h" },
1429 {
"Waypoint",
"Waypoint",
true,
"waypoint.h" },
1430 {
"WifiMode",
"WifiMode",
true,
"wifi-mode.h" },
1433 {
"Boolean",
"bool",
false,
"boolean.h" },
1434 {
"Callback",
"Callback",
true,
"callback.h" },
1435 {
"Double",
"double",
false,
"double.h" },
1436 {
"Enum",
"int",
false,
"enum.h" },
1437 {
"Integer",
"int64_t",
false,
"integer.h" },
1438 {
"Pointer",
"Pointer",
false,
"pointer.h" },
1439 {
"String",
"std::string",
false,
"string.h" },
1440 {
"Time",
"Time",
true,
"nstime.h" },
1441 {
"Uinteger",
"uint64_t",
false,
"uinteger.h" },
1442 {
"",
"",
false,
"last placeholder" }
1447 while (attributes[i].m_name !=
"")
1459 "ObjectPtrContainer",
1460 "ObjectPtrContainer",
1461 "object-ptr-container.h");
1492main(
int argc,
char* argv[])
1497 cmd.Usage(
"Generate documentation for all ns-3 registered types, "
1498 "trace sources, attributes and global variables.");
1499 cmd.AddValue(
"output-text",
"format output as plain text",
outputText);
1500 cmd.Parse(argc, argv);
1508 std::cout << std::endl;
1511 <<
"Doxygen docs generated from the TypeId database.\n"
1512 <<
note <<
"This file is automatically generated by " <<
codeWord
1513 <<
"print-introspected-doxygen.cc. Do not edit this file! "
1514 <<
"Edit that file instead.\n"
Parse command-line arguments.
Vector::const_iterator Iterator
Iterator type for the list of all global values.
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.
AttributeChecker implementation for ObjectPtrContainerValue.
virtual TypeId GetItemTypeId() const =0
Get the TypeId of the container class type.
AttributeChecker implementation for PointerValue.
virtual TypeId GetPointeeTypeId() const =0
Get the TypeId of the base type.
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.
struct TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const
Get the trace source by index.
bool MustHideFromDocumentation() const
Check if this TypeId should not be listed in documentation.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
std::size_t GetAttributeN() const
Get the number of attributes.
TypeId GetParent() const
Get the parent of this TypeId.
std::size_t GetSize() const
Get the size of this object.
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 ",...
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
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::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 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.
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 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.