diff --git a/src/config-store/model/attribute-default-iterator.cc b/src/config-store/model/attribute-default-iterator.cc index aec678839..ddf366b39 100644 --- a/src/config-store/model/attribute-default-iterator.cc +++ b/src/config-store/model/attribute-default-iterator.cc @@ -43,43 +43,40 @@ AttributeDefaultIterator::Iterate (void) bool calledStart = false; for (uint32_t j = 0; j < tid.GetAttributeN (); j++) { - uint32_t flags = tid.GetAttributeFlags (j); - if (!(flags & TypeId::ATTR_CONSTRUCT)) + struct TypeId::AttributeInformation info = tid.GetAttribute (j); + if (!(info.flags & TypeId::ATTR_CONSTRUCT)) { // we can't construct the attribute, so, there is no // initial value for the attribute continue; } - Ptr accessor = tid.GetAttributeAccessor (j); //No accessor, go to next attribute - if (accessor == 0) + if (info.accessor == 0) { continue; } - if (!accessor->HasSetter ()) + if (!info.accessor->HasSetter ()) { //skip this attribute it doesn't have an setter continue; } - Ptr checker = tid.GetAttributeChecker (j); - if (checker == 0) + if (info.checker == 0) { //skip, it doesn't have a checker continue; } - Ptr value = tid.GetAttributeInitialValue (j); - if (value == 0) + if (info.initialValue == 0) { //No value, check next attribute continue; } - Ptr vector = DynamicCast (value); + Ptr vector = DynamicCast (info.initialValue); if (vector != 0) { //a vector value, won't take it continue; } - Ptr pointer = DynamicCast (value); + Ptr pointer = DynamicCast (info.initialValue); if (pointer != 0) { //pointer value, won't take it @@ -88,9 +85,9 @@ AttributeDefaultIterator::Iterate (void) //We take only values, no pointers or vectors if (!calledStart) { - StartVisitTypeId (tid.GetName ()); + StartVisitTypeId (info.name); } - VisitAttribute (tid, tid.GetAttributeName (j), value->SerializeToString (checker), j); + VisitAttribute (tid, info.name, info.initialValue->SerializeToString (info.checker), j); calledStart = true; } if (calledStart) diff --git a/src/config-store/model/attribute-iterator.cc b/src/config-store/model/attribute-iterator.cc index a6cd0c77c..fe6d634d6 100644 --- a/src/config-store/model/attribute-iterator.cc +++ b/src/config-store/model/attribute-iterator.cc @@ -203,17 +203,17 @@ AttributeIterator::DoIterate (Ptr object) NS_LOG_DEBUG ("store " << tid.GetName ()); for (uint32_t i = 0; i < tid.GetAttributeN (); ++i) { - Ptr checker = tid.GetAttributeChecker (i); - const PointerChecker *ptrChecker = dynamic_cast (PeekPointer (checker)); + struct TypeId::AttributeInformation info = tid.GetAttribute(i); + const PointerChecker *ptrChecker = dynamic_cast (PeekPointer (info.checker)); if (ptrChecker != 0) { - NS_LOG_DEBUG ("pointer attribute " << tid.GetAttributeName (i)); + NS_LOG_DEBUG ("pointer attribute " << info.name); PointerValue ptr; - object->GetAttribute (tid.GetAttributeName (i), ptr); + object->GetAttribute (info.name, ptr); Ptr tmp = ptr.Get (); if (tmp != 0) { - StartVisitPointerAttribute (object, tid.GetAttributeName (i), + StartVisitPointerAttribute (object, info.name, tmp); m_examined.push_back (object); DoIterate (tmp); @@ -223,13 +223,13 @@ AttributeIterator::DoIterate (Ptr object) continue; } // attempt to cast to an object vector. - const ObjectVectorChecker *vectorChecker = dynamic_cast (PeekPointer (checker)); + const ObjectVectorChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); if (vectorChecker != 0) { - NS_LOG_DEBUG ("vector attribute " << tid.GetAttributeName (i)); + NS_LOG_DEBUG ("vector attribute " << info.name); ObjectVectorValue vector; - object->GetAttribute (tid.GetAttributeName (i), vector); - StartVisitArrayAttribute (object, tid.GetAttributeName (i), vector); + object->GetAttribute (info.name, vector); + StartVisitArrayAttribute (object, info.name, vector); for (uint32_t j = 0; j < vector.GetN (); ++j) { NS_LOG_DEBUG ("vector attribute item " << j); @@ -243,16 +243,14 @@ AttributeIterator::DoIterate (Ptr object) EndVisitArrayAttribute (); continue; } - uint32_t flags = tid.GetAttributeFlags (i); - Ptr accessor = tid.GetAttributeAccessor (i); - if ((flags & TypeId::ATTR_GET) && accessor->HasGetter () && - (flags & TypeId::ATTR_SET) && accessor->HasSetter ()) + if ((info.flags & TypeId::ATTR_GET) && info.accessor->HasGetter () && + (info.flags & TypeId::ATTR_SET) && info.accessor->HasSetter ()) { - VisitAttribute (object, tid.GetAttributeName (i)); + VisitAttribute (object, info.name); } else { - NS_LOG_DEBUG ("could not store " << tid.GetAttributeName (i)); + NS_LOG_DEBUG ("could not store " << info.name); } } } diff --git a/src/core/model/attribute-list.cc b/src/core/model/attribute-list.cc index e22e7e001..16c2f6b25 100644 --- a/src/core/model/attribute-list.cc +++ b/src/core/model/attribute-list.cc @@ -62,7 +62,7 @@ AttributeList::~AttributeList () void AttributeList::Set (std::string name, const AttributeValue &value) { - struct TypeId::AttributeInfo info; + struct TypeId::AttributeInformation info; bool ok = TypeId::LookupAttributeByFullName (name, &info); if (!ok) { @@ -77,7 +77,7 @@ AttributeList::Set (std::string name, const AttributeValue &value) bool AttributeList::SetFailSafe (std::string name, const AttributeValue &value) { - struct TypeId::AttributeInfo info; + struct TypeId::AttributeInformation info; bool ok = TypeId::LookupAttributeByFullName (name, &info); if (!ok) { @@ -89,7 +89,7 @@ AttributeList::SetFailSafe (std::string name, const AttributeValue &value) void AttributeList::SetWithTid (TypeId tid, std::string name, const AttributeValue & value) { - struct TypeId::AttributeInfo info; + struct TypeId::AttributeInformation info; bool ok = tid.LookupAttributeByName (name, &info); if (!ok) { @@ -122,7 +122,7 @@ AttributeList::DoSetOne (Ptr checker, const AttributeVal m_attributes.push_back (attr); } bool -AttributeList::DoSet (struct TypeId::AttributeInfo *info, const AttributeValue &value) +AttributeList::DoSet (struct TypeId::AttributeInformation *info, const AttributeValue &value) { if (info->checker == 0) { @@ -175,7 +175,8 @@ AttributeList::LookupAttributeFullNameByChecker (Ptr che TypeId tid = TypeId::GetRegistered (i); for (uint32_t j = 0; j < tid.GetAttributeN (); j++) { - if (checker == tid.GetAttributeChecker (j)) + struct TypeId::AttributeInformation info = tid.GetAttribute(j); + if (checker == info.checker) { return tid.GetAttributeFullName (j); } @@ -220,7 +221,7 @@ AttributeList::DeserializeFromString (std::string str) else { std::string name = str.substr (cur, equal-cur); - struct TypeId::AttributeInfo info; + struct TypeId::AttributeInformation info; if (!TypeId::LookupAttributeByFullName (name, &info)) { NS_FATAL_ERROR ("Error while parsing serialized attribute: name does not exist: \"" << name << "\""); diff --git a/src/core/model/attribute-list.h b/src/core/model/attribute-list.h index be2583f43..17850adfb 100644 --- a/src/core/model/attribute-list.h +++ b/src/core/model/attribute-list.h @@ -101,7 +101,7 @@ private: - bool DoSet (struct TypeId::AttributeInfo *info, const AttributeValue ¶m); + bool DoSet (struct TypeId::AttributeInformation *info, const AttributeValue ¶m); void DoSetOne (Ptr checker, const AttributeValue ¶m); std::string LookupAttributeFullNameByChecker (Ptr checker) const; diff --git a/src/core/model/command-line.cc b/src/core/model/command-line.cc index aab4966fe..559aa2f18 100644 --- a/src/core/model/command-line.cc +++ b/src/core/model/command-line.cc @@ -157,10 +157,9 @@ CommandLine::PrintAttributes (std::string type) const for (uint32_t i = 0; i < tid.GetAttributeN (); ++i) { std::cout << " --"< checker = tid.GetAttributeChecker (i); - Ptr initial = tid.GetAttributeInitialValue (i); - std::cout << initial->SerializeToString (checker) << "]: " - << tid.GetAttributeHelp (i) << std::endl; + struct TypeId::AttributeInformation info = tid.GetAttribute (i); + std::cout << info.initialValue->SerializeToString (info.checker) << "]: " + << info.help << std::endl; } } diff --git a/src/core/model/config.cc b/src/core/model/config.cc index 2fd0687cc..a1b3bf158 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -377,7 +377,7 @@ Resolver::DoResolve (std::string path, Ptr root) { // this is a normal attribute. TypeId tid = root->GetInstanceTypeId (); - struct TypeId::AttributeInfo info; + struct TypeId::AttributeInformation info; if (!tid.LookupAttributeByName (item, &info)) { NS_LOG_DEBUG ("Requested item="<accessor = tid.GetAttributeAccessor (i); - info->flags = tid.GetAttributeFlags (i); - info->initialValue = tid.GetAttributeInitialValue (i); - info->checker = tid.GetAttributeChecker (i); + *info = tmp; return true; } } @@ -643,27 +640,6 @@ TypeId::GetAttributeInitialValue (uint32_t i) const Ptr value = Singleton::Get ()->GetAttributeInitialValue (m_tid, i); return value; } -Ptr -TypeId::GetAttributeAccessor (uint32_t i) const -{ - // Used exclusively by the Object class. - Ptr accessor = Singleton::Get ()->GetAttributeAccessor (m_tid, i); - return accessor; -} -uint32_t -TypeId::GetAttributeFlags (uint32_t i) const -{ - // Used exclusively by the Object class. - uint32_t flags = Singleton::Get ()->GetAttributeFlags (m_tid, i); - return flags; -} -Ptr -TypeId::GetAttributeChecker (uint32_t i) const -{ - // Used exclusively by the Object class. - Ptr checker = Singleton::Get ()->GetAttributeChecker (m_tid, i); - return checker; -} uint32_t TypeId::GetTraceSourceN (void) const diff --git a/src/core/model/type-id.h b/src/core/model/type-id.h index ef2bf1af5..ed752be77 100644 --- a/src/core/model/type-id.h +++ b/src/core/model/type-id.h @@ -176,21 +176,6 @@ public: * is initialized. */ Ptr GetAttributeInitialValue (uint32_t i) const; - /** - * \param i index into attribute array. - * \returns the flags associated to the requested attribute. - */ - uint32_t GetAttributeFlags (uint32_t i) const; - /** - * \param i index into attribute array. - * \returns the checker associated to the requested attribute. - */ - Ptr GetAttributeChecker (uint32_t i) const; - /** - * \param i index into attribute array. - * \returns the accessor associated to the requested attribute. - */ - Ptr GetAttributeAccessor (uint32_t i) const; /** * \returns a callback which can be used to instanciate an object @@ -318,26 +303,13 @@ public: TypeId HideFromDocumentation (void); - /** - * \brief store together a set of attribute properties. - */ - struct AttributeInfo { - // The accessor associated to the attribute. - Ptr accessor; - // The initial value associated to the attribute. - Ptr initialValue; - // The set of access control flags associated to the attribute. - uint32_t flags; - // The checker associated to the attribute. - Ptr checker; - }; /** * \param name the name of the requested attribute - * \param info a pointer to the TypeId::AttributeInfo data structure + * \param info a pointer to the TypeId::AttributeInformation data structure * where the result value of this method will be stored. * \returns true if the requested attribute could be found, false otherwise. */ - bool LookupAttributeByName (std::string name, struct AttributeInfo *info) const; + bool LookupAttributeByName (std::string name, struct AttributeInformation *info) const; /** * \param name the name of the requested trace source * \returns the trace source accessor which can be used to connect and disconnect @@ -350,11 +322,11 @@ public: /** * \param fullName the full name of the requested attribute - * \param info a pointer to the TypeId::AttributeInfo data structure + * \param info a pointer to the TypeId::AttributeInformation data structure * where the result value of this method will be stored. * \returns the Accessor associated to the requested attribute */ - static bool LookupAttributeByFullName (std::string fullName, struct AttributeInfo *info); + static bool LookupAttributeByFullName (std::string fullName, struct AttributeInformation *info); /** * \returns the internal integer which uniquely identifies this diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index be89b7574..dc71f2c1f 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -19,32 +19,29 @@ PrintAttributes (TypeId tid, std::ostream &os) os << "
    "<" << tid.GetAttributeName (j) << ": " - << tid.GetAttributeHelp (j) << std::endl; - Ptr checker = tid.GetAttributeChecker (j); + struct TypeId::AttributeInformation info = tid.GetAttribute(j); + os << "
  • " << info.name << ": " + << info.help << std::endl; os << "
      " << std::endl - << "
    • Set with class: \\ref " << checker->GetValueTypeName () << "
    • " << std::endl; - if (checker->HasUnderlyingTypeInformation ()) + << "
    • Set with class: \\ref " << info.checker->GetValueTypeName () << "
    • " << std::endl; + if (info.checker->HasUnderlyingTypeInformation ()) { - os << "
    • Underlying type: \\ref " << checker->GetUnderlyingTypeInformation () << "
    • " << std::endl; + os << "
    • Underlying type: \\ref " << info.checker->GetUnderlyingTypeInformation () << "
    • " << std::endl; } - uint32_t flags = tid.GetAttributeFlags (j); - Ptr accessor = tid.GetAttributeAccessor (j); - if (flags & TypeId::ATTR_CONSTRUCT && accessor->HasSetter ()) + if (info.flags & TypeId::ATTR_CONSTRUCT && info.accessor->HasSetter ()) { - Ptr initial = tid.GetAttributeInitialValue (j); - os << "
    • Initial value: " << initial->SerializeToString (checker) << "
    • " << std::endl; + os << "
    • Initial value: " << info.initialValue->SerializeToString (info.checker) << "
    • " << std::endl; } os << "
    • Flags: "; - if (flags & TypeId::ATTR_CONSTRUCT && accessor->HasSetter ()) + if (info.flags & TypeId::ATTR_CONSTRUCT && info.accessor->HasSetter ()) { os << "construct "; } - if (flags & TypeId::ATTR_SET && accessor->HasSetter ()) + if (info.flags & TypeId::ATTR_SET && info.accessor->HasSetter ()) { os << "write "; } - if (flags & TypeId::ATTR_GET && accessor->HasGetter ()) + if (info.flags & TypeId::ATTR_GET && info.accessor->HasGetter ()) { os << "read "; } @@ -173,12 +170,12 @@ StaticInformation::DoGather (TypeId tid) RecordOutput (tid); for (uint32_t i = 0; i < tid.GetAttributeN (); ++i) { - Ptr checker = tid.GetAttributeChecker (i); - const PointerChecker *ptrChecker = dynamic_cast (PeekPointer (checker)); + struct TypeId::AttributeInformation info = tid.GetAttribute(i); + const PointerChecker *ptrChecker = dynamic_cast (PeekPointer (info.checker)); if (ptrChecker != 0) { TypeId pointee = ptrChecker->GetPointeeTypeId (); - m_currentPath.push_back (tid.GetAttributeName (i)); + m_currentPath.push_back (info.name); m_alreadyProcessed.push_back (tid); DoGather (pointee); m_alreadyProcessed.pop_back (); @@ -186,11 +183,11 @@ StaticInformation::DoGather (TypeId tid) continue; } // attempt to cast to an object vector. - const ObjectVectorChecker *vectorChecker = dynamic_cast (PeekPointer (checker)); + const ObjectVectorChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); if (vectorChecker != 0) { TypeId item = vectorChecker->GetItemTypeId (); - m_currentPath.push_back (tid.GetAttributeName (i) + "/[i]"); + m_currentPath.push_back (info.name + "/[i]"); m_alreadyProcessed.push_back (tid); DoGather (item); m_alreadyProcessed.pop_back ();