4 #include "ns3/object.h"
5 #include "ns3/pointer.h"
6 #include "ns3/object-vector.h"
7 #include "ns3/config.h"
9 #include "ns3/global-value.h"
10 #include "ns3/string.h"
11 #include "ns3/node-container.h"
12 #include "ns3/csma-channel.h"
53 PrintAttributes (
TypeId tid, std::ostream &os)
55 os << listStart << std::endl;
59 os << listLineStart << boldStart << info.name << boldStop <<
": "
60 << info.help << std::endl;
61 os <<
" " << listStart << std::endl
62 <<
" " << listLineStart <<
"Set with class: " << reference << info.checker->
GetValueTypeName () << listLineStop << std::endl;
65 os <<
" " << listLineStart <<
"Underlying type: ";
76 os <<
" " << listLineStart <<
"Initial value: " << info.initialValue->SerializeToString (info.checker) << listLineStop << std::endl;
78 os <<
" " << listLineStart <<
"Flags: ";
81 os << flagSpanStart <<
"construct " << flagSpanStop;
85 os << flagSpanStart <<
"write " << flagSpanStop;
89 os << flagSpanStart <<
"read " << flagSpanStop;
91 os << listLineStop << std::endl;
92 os <<
" " << listStop <<
" " << std::endl;
99 PrintTraceSources (
TypeId tid, std::ostream &os)
126 void RecordAggregationInfo (std::string a, std::string b);
136 void Print (
void)
const;
143 std::vector<std::string> Get (
TypeId tid);
149 std::string GetCurrentPath (
void)
const;
155 void DoGather (
TypeId tid);
161 void RecordOutput (
TypeId tid);
167 bool HasAlreadyBeenProcessed (
TypeId tid)
const;
175 void find_and_replace (std::string &source,
const std::string find, std::string replace );
179 std::vector<std::pair<TypeId,std::string> >
m_output;
203 for (std::vector<std::pair<TypeId,std::string> >::const_iterator i = m_output.begin (); i != m_output.end (); ++i)
205 std::pair<TypeId,std::string> item = *i;
206 std::cout << item.first.GetName () <<
" -> " << item.second << std::endl;
213 std::ostringstream oss;
214 for (std::vector<std::string>::const_iterator i = m_currentPath.begin (); i != m_currentPath.end (); ++i)
216 std::string item = *i;
225 m_output.push_back (std::make_pair (tid, GetCurrentPath ()));
231 for (uint32_t i = 0; i < m_alreadyProcessed.size (); ++i)
233 if (m_alreadyProcessed[i] == tid)
241 std::vector<std::string>
244 std::vector<std::string> paths;
245 for (uint32_t i = 0; i < m_output.size (); ++i)
247 std::pair<TypeId,std::string> tmp = m_output[i];
248 if (tmp.first == tid)
250 paths.push_back (tmp.second);
261 std::sort (m_output.begin (), m_output.end ());
262 m_output.erase (std::unique (m_output.begin (), m_output.end ()), m_output.end ());
269 if (HasAlreadyBeenProcessed (tid))
280 TypeId pointee = ptrChecker->GetPointeeTypeId ();
284 TypeId objectTypeId =
object->GetTypeId ();
285 if (objectTypeId == pointee)
294 m_currentPath.push_back (info.name);
295 m_alreadyProcessed.push_back (tid);
297 m_alreadyProcessed.pop_back ();
298 m_currentPath.pop_back ();
303 if (vectorChecker != 0)
305 TypeId item = vectorChecker->GetItemTypeId ();
306 m_currentPath.push_back (info.name +
"/[i]");
307 m_alreadyProcessed.push_back (tid);
309 m_alreadyProcessed.pop_back ();
310 m_currentPath.pop_back ();
320 std::string childName =
"$" + temporaryCharacter + child.
GetName ();
321 std::string replaceWith =
"::" + temporaryCharacter;
322 find_and_replace(childName,
"::",replaceWith);
323 m_currentPath.push_back (childName);
324 m_alreadyProcessed.push_back (tid);
326 m_alreadyProcessed.pop_back ();
327 m_currentPath.pop_back ();
330 for (uint32_t k = 0; k < m_aggregates.size (); ++k)
332 std::pair<TypeId,TypeId> tmp = m_aggregates[k];
333 if (tmp.first == tid || tmp.second == tid)
336 if (tmp.first == tid)
340 if (tmp.second == tid)
355 std::string name =
"$" + temporaryCharacter + other.
GetName ();
357 std::string replaceWith =
"::" + temporaryCharacter;
358 find_and_replace(name,
"::",replaceWith);
359 m_currentPath.push_back (name);
360 m_alreadyProcessed.push_back (tid);
362 m_alreadyProcessed.pop_back ();
363 m_currentPath.pop_back ();
372 j = source.find (find);
373 while (j != std::string::npos )
375 source.replace (j, find.length (),replace);
376 j = source.find (find,j+1);
381 PrintHelp (
const char *program_name)
383 std::cout <<
"Usage: " << program_name <<
" [options]" << std::endl
385 <<
"Options:" << std::endl
386 <<
" --help : print these options" << std::endl
387 <<
" --output-text : format output as plain text" << std::endl;
390 int main (
int argc,
char *argv[])
392 bool outputText =
false;
393 char *programName = argv[0];
401 if (strcmp (arg,
"--help") == 0)
403 PrintHelp (programName);
406 else if (strcmp(arg,
"--output-text") == 0)
413 PrintHelp (programName);
428 commentStart =
"===============================================================\n";
509 csma = CreateObject<CsmaChannel> ();
517 std::map< std::string, uint32_t> nameMap;
518 std::map< std::string, uint32_t>::const_iterator nameMapIterator;
532 std::string name = tid.
GetName ();
533 for (uint32_t j = 0; j < name.length (); j++)
535 name[j] = toupper (name[j]);
544 for (nameMapIterator = nameMap.begin ();
545 nameMapIterator != nameMap.end ();
549 uint32_t i = nameMapIterator->second;
558 std::cout << std::endl;
559 std::vector<std::string> paths = info.
Get (tid);
564 std::cout <<
"Doxygen introspection did not find any typical Config paths."
572 std::cout << std::endl;
574 <<
" is accessible through the following paths"
575 <<
" with Config::Set and Config::Connect:"
578 for (uint32_t k = 0; k < paths.size (); ++k)
580 std::string path = paths[k];
590 std::cout <<
"No Attributes are defined for this type."
597 PrintAttributes (tid, std::cout);
605 <<
"Attributes defined in parent class "
608 PrintAttributes (tmp, std::cout);
617 std::cout <<
"No TraceSources are defined for this type."
624 PrintTraceSources (tid, std::cout);
633 <<
"TraceSources defined in parent class "
636 PrintTraceSources (tmp, std::cout);
707 (*i)->GetValue (val);
712 <<
"GlobalValue" << (*i)->GetName () <<
" " << (*i)->GetName ()
714 <<
": " << (*i)->GetHelp () <<
"(" << val.Get () <<
")"
uint32_t GetAttributeN(void) const
#define NS_LOG_FUNCTION(parameters)
std::string functionStop
end of a class/function
virtual TypeId GetInstanceTypeId(void) const
std::string headingStop
end of section heading (h3)
hold variables of type string
std::string defgroupAttributeListStop
end of AttributeList group
std::string defgroupTraceSourceListStart
start of TraceSourceList group
std::string defgroupGlobalValueListStop
end of GlobalValueList group
std::string headingStart
start of section heading (h3)
std::string flagSpanStart
start of Attribute flag value
#define NS_LOG_COMPONENT_DEFINE(name)
TypeId GetParent(void) const
std::string boldStart
start of bold span
std::string commentStop
end of code comment
Ptr< Object > GetRootNamespaceObject(uint32_t i)
std::string listLineStart
start unordered list item
std::string breakTextOnly
linebreak for text output only
virtual bool HasUnderlyingTypeInformation(void) const =0
bool MustHideFromDocumentation(void) const
std::string indentHtmlOnly
small indent
std::string defgroupGlobalValueListStart
start of GlobalValueList group
std::string defgroupTraceSourceListStop
end of TraceSourceList group
std::string brief
brief tag
static uint32_t GetRegisteredN(void)
static Iterator Begin(void)
virtual std::string GetValueTypeName(void) const =0
uint32_t GetTraceSourceN(void) const
static TypeId GetRegistered(uint32_t i)
std::string breakHtmlOnly
linebreak for html output only
keep track of a set of node pointers.
std::string listLineStop
end unordered list item
std::string reference
reference tag
std::string GetName(void) const
std::string listStart
start unordered list
std::string listStop
end unordered list
std::string temporaryCharacter
"%" placeholder
std::string anchor
hyperlink anchor
std::string ingroupConstructs
add to constructs group
static Iterator End(void)
uint32_t GetRootNamespaceObjectN(void)
bool IsChildOf(TypeId other) const
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
std::string defgroupAttributeListStart
start of AttributeList group
struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const
std::string functionStart
start of a class/function
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
std::string breakBoth
linebreak
virtual std::string GetUnderlyingTypeInformation(void) const =0
std::string flagSpanStop
end of Attribute flag value
a unique identifier for an interface.
std::string boldStop
end of bold span
std::string commentStart
start of code comment
static TypeId LookupByName(std::string name)