|
|
| 32 |
#include "ns3/pointer.h" |
32 |
#include "ns3/pointer.h" |
| 33 |
#include "ns3/string.h" |
33 |
#include "ns3/string.h" |
| 34 |
#include "ns3/node-container.h" |
34 |
#include "ns3/node-container.h" |
| 35 |
#include "ns3/csma-channel.h" |
35 |
#include "ns3/simple-channel.h" |
| 36 |
|
36 |
|
| 37 |
using namespace ns3; |
37 |
using namespace ns3; |
| 38 |
|
38 |
|
|
|
| 961 |
*/ |
961 |
*/ |
| 962 |
std::vector<std::string> Get (TypeId tid) const; |
962 |
std::vector<std::string> Get (TypeId tid) const; |
| 963 |
|
963 |
|
|
|
964 |
/** |
| 965 |
* \return the type names we couldn't aggregate. |
| 966 |
*/ |
| 967 |
std::vector<std::string> GetNoTypeIds (void) const; |
| 968 |
|
| 964 |
private: |
969 |
private: |
| 965 |
/** |
970 |
/** |
| 966 |
* \return the current configuration path |
971 |
* \return the current configuration path |
|
|
| 1000 |
* List of aggregation relationships. |
1005 |
* List of aggregation relationships. |
| 1001 |
*/ |
1006 |
*/ |
| 1002 |
std::vector<std::pair<TypeId,TypeId> > m_aggregates; |
1007 |
std::vector<std::pair<TypeId,TypeId> > m_aggregates; |
|
|
1008 |
/** |
| 1009 |
* List of type names without TypeIds, because those modules aren't enabled. |
| 1010 |
* |
| 1011 |
* This is mutable because GetNoTypeIds sorts and uniquifies this list |
| 1012 |
* before returning it. |
| 1013 |
*/ |
| 1014 |
mutable std::vector<std::string> m_noTids; |
| 1015 |
|
| 1003 |
}; // class StaticInformation |
1016 |
}; // class StaticInformation |
| 1004 |
|
1017 |
|
| 1005 |
|
1018 |
|
|
|
| 1007 |
StaticInformation::RecordAggregationInfo (std::string a, std::string b) |
1020 |
StaticInformation::RecordAggregationInfo (std::string a, std::string b) |
| 1008 |
{ |
1021 |
{ |
| 1009 |
NS_LOG_FUNCTION (this << a << b); |
1022 |
NS_LOG_FUNCTION (this << a << b); |
| 1010 |
m_aggregates.push_back (std::make_pair (TypeId::LookupByName (a), TypeId::LookupByName (b))); |
1023 |
TypeId aTid; |
|
|
1024 |
bool found = TypeId::LookupByNameFailSafe (a, &aTid); |
| 1025 |
if (!found) |
| 1026 |
{ |
| 1027 |
m_noTids.push_back (a); |
| 1028 |
return; |
| 1029 |
} |
| 1030 |
TypeId bTid; |
| 1031 |
found = TypeId::LookupByNameFailSafe (b, &bTid); |
| 1032 |
if (!found) |
| 1033 |
{ |
| 1034 |
m_noTids.push_back (b); |
| 1035 |
return; |
| 1036 |
} |
| 1037 |
|
| 1038 |
m_aggregates.push_back (std::make_pair (aTid, bTid)); |
| 1011 |
} |
1039 |
} |
| 1012 |
|
1040 |
|
| 1013 |
|
1041 |
|
|
|
| 1076 |
return paths; |
1104 |
return paths; |
| 1077 |
} |
1105 |
} |
| 1078 |
|
1106 |
|
|
|
1107 |
/** |
| 1108 |
* Helper to keep only the unique items in a container. |
| 1109 |
* |
| 1110 |
* The container is modified in place; the elements end up sorted. |
| 1111 |
* |
| 1112 |
* The container must support \c begin(), \c end() and \c erase(), |
| 1113 |
* which, among the STL containers, limits this to |
| 1114 |
* \c std::vector, \c std::dequeue and \c std::list. |
| 1115 |
* |
| 1116 |
* The container elements must support \c operator< (for \c std::sort) |
| 1117 |
* and \c operator== (for \c std::unique). |
| 1118 |
* |
| 1119 |
* \tparam T The container type. |
| 1120 |
* \param t The container. |
| 1121 |
*/ |
| 1122 |
template <typename T> |
| 1123 |
void |
| 1124 |
Uniquefy (T t) |
| 1125 |
{ |
| 1126 |
std::sort (t.begin (), t.end ()); |
| 1127 |
t.erase (std::unique (t.begin (), t.end ()), t.end ()); |
| 1128 |
} |
| 1129 |
|
| 1130 |
std::vector<std::string> |
| 1131 |
StaticInformation::GetNoTypeIds (void) const |
| 1132 |
{ |
| 1133 |
NS_LOG_FUNCTION (this); |
| 1134 |
Uniquefy (m_noTids); |
| 1135 |
return m_noTids; |
| 1136 |
} |
| 1137 |
|
| 1079 |
|
1138 |
|
| 1080 |
void |
1139 |
void |
| 1081 |
StaticInformation::Gather (TypeId tid) |
1140 |
StaticInformation::Gather (TypeId tid) |
| 1082 |
{ |
1141 |
{ |
| 1083 |
NS_LOG_FUNCTION (this << tid); |
1142 |
NS_LOG_FUNCTION (this << tid); |
| 1084 |
DoGather (tid); |
1143 |
DoGather (tid); |
| 1085 |
|
1144 |
Uniquefy (m_output); |
| 1086 |
std::sort (m_output.begin (), m_output.end ()); |
|
|
| 1087 |
m_output.erase (std::unique (m_output.begin (), m_output.end ()), m_output.end ()); |
| 1088 |
} |
1145 |
} |
| 1089 |
|
1146 |
|
| 1090 |
|
1147 |
|
|
|
| 1211 |
|
1268 |
|
| 1212 |
// Create a channel object so that channels appear in the namespace |
1269 |
// Create a channel object so that channels appear in the namespace |
| 1213 |
// paths that will be generated here. |
1270 |
// paths that will be generated here. |
| 1214 |
Ptr<CsmaChannel> csma; |
1271 |
Ptr<SimpleChannel> simpleChannel; |
| 1215 |
csma = CreateObject<CsmaChannel> (); |
1272 |
simpleChannel = CreateObject<SimpleChannel> (); |
| 1216 |
|
1273 |
|
| 1217 |
for (uint32_t i = 0; i < Config::GetRootNamespaceObjectN (); ++i) |
1274 |
for (uint32_t i = 0; i < Config::GetRootNamespaceObjectN (); ++i) |
| 1218 |
{ |
1275 |
{ |
|
|
| 1226 |
|
1283 |
|
| 1227 |
|
1284 |
|
| 1228 |
// Map from TypeId name to tid |
1285 |
// Map from TypeId name to tid |
| 1229 |
typedef std::map< std::string, uint32_t> NameMap; |
1286 |
typedef std::map< std::string, int32_t> NameMap; |
| 1230 |
typedef NameMap::const_iterator NameMapIterator; |
1287 |
typedef NameMap::const_iterator NameMapIterator; |
| 1231 |
|
1288 |
|
| 1232 |
|
1289 |
|
| 1233 |
// Create a map from the class names to their index in the vector of |
1290 |
// Create a map from the class names to their index in the vector of |
| 1234 |
// TypeId's so that the names will end up in alphabetical order. |
1291 |
// TypeId's so that the names will end up in alphabetical order. |
| 1235 |
NameMap |
1292 |
NameMap |
| 1236 |
GetNameMap (void) |
1293 |
GetNameMap (const StaticInformation & info) |
| 1237 |
{ |
1294 |
{ |
| 1238 |
NS_LOG_FUNCTION_NOARGS (); |
1295 |
NS_LOG_FUNCTION_NOARGS (); |
| 1239 |
NameMap nameMap; |
1296 |
NameMap nameMap; |
| 1240 |
|
1297 |
|
|
|
1298 |
// Registered types |
| 1241 |
for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++) |
1299 |
for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++) |
| 1242 |
{ |
1300 |
{ |
| 1243 |
TypeId tid = TypeId::GetRegistered (i); |
1301 |
TypeId tid = TypeId::GetRegistered (i); |
|
|
| 1257 |
// Save this name's index. |
1315 |
// Save this name's index. |
| 1258 |
nameMap[name] = i; |
1316 |
nameMap[name] = i; |
| 1259 |
} |
1317 |
} |
|
|
1318 |
|
| 1319 |
// Type names without TypeIds |
| 1320 |
std::vector<std::string> noTids = info.GetNoTypeIds (); |
| 1321 |
for (std::vector<std::string>::const_iterator i = noTids.begin (); |
| 1322 |
i != noTids.end (); |
| 1323 |
++i) |
| 1324 |
{ |
| 1325 |
nameMap[*i] = -1; |
| 1326 |
} |
| 1327 |
|
| 1260 |
return nameMap; |
1328 |
return nameMap; |
| 1261 |
} // GetNameMap () |
1329 |
} // GetNameMap () |
| 1262 |
|
1330 |
|
|
|
| 1271 |
// Config -------------- |
1339 |
// Config -------------- |
| 1272 |
if (paths.empty ()) |
1340 |
if (paths.empty ()) |
| 1273 |
{ |
1341 |
{ |
| 1274 |
os << "Doxygen introspection did not find any typical Config paths." |
1342 |
os << "Introspection did not find any typical Config paths." |
| 1275 |
<< breakBoth |
1343 |
<< breakBoth |
| 1276 |
<< std::endl; |
1344 |
<< std::endl; |
| 1277 |
} |
1345 |
} |
|
|
| 1334 |
// Get typical aggregation relationships. |
1402 |
// Get typical aggregation relationships. |
| 1335 |
StaticInformation info = GetTypicalAggregations (); |
1403 |
StaticInformation info = GetTypicalAggregations (); |
| 1336 |
|
1404 |
|
| 1337 |
NameMap nameMap = GetNameMap (); |
1405 |
NameMap nameMap = GetNameMap (info); |
| 1338 |
|
1406 |
|
| 1339 |
// Iterate over the map, which will print the class names in |
1407 |
// Iterate over the map, which will print the class names in |
| 1340 |
// alphabetical order. |
1408 |
// alphabetical order. |
|
|
| 1343 |
nameMapIterator++) |
1411 |
nameMapIterator++) |
| 1344 |
{ |
1412 |
{ |
| 1345 |
// Get the class's index out of the map; |
1413 |
// Get the class's index out of the map; |
| 1346 |
uint32_t i = nameMapIterator->second; |
1414 |
std::string name = nameMapIterator->first; |
|
|
1415 |
int32_t i = nameMapIterator->second; |
| 1416 |
TypeId tid; |
| 1347 |
|
1417 |
|
|
|
1418 |
if (i >= 0) |
| 1419 |
{ |
| 1420 |
tid = TypeId::GetRegistered (i); |
| 1421 |
if (tid.MustHideFromDocumentation ()) |
| 1422 |
{ |
| 1423 |
continue; |
| 1424 |
} |
| 1425 |
name = tid.GetName (); |
| 1426 |
} |
| 1427 |
|
| 1348 |
std::cout << commentStart << std::endl; |
1428 |
std::cout << commentStart << std::endl; |
| 1349 |
|
1429 |
|
| 1350 |
TypeId tid = TypeId::GetRegistered (i); |
1430 |
std::cout << classStart << name << std::endl; |
| 1351 |
if (tid.MustHideFromDocumentation ()) |
|
|
| 1352 |
{ |
| 1353 |
continue; |
| 1354 |
} |
| 1355 |
|
| 1356 |
std::cout << classStart << tid.GetName () << std::endl; |
| 1357 |
std::cout << std::endl; |
1431 |
std::cout << std::endl; |
| 1358 |
|
1432 |
|
| 1359 |
PrintConfigPaths (std::cout, info, tid); |
1433 |
if (i >= 0) |
| 1360 |
PrintAttributes (std::cout, tid); |
1434 |
{ |
| 1361 |
PrintTraceSources (std::cout, tid); |
1435 |
PrintConfigPaths (std::cout, info, tid); |
| 1362 |
PrintSize (std::cout, tid); |
1436 |
PrintAttributes (std::cout, tid); |
|
|
1437 |
PrintTraceSources (std::cout, tid); |
| 1438 |
PrintSize (std::cout, tid); |
| 1439 |
} |
| 1440 |
else |
| 1441 |
{ |
| 1442 |
std::cout << "Introspection could not find Config paths for " << name |
| 1443 |
<< " in this build because the parent module" |
| 1444 |
<< " was not included in the waf configuration." |
| 1445 |
<< breakBoth |
| 1446 |
<< std::endl; |
| 1447 |
} |
| 1363 |
|
1448 |
|
| 1364 |
std::cout << commentStop << std::endl; |
1449 |
std::cout << commentStop << std::endl; |
| 1365 |
} // class documentation |
1450 |
} // class documentation |