Branch data Line data Source code
1 : : // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
2 : : //
3 : : // Permission to use, copy, modify, and/or distribute this software for any
4 : : // purpose with or without fee is hereby granted, provided that the above
5 : : // copyright notice and this permission notice appear in all copies.
6 : : //
7 : : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 : : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 : : // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 : : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 : : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 : : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 : : // PERFORMANCE OF THIS SOFTWARE.
14 : :
15 : : #ifndef __NSAS_ENTRY_COMPARE_H
16 : : #define __NSAS_ENTRY_COMPARE_H
17 : :
18 : : #include "hash_key.h"
19 : : #include "hash_table.h"
20 : :
21 : : namespace isc {
22 : : namespace nsas {
23 : :
24 : : /// \brief Hash Table Comparison Object
25 : : ///
26 : : /// The HashTable class requires a comparison object that checks if an object
27 : : /// matches a hash key. This check can be generalised for objects derived from
28 : : /// NsasEntry, as they all have the hashKey() method; this class takes
29 : : /// advantage of that.
30 : : template <typename T>
31 : 223 : class NsasEntryCompare : public HashTableCompare<T> {
32 : : public:
33 : :
34 : : // The default constructor is OK for this class.
35 : :
36 : : /// \brief Comparison Function
37 : : ///
38 : : /// Checks the hash key given against the hash key provided by the NSAS
39 : : /// element.
40 : : ///
41 : : /// \param object Pointer to the object
42 : : /// \param key Hash key to compare against.
43 : : ///
44 : : /// \return true if the object matches the key.
45 : 2448 : virtual bool operator()(T* object, const HashKey& key) const {
46 : 2448 : return (object->hashKey() == key);
47 : : }
48 : : };
49 : :
50 : : } // namespace nsas
51 : : } // namespace isc
52 : :
53 : : #endif // __NSAS_ENTRY_COMPARE_H
|