use new API. kill old one.
authorMathieu Lacage <mathieu.lacage@gmail.com>
Wed, 03 Aug 2011 10:04:56 -0400
changeset 7393 8c3dfe0be54d
parent 7392 88230da4bb1a
child 7394 48475b398d9d
use new API. kill old one.
src/config-store/model/attribute-default-iterator.cc
src/config-store/model/attribute-iterator.cc
src/core/model/attribute-list.cc
src/core/model/attribute-list.h
src/core/model/command-line.cc
src/core/model/config.cc
src/core/model/object-base.cc
src/core/model/type-id.cc
src/core/model/type-id.h
utils/print-introspected-doxygen.cc
--- a/src/config-store/model/attribute-default-iterator.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/config-store/model/attribute-default-iterator.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -43,43 +43,40 @@
       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<const AttributeAccessor> 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<const AttributeChecker> checker = tid.GetAttributeChecker (j);
-          if (checker == 0)
+          if (info.checker == 0)
             {
               //skip, it doesn't have a checker
               continue;
             }
-          Ptr<const AttributeValue> value = tid.GetAttributeInitialValue (j);
-          if (value == 0)
+          if (info.initialValue == 0)
             {
               //No value, check next attribute
               continue;
             }
-          Ptr<const ObjectVectorValue> vector = DynamicCast<const ObjectVectorValue> (value);
+          Ptr<const ObjectVectorValue> vector = DynamicCast<const ObjectVectorValue> (info.initialValue);
           if (vector != 0)
             {
               //a vector value, won't take it
               continue;
             }
-          Ptr<const PointerValue> pointer = DynamicCast<const PointerValue> (value);
+          Ptr<const PointerValue> pointer = DynamicCast<const PointerValue> (info.initialValue);
           if (pointer != 0)
             {
               //pointer value, won't take it
@@ -88,9 +85,9 @@
           //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)
--- a/src/config-store/model/attribute-iterator.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/config-store/model/attribute-iterator.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -203,17 +203,17 @@
       NS_LOG_DEBUG ("store " << tid.GetName ());
       for (uint32_t i = 0; i < tid.GetAttributeN (); ++i)
         {
-          Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
-          const PointerChecker *ptrChecker = dynamic_cast<const PointerChecker *> (PeekPointer (checker));
+          struct TypeId::AttributeInformation info = tid.GetAttribute(i);
+          const PointerChecker *ptrChecker = dynamic_cast<const PointerChecker *> (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<Object> tmp = ptr.Get<Object> ();
               if (tmp != 0)
                 {
-                  StartVisitPointerAttribute (object, tid.GetAttributeName (i),
+                  StartVisitPointerAttribute (object, info.name,
                                               tmp);
                   m_examined.push_back (object);
                   DoIterate (tmp);
@@ -223,13 +223,13 @@
               continue;
             }
           // attempt to cast to an object vector.
-          const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (PeekPointer (checker));
+          const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (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 @@
               EndVisitArrayAttribute ();
               continue;
             }
-          uint32_t flags = tid.GetAttributeFlags (i);
-          Ptr<const AttributeAccessor> 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);
             }
         }
     }
--- a/src/core/model/attribute-list.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/attribute-list.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -62,7 +62,7 @@
 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 @@
 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 @@
 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 @@
   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 @@
       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 @@
       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 << "\"");
--- a/src/core/model/attribute-list.h	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/attribute-list.h	Wed Aug 03 10:04:56 2011 -0400
@@ -101,7 +101,7 @@
 
 
 
-  bool DoSet (struct TypeId::AttributeInfo *info, const AttributeValue &param);
+  bool DoSet (struct TypeId::AttributeInformation *info, const AttributeValue &param);
   void DoSetOne (Ptr<const AttributeChecker> checker, const AttributeValue &param);
   std::string LookupAttributeFullNameByChecker (Ptr<const AttributeChecker> checker) const;
 
--- a/src/core/model/command-line.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/command-line.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -157,10 +157,9 @@
   for (uint32_t i = 0; i < tid.GetAttributeN (); ++i)
     {
       std::cout << "    --"<<tid.GetAttributeFullName (i)<<"=[";
-      Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
-      Ptr<const AttributeValue> 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;
     }
 }
 
--- a/src/core/model/config.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/config.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -377,7 +377,7 @@
     {
       // 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="<<item<<" does not exist on path="<<GetResolvedPath ());
--- a/src/core/model/object-base.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/object-base.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -158,14 +158,14 @@
 }
 
 bool
-ObjectBase::DoSet (Ptr<const AttributeAccessor> spec, 
+ObjectBase::DoSet (Ptr<const AttributeAccessor> accessor, 
                    Ptr<const AttributeChecker> checker,
                    const AttributeValue &value)
 {
   bool ok = checker->Check (value);
   if (ok)
     {
-      ok = spec->Set (this, value);
+      ok = accessor->Set (this, value);
       return ok;
     }
   // attempt to convert to string
@@ -186,13 +186,13 @@
     {
       return false;
     }
-  ok = spec->Set (this, *v);
+  ok = accessor->Set (this, *v);
   return ok;
 }
 void
 ObjectBase::SetAttribute (std::string name, const AttributeValue &value)
 {
-  struct TypeId::AttributeInfo info;
+  struct TypeId::AttributeInformation info;
   TypeId tid = GetInstanceTypeId ();
   if (!tid.LookupAttributeByName (name, &info))
     {
@@ -211,7 +211,7 @@
 bool 
 ObjectBase::SetAttributeFailSafe (std::string name, const AttributeValue &value)
 {
-  struct TypeId::AttributeInfo info;
+  struct TypeId::AttributeInformation info;
   TypeId tid = GetInstanceTypeId ();
   if (!tid.LookupAttributeByName (name, &info))
     {
@@ -228,7 +228,7 @@
 void
 ObjectBase::GetAttribute (std::string name, AttributeValue &value) const
 {
-  struct TypeId::AttributeInfo info;
+  struct TypeId::AttributeInformation info;
   TypeId tid = GetInstanceTypeId ();
   if (!tid.LookupAttributeByName (name, &info))
     {
@@ -262,7 +262,7 @@
 bool
 ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const
 {
-  struct TypeId::AttributeInfo info;
+  struct TypeId::AttributeInformation info;
   TypeId tid = GetInstanceTypeId ();
   if (!tid.LookupAttributeByName (name, &info))
     {
--- a/src/core/model/type-id.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/type-id.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -459,7 +459,7 @@
 }
 
 bool
-TypeId::LookupAttributeByFullName (std::string fullName, struct TypeId::AttributeInfo *info)
+TypeId::LookupAttributeByFullName (std::string fullName, struct TypeId::AttributeInformation *info)
 {
   std::string::size_type pos = fullName.rfind ("::");
   if (pos == std::string::npos)
@@ -488,7 +488,7 @@
 }
 
 bool
-TypeId::LookupAttributeByName (std::string name, struct TypeId::AttributeInfo *info) const
+TypeId::LookupAttributeByName (std::string name, struct TypeId::AttributeInformation *info) const
 {
   TypeId tid;
   TypeId nextTid = *this;
@@ -496,13 +496,10 @@
       tid = nextTid;
       for (uint32_t i = 0; i < tid.GetAttributeN (); i++)
         {
-          std::string paramName = tid.GetAttributeName (i);
-          if (paramName == name)
+          struct TypeId::AttributeInformation tmp = tid.GetAttribute(i);
+          if (tmp.name == name)
             {
-              info->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 @@
   Ptr<const AttributeValue> value = Singleton<IidManager>::Get ()->GetAttributeInitialValue (m_tid, i);
   return value;
 }
-Ptr<const AttributeAccessor>
-TypeId::GetAttributeAccessor (uint32_t i) const
-{
-  // Used exclusively by the Object class.
-  Ptr<const AttributeAccessor> accessor = Singleton<IidManager>::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<IidManager>::Get ()->GetAttributeFlags (m_tid, i);
-  return flags;
-}
-Ptr<const AttributeChecker>
-TypeId::GetAttributeChecker (uint32_t i) const
-{
-  // Used exclusively by the Object class.
-  Ptr<const AttributeChecker> checker = Singleton<IidManager>::Get ()->GetAttributeChecker (m_tid, i);
-  return checker;
-}
 
 uint32_t 
 TypeId::GetTraceSourceN (void) const
--- a/src/core/model/type-id.h	Wed Aug 03 09:42:10 2011 -0400
+++ b/src/core/model/type-id.h	Wed Aug 03 10:04:56 2011 -0400
@@ -176,21 +176,6 @@
    *          is initialized.
    */
   Ptr<const AttributeValue> 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<const AttributeChecker> GetAttributeChecker (uint32_t i) const;
-  /**
-   * \param i index into attribute array.
-   * \returns the accessor associated to the requested attribute.
-   */
-  Ptr<const AttributeAccessor> GetAttributeAccessor (uint32_t i) const;
 
   /**
    * \returns a callback which can be used to instanciate an object
@@ -319,25 +304,12 @@
   TypeId HideFromDocumentation (void);
 
   /**
-   * \brief store together a set of attribute properties.
-   */
-  struct AttributeInfo {
-    // The accessor associated to the attribute.
-    Ptr<const AttributeAccessor> accessor;
-    // The initial value associated to the attribute.
-    Ptr<const AttributeValue> initialValue;
-    // The set of access control flags associated to the attribute.
-    uint32_t flags;
-    // The checker associated to the attribute.
-    Ptr<const AttributeChecker> 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 @@
 
   /**
    * \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
--- a/utils/print-introspected-doxygen.cc	Wed Aug 03 09:42:10 2011 -0400
+++ b/utils/print-introspected-doxygen.cc	Wed Aug 03 10:04:56 2011 -0400
@@ -19,32 +19,29 @@
   os << "<ul>"<<std::endl;
   for (uint32_t j = 0; j < tid.GetAttributeN (); j++)
     {
-      os << "<li><b>" << tid.GetAttributeName (j) << "</b>: "
-		<< tid.GetAttributeHelp (j) << std::endl;
-      Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (j);
+      struct TypeId::AttributeInformation info = tid.GetAttribute(j);
+      os << "<li><b>" << info.name << "</b>: "
+		<< info.help << std::endl;
       os << "  <ul>" << std::endl 
-	 << "    <li>Set with class: \\ref " <<  checker->GetValueTypeName () << "</li>" << std::endl;
-      if (checker->HasUnderlyingTypeInformation ())
+	 << "    <li>Set with class: \\ref " <<  info.checker->GetValueTypeName () << "</li>" << std::endl;
+      if (info.checker->HasUnderlyingTypeInformation ())
 	{
-	  os << "    <li>Underlying type: \\ref " << checker->GetUnderlyingTypeInformation () << "</li>" << std::endl;
+	  os << "    <li>Underlying type: \\ref " << info.checker->GetUnderlyingTypeInformation () << "</li>" << std::endl;
 	}
-      uint32_t flags = tid.GetAttributeFlags (j);
-      Ptr<const AttributeAccessor> accessor = tid.GetAttributeAccessor (j);
-      if (flags & TypeId::ATTR_CONSTRUCT && accessor->HasSetter ())
+      if (info.flags & TypeId::ATTR_CONSTRUCT && info.accessor->HasSetter ())
 	{
-	  Ptr<const AttributeValue> initial = tid.GetAttributeInitialValue (j);
-	  os << "    <li>Initial value: " << initial->SerializeToString (checker) << "</li>" << std::endl;
+	  os << "    <li>Initial value: " << info.initialValue->SerializeToString (info.checker) << "</li>" << std::endl;
 	}
       os << "    <li>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 @@
   RecordOutput (tid);
   for (uint32_t i = 0; i < tid.GetAttributeN (); ++i)
     {
-      Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
-      const PointerChecker *ptrChecker = dynamic_cast<const PointerChecker *> (PeekPointer (checker));
+      struct TypeId::AttributeInformation info = tid.GetAttribute(i);
+      const PointerChecker *ptrChecker = dynamic_cast<const PointerChecker *> (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 @@
           continue;
         }
       // attempt to cast to an object vector.
-      const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (PeekPointer (checker));
+      const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (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 ();