diff --git a/src/core/model/type-id.cc b/src/core/model/type-id.cc index d52b803a6..d1d46fdf8 100644 --- a/src/core/model/type-id.cc +++ b/src/core/model/type-id.cc @@ -54,6 +54,7 @@ public: ns3::Ptr spec, ns3::Ptr checker); uint32_t GetAttributeN (uint16_t uid) const; + struct ns3::TypeId::AttributeInformation GetAttribute(uint16_t uid, uint32_t i) const; std::string GetAttributeName (uint16_t uid, uint32_t i) const; std::string GetAttributeHelp (uint16_t uid, uint32_t i) const; uint32_t GetAttributeFlags (uint16_t uid, uint32_t i) const; @@ -65,6 +66,7 @@ public: std::string help, ns3::Ptr accessor); uint32_t GetTraceSourceN (uint16_t uid) const; + struct ns3::TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, uint32_t i) const; std::string GetTraceSourceName (uint16_t uid, uint32_t i) const; std::string GetTraceSourceHelp (uint16_t uid, uint32_t i) const; ns3::Ptr GetTraceSourceAccessor (uint16_t uid, uint32_t i) const; @@ -74,19 +76,6 @@ private: bool HasTraceSource (uint16_t uid, std::string name); bool HasAttribute (uint16_t uid, std::string name); - struct AttributeInformation { - std::string name; - std::string help; - uint32_t flags; - ns3::Ptr initialValue; - ns3::Ptr param; - ns3::Ptr checker; - }; - struct TraceSourceInformation { - std::string name; - std::string help; - ns3::Ptr accessor; - }; struct IidInformation { std::string name; uint16_t parent; @@ -94,8 +83,8 @@ private: bool hasConstructor; ns3::Callback constructor; bool mustHideFromDocumentation; - std::vector attributes; - std::vector traceSources; + std::vector attributes; + std::vector traceSources; }; typedef std::vector::const_iterator Iterator; @@ -242,7 +231,7 @@ IidManager::HasAttribute (uint16_t uid, struct IidInformation *information = LookupInformation (uid); while (true) { - for (std::vector::const_iterator i = information->attributes.begin (); + for (std::vector::const_iterator i = information->attributes.begin (); i != information->attributes.end (); ++i) { if (i->name == name) @@ -277,7 +266,7 @@ IidManager::AddAttribute (uint16_t uid, NS_FATAL_ERROR ("Attribute \"" << name << "\" already registered on tid=\"" << information->name << "\""); } - struct AttributeInformation param; + struct ns3::TypeId::AttributeInformation param; param.name = name; param.help = help; param.flags = flags; @@ -294,6 +283,13 @@ IidManager::GetAttributeN (uint16_t uid) const struct IidInformation *information = LookupInformation (uid); return information->attributes.size (); } +struct ns3::TypeId::AttributeInformation +IidManager::GetAttribute(uint16_t uid, uint32_t i) const +{ + struct IidInformation *information = LookupInformation (uid); + NS_ASSERT (i < information->attributes.size ()); + return information->attributes[i]; +} std::string IidManager::GetAttributeName (uint16_t uid, uint32_t i) const { @@ -344,7 +340,7 @@ IidManager::HasTraceSource (uint16_t uid, struct IidInformation *information = LookupInformation (uid); while (true) { - for (std::vector::const_iterator i = information->traceSources.begin (); + for (std::vector::const_iterator i = information->traceSources.begin (); i != information->traceSources.end (); ++i) { if (i->name == name) @@ -376,7 +372,7 @@ IidManager::AddTraceSource (uint16_t uid, NS_FATAL_ERROR ("Trace source \"" << name << "\" already registered on tid=\"" << information->name << "\""); } - struct TraceSourceInformation source; + struct ns3::TypeId::TraceSourceInformation source; source.name = name; source.help = help; source.accessor = accessor; @@ -388,6 +384,13 @@ IidManager::GetTraceSourceN (uint16_t uid) const struct IidInformation *information = LookupInformation (uid); return information->traceSources.size (); } +struct ns3::TypeId::TraceSourceInformation +IidManager::GetTraceSource(uint16_t uid, uint32_t i) const +{ + struct IidInformation *information = LookupInformation (uid); + NS_ASSERT (i < information->traceSources.size ()); + return information->traceSources[i]; +} std::string IidManager::GetTraceSourceName (uint16_t uid, uint32_t i) const { @@ -612,6 +615,11 @@ TypeId::GetAttributeN (void) const uint32_t n = Singleton::Get ()->GetAttributeN (m_tid); return n; } +struct TypeId::AttributeInformation +TypeId::GetAttribute(uint32_t i) const +{ + return Singleton::Get ()->GetAttribute(m_tid, i); +} std::string TypeId::GetAttributeName (uint32_t i) const { @@ -662,6 +670,12 @@ TypeId::GetTraceSourceN (void) const { return Singleton::Get ()->GetTraceSourceN (m_tid); } +struct TypeId::TraceSourceInformation +TypeId::GetTraceSource(uint32_t i) const +{ + return Singleton::Get ()->GetTraceSource(m_tid, i); +} + std::string TypeId::GetTraceSourceName (uint32_t i) const { diff --git a/src/core/model/type-id.h b/src/core/model/type-id.h index f79514a1e..0b96ca1c8 100644 --- a/src/core/model/type-id.h +++ b/src/core/model/type-id.h @@ -53,6 +53,19 @@ public: ATTR_CONSTRUCT = 1<<2, /**< The attribute can be written at construction-time */ ATTR_SGC = ATTR_GET | ATTR_SET | ATTR_CONSTRUCT, /**< The attribute can be read, and written at any time */ }; + struct AttributeInformation { + std::string name; + std::string help; + uint32_t flags; + ns3::Ptr initialValue; + ns3::Ptr param; + ns3::Ptr checker; + }; + struct TraceSourceInformation { + std::string name; + std::string help; + ns3::Ptr accessor; + }; /** * \param name the name of the requested TypeId @@ -132,6 +145,12 @@ public: * \returns the number of attributes associated to this TypeId */ uint32_t GetAttributeN (void) const; + /** + * \param i index into attribute array + * \returns the information associated to attribute whose + * index is i. + */ + struct TypeId::AttributeInformation GetAttribute(uint32_t i) const; /** * \param i index into attribute array * \returns the name associated to the attribute whose @@ -190,6 +209,11 @@ public: * \returns the number of trace sources defined in this TypeId. */ uint32_t GetTraceSourceN (void) const; + /** + * \param i index into trace source array. + * \returns detailed information about the requested trace source. + */ + struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const; /** * \param i index into trace source array. * \returns the name of the requested trace source.