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
ISC Open Source Projects
Kea
Commits
fc64e5bb
Commit
fc64e5bb
authored
Mar 05, 2013
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2701] Changes as a result of the code review.
parent
b58a4e5e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
32 deletions
+47
-32
src/lib/dhcpsrv/key_from_key.h
src/lib/dhcpsrv/key_from_key.h
+36
-23
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.h
+8
-6
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/subnet.h
+3
-3
No files found.
src/lib/dhcpsrv/key_from_key.h
View file @
fc64e5bb
...
@@ -20,36 +20,45 @@
...
@@ -20,36 +20,45 @@
namespace
isc
{
namespace
isc
{
namespace
dhcp
{
namespace
dhcp
{
/// @brief
Extractor class to extract key with another key
.
/// @brief
Utility class which cascades two key extractors
.
///
///
/// This class solves the problem whereby the multi_index_container
/// The key extractor (a.k.a. key extraction class) is used by the
/// must access the values stored in object nested in other object.
/// key-based indices to obtain the indexing keys from the elements of
/// Assume that there is a multi_index_container that holds objects
/// a multi_index_container. The standard key extractors can be used
/// of the type A. Each object A contains the member object B.
/// to retrieve indexing key values by accessing members or methods
/// Each object B holds the member of the type C that is to be used
/// exposed by the elements (objects or structures) stored in a
/// for indexing objects A. Objects C can't be accessed directly
/// multi_index_container. For example, if a container holds objects
/// from the object A as they are nested in the object B. In such case
/// of type A, then the public members of object A or its accessors can
/// there is no easy way to point in the definition of the container
/// be used by the standard extractor classes such as "member" or
/// that C should be used for indexing objects. The KeyFromKey class
/// "const_mem_fun" respectively. Assume more complex scenario, where
/// represents the cascaded key which can be used to extract the nested
/// multi_index_container holds objects of a type A, object A exposes
/// key value C from the object B.
/// its public member B, which in turn exposes the accessor function
/// For some more examples of complex keys see:
/// returning object C. One may want to use the value C (e.g. integer)
/// http://www.cs.brown.edu/~jwicks/boost/libs/multi_index/doc/index.html
/// to index objects A in the container. This can't be solved by using
/// standard key extractors because object C is nested in B and thus
/// it is not directly accessible from A. However, it is possible
/// to specify two distinct key extractors, one used to extract value
/// C from B, another one to extract value B from A. These two extractors
/// can be then wrapped by another key extractor which can be used
/// to obtain index key C from object A. This key extractor is implemented
/// as a functor class. The functor calls functors specified as
/// template parameters to retrieve the index value from the cascaded
/// structure.
///
///
/// @tparam KeyExtractor1 extractor used to
access the object used as
/// @tparam KeyExtractor1 extractor used to
extract the key value from
///
a key from the other object that holds
it.
///
the object containing
it.
/// @tparam KeyExtractor2 extractor used to
access data in the
object
/// @tparam KeyExtractor2 extractor used to
extract the nested
object
///
holding nested object used as
a key.
///
containing
a key.
template
<
typename
KeyExtractor1
,
typename
KeyExtractor2
>
template
<
typename
KeyExtractor1
,
typename
KeyExtractor2
>
class
KeyFromKey
{
class
KeyFromKey
Extractor
{
public:
public:
typedef
typename
KeyExtractor1
::
result_type
result_type
;
typedef
typename
KeyExtractor1
::
result_type
result_type
;
/// @brief Constructor.
/// @brief Constructor.
KeyFromKey
()
KeyFromKey
Extractor
()
:
key1_
(
KeyExtractor1
()),
key2_
(
KeyExtractor2
())
{
};
:
key1_
(
KeyExtractor1
()),
key2_
(
KeyExtractor2
())
{
};
/// @brief Extract key
with another ke
y.
/// @brief Extract key
value from the object hierarch
y.
///
///
/// @param arg the key value.
/// @param arg the key value.
///
///
...
@@ -59,8 +68,12 @@ public:
...
@@ -59,8 +68,12 @@ public:
return
(
key1_
(
key2_
(
arg
)));
return
(
key1_
(
key2_
(
arg
)));
}
}
private:
private:
KeyExtractor1
key1_
;
///< key 1.
/// Key Extractor used to extract the key value from the
KeyExtractor2
key2_
;
///< key 2.
/// object containing it.
KeyExtractor1
key1_
;
/// Key Extractor used to extract the nested object
/// containing a key.
KeyExtractor2
key2_
;
};
};
}
// end of isc::dhcp namespace
}
// end of isc::dhcp namespace
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
fc64e5bb
...
@@ -243,9 +243,10 @@ protected:
...
@@ -243,9 +243,10 @@ protected:
Lease6
,
Lease6
,
// The DUID value can't be directly accessed from the Lease6
// The DUID value can't be directly accessed from the Lease6
// object because it is wrapped with the DUID object (actually
// object because it is wrapped with the DUID object (actually
// pointer to this object). Therefore we need to use KeyFromKey
// pointer to this object). Therefore we need to use
// class to extract the DUID value from this cascaded structure.
// KeyFromKeyExtractor class to extract the DUID value from
KeyFromKey
<
// this cascaded structure.
KeyFromKeyExtractor
<
// The value of the DUID is accessed by the getDuid() method
// The value of the DUID is accessed by the getDuid() method
// from the DUID object.
// from the DUID object.
boost
::
multi_index
::
const_mem_fun
<
DUID
,
std
::
vector
<
uint8_t
>
,
boost
::
multi_index
::
const_mem_fun
<
DUID
,
std
::
vector
<
uint8_t
>
,
...
@@ -305,9 +306,10 @@ protected:
...
@@ -305,9 +306,10 @@ protected:
Lease4
,
Lease4
,
// The client id value is not directly accessible through the
// The client id value is not directly accessible through the
// Lease4 object as it is wrapped with the ClientIdPtr object.
// Lease4 object as it is wrapped with the ClientIdPtr object.
// Therefore we use the KeyFromKey class to specify the key
// Therefore we use the KeyFromKeyExtractor class to access
// that gets the client id value through this cascade.
// client id through this cascaded structure. The client id
KeyFromKey
<
// is used as an index value.
KeyFromKeyExtractor
<
// Specify that the vector holding client id value can be obtained
// Specify that the vector holding client id value can be obtained
// from the ClientId object.
// from the ClientId object.
boost
::
multi_index
::
const_mem_fun
<
ClientId
,
std
::
vector
<
uint8_t
>
,
boost
::
multi_index
::
const_mem_fun
<
ClientId
,
std
::
vector
<
uint8_t
>
,
...
...
src/lib/dhcpsrv/subnet.h
View file @
fc64e5bb
...
@@ -121,10 +121,10 @@ public:
...
@@ -121,10 +121,10 @@ public:
boost
::
multi_index
::
sequenced
<>
,
boost
::
multi_index
::
sequenced
<>
,
// Start definition of index #1.
// Start definition of index #1.
boost
::
multi_index
::
hashed_non_unique
<
boost
::
multi_index
::
hashed_non_unique
<
// KeyFromKey is the index key extractor that allows
accessing
// KeyFromKey
Extractor
is the index key extractor that allows
// option type being held by the OptionPtr through
//
accessing
option type being held by the OptionPtr through
// OptionDescriptor structure.
// OptionDescriptor structure.
KeyFromKey
<
KeyFromKey
Extractor
<
// Use option type as the index key. The type is held
// Use option type as the index key. The type is held
// in OptionPtr object so we have to call Option::getType
// in OptionPtr object so we have to call Option::getType
// to retrieve this key for each element.
// to retrieve this key for each element.
...
...
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