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;
209 const std::string &supportMsg =
"");
250 Ptr<const TraceSourceAccessor> accessor,
251 std::string callback,
252 TypeId::SupportLevel supportLevel = TypeId::SUPPORTED,
253 const std::string &supportMsg = "");
324 typedef std::vector<struct IidInformation>::const_iterator
Iterator;
364 static ns3::Hasher hasher ( Create<Hash::Function::Murmur3> () );
373 #define IID "IidManager" 379 #define IIDL IID << ": " 387 "Trying to allocate twice the same uid: " << name);
391 NS_LOG_ERROR (
"Hash chaining TypeId for '" << name <<
"'. " 392 <<
"This is not a bug, but is extremely unlikely. " 393 <<
"Please contact the ns3 developers.");
407 "Triplicate hash detected while chaining TypeId for '" 409 <<
"'. Please contact the ns3 developers for assistance.");
418 if (name > hinfo->
name)
435 information.
name = name;
436 information.
hash = hash;
439 information.
size = (std::size_t)(-1);
445 uint16_t uid =
static_cast<uint16_t
> (tuid);
448 m_namemap.insert (std::make_pair (name, uid));
449 m_hashmap.insert (std::make_pair (hash, uid));
469 information->
parent = parent;
483 information->
size = size;
511 namemap_t::const_iterator it =
m_namemap.find (name);
523 hashmap_t::const_iterator it =
m_hashmap.find (hash);
538 return information->
name;
554 uint16_t pid = information->
parent;
571 std::size_t size = information->
size;
583 NS_FATAL_ERROR (
"Requested constructor for "<<information->
name<<
" but it does not have one.");
619 for (std::vector<struct TypeId::AttributeInformation>::const_iterator i = information->
attributes.begin ();
629 if (parent == information)
636 information = parent;
651 const std::string &supportMsg)
654 << initialValue << accessor << checker
655 << supportLevel << supportMsg);
657 if (name.find (
' ') != std::string::npos)
659 NS_FATAL_ERROR (
"Attribute name \"" << name <<
"\" may not contain spaces ' ', " 660 <<
"encountered when registering TypeId \"" 661 << information->
name <<
"\"");
665 NS_FATAL_ERROR (
"Attribute \"" << name <<
"\" already registered on tid=\"" <<
666 information->
name <<
"\"");
688 NS_ASSERT (i < information->attributes.size ());
689 information->
attributes[i].initialValue = initialValue;
699 std::size_t size = information->
attributes.size ();
708 NS_ASSERT (i < information->attributes.size ());
721 for (std::vector<struct TypeId::TraceSourceInformation>::const_iterator i = information->
traceSources.begin ();
731 if (parent == information)
738 information = parent;
749 std::string callback,
751 const std::string &supportMsg)
754 << accessor << callback
755 << supportLevel << supportMsg);
759 NS_FATAL_ERROR (
"Trace source \"" << name <<
"\" already registered on tid=\"" <<
760 information->
name <<
"\"");
782 IidManager::GetTraceSource (uint16_t uid, std::size_t i) const
786 NS_ASSERT (i < information->traceSources.size ());
828 NS_ASSERT_MSG (uid != 0,
"Assert in TypeId::LookupByName: " << name <<
" not found");
847 NS_ASSERT_MSG (uid != 0,
"Assert in TypeId::LookupByHash: 0x" 848 << std::hex << hash << std::dec <<
" not found");
887 if (tmp.
name == name)
896 std::cerr <<
"Attribute '" << name <<
"' is deprecated: " 904 <<
"' is obsolete, with no fallback: " 910 }
while (nextTid != tid);
947 return parent !=
m_tid;
954 while (tmp != other && tmp != tmp.
GetParent ())
958 return tmp == other && *
this != other;
995 return hasConstructor;
1012 const std::string &supportMsg)
1015 << &initialValue << accessor << checker
1016 << supportLevel << supportMsg);
1018 initialValue.
Copy (), accessor, checker,
1019 supportLevel, supportMsg);
1031 const std::string &supportMsg)
1034 << &initialValue << accessor << checker
1035 << supportLevel << supportMsg);
1037 initialValue.
Copy (), accessor, checker,
1038 supportLevel, supportMsg);
1107 return AddTraceSource (name, help, accessor,
"(not yet documented)");
1114 std::string callback,
1116 const std::string &supportMsg)
1119 << accessor << callback
1120 << supportLevel << supportMsg);
1123 supportLevel, supportMsg);
1148 if (tmp.
name == name)
1157 std::cerr <<
"TraceSource '" << name <<
"' is deprecated: " 1165 <<
"' is obsolete, with no fallback: " 1171 }
while (nextTid != tid);
1214 std::string tidString;
1219 is.setstate (std::ios_base::badbit);
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
void SetAttributeInitialValue(uint16_t uid, std::size_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
static TypeId::hash_t Hasher(const std::string name)
Hashing function.
uint32_t hash_t
Type of hash values.
uint32_t GetHash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer.
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Callback< ObjectBase * > GetConstructor(void) const
Get the constructor callback.
std::string GetName(void) const
Get the name.
hash_t GetHash(void) const
Get the hash.
bool HasAttribute(uint16_t uid, std::string name)
Check if a type id has a given Attribute.
TypeId AddAttribute(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeAccessor > accessor, Ptr< const AttributeChecker > checker, SupportLevel supportLevel=SUPPORTED, const std::string &supportMsg="")
Record in this TypeId the fact that a new attribute exists.
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.
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
Find a TraceSource by name.
bool HasConstructor(void) const
Check if this TypeId has a constructor.
bool HasTraceSource(uint16_t uid, std::string name)
Check if a type id has a given TraceSource.
TypeId SetParent(void)
Set the parent TypeId.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
std::vector< struct IidInformation > m_information
The container of all type id records.
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.
#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.
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
bool HasConstructor(uint16_t uid) const
Check if a type id has a constructor Callback.
struct TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, std::size_t i) const
Get the trace source by index.
std::size_t GetAttributeN(uint16_t uid) const
Get the number of attributes.
#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.
std::size_t GetSize(uint16_t uid) const
Get the size of a type id.
bool HasParent(void) const
Check if this TypeId has a parent.
bool LookupAttributeByName(std::string name, struct AttributeInformation *info) const
Find an Attribute by name, retrieving the associated AttributeInformation.
uint16_t GetUid(std::string name) const
Get a type id by name.
ns3::Hasher, ns3::Hash32() and ns3::Hash64() function declarations.
The attribute can be read, and written at any time.
static IidManager * Get(void)
Get a pointer to the singleton instance.
std::size_t GetTraceSourceN(void) const
Get the number of Trace sources.
bool SetAttributeInitialValue(std::size_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
TypeId GetParent(void) const
Get the parent of this TypeId.
static bool LookupByHashFailSafe(hash_t hash, TypeId *tid)
Get a TypeId by hash.
bool operator<(const EventId &a, const EventId &b)
void DoAddConstructor(Callback< ObjectBase *> callback)
Implementation for AddConstructor().
TypeId information manager.
uint16_t GetRegisteredN(void) const
Get the total number of type ids.
std::string GetName(uint16_t uid) const
Get the name of a type id.
uint16_t GetParent(uint16_t uid) const
Get the parent of a type id.
uint16_t m_tid
The TypeId value.
TypeId()
Default constructor.
bool MustHideFromDocumentation(void) const
Check if this TypeId should not be listed in documentation.
struct TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const
Get the trace source by index.
void HideFromDocumentation(uint16_t uid)
Mark this type id to be excluded from documentation.
std::string GetGroupName(uint16_t uid) const
Get the group name of a type id.
TypeId SetGroupName(std::string groupName)
Set the group name.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
virtual Ptr< AttributeValue > Copy(void) const =0
uint16_t GetUid(void) const
Get the internal id of this TypeId.
Hasher & clear(void)
Restore initial state.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations.
std::string GetGroupName(void) const
Get the group name.
std::size_t GetSize(void) const
Get the size of this object.
ns3::TypeId declaration; inline and template implementations.
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
Attribute or trace source is currently used.
std::map< std::string, uint16_t > namemap_t
Type of the by-name index.
struct IidManager::IidInformation * LookupInformation(uint16_t uid) const
Retrieve the information record for a type.
void AddConstructor(uint16_t uid, Callback< ObjectBase *> callback)
Add a constructor Callback to this type id.
uint16_t GetRegistered(uint16_t i) const
Get a type id by index.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void SetUid(uint16_t uid)
Set the internal id of this TypeId.
NS_DEPRECATED TypeId AddTraceSource(std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor)
Record a new TraceSource.
uint16_t AllocateUid(std::string name)
Create a new unique type id.
bool MustHideFromDocumentation(uint16_t uid) const
Check if this TypeId should not be listed in documentation.
Attribute or trace source is not used anymore; simulation fails.
std::size_t GetTraceSourceN(uint16_t uid) const
Get the number of Trace sources.
struct TypeId::AttributeInformation GetAttribute(uint16_t uid, std::size_t i) const
Get Attribute information by index.
void SetParent(uint16_t uid, uint16_t parent)
Set the parent of a type id.
TypeId::hash_t GetHash(uint16_t uid) const
Get the hash of a type id.
std::size_t GetAttributeN(void) const
Get the number of attributes.
void SetSize(uint16_t uid, std::size_t size)
Set the size of the object class referred to by this id.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
TypeId SetSize(std::size_t size)
Set the size of this type.
void AddTraceSource(uint16_t uid, std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor, std::string callback, TypeId::SupportLevel supportLevel=TypeId::SUPPORTED, const std::string &supportMsg="")
Record a new TraceSource.
Attribute or trace source is deprecated; user is warned.
SupportLevel
The level of support or deprecation for attributes or trace sources.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Callback< ObjectBase * > GetConstructor(uint16_t uid) const
Get the constructor Callback of a type id.
static uint16_t GetRegisteredN(void)
Get the number of registered TypeIds.
a unique identifier for an interface.
std::vector< struct IidInformation >::const_iterator Iterator
Iterator type.
Generic Hash function interface.
TypeId HideFromDocumentation(void)
Hide this TypeId from documentation.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
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, TypeId::SupportLevel supportLevel=TypeId::SUPPORTED, const std::string &supportMsg="")
Record a new attribute in a type id.