A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::IidManager Class Reference

TypeId information manager. More...

+ Collaboration diagram for ns3::IidManager:

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::IidInformationLookupInformation (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
 

Detailed Description

TypeId information manager.

Information records are stored in a vector. Name and hash lookup are performed by maps to the vector index.

Internal:
Hash Chaining

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.

Member Typedef Documentation

typedef std::map<TypeId::hash_t, uint16_t> ns3::IidManager::hashmap_t
private

Definition at line 135 of file type-id.cc.

typedef std::vector<struct IidInformation>::const_iterator ns3::IidManager::Iterator
private

Definition at line 126 of file type-id.cc.

typedef std::map<std::string, uint16_t> ns3::IidManager::namemap_t
private

Definition at line 132 of file type-id.cc.

Member Enumeration Documentation

anonymous enum
private
Enumerator
HashChainFlag 

Definition at line 141 of file type-id.cc.

Constructor & Destructor Documentation

ns3::IidManager::IidManager ( )

Definition at line 144 of file type-id.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

void ns3::IidManager::AddConstructor ( uint16_t  uid,
Callback< ObjectBase * >  callback 
)
void ns3::IidManager::AddTraceSource ( uint16_t  uid,
std::string  name,
std::string  help,
Ptr< const TraceSourceAccessor accessor 
)
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.

+ Here is the call graph for this function:

Callback< ObjectBase * > ns3::IidManager::GetConstructor ( uint16_t  uid) const
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.

+ Here is the call graph for this 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.

+ Here is the call graph for this 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.

+ Here is the call graph for this 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.

+ Here is the call graph for this function:

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.

+ Here is the call graph for this function:

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().

+ Here is the caller graph for this function:

uint16_t ns3::IidManager::GetUid ( TypeId::hash_t  hash) const

Definition at line 286 of file type-id.cc.

References m_hashmap.

bool ns3::IidManager::HasAttribute ( uint16_t  uid,
std::string  name 
)
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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

+ Here is the call graph for this function:

TypeId::hash_t ns3::IidManager::Hasher ( const std::string  name)
staticprivate

Definition at line 151 of file type-id.cc.

References ns3::Hasher::clear(), and ns3::Hasher::GetHash32().

Referenced by AllocateUid().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::IidManager::HasTraceSource ( uint16_t  uid,
std::string  name 
)
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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

+ Here is the call graph for this function:

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.

+ Here is the call graph for this 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.

+ Here is the call graph for this 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.

+ Here is the call graph for this 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.

+ Here is the call graph for this function:

Member Data Documentation

hashmap_t ns3::IidManager::m_hashmap
private

Definition at line 136 of file type-id.cc.

Referenced by AllocateUid(), and GetUid().

std::vector<struct IidInformation> ns3::IidManager::m_information
private

Definition at line 130 of file type-id.cc.

Referenced by AllocateUid(), GetRegisteredN(), LookupInformation(), and SetParent().

namemap_t ns3::IidManager::m_namemap
private

Definition at line 133 of file type-id.cc.

Referenced by AllocateUid(), and GetUid().


The documentation for this class was generated from the following file: