92 void SetParent (uint16_t uid, uint16_t parent);
104 void SetSize (uint16_t uid, std::size_t size);
121 uint16_t
GetUid (std::string name)
const;
133 std::string
GetName (uint16_t uid)
const;
157 std::size_t
GetSize (uint16_t uid)
const;
245 std::string callback);
312 typedef std::vector<struct IidInformation>::const_iterator
Iterator;
351 static ns3::Hasher hasher ( Create<Hash::Function::Murmur3> () );
361 "Trying to allocate twice the same uid: " << name);
365 NS_LOG_ERROR (
"Hash chaining TypeId for '" << name <<
"'. "
366 <<
"This is not a bug, but is extremely unlikely. "
367 <<
"Please contact the ns3 developers.");
381 "Triplicate hash detected while chaining TypeId for '"
383 <<
"'. Please contact the ns3 developers for assistance.");
392 if (name > hinfo->
name)
394 NS_LOG_LOGIC (
"New TypeId '" << name <<
"' getting chained.");
409 information.
name = name;
410 information.
hash = hash;
413 information.
size = (std::size_t)(-1);
421 m_namemap.insert (std::make_pair (name, uid));
422 m_hashmap.insert (std::make_pair (hash, uid));
440 information->
parent = parent;
454 information->
size = size;
481 namemap_t::const_iterator it =
m_namemap.find (name);
494 hashmap_t::const_iterator it =
m_hashmap.find (hash);
509 return information->
name;
516 return information->
hash;
523 return information->
parent;
537 return information->
size;
547 NS_FATAL_ERROR (
"Requested constructor for "<<information->
name<<
" but it does not have one.");
581 for (std::vector<struct TypeId::AttributeInformation>::const_iterator i = information->
attributes.begin ();
590 if (parent == information)
596 information = parent;
610 NS_LOG_FUNCTION (
this << uid << name << help << flags << initialValue << accessor << checker);
614 NS_FATAL_ERROR (
"Attribute \"" << name <<
"\" already registered on tid=\"" <<
615 information->
name <<
"\"");
634 NS_ASSERT (i < information->attributes.size ());
635 information->
attributes[i].initialValue = initialValue;
652 NS_ASSERT (i < information->attributes.size ());
664 for (std::vector<struct TypeId::TraceSourceInformation>::const_iterator i = information->
traceSources.begin ();
673 if (parent == information)
679 information = parent;
689 std::string callback)
695 NS_FATAL_ERROR (
"Trace source \"" << name <<
"\" already registered on tid=\"" <<
696 information->
name <<
"\"");
717 NS_ASSERT (i < information->traceSources.size ());
755 NS_ASSERT_MSG (uid != 0,
"Assert in TypeId::LookupByName: " << name <<
" not found");
774 NS_ASSERT_MSG (uid != 0,
"Assert in TypeId::LookupByHash: 0x"
775 << std::hex << hash << std::dec <<
" not found");
814 if (tmp.
name == name)
821 }
while (nextTid != tid);
858 return parent !=
m_tid;
865 while (tmp != other && tmp != tmp.
GetParent ())
869 return tmp == other && *
this != other;
906 return hasConstructor;
923 NS_LOG_FUNCTION (
this << name << help << &initialValue << accessor << checker);
936 NS_LOG_FUNCTION (
this << name << help << flags << &initialValue << accessor << checker);
1006 return AddTraceSource (name, help, accessor,
"(not yet documented)");
1013 std::string callback)
1040 if (info.
name == name)
1046 }
while (nextTid != tid);
1070 std::string tidString;
1075 is.setstate (std::ios_base::badbit);
uint32_t GetAttributeN(void) const
Get the number of attributes.
static TypeId::hash_t Hasher(const std::string name)
Hashing function.
uint32_t hash_t
Type of hash values.
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
TypeId AddTraceSource(std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor) NS_DEPRECATED
Record a new TraceSource.
bool HasAttribute(uint16_t uid, std::string name)
Check if a type id has a given Attribute.
Callback< ObjectBase * > GetConstructor(uint16_t uid) const
Get the constructor Callback of a type id.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
ns3::Singleton declaration and template implementation.
bool HasTraceSource(uint16_t uid, std::string name)
Check if a type id has a given TraceSource.
TypeId SetParent(void)
Set the parent TypeId.
std::vector< struct IidInformation > m_information
The container of all type id records.
std::string GetGroupName(uint16_t uid) const
Get the group name of a type id.
static TypeId LookupByHash(hash_t hash)
Get a TypeId by hash.
hashmap_t m_hashmap
The by-hash index.
namemap_t m_namemap
The by-name index.
std::map< TypeId::hash_t, uint16_t > hashmap_t
Type of the by-hash index.
Hold a value for an Attribute.
struct TypeId::AttributeInformation GetAttribute(uint16_t uid, uint32_t i) const
Get Attribute information by index.
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
void SetGroupName(uint16_t uid, std::string groupName)
Set the group name of a type id.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
TypeId GetParent(void) const
Get the parent of this TypeId.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
void AddTraceSource(uint16_t uid, std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor, std::string callback)
Record a new TraceSource.
uint32_t GetRegisteredN(void) const
Get the total number of type ids.
ns3::Hasher, ns3::Hash32() and ns3::Hash64() function declarations.
static IidManager * Get(void)
Get a pointer to the singleton instance.
Callback< ObjectBase * > GetConstructor(void) const
Get the constructor callback.
static bool LookupByHashFailSafe(hash_t hash, TypeId *tid)
Get a TypeId by hash.
bool HasConstructor(void) const
Check if this TypeId has a constructor.
bool MustHideFromDocumentation(void) const
Check if this TypeId should not be listed in documentation.
TypeId information manager.
static uint32_t GetRegisteredN(void)
Get the number of registered TypeIds.
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
Find a TraceSource by name.
uint32_t GetAttributeN(uint16_t uid) const
Get the number of attributes.
uint16_t m_tid
The TypeId value.
TypeId()
Default constructor.
bool HasParent(void) const
Check if this TypeId has a parent.
uint32_t GetHash32(const char *buffer, const size_t size)
Compute 32-bit hash of a byte buffer.
uint32_t GetTraceSourceN(void) const
Get the number of Trace sources.
static TypeId GetRegistered(uint32_t i)
Get a TypeId by index.
uint32_t GetTraceSourceN(uint16_t uid) const
Get the number of Trace sources.
void SetAttributeInitialValue(uint16_t uid, uint32_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
struct TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, uint32_t i) const
Get the trace source by index.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void HideFromDocumentation(uint16_t uid)
Mark this type id to be excluded from documentation.
bool MustHideFromDocumentation(uint16_t uid) const
Check if this TypeId should not be listed in documentation.
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
TypeId SetGroupName(std::string groupName)
Set the group name.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
TypeId AddAttribute(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeAccessor > accessor, Ptr< const AttributeChecker > checker)
Record in this TypeId the fact that a new attribute exists.
virtual Ptr< AttributeValue > Copy(void) const =0
Hasher & clear(void)
Restore initial state.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetUid(uint16_t tid)
Set the internal id of this TypeId.
bool LookupAttributeByName(std::string name, struct AttributeInformation *info) const
Find an Attribute by name.
ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations.
ns3::TypeId declaration; inline and template implementations.
std::map< std::string, uint16_t > namemap_t
Type of the by-name index.
uint16_t GetRegistered(uint32_t i) const
Get a type id by index.
std::string GetName(void) const
Get the name.
The attribute can be read, and written at any time.
uint16_t GetUid(void) const
Get the internal id of this TypeId.
void DoAddConstructor(Callback< ObjectBase * > callback)
Implementation for AddConstructor().
hash_t GetHash(void) const
Get the hash.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
bool SetAttributeInitialValue(uint32_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
uint16_t AllocateUid(std::string name)
Create a new unique type id.
void SetParent(uint16_t uid, uint16_t parent)
Set the parent of a type id.
std::size_t GetSize(void) const
Get the size of this object.
uint16_t GetParent(uint16_t uid) const
Get the parent of a type id.
void SetSize(uint16_t uid, std::size_t size)
Set the size of the object class referred to by this id.
TypeId SetSize(std::size_t size)
Set the size of this type.
std::string GetName(uint16_t uid) const
Get the name of a type id.
TypeId::hash_t GetHash(uint16_t uid) const
Get the hash of a type id.
std::string GetAttributeFullName(uint32_t i) const
Get the Attribute name by index.
bool HasConstructor(uint16_t uid) const
Check if a type id has a constructor Callback.
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const
Get the trace source by index.
std::string GetGroupName(void) const
Get the group name.
struct IidManager::IidInformation * LookupInformation(uint16_t uid) const
Retrieve the information record for a type.
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
Get Attribute information by index.
void AddConstructor(uint16_t uid, Callback< ObjectBase * > callback)
Add a constructor Callback to this type id.
a unique identifier for an interface.
std::vector< struct IidInformation >::const_iterator Iterator
Iterator type.
std::size_t GetSize(uint16_t uid) const
Get the size of a type id.
Generic Hash function interface.
TypeId HideFromDocumentation(void)
Hide this TypeId from documentation.
void AddAttribute(uint16_t uid, std::string name, std::string help, uint32_t flags, Ptr< const AttributeValue > initialValue, Ptr< const AttributeAccessor > accessor, Ptr< const AttributeChecker > checker)
Record a new attribute in a type id.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
uint16_t GetUid(std::string name) const
Get a type id by name.