BIND 10 trac2701, updated. 6085d54e697681307b4a5f60d169c9e4110c8286 [2701] Moved the KeyFromKey class to the common header.

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Feb 14 12:28:45 UTC 2013


The branch, trac2701 has been updated
       via  6085d54e697681307b4a5f60d169c9e4110c8286 (commit)
      from  0cbbce437ec709e5dde8056c0462d7bd501f65c9 (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 6085d54e697681307b4a5f60d169c9e4110c8286
Author: Marcin Siodelski <marcin at isc.org>
Date:   Thu Feb 14 13:28:36 2013 +0100

    [2701] Moved the KeyFromKey class to the common header.

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

Summary of changes:
 src/lib/dhcpsrv/Makefile.am         |    1 +
 src/lib/dhcpsrv/memfile_lease_mgr.h |   24 +----------------
 src/lib/dhcpsrv/subnet.h            |   50 +----------------------------------
 3 files changed, 3 insertions(+), 72 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am
index e721267..db82513 100644
--- a/src/lib/dhcpsrv/Makefile.am
+++ b/src/lib/dhcpsrv/Makefile.am
@@ -37,6 +37,7 @@ libb10_dhcpsrv_la_SOURCES += dbaccess_parser.cc dbaccess_parser.h
 libb10_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h
 libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
 libb10_dhcpsrv_la_SOURCES += dhcp_config_parser.h
+libb10_dhcpsrv_la_SOURCES += key_from_key.h
 libb10_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h
 libb10_dhcpsrv_la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h
 libb10_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h
index 917e064..0f896a7 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.h
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.h
@@ -16,6 +16,7 @@
 #define MEMFILE_LEASE_MGR_H
 
 #include <dhcp/hwaddr.h>
+#include <dhcpsrv/key_from_key.h>
 #include <dhcpsrv/lease_mgr.h>
 
 #include <boost/multi_index/indexed_by.hpp>
@@ -221,29 +222,6 @@ public:
 
 protected:
 
-    template<typename KeyExtractor1, typename KeyExtractor2>
-    class KeyFromKey {
-    public:
-        typedef typename KeyExtractor1::result_type result_type;
-
-        /// @brief Constructor.
-        KeyFromKey()
-            : key1_(KeyExtractor1()), key2_(KeyExtractor2()) { };
-
-        /// @brief Extract key with another key.
-        ///
-        /// @param arg the key value.
-        ///
-        /// @tparam key value type.
-        template<typename T>
-        result_type operator() (T& arg) const {
-            return (key1_(key2_(arg)));
-        }
-    private:
-        KeyExtractor1 key1_; ///< key 1.
-        KeyExtractor2 key2_; ///< key 2.
-    };
-
     // This is a multi-index container, which holds elements that can
     // be accessed using different search indexes.
     typedef boost::multi_index_container<
diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h
index cf29450..ea08fb0 100644
--- a/src/lib/dhcpsrv/subnet.h
+++ b/src/lib/dhcpsrv/subnet.h
@@ -24,6 +24,7 @@
 
 #include <asiolink/io_address.h>
 #include <dhcp/option.h>
+#include <dhcpsrv/key_from_key.h>
 #include <dhcpsrv/option_space_container.h>
 #include <dhcpsrv/pool.h>
 #include <dhcpsrv/triplet.h>
@@ -82,55 +83,6 @@ public:
     /// A pointer to option descriptor.
     typedef boost::shared_ptr<OptionDescriptor> OptionDescriptorPtr;
 
-    /// @brief Extractor class to extract key with another key.
-    ///
-    /// This class solves the problem of accessing index key values
-    /// that are stored in objects nested in other objects.
-    /// Each OptionDescriptor structure contains the OptionPtr object.
-    /// The value retured by one of its accessors (getType) is used
-    /// as an indexing value in the multi_index_container defined below.
-    /// There is no easy way to mark that value returned by Option::getType
-    /// should be an index of this multi_index_container. There are standard
-    /// key extractors such as 'member' or 'mem_fun' but they are not
-    /// sufficient here. The former can be used to mark that member of
-    /// the structure that is held in the container should be used as an
-    /// indexing value. The latter can be used if the indexing value is
-    /// a product of the class being held in the container. In this complex
-    /// scenario when the indexing value is a product of the function that
-    /// is wrapped by the structure, this new extractor template has to be
-    /// defined. The template class provides a 'chain' of two extractors
-    /// to access the value returned by nested object and to use it as
-    /// indexing value.
-    /// For some more examples of complex keys see:
-    /// http://www.cs.brown.edu/~jwicks/boost/libs/multi_index/doc/index.html
-    ///
-    /// @tparam KeyExtractor1 extractor used to access data in
-    /// OptionDescriptor::option
-    /// @tparam KeyExtractor2 extractor used to access
-    /// OptionDescriptor::option member.
-    template<typename KeyExtractor1, typename KeyExtractor2>
-    class KeyFromKey {
-    public:
-        typedef typename KeyExtractor1::result_type result_type;
-
-        /// @brief Constructor.
-        KeyFromKey()
-            : key1_(KeyExtractor1()), key2_(KeyExtractor2()) { };
-
-        /// @brief Extract key with another key.
-        ///
-        /// @param arg the key value.
-        ///
-        /// @tparam key value type.
-        template<typename T>
-        result_type operator() (T& arg) const {
-            return (key1_(key2_(arg)));
-        }
-    private:
-        KeyExtractor1 key1_; ///< key 1.
-        KeyExtractor2 key2_; ///< key 2.
-    };
-
     /// @brief Multi index container for DHCP option descriptors.
     ///
     /// This container comprises three indexes to access option



More information about the bind10-changes mailing list