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"
110 commentStart =
"===============================================================\n";
205 << info.
checker->GetValueTypeName ()
208 if (info.
checker->HasUnderlyingTypeInformation ())
212 <<
"Underlying type: ";
214 std::string valType = info.
checker->GetValueTypeName ();
215 std::string underType = info.
checker->GetUnderlyingTypeInformation ();
216 if ((valType !=
"ns3::EnumValue") && (underType !=
"std::string"))
219 bool handled =
false;
221 if (valType ==
"ns3::PointerValue")
233 else if (valType ==
"ns3::ObjectPtrContainerValue")
246 class StringBeginMatcher
249 StringBeginMatcher (
const std::string s)
251 bool operator () (
const std::string t)
253 std::size_t pos = m_string.find (t);
257 std::string m_string;
259 StringBeginMatcher match (underType);
261 if ( match (
"bool") || match (
"double") ||
262 match (
"int8_t") || match (
"uint8_t") ||
263 match (
"int16_t") || match (
"uint16_t") ||
264 match (
"int32_t") || match (
"uint32_t") ||
265 match (
"int64_t") || match (
"uint64_t")
326 os <<
"No Attributes are defined for this type."
346 <<
"Attributes defined in parent class "
378 <<
"%Callback signature: "
403 os <<
"No TraceSources are defined for this type."
422 <<
"TraceSources defined in parent class "
443 std::size_t arch = (
sizeof (
void *) * CHAR_BIT);
446 <<
" of this type is " << tid.
GetSize ()
447 <<
" bytes (on a " << arch <<
"-bit architecture)."
467 os <<
"This is a list of all" <<
reference <<
"attribute by class. "
468 <<
"For more information see the" <<
reference <<
"attribute "
469 <<
"section of this API documentation and the Attributes sections "
470 <<
"in the Tutorial and Manual.\n"
512 os <<
"This is a list of all" <<
reference <<
"ns3::GlobalValue instances.\n"
521 (*i)->GetValue (val);
526 <<
"GlobalValue" << (*i)->GetName () <<
" " << (*i)->GetName ()
528 <<
": " << (*i)->GetHelp ()
529 <<
". Default value: " << val.
Get () <<
"."
550 os <<
"This is a list of all" <<
reference <<
"ns3::LogComponent instances.\n"
559 LogComponent::ComponentList::const_iterator it;
560 for (it = logs->begin (); it != logs->end (); ++it)
562 std::string file = it->second->File ();
565 while (file.find (
"../") == 0)
567 file = file.substr (3);
591 os <<
"This is a list of all" <<
reference <<
"tracing sources. "
592 <<
"For more information see the " <<
reference <<
"tracing "
593 <<
"section of this API documentation and the Tracing sections "
594 <<
"in the Tutorial and Manual.\n"
645 const std::string & name,
646 const bool seeBase =
true)
649 std::string section =
"attribute_" + name;
655 << name <<
" Attribute\n"
656 <<
"Attribute implementation for " << name <<
"\n";
660 if (name !=
"IeMeshId")
662 os <<
seeAlso <<
"ns3::" << name <<
"\n";
666 os <<
seeAlso <<
"ns3::dot11s::" << name <<
"\n";
686 const std::string & name,
687 const std::string & type,
688 const std::string & header)
691 std::string sectAttr =
sectionStart +
"attribute_" + name;
695 std::string valClass = name +
"Value";
696 std::string qualClass =
" ns3::" + valClass;
699 os <<
classStart << qualClass <<
" \"" << header <<
"\"" << std::endl;
700 os <<
"AttributeValue implementation for " << name <<
"." << std::endl;
701 os <<
seeAlso <<
"AttributeValue" << std::endl;
707 << qualClass <<
"::" << valClass;
708 if ( (name ==
"EmptyAttribute") ||
709 (name ==
"ObjectPtrContainer") )
717 os <<
"(const " << type <<
" & value)\n"
718 <<
"Copy constructor.\n"
719 <<
argument <<
"[in] value The " << name <<
" value to copy.\n";
726 << qualClass <<
"::Get (void) const\n"
727 <<
returns <<
"The " << name <<
" value.\n"
733 << qualClass <<
"::GetAccessor (T & value) const\n"
734 <<
"Access the " << name <<
" value as type " <<
codeWord <<
"T.\n"
736 <<
argument <<
"[out] value The " << name <<
" value, as type "
742 if (type !=
"Callback")
746 << qualClass <<
"::Set (const " << type <<
" & value)\n"
747 <<
"Set the value.\n"
748 <<
argument <<
"[in] value The value to adopt.\n"
755 << qualClass <<
"::m_value\n"
756 <<
"The stored " << name <<
" instance.\n"
775 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
776 std::string make =
"ns3::Make" + name +
"Accessor ";
781 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeAccessor> "
782 << make <<
"(T1 a1)\n"
783 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1)\n"
784 <<
seeAlso <<
"AttributeAccessor\n"
790 <<
functionStart <<
"ns3::Ptr<const ns3::AttributeAccessor> "
791 << make <<
"(T1 a1, T2 a2)\n"
792 <<
copyDoc <<
"ns3::MakeAccessorHelper(T1,T2)\n"
793 <<
seeAlso <<
"AttributeAccessor\n"
809 const std::string & name,
810 const std::string & header)
813 std::string sectAttr =
sectionStart +
"attribute_" + name +
"\n";
814 std::string make =
"ns3::Make" + name +
"Checker ";
819 os <<
classStart <<
" ns3::" << name <<
"Checker"
820 <<
" \"" << header <<
"\"" << std::endl;
821 os <<
"AttributeChecker implementation for " << name <<
"Value." << std::endl;
822 os <<
seeAlso <<
"AttributeChecker" << std::endl;
829 << make <<
"(void)\n"
830 <<
returns <<
"The AttributeChecker.\n"
831 <<
seeAlso <<
"AttributeChecker\n"
878 {
"Address",
"Address",
true,
"address.h" },
879 {
"Box",
"Box",
true,
"box.h" },
880 {
"DataRate",
"DataRate",
true,
"data-rate.h" },
881 {
"HtCapabilities",
"HtCapabilities",
true,
"ht-capabilities.h" },
882 {
"IeMeshId",
"IeMeshId",
true,
"ie-dot11s-id.h" },
883 {
"Ipv4Address",
"Ipv4Address",
true,
"ipv4-address.h" },
884 {
"Ipv4Mask",
"Ipv4Mask",
true,
"ipv4-address.h" },
885 {
"Ipv6Address",
"Ipv6Address",
true,
"ipv6-address.h" },
886 {
"Ipv6Prefix",
"Ipv6Prefix",
true,
"ipv6-address.h" },
887 {
"Mac16Address",
"Mac16Address",
true,
"mac16-address.h" },
888 {
"Mac48Address",
"Mac48Address",
true,
"mac48-address.h" },
889 {
"Mac64Address",
"Mac64Address",
true,
"mac64-address.h" },
890 {
"ObjectFactory",
"ObjectFactory",
true,
"object-factory.h" },
891 {
"OrganizationIdentifier",
892 "OrganizationIdentifier",
893 true,
"vendor-specific-action.h" },
894 {
"Rectangle",
"Rectangle",
true,
"rectangle.h" },
895 {
"Ssid",
"Ssid",
true,
"ssid.h" },
896 {
"TypeId",
"TypeId",
true,
"type-id.h" },
897 {
"UanModesList",
"UanModesList",
true,
"uan-tx-mode.h" },
898 {
"ValueClassTest",
"ValueClassTest",
false,
"" },
899 {
"Vector2D",
"Vector2D",
true,
"vector.h" },
900 {
"Vector3D",
"Vector3D",
true,
"vector.h" },
901 {
"Waypoint",
"Waypoint",
true,
"waypoint.h" },
902 {
"WifiMode",
"WifiMode",
true,
"wifi-mode.h" },
905 {
"Boolean",
"Boolean",
false,
"boolean.h" },
906 {
"Callback",
"Callback",
true,
"callback.h" },
907 {
"Double",
"double",
false,
"double.h" },
908 {
"Enum",
"int",
false,
"enum.h" },
909 {
"Integer",
"int64_t",
false,
"integer.h" },
910 {
"Pointer",
"Pointer",
false,
"pointer.h" },
911 {
"RandomVariable",
"RandomVariable",
true,
"random-variable-stream.h" },
912 {
"String",
"std::string",
false,
"string.h" },
913 {
"Time",
"Time",
true,
"nstime.h" },
914 {
"Uinteger",
"uint64_t",
false,
"uinteger.h" },
915 {
"",
"",
false,
"last placeholder" }
919 while (attributes[i].m_name !=
"")
961 void RecordAggregationInfo (std::string a, std::string b);
971 void Print (
void)
const;
978 std::vector<std::string> Get (
TypeId tid)
const;
983 std::vector<std::string> GetNoTypeIds (
void)
const;
989 std::string GetCurrentPath (
void)
const;
995 void DoGather (
TypeId tid);
1001 void RecordOutput (
TypeId tid);
1007 bool HasAlreadyBeenProcessed (
TypeId tid)
const;
1043 m_noTids.push_back (a);
1050 m_noTids.push_back (b);
1054 m_aggregates.push_back (std::make_pair (aTid, bTid));
1062 for (std::vector<std::pair<TypeId,std::string> >::const_iterator i = m_output.begin (); i != m_output.end (); ++i)
1064 std::pair<TypeId,std::string> item = *i;
1065 std::cout << item.first.GetName () <<
" -> " << item.second << std::endl;
1074 std::ostringstream oss;
1075 for (std::vector<std::string>::const_iterator i = m_currentPath.begin (); i != m_currentPath.end (); ++i)
1077 std::string item = *i;
1088 m_output.push_back (std::make_pair (tid, GetCurrentPath ()));
1096 for (uint32_t i = 0; i < m_alreadyProcessed.size (); ++i)
1098 if (m_alreadyProcessed[i] == tid)
1107 std::vector<std::string>
1111 std::vector<std::string> paths;
1112 for (uint32_t i = 0; i < m_output.size (); ++i)
1114 std::pair<TypeId,std::string> tmp = m_output[i];
1115 if (tmp.first == tid)
1117 paths.push_back (tmp.second);
1138 template <
typename T>
1142 std::sort (t.begin (), t.end ());
1143 t.erase (std::unique (t.begin (), t.end ()), t.end ());
1146 std::vector<std::string>
1168 if (HasAlreadyBeenProcessed (tid))
1177 if (ptrChecker != 0)
1183 TypeId objectTypeId =
object->GetTypeId ();
1184 if (objectTypeId == pointee)
1193 m_currentPath.push_back (info.
name);
1194 m_alreadyProcessed.push_back (tid);
1196 m_alreadyProcessed.pop_back ();
1197 m_currentPath.pop_back ();
1202 if (vectorChecker != 0)
1205 m_currentPath.push_back (info.
name +
"/[i]");
1206 m_alreadyProcessed.push_back (tid);
1208 m_alreadyProcessed.pop_back ();
1209 m_currentPath.pop_back ();
1218 std::string childName =
"$" + child.
GetName ();
1219 m_currentPath.push_back (childName);
1220 m_alreadyProcessed.push_back (tid);
1222 m_alreadyProcessed.pop_back ();
1223 m_currentPath.pop_back ();
1226 for (uint32_t k = 0; k < m_aggregates.size (); ++k)
1228 std::pair<TypeId,TypeId> tmp = m_aggregates[k];
1229 if (tmp.first == tid || tmp.second == tid)
1232 if (tmp.first == tid)
1236 if (tmp.second == tid)
1240 std::string name =
"$" + other.
GetName ();
1241 m_currentPath.push_back (name);
1242 m_alreadyProcessed.push_back (tid);
1244 m_alreadyProcessed.pop_back ();
1245 m_currentPath.pop_back ();
1287 simpleChannel = CreateObject<SimpleChannel> ();
1324 std::string name = tid.
GetName ();
1325 for (uint32_t j = 0; j < name.length (); j++)
1327 name[j] = toupper (name[j]);
1335 std::vector<std::string> noTids = info.
GetNoTypeIds ();
1336 for (std::vector<std::string>::const_iterator i = noTids.begin ();
1352 std::vector<std::string> paths = info.
Get (tid);
1357 os <<
"Introspection did not find any typical Config paths."
1369 <<
" is accessible through the following paths"
1370 <<
" with Config::Set and Config::Connect:"
1373 for (uint32_t k = 0; k < paths.size (); ++k)
1375 std::string path = paths[k];
1377 <<
"\"" << path <<
"\""
1391 int main (
int argc,
char *argv[])
1394 bool outputText =
false;
1397 cmd.
Usage (
"Generate documentation for all ns-3 registered types, "
1398 "trace sources, attributes and global variables.");
1399 cmd.
AddValue (
"output-text",
"format output as plain text", outputText);
1400 cmd.
Parse (argc, argv);
1412 std::cout <<
"/* -*- Mode:C++; c-file-style:\"gnu\"; "
1413 "indent-tabs-mode:nil; -*- */\n"
1425 nameMapIterator != nameMap.end ();
1429 std::string name = nameMapIterator->first;
1430 int32_t i = nameMapIterator->second;
1445 std::cout <<
classStart << name << std::endl;
1446 std::cout << std::endl;
1457 std::cout <<
"Introspection could not find Config paths for " << name
1458 <<
" in this build because the parent module"
1459 <<
" 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)
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.
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)
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.
The attribute can be written at construction-time.
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
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.
The attribute can be read.
bool MustHideFromDocumentation(void) const
Check if this TypeId should not be listed in documentation.
std::map< std::string, int32_t > NameMap
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
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
std::map< std::string, LogComponent * > ComponentList
LogComponent name map.
std::string codeWord
format next word as source code
keep track of a set of node pointers.
The attribute can be written.
virtual TypeId GetInstanceTypeId(void) const
Implement the GetInstanceTypeId method defined in ObjectBase.
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()
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.
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.
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