From 617c57a45041b26a50f1c3188114fc2b11477cb4 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 23 Mar 2012 07:38:42 +0100 Subject: [PATCH] Handle the case where '*' is used against the name of an attribute in a configuration path --- src/core/model/config.cc | 85 +++++++++++++++++------------- src/core/test/config-test-suite.cc | 11 ++++ 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/core/model/config.cc b/src/core/model/config.cc index 89ba1d364..ed87fa059 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -377,56 +377,69 @@ Resolver::DoResolve (std::string path, Ptr root) { // this is a normal attribute. TypeId tid = root->GetInstanceTypeId (); - struct TypeId::AttributeInformation info; - if (!tid.LookupAttributeByName (item, &info)) + bool foundMatch = false; + for (uint32_t i = 0; i < tid.GetAttributeN(); i++) + { + struct TypeId::AttributeInformation info; + info = tid.GetAttribute(i); + if (info.name != item && item != "*") + { + continue; + } + // attempt to cast to a pointer checker. + const PointerChecker *ptr = dynamic_cast (PeekPointer (info.checker)); + if (ptr != 0) + { + NS_LOG_DEBUG ("GetAttribute(ptr)="< (PeekPointer (info.checker)); + if (vectorChecker != 0) + { + NS_LOG_DEBUG ("GetAttribute(vector)="< (PeekPointer (info.checker)); - if (vectorChecker != 0) - { - NS_LOG_DEBUG ("GetAttribute(vector)="<GetAttribute ("A", iv); NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly"); + // // We should find the default values of "B" too. // @@ -292,6 +293,16 @@ UnderRootNamespaceConfigTestCase::DoRun (void) NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set as expected"); b->GetAttribute ("B", iv); NS_TEST_ASSERT_MSG_EQ (iv.Get (), -4, "Object Attribute \"B\" not set as expected"); + + + // + // Try '*' for attributes + // + Config::Set ("/*/A", IntegerValue (2)); + a->GetAttribute ("A", iv); + NS_TEST_ASSERT_MSG_EQ (iv.Get (), 2, "Object Attribute \"A\" not set correctly"); + b->GetAttribute ("A", iv); + NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set correctly"); } // ===========================================================================