BIND 10 trac510, updated. b14866797ef758fd4e3a920b8ca9eab50053e120 [510] modify interface for enumerating zone names in CounterDictionary

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Dec 13 07:52:01 UTC 2011


The branch, trac510 has been updated
       via  b14866797ef758fd4e3a920b8ca9eab50053e120 (commit)
       via  a5c940634fbc5dffd80ff2c0cfd98294322583f7 (commit)
      from  f84f26374fd7f359eafd98a00c9065d2c1aaa924 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b14866797ef758fd4e3a920b8ca9eab50053e120
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Tue Dec 13 16:45:52 2011 +0900

    [510] modify interface for enumerating zone names in CounterDictionary

commit a5c940634fbc5dffd80ff2c0cfd98294322583f7
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Tue Dec 13 15:41:01 2011 +0900

    [510] fix unused variable

-----------------------------------------------------------------------

Summary of changes:
 src/lib/statistics/counter_dict.cc                |   12 ++++++------
 src/lib/statistics/counter_dict.h                 |   17 +++--------------
 src/lib/statistics/tests/counter_dict_unittest.cc |   20 ++++++++++++--------
 3 files changed, 21 insertions(+), 28 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/statistics/counter_dict.cc b/src/lib/statistics/counter_dict.cc
index d40bd3f..08302be 100644
--- a/src/lib/statistics/counter_dict.cc
+++ b/src/lib/statistics/counter_dict.cc
@@ -77,7 +77,7 @@ Counter&
 CounterDictionaryImpl::getElement(const std::string& name) {
     try {
         return (*(dictionary_.at(name)));
-    } catch (const std::out_of_range &e) {
+    } catch (const std::out_of_range&) {
         // If an element with specified name does not exist, throw
         // isc::OutOfRange.
         isc_throw(isc::OutOfRange, "Element " << name << " does not exist");
@@ -127,7 +127,8 @@ class CounterDictionaryConstIteratorImpl {
             DictionaryMap::const_iterator iterator);
     public:
         void increment();
-        CounterDictionary::ValueType dereference() const;
+        const CounterDictionary::ConstIterator::value_type&
+            dereference() const;
         bool equal(const CounterDictionaryConstIteratorImpl& other) const;
     private:
         DictionaryMap::const_iterator iterator_;
@@ -174,10 +175,9 @@ CounterDictionaryConstIteratorImpl::increment() {
     return;
 }
 
-CounterDictionary::ValueType
+const CounterDictionary::ConstIterator::value_type&
 CounterDictionaryConstIteratorImpl::dereference() const {
-    return (CounterDictionary::ValueType(iterator_->first,
-                                         *(iterator_->second)));
+    return (iterator_->first);
 }
 
 bool
@@ -226,7 +226,7 @@ CounterDictionary::ConstIterator::ConstIterator(
     impl_(new CounterDictionaryConstIteratorImpl(source))
 {}
 
-const CounterDictionary::ValueType
+const CounterDictionary::ConstIterator::value_type&
 CounterDictionary::ConstIterator::dereference() const
 {
     return (impl_->dereference());
diff --git a/src/lib/statistics/counter_dict.h b/src/lib/statistics/counter_dict.h
index f5c1fbd..4a4cab1 100644
--- a/src/lib/statistics/counter_dict.h
+++ b/src/lib/statistics/counter_dict.h
@@ -62,19 +62,8 @@ public:
     /// Same as getElement()
     Counter& operator[](const std::string &name) const;
 
-    /// \brief A helper structure to represent an element of
-    /// CounterDictionary. This type is used for the iterator.
-    struct ValueType {
-        public:
-        const std::string& name;
-        const Counter& element;
-        ValueType(const std::string& name_, const Counter& element_) :
-            name(name_), element(element_)
-        {}
-    };
-
     /// \brief \c ConstIterator is a constant iterator that provides an
-    /// interface for accessing elements stored in CounterDictionary.
+    /// interface for enumerating name of zones stored in CounterDictionary.
     ///
     /// This class is derived from boost::iterator_facade and uses pImpl
     /// idiom not to expose implementation detail of
@@ -84,7 +73,7 @@ public:
     /// counters to statistics module.
     class ConstIterator :
         public boost::iterator_facade<ConstIterator,
-                                const ValueType,
+                                const std::string,
                                 boost::forward_traversal_tag>
     {
         private:
@@ -128,7 +117,7 @@ public:
             /// \brief An internal method to check equality.
             bool equal(const ConstIterator& other) const;
             /// \brief An internal method to dereference this iterator.
-            const value_type dereference() const;
+            const value_type& dereference() const;
         private:
             friend class boost::iterator_core_access;
     };
diff --git a/src/lib/statistics/tests/counter_dict_unittest.cc b/src/lib/statistics/tests/counter_dict_unittest.cc
index d093e3d..34ab219 100644
--- a/src/lib/statistics/tests/counter_dict_unittest.cc
+++ b/src/lib/statistics/tests/counter_dict_unittest.cc
@@ -118,20 +118,24 @@ TEST_F(CounterDictionaryTest, iteratorTest) {
     // Walk through the elements with iterator
     // Check if the elements "test" and "sub.test" appears only once
     //  and the counters have expected value
-    BOOST_FOREACH(CounterDictionary::ValueType i,
-                  static_cast<const CounterDictionary &>(counters))
+    for (CounterDictionary::ConstIterator i = counters.begin(),
+                                          e = counters.end();
+         i != e;
+         ++i
+         )
     {
-        if (i.name == "test" && element_test_visited == false) {
+        const std::string& zone = *i;
+        if (zone == "test" && element_test_visited == false) {
             element_test_visited = true;
             // Check if the counters have expected value
-            EXPECT_EQ(i.element.get(ITEM1), 1);
-            EXPECT_EQ(i.element.get(ITEM2), 0);
-        } else if (i.name == "sub.test" &&
+            EXPECT_EQ(counters[zone].get(ITEM1), 1);
+            EXPECT_EQ(counters[zone].get(ITEM2), 0);
+        } else if (zone == "sub.test" &&
                    element_sub_test_visited == false) {
             element_sub_test_visited = true;
             // Check if the counters have expected value
-            EXPECT_EQ(i.element.get(ITEM1), 0);
-            EXPECT_EQ(i.element.get(ITEM2), 2);
+            EXPECT_EQ(counters[zone].get(ITEM1), 0);
+            EXPECT_EQ(counters[zone].get(ITEM2), 2);
         } else {
             // Test fails when reaches here: the element is not expected or
             //  the element appeared twice




More information about the bind10-changes mailing list