TypeId information manager. More...
Classes | |
struct | IidInformation |
Public Member Functions | |
IidManager () | |
void | AddAttribute (uint16_t uid, std::string name, std::string help, uint32_t flags, Ptr< const AttributeValue > initialValue, Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker) |
void | AddConstructor (uint16_t uid, Callback< ObjectBase * > callback) |
void | AddTraceSource (uint16_t uid, std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor) |
uint16_t | AllocateUid (std::string name) |
struct TypeId::AttributeInformation | GetAttribute (uint16_t uid, uint32_t i) const |
uint32_t | GetAttributeN (uint16_t uid) const |
Callback< ObjectBase * > | GetConstructor (uint16_t uid) const |
std::string | GetGroupName (uint16_t uid) const |
TypeId::hash_t | GetHash (uint16_t uid) const |
std::string | GetName (uint16_t uid) const |
uint16_t | GetParent (uint16_t uid) const |
uint16_t | GetRegistered (uint32_t i) const |
uint32_t | GetRegisteredN (void) const |
struct TypeId::TraceSourceInformation | GetTraceSource (uint16_t uid, uint32_t i) const |
uint32_t | GetTraceSourceN (uint16_t uid) const |
uint16_t | GetUid (std::string name) const |
uint16_t | GetUid (TypeId::hash_t hash) const |
bool | HasConstructor (uint16_t uid) const |
void | HideFromDocumentation (uint16_t uid) |
bool | MustHideFromDocumentation (uint16_t uid) const |
void | SetAttributeInitialValue (uint16_t uid, uint32_t i, Ptr< const AttributeValue > initialValue) |
void | SetGroupName (uint16_t uid, std::string groupName) |
void | SetParent (uint16_t uid, uint16_t parent) |
Private Types | |
enum | { HashChainFlag = 0x80000000 } |
typedef std::map < TypeId::hash_t, uint16_t > | hashmap_t |
typedef std::vector< struct IidInformation > ::const_iterator | Iterator |
typedef std::map< std::string, uint16_t > | namemap_t |
Private Member Functions | |
bool | HasAttribute (uint16_t uid, std::string name) |
bool | HasTraceSource (uint16_t uid, std::string name) |
struct IidManager::IidInformation * | LookupInformation (uint16_t uid) const |
Static Private Member Functions | |
static TypeId::hash_t | Hasher (const std::string name) |
Private Attributes | |
hashmap_t | m_hashmap |
std::vector< struct IidInformation > | m_information |
namemap_t | m_namemap |
TypeId information manager.
Information records are stored in a vector. Name and hash lookup are performed by maps to the vector index.
We require all types to produce distinct hashes. What if we encounter two types that produce the same hash value? As we move to a federated distribution model (the App store), it becomes increasingly likely that the core ns3 team won't discover this in test builds. Therefore, we need to handle this case explicitly.
Note, we expect this to be extremely rare. As of this writing we have ~400 < 2^9 types, so the probability of getting a collision when we introduce a new type is ~2^9/2^31 = 2^-22, assuming we reserve 31 bits for the hash, and one bit for chaining. Even with double the number of types the probability of having a collision is only 2 x 10^-4. The probability for a three-fold collision is 1 x 10^-10.
Therefore, we'll handle one collision explicitly by reserving the high order bit of the hash value, and assert on higher level collisions. The three-fold collision probability should be an acceptablly small error rate.
Definition at line 71 of file type-id.cc.
|
private |
Definition at line 135 of file type-id.cc.
|
private |
Definition at line 126 of file type-id.cc.
|
private |
Definition at line 132 of file type-id.cc.
|
private |
Enumerator | |
---|---|
HashChainFlag |
Definition at line 141 of file type-id.cc.
ns3::IidManager::IidManager | ( | ) |
Definition at line 144 of file type-id.cc.
References NS_LOG_FUNCTION.
void ns3::IidManager::AddAttribute | ( | uint16_t | uid, |
std::string | name, | ||
std::string | help, | ||
uint32_t | flags, | ||
Ptr< const AttributeValue > | initialValue, | ||
Ptr< const AttributeAccessor > | spec, | ||
Ptr< const AttributeChecker > | checker | ||
) |
Definition at line 389 of file type-id.cc.
References ns3::TypeId::AttributeInformation::accessor, ns3::IidManager::IidInformation::attributes, ns3::TypeId::AttributeInformation::checker, ns3::TypeId::AttributeInformation::flags, HasAttribute(), ns3::TypeId::AttributeInformation::help, ns3::TypeId::AttributeInformation::initialValue, LookupInformation(), ns3::TypeId::AttributeInformation::name, ns3::IidManager::IidInformation::name, NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::TypeId::AttributeInformation::originalInitialValue.
void ns3::IidManager::AddConstructor | ( | uint16_t | uid, |
Callback< ObjectBase * > | callback | ||
) |
Definition at line 259 of file type-id.cc.
References ns3::IidManager::IidInformation::constructor, ns3::IidManager::IidInformation::hasConstructor, LookupInformation(), ns3::IidManager::IidInformation::name, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
void ns3::IidManager::AddTraceSource | ( | uint16_t | uid, |
std::string | name, | ||
std::string | help, | ||
Ptr< const TraceSourceAccessor > | accessor | ||
) |
Definition at line 472 of file type-id.cc.
References ns3::TypeId::TraceSourceInformation::accessor, HasTraceSource(), ns3::TypeId::TraceSourceInformation::help, LookupInformation(), ns3::TypeId::TraceSourceInformation::name, ns3::IidManager::IidInformation::name, NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::IidManager::IidInformation::traceSources.
uint16_t ns3::IidManager::AllocateUid | ( | std::string | name | ) |
Definition at line 158 of file type-id.cc.
References GetUid(), ns3::IidManager::IidInformation::groupName, ns3::IidManager::IidInformation::hasConstructor, ns3::IidManager::IidInformation::hash, HashChainFlag, Hasher(), LookupInformation(), m_hashmap, m_information, m_namemap, ns3::IidManager::IidInformation::mustHideFromDocumentation, ns3::IidManager::IidInformation::name, NS_ASSERT, NS_ASSERT_MSG, NS_LOG_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::IidManager::IidInformation::parent.
struct TypeId::AttributeInformation ns3::IidManager::GetAttribute | ( | uint16_t | uid, |
uint32_t | i | ||
) | const |
Definition at line 435 of file type-id.cc.
References NS_ASSERT, and NS_LOG_FUNCTION.
uint32_t ns3::IidManager::GetAttributeN | ( | uint16_t | uid | ) | const |
Definition at line 428 of file type-id.cc.
References ns3::IidManager::IidInformation::attributes, LookupInformation(), and NS_LOG_FUNCTION.
Callback< ObjectBase * > ns3::IidManager::GetConstructor | ( | uint16_t | uid | ) | const |
Definition at line 328 of file type-id.cc.
References ns3::IidManager::IidInformation::constructor, ns3::IidManager::IidInformation::hasConstructor, LookupInformation(), ns3::IidManager::IidInformation::name, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
std::string ns3::IidManager::GetGroupName | ( | uint16_t | uid | ) | const |
Definition at line 320 of file type-id.cc.
References ns3::IidManager::IidInformation::groupName, LookupInformation(), and NS_LOG_FUNCTION.
TypeId::hash_t ns3::IidManager::GetHash | ( | uint16_t | uid | ) | const |
Definition at line 306 of file type-id.cc.
References ns3::IidManager::IidInformation::hash, LookupInformation(), and NS_LOG_FUNCTION.
std::string ns3::IidManager::GetName | ( | uint16_t | uid | ) | const |
Definition at line 299 of file type-id.cc.
References LookupInformation(), ns3::IidManager::IidInformation::name, and NS_LOG_FUNCTION.
uint16_t ns3::IidManager::GetParent | ( | uint16_t | uid | ) | const |
Definition at line 313 of file type-id.cc.
References LookupInformation(), NS_LOG_FUNCTION, and ns3::IidManager::IidInformation::parent.
uint16_t ns3::IidManager::GetRegistered | ( | uint32_t | i | ) | const |
Definition at line 354 of file type-id.cc.
References NS_LOG_FUNCTION.
uint32_t ns3::IidManager::GetRegisteredN | ( | void | ) | const |
Definition at line 348 of file type-id.cc.
References m_information, and NS_LOG_FUNCTION.
struct TypeId::TraceSourceInformation ns3::IidManager::GetTraceSource | ( | uint16_t | uid, |
uint32_t | i | ||
) | const |
Definition at line 498 of file type-id.cc.
References NS_ASSERT, and NS_LOG_FUNCTION.
uint32_t ns3::IidManager::GetTraceSourceN | ( | uint16_t | uid | ) | const |
Definition at line 491 of file type-id.cc.
References LookupInformation(), NS_LOG_FUNCTION, and ns3::IidManager::IidInformation::traceSources.
uint16_t ns3::IidManager::GetUid | ( | std::string | name | ) | const |
Definition at line 272 of file type-id.cc.
References m_namemap, and NS_LOG_FUNCTION.
Referenced by AllocateUid().
uint16_t ns3::IidManager::GetUid | ( | TypeId::hash_t | hash | ) | const |
Definition at line 286 of file type-id.cc.
References m_hashmap.
|
private |
Definition at line 361 of file type-id.cc.
References ns3::IidManager::IidInformation::attributes, LookupInformation(), NS_LOG_FUNCTION, and ns3::IidManager::IidInformation::parent.
Referenced by AddAttribute().
bool ns3::IidManager::HasConstructor | ( | uint16_t | uid | ) | const |
Definition at line 340 of file type-id.cc.
References ns3::IidManager::IidInformation::hasConstructor, LookupInformation(), and NS_LOG_FUNCTION.
|
staticprivate |
Definition at line 151 of file type-id.cc.
References ns3::Hasher::clear(), and ns3::Hasher::GetHash32().
Referenced by AllocateUid().
|
private |
Definition at line 444 of file type-id.cc.
References LookupInformation(), NS_LOG_FUNCTION, ns3::IidManager::IidInformation::parent, and ns3::IidManager::IidInformation::traceSources.
Referenced by AddTraceSource().
void ns3::IidManager::HideFromDocumentation | ( | uint16_t | uid | ) |
Definition at line 251 of file type-id.cc.
References LookupInformation(), ns3::IidManager::IidInformation::mustHideFromDocumentation, and NS_LOG_FUNCTION.
|
private |
Definition at line 228 of file type-id.cc.
References m_information, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by AddAttribute(), AddConstructor(), AddTraceSource(), AllocateUid(), GetAttributeN(), GetConstructor(), GetGroupName(), GetHash(), GetName(), GetParent(), GetTraceSourceN(), HasAttribute(), HasConstructor(), HasTraceSource(), HideFromDocumentation(), MustHideFromDocumentation(), SetAttributeInitialValue(), SetGroupName(), and SetParent().
bool ns3::IidManager::MustHideFromDocumentation | ( | uint16_t | uid | ) | const |
Definition at line 506 of file type-id.cc.
References LookupInformation(), ns3::IidManager::IidInformation::mustHideFromDocumentation, and NS_LOG_FUNCTION.
void ns3::IidManager::SetAttributeInitialValue | ( | uint16_t | uid, |
uint32_t | i, | ||
Ptr< const AttributeValue > | initialValue | ||
) |
Definition at line 415 of file type-id.cc.
References ns3::IidManager::IidInformation::attributes, LookupInformation(), NS_ASSERT, and NS_LOG_FUNCTION.
void ns3::IidManager::SetGroupName | ( | uint16_t | uid, |
std::string | groupName | ||
) |
Definition at line 244 of file type-id.cc.
References ns3::IidManager::IidInformation::groupName, LookupInformation(), and NS_LOG_FUNCTION.
void ns3::IidManager::SetParent | ( | uint16_t | uid, |
uint16_t | parent | ||
) |
Definition at line 236 of file type-id.cc.
References LookupInformation(), m_information, NS_ASSERT, NS_LOG_FUNCTION, and ns3::IidManager::IidInformation::parent.
|
private |
Definition at line 136 of file type-id.cc.
Referenced by AllocateUid(), and GetUid().
|
private |
Definition at line 130 of file type-id.cc.
Referenced by AllocateUid(), GetRegisteredN(), LookupInformation(), and SetParent().
|
private |
Definition at line 133 of file type-id.cc.
Referenced by AllocateUid(), and GetUid().