From 8acd8baa33d404ed3cbf790f0f243c2df26bec59 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 13:04:55 -0700 Subject: [PATCH] use FailSafe postfix in a more rigorous way. --- src/core/attribute-test.cc | 20 +++++++------- src/core/object-base.cc | 55 +++++++++++++++++++++++++++++++++----- src/core/object-base.h | 30 ++++++++++++++++++--- 3 files changed, 86 insertions(+), 19 deletions(-) diff --git a/src/core/attribute-test.cc b/src/core/attribute-test.cc index 45afc9a65..9a2a38a4a 100644 --- a/src/core/attribute-test.cc +++ b/src/core/attribute-test.cc @@ -231,20 +231,22 @@ private: }; -#define CHECK_GET_STR(p,name,value) \ - { \ - std::string expected = value; \ - std::string got; \ - bool ok = p->GetAttribute (name, got); \ - NS_TEST_ASSERT (ok); \ - NS_TEST_ASSERT_EQUAL (got, expected); \ +#define CHECK_GET_STR(p,name,value) \ + { \ + std::string expected = value; \ + std::string got; \ + bool ok = p->GetAttributeAsStringFailSafe (name, got); \ + NS_TEST_ASSERT (ok); \ + NS_TEST_ASSERT_EQUAL (got, expected); \ } #define CHECK_GET_PARAM(p,name,type,value) \ { \ const type expected = value; \ type got = value; \ - Attribute v = p->GetAttribute (name); \ - got = v; \ + Attribute v; \ + bool ok = p->GetAttributeFailSafe (name, v); \ + NS_TEST_ASSERT (ok); \ + got = v; \ NS_TEST_ASSERT_EQUAL (got.Get (), expected.Get ()); \ } diff --git a/src/core/object-base.cc b/src/core/object-base.cc index 07518aaa4..9c3ea4f4b 100644 --- a/src/core/object-base.cc +++ b/src/core/object-base.cc @@ -156,26 +156,27 @@ ObjectBase::SetAttributeFailSafe (std::string name, Attribute value) } return DoSet (info.accessor, info.initialValue, info.checker, value); } -bool -ObjectBase::GetAttribute (std::string name, std::string &value) const +std::string +ObjectBase::GetAttributeAsString (std::string name) const { struct TypeId::AttributeInfo info; TypeId tid = GetInstanceTypeId (); if (!tid.LookupAttributeByName (name, &info)) { - return false; + NS_FATAL_ERROR ("Attribute name="<