Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Adam Osuchowski
Kea
Commits
6085d54e
Commit
6085d54e
authored
Feb 14, 2013
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2701] Moved the KeyFromKey class to the common header.
parent
0cbbce43
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
72 deletions
+3
-72
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/Makefile.am
+1
-0
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.h
+1
-23
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/subnet.h
+1
-49
No files found.
src/lib/dhcpsrv/Makefile.am
View file @
6085d54e
...
...
@@ -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
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
6085d54e
...
...
@@ -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
<
...
...
src/lib/dhcpsrv/subnet.h
View file @
6085d54e
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment