32 #include "ns3/command-line.h"
33 #include "ns3/config.h"
34 #include "ns3/global-value.h"
36 #include "ns3/object-vector.h"
37 #include "ns3/object.h"
38 #include "ns3/pointer.h"
39 #include "ns3/string.h"
40 #include "ns3/node-container.h"
41 #include "ns3/simple-channel.h"
42 #include "ns3/system-path.h"
113 commentStart =
"===============================================================\n";
212 << info.
checker->GetValueTypeName ()
215 if (info.
checker->HasUnderlyingTypeInformation ())
219 <<
"Underlying type: ";
221 std::string valType = info.
checker->GetValueTypeName ();
222 std::string underType = info.
checker->GetUnderlyingTypeInformation ();
223 if ((valType !=
"ns3::EnumValue") && (underType !=
"std::string"))
226 bool handled =
false;
228 if (valType ==
"ns3::PointerValue")
240 else if (valType ==
"ns3::ObjectPtrContainerValue")
253 class StringBeginMatcher
256 StringBeginMatcher (
const std::string s)
258 bool operator () (
const std::string t)
260 std::size_t pos = m_string.find (t);
264 std::string m_string;
266 StringBeginMatcher match (underType);
268 if ( match (
"bool") || match (
"double") ||
269 match (
"int8_t") || match (
"uint8_t") ||
270 match (
"int16_t") || match (
"uint16_t") ||
271 match (
"int32_t") || match (
"uint32_t") ||
272 match (
"int64_t") || match (
"uint64_t")
333 os <<
"No Attributes are defined for this type."
353 <<
"Attributes defined in parent class "
385 <<
"%Callback signature: "
410 os <<
"No TraceSources are defined for this type."
429 <<
"TraceSources defined in parent class "
450 std::size_t arch = (
sizeof (
void *) * CHAR_BIT);
453 <<
" of this type is " << tid.
GetSize ()
454 <<
" bytes (on a " << arch <<
"-bit architecture)."
474 os <<
"This is a list of all" <<
reference <<
"attribute by class. "
475 <<
"For more information see the" <<
reference <<
"attribute "
476 <<
"section of this API documentation and the Attributes sections "
477 <<
"in the Tutorial and Manual.\n"
519 os <<
"This is a list of all" <<
reference <<
"ns3::GlobalValue instances.\n"
528 (*i)->GetValue (val);
533 <<
"GlobalValue" << (*i)->GetName () <<
" " << (*i)->GetName ()
535 <<
": " << (*i)->GetHelp ()
536 <<
". Default value: " << val.
Get () <<
"."
557 os <<
"This is a list of all" <<
reference <<
"ns3::LogComponent instances.\n"
566 LogComponent::ComponentList::const_iterator it;
567 for (it = logs->begin (); it != logs->end (); ++it)
569 std::string
file = it->second->File ();
572 while (file.find (
"../") == 0)
574 file = file.substr (3);
598 os <<
"This is a list of all" <<
reference <<
"tracing sources. "
599 <<
"For more information see the " <<
reference <<
"tracing "
600 <<
"section of this API documentation and the Tracing sections "
601 <<
"in the Tutorial and Manual.\n"
652 const std::string & name,
653 const bool seeBase =
true)
656 std::string section =
"attribute_" + name;
662 << name <<
" Attribute\n"
663 <<
"Attribute implementation for " << name <<
"\n";
667 if (name !=
"IeMeshId")
669 os <<
seeAlso <<
"ns3::" << name <<
"\n";
673 os <<
seeAlso <<
"ns3::dot11s::" << name <<
"\n";
693 const std::string & name,
694 const std::string & type,
695 const std::string & header)
698 std::string sectAttr =
sectionStart +
"attribute_" + name;
702 std::string valClass = name +
"Value";
703 std::string qualClass =
" ns3::" + valClass;
706 os <<
classStart << qualClass <<
" \"" << header <<
"\"" << std::endl;
707 os <<
"AttributeValue implementation for " << name <<
"." << std::endl;
708 os <<
seeAlso <<
"AttributeValue" << std::endl;
714 << qualClass <<
"::" << valClass;
715 if ( (name ==
"EmptyAttribute") ||
716 (name ==
"ObjectPtrContainer") )
724 os <<
"(const " << type <<
" & value)\n"
725 <<
"Copy constructor.\n"
726 <<
argument <<
"[in] value The " << name <<
" value to copy.\n";
733 << qualClass <<
"::Get (void) const\n"
734 <<
returns <<
"The " << name <<
" value.\n"
740 << qualClass <<
"::GetAccessor (T & value) const\n"
741 <<
"Access the " << name <<
" value as type " <<
codeWord <<
"T.\n"
743 <<
argument <<
"[out] value The " << name <<
" value, as type "
749 if (type !=
"Callback")
753 << qualClass <<
"::Set (const " << type <<
" & value)\n"
754 <<
"Set the value.\n"
755 <<
argument <<
"[in] value The value to adopt.\n"
762 << qualClass <<
"::m_value\n"
763 <<
"The stored " << name <<
" instance.\n"
782 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
783 std::string make =
"ns3::Make" + name +
"Accessor ";
788 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeAccessor> "
789 << make <<
"(T1 a1)\n"
790 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1)\n"
791 <<
seeAlso <<
"AttributeAccessor\n"
797 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeAccessor> "
798 << make <<
"(T1 a1, T2 a2)\n"
799 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1,T2)\n"
800 <<
seeAlso <<
"AttributeAccessor\n"
816 const std::string & name,
817 const std::string & header)
820 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
821 std::string make =
"ns3::Make" + name +
"Checker ";
826 os <<
classStart <<
" ns3::" << name <<
"Checker"
827 <<
" \"" << header <<
"\"" << std::endl;
828 os <<
"AttributeChecker implementation for " << name <<
"Value." << std::endl;
829 os <<
seeAlso <<
"AttributeChecker" << std::endl;
836 << make <<
"(void)\n"
837 <<
returns <<
"The AttributeChecker.\n"
838 <<
seeAlso <<
"AttributeChecker\n"
886 {
"Address",
"Address",
true,
"address.h" },
887 {
"Box",
"Box",
true,
"box.h" },
888 {
"DataRate",
"DataRate",
true,
"data-rate.h" },
889 {
"DsssParameterSet",
891 true,
"dsss-parameter-set.h"},
892 {
"EdcaParameterSet",
894 true,
"edca-parameter-set.h"},
895 {
"ErpInformation",
"ErpInformation",
true,
"erp-information.h" },
896 {
"HeCapabilities",
"HeCapabilities",
true,
"he-capabilities.h" },
897 {
"HtCapabilities",
"HtCapabilities",
true,
"ht-capabilities.h" },
898 {
"IeMeshId",
"IeMeshId",
true,
"ie-dot11s-id.h" },
899 {
"Ipv4Address",
"Ipv4Address",
true,
"ipv4-address.h" },
900 {
"Ipv4Mask",
"Ipv4Mask",
true,
"ipv4-address.h" },
901 {
"Ipv6Address",
"Ipv6Address",
true,
"ipv6-address.h" },
902 {
"Ipv6Prefix",
"Ipv6Prefix",
true,
"ipv6-address.h" },
903 {
"Mac16Address",
"Mac16Address",
true,
"mac16-address.h" },
904 {
"Mac48Address",
"Mac48Address",
true,
"mac48-address.h" },
905 {
"Mac64Address",
"Mac64Address",
true,
"mac64-address.h" },
906 {
"ObjectFactory",
"ObjectFactory",
true,
"object-factory.h" },
907 {
"OrganizationIdentifier",
908 "OrganizationIdentifier",
909 true,
"vendor-specific-action.h" },
910 {
"Rectangle",
"Rectangle",
true,
"rectangle.h" },
911 {
"Ssid",
"Ssid",
true,
"ssid.h" },
912 {
"TypeId",
"TypeId",
true,
"type-id.h" },
913 {
"UanModesList",
"UanModesList",
true,
"uan-tx-mode.h" },
915 {
"Vector2D",
"Vector2D",
true,
"vector.h" },
916 {
"Vector3D",
"Vector3D",
true,
"vector.h" },
917 {
"VhtCapabilities",
"VhtCapabilities",
true,
"vht-capabilities.h" },
918 {
"VhtOperation",
"VhtOperation",
true,
"vht-operation.h" },
919 {
"Waypoint",
"Waypoint",
true,
"waypoint.h" },
920 {
"WifiMode",
"WifiMode",
true,
"wifi-mode.h" },
923 {
"Boolean",
"Boolean",
false,
"boolean.h" },
924 {
"Callback",
"Callback",
true,
"callback.h" },
925 {
"Double",
"double",
false,
"double.h" },
926 {
"Enum",
"int",
false,
"enum.h" },
927 {
"Integer",
"int64_t",
false,
"integer.h" },
928 {
"Pointer",
"Pointer",
false,
"pointer.h" },
929 {
"RandomVariable",
"RandomVariable",
true,
"random-variable-stream.h" },
930 {
"String",
"std::string",
false,
"string.h" },
931 {
"Time",
"Time",
true,
"nstime.h" },
932 {
"Uinteger",
"uint64_t",
false,
"uinteger.h" },
933 {
"",
"",
false,
"last placeholder" }
937 while (attributes[i].m_name !=
"")
979 void RecordAggregationInfo (std::string a, std::string b);
989 void Print (
void)
const;
996 std::vector<std::string> Get (
TypeId tid)
const;
1001 std::vector<std::string> GetNoTypeIds (
void)
const;
1007 std::string GetCurrentPath (
void)
const;
1013 void DoGather (
TypeId tid);
1019 void RecordOutput (
TypeId tid);
1025 bool HasAlreadyBeenProcessed (
TypeId tid)
const;
1061 m_noTids.push_back (a);
1068 m_noTids.push_back (b);
1072 m_aggregates.push_back (std::make_pair (aTid, bTid));
1080 for (std::vector<std::pair<TypeId,std::string> >::const_iterator i = m_output.begin (); i != m_output.end (); ++i)
1082 std::pair<TypeId,std::string> item = *i;
1083 std::cout << item.first.GetName () <<
" -> " << item.second << std::endl;
1092 std::ostringstream oss;
1093 for (std::vector<std::string>::const_iterator i = m_currentPath.begin (); i != m_currentPath.end (); ++i)
1095 std::string item = *i;
1106 m_output.push_back (std::make_pair (tid, GetCurrentPath ()));
1114 for (uint32_t i = 0; i < m_alreadyProcessed.size (); ++i)
1116 if (m_alreadyProcessed[i] == tid)
1125 std::vector<std::string>
1129 std::vector<std::string> paths;
1130 for (uint32_t i = 0; i < m_output.size (); ++i)
1132 std::pair<TypeId,std::string> tmp = m_output[i];
1133 if (tmp.first == tid)
1135 paths.push_back (tmp.second);
1156 template <
typename T>
1160 std::sort (t.begin (), t.end ());
1161 t.erase (std::unique (t.begin (), t.end ()), t.end ());
1164 std::vector<std::string>
1186 if (HasAlreadyBeenProcessed (tid))
1195 if (ptrChecker != 0)
1201 TypeId objectTypeId =
object->GetTypeId ();
1202 if (objectTypeId == pointee)
1211 m_currentPath.push_back (info.
name);
1212 m_alreadyProcessed.push_back (tid);
1214 m_alreadyProcessed.pop_back ();
1215 m_currentPath.pop_back ();
1220 if (vectorChecker != 0)
1223 m_currentPath.push_back (info.
name +
"/[i]");
1224 m_alreadyProcessed.push_back (tid);
1226 m_alreadyProcessed.pop_back ();
1227 m_currentPath.pop_back ();
1236 std::string childName =
"$" + child.
GetName ();
1237 m_currentPath.push_back (childName);
1238 m_alreadyProcessed.push_back (tid);
1240 m_alreadyProcessed.pop_back ();
1241 m_currentPath.pop_back ();
1244 for (uint32_t k = 0; k < m_aggregates.size (); ++k)
1246 std::pair<TypeId,TypeId> tmp = m_aggregates[k];
1247 if (tmp.first == tid || tmp.second == tid)
1250 if (tmp.first == tid)
1254 if (tmp.second == tid)
1258 std::string name =
"$" + other.
GetName ();
1259 m_currentPath.push_back (name);
1260 m_alreadyProcessed.push_back (tid);
1262 m_alreadyProcessed.pop_back ();
1263 m_currentPath.pop_back ();
1308 simpleChannel = CreateObject<SimpleChannel> ();
1350 std::string name = tid.
GetName ();
1351 for (uint32_t j = 0; j < name.length (); j++)
1353 name[j] = toupper (name[j]);
1361 std::vector<std::string> noTids = info.
GetNoTypeIds ();
1362 for (std::vector<std::string>::const_iterator i = noTids.begin ();
1384 std::vector<std::string> paths = info.
Get (tid);
1389 os <<
"Introspection did not find any typical Config paths."
1401 <<
" is accessible through the following paths"
1402 <<
" with Config::Set and Config::Connect:"
1405 for (uint32_t k = 0; k < paths.size (); ++k)
1407 std::string path = paths[k];
1409 <<
"\"" << path <<
"\""
1423 int main (
int argc,
char *argv[])
1426 bool outputText =
false;
1429 cmd.
Usage (
"Generate documentation for all ns-3 registered types, "
1430 "trace sources, attributes and global variables.");
1431 cmd.
AddValue (
"output-text",
"format output as plain text", outputText);
1432 cmd.
Parse (argc, argv);
1444 std::cout <<
"/* -*- Mode:C++; c-file-style:\"gnu\"; "
1445 "indent-tabs-mode:nil; -*- */\n"
1447 std::cout <<
"#include \"ns3/log.h\""
1452 std::cout << std::endl;
1456 <<
"Doxygen docs generated from the TypeId database.\n"
1457 <<
note <<
"This file is automatically generated by "
1458 <<
codeWord <<
"print-introspected-doxygen.cc. Do not edit this file! "
1459 <<
"Edit that file instead.\n"
1471 nameMapIterator != nameMap.end ();
1475 std::string name = nameMapIterator->first;
1476 int32_t i = nameMapIterator->second;
1491 std::cout <<
classStart << name << std::endl;
1492 std::cout << std::endl;
1503 std::cout <<
"Introspection could not find Config paths for " << name
1504 <<
" in this build because the parent module"
1505 <<
" was not included in the waf configuration."
uint32_t GetAttributeN(void) const
Get the number of attributes.
std::string classStart
start of a class
NameMap GetNameMap(const StaticInformation &info)
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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
std::string Get(void) const
std::string functionStop
end of a method/function
const std::string m_header
The header file name.
std::string headingStop
end of section heading (h3)
Hold variables of type string.
std::string note
start a note section
void PrintAttributes(std::ostream &os, const TypeId tid)
Print the Attributes block for tid, including Attributes declared in base classes.
void Uniquefy(T t)
Helper to keep only the unique items in a container.
std::string templArgDeduced
template argument deduced from function
void PrintConfigPaths(std::ostream &os, const StaticInformation &info, const TypeId tid)
Print config paths.
std::string argument
function argument
std::string headingStart
start of section heading (h3)
U * PeekPointer(const Ptr< U > &p)
const std::string m_type
The name of the underlying type.
virtual TypeId GetPointeeTypeId(void) const =0
Get the TypeId of the base type.
std::string flagSpanStart
start of Attribute flag value
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
TypeId GetParent(void) const
Get the parent of this TypeId.
Vector::const_iterator Iterator
Iterator type for the list of all global values.
std::string boldStart
start of bold span
std::string templArgExplicit
template argument required
std::string commentStop
end of code comment
void PrintAllAttributes(std::ostream &os)
Print the list of all Attributes.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
void PrintAllLogComponents(std::ostream &os)
Print the list of all LogComponents.
void SetMarkup(bool outputText)
Initialize the markup strings, for either doxygen or text.
virtual TypeId GetItemTypeId(void) const =0
Get the TypeId of the container class type.
void PrintTraceSources(std::ostream &os, const TypeId tid)
Print the Trace sources block for tid, including Trace sources declared in base classes.
std::string listLineStart
start unordered list item
The attribute can be written at construction-time.
std::string breakTextOnly
linebreak for text output only
void PrintAttributeValueSection(std::ostream &os, const std::string &name, const bool seeBase=true)
Print the section definition for an AttributeValue.
void Usage(const std::string usage)
Supply the program usage and documentation.
bool MustHideFromDocumentation(void) const
Check if this TypeId should not be listed in documentation.
std::map< std::string, int32_t > NameMap
Map from TypeId name to tid.
std::string indentHtmlOnly
small indent
std::string templateArgument
template argument
void PrintAttributeHelper(std::ostream &os, const AttributeDescriptor &attr)
Print documentation corresponding to use of the ATTRIBUTE_HELPER_HEADER macro or ATTRIBUTE_VALUE_DEFI...
std::string brief
brief tag
static uint32_t GetRegisteredN(void)
Get the number of registered TypeIds.
const std::string m_name
The base name of the resulting AttributeValue type.
static Iterator Begin(void)
The Begin iterator.
std::string subSectionStart
start a new subsection
std::string variable
variable or class member
std::string sectionStart
start of a section or group
Ptr< Object > GetRootNamespaceObject(uint32_t i)
AttributeChecker implementation for ObjectPtrContainerValue.
NameMap::const_iterator NameMapIterator
NameMap iterator.
uint32_t GetTraceSourceN(void) const
Get the number of Trace sources.
static TypeId GetRegistered(uint32_t i)
Get a TypeId by index.
void PrintSize(std::ostream &os, const TypeId tid)
Print the size of the type represented by this tid.
uint32_t GetRootNamespaceObjectN(void)
Parse command-line arguments.
std::string returns
the return value
std::string breakHtmlOnly
linebreak for html output only
The attribute can be written.
std::map< std::string, LogComponent * > ComponentList
LogComponent name map.
std::string codeWord
format next word as source code
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
std::string listLineStop
end unordered list item
static ComponentList * GetComponentList(void)
Get the list of LogComponnents.
std::string reference
reference tag
std::string GetName(void) const
Get the name.
const bool m_seeBase
Print a "see also" pointing to the base class.
std::string listStart
start unordered list
std::string listStop
end unordered list
void PrintMakeChecker(std::ostream &os, const std::string &name, const std::string &header)
Print the AttributeValue MakeChecker documentation for a class.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
std::string classStop
end of a class
StaticInformation GetTypicalAggregations()
Register aggregation relationships that are not automatically detected by this introspection program...
AttributeChecker implementation for PointerValue.
void PrintAttributeValueWithName(std::ostream &os, const std::string &name, const std::string &type, const std::string &header)
Print the AttributeValue documentation for a class.
The attribute can be read.
Descriptor for an AttributeValue.
std::size_t GetSize(void) const
Get the size of this object.
std::string anchor
hyperlink anchor
void PrintMakeAccessors(std::ostream &os, const std::string &name)
Print the AttributeValue MakeAccessor documentation for a class.
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static Iterator End(void)
The End iterator.
void Print(ComponentCarrier cc)
std::string copyDoc
copy (or refer) to docs elsewhere
std::string page
start a separate page
std::string seeAlso
Reference to other docs.
void Parse(int argc, char *argv[])
Parse the program arguments.
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void PrintAttributeImplementations(std::ostream &os)
Print documentation for Attribute implementations.
struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const
Get the trace source by index.
std::string functionStart
start of a method/function
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
Get Attribute information by index.
std::string breakBoth
linebreak
void PrintAttributesTid(std::ostream &os, const TypeId tid)
Print direct Attributes for this TypeId.
std::string flagSpanStop
end of Attribute flag value
a unique identifier for an interface.
std::string boldStop
end of bold span
void PrintAllGlobals(std::ostream &os)
Print the list of all global variables.
void PrintTraceSourcesTid(std::ostream &os, const TypeId tid)
Print direct Trace sources for this TypeId.
std::string commentStart
start of code comment