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"
55 << info.
help << std::endl;
80 os <<
" " <<
listStop <<
" " << std::endl;
105 void RecordAggregationInfo (std::string a, std::string b);
107 void Print (
void)
const;
109 std::vector<std::string> Get (
TypeId tid);
112 std::string GetCurrentPath (
void)
const;
113 void DoGather (
TypeId tid);
114 void RecordOutput (
TypeId tid);
115 bool HasAlreadyBeenProcessed (
TypeId tid)
const;
116 void find_and_replace (std::string &source,
const std::string find, std::string replace );
117 std::vector<std::pair<TypeId,std::string> >
m_output;
132 for (std::vector<std::pair<TypeId,std::string> >::const_iterator i = m_output.begin (); i != m_output.end (); ++i)
134 std::pair<TypeId,std::string> item = *i;
135 std::cout << item.first.GetName () <<
" -> " << item.second << std::endl;
142 std::ostringstream oss;
143 for (std::vector<std::string>::const_iterator i = m_currentPath.begin (); i != m_currentPath.end (); ++i)
145 std::string item = *i;
154 m_output.push_back (std::make_pair (tid, GetCurrentPath ()));
160 for (uint32_t i = 0; i < m_alreadyProcessed.size (); ++i)
162 if (m_alreadyProcessed[i] == tid)
170 std::vector<std::string>
173 std::vector<std::string> paths;
174 for (uint32_t i = 0; i < m_output.size (); ++i)
176 std::pair<TypeId,std::string> tmp = m_output[i];
177 if (tmp.first == tid)
179 paths.push_back (tmp.second);
190 std::sort (m_output.begin (), m_output.end ());
191 m_output.erase (std::unique (m_output.begin (), m_output.end ()), m_output.end ());
198 if (HasAlreadyBeenProcessed (tid))
213 TypeId objectTypeId =
object->GetTypeId ();
214 if (objectTypeId == pointee)
223 m_currentPath.push_back (info.
name);
224 m_alreadyProcessed.push_back (tid);
226 m_alreadyProcessed.pop_back ();
227 m_currentPath.pop_back ();
232 if (vectorChecker != 0)
235 m_currentPath.push_back (info.
name +
"/[i]");
236 m_alreadyProcessed.push_back (tid);
238 m_alreadyProcessed.pop_back ();
239 m_currentPath.pop_back ();
251 find_and_replace(childName,
"::",replaceWith);
252 m_currentPath.push_back (childName);
253 m_alreadyProcessed.push_back (tid);
255 m_alreadyProcessed.pop_back ();
256 m_currentPath.pop_back ();
259 for (uint32_t k = 0; k < m_aggregates.size (); ++k)
261 std::pair<TypeId,TypeId> tmp = m_aggregates[k];
262 if (tmp.first == tid || tmp.second == tid)
265 if (tmp.first == tid)
269 if (tmp.second == tid)
287 find_and_replace(name,
"::",replaceWith);
288 m_currentPath.push_back (name);
289 m_alreadyProcessed.push_back (tid);
291 m_alreadyProcessed.pop_back ();
292 m_currentPath.pop_back ();
301 j = source.find (find);
302 while (j != std::string::npos )
304 source.replace (j, find.length (),replace);
305 j = source.find (find,j+1);
312 std::cout <<
"Usage: " << program_name <<
" [options]" << std::endl
314 <<
"Options:" << std::endl
315 <<
" --help : print these options" << std::endl
316 <<
" --output-text : format output as plain text" << std::endl;
319 int main (
int argc,
char *argv[])
321 bool outputText =
false;
322 char *programName = argv[0];
330 if (strcmp (arg,
"--help") == 0)
335 else if (strcmp(arg,
"--output-text") == 0)
357 commentStart =
"===============================================================\n";
422 std::map< std::string, uint32_t> nameMap;
423 std::map< std::string, uint32_t>::const_iterator nameMapIterator;
437 std::string name = tid.
GetName ();
438 for (uint32_t j = 0; j < name.length (); j++)
440 name[j] = toupper (name[j]);
449 for (nameMapIterator = nameMap.begin (); nameMapIterator != nameMap.end (); nameMapIterator++)
452 uint32_t i = nameMapIterator->second;
461 std::cout <<
brief <<
"This method returns the TypeId associated to " <<
reference << tid.
GetName () <<
"."
462 << std::endl << std::endl;
463 std::vector<std::string> paths = info.
Get (tid);
466 std::cout <<
"This object is accessible through the following paths with Config::Set and Config::Connect:"
469 for (uint32_t k = 0; k < paths.size (); ++k)
471 std::string path = paths[k];
478 std::cout <<
"No Attributes defined for this type." <<
breakBoth << std::endl;
482 std::cout <<
"Attributes defined for this type:" <<
breakHtmlOnly << std::endl;
491 std::cout <<
"Attributes defined in parent class " << tmp.
GetName () <<
":" <<
breakHtmlOnly << std::endl;
499 std::cout <<
"No TraceSources defined for this type." <<
breakBoth << std::endl;
503 std::cout <<
"TraceSources defined for this type:" <<
breakHtmlOnly << std::endl;
512 std::cout <<
"TraceSources defined in parent class " << tmp.
GetName () <<
":" <<
breakHtmlOnly << std::endl;
575 (*i)->GetValue (val);