nsas_entry_compare.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef __NSAS_ENTRY_COMPARE_H
  15. #define __NSAS_ENTRY_COMPARE_H
  16. #include "hash_key.h"
  17. #include "hash_table.h"
  18. namespace isc {
  19. namespace nsas {
  20. /// \brief Hash Table Comparison Object
  21. ///
  22. /// The HashTable class requires a comparison object that checks if an object
  23. /// matches a hash key. This check can be generalised for objects derived from
  24. /// NsasEntry, as they all have the hashKey() method; this class takes
  25. /// advantage of that.
  26. template <typename T>
  27. class NsasEntryCompare : public HashTableCompare<T> {
  28. public:
  29. // The default constructor is OK for this class.
  30. /// \brief Comparison Function
  31. ///
  32. /// Checks the hash key given against the hash key provided by the NSAS
  33. /// element.
  34. ///
  35. /// \param object Pointer to the object
  36. /// \param key Hash key to compare against.
  37. ///
  38. /// \return true if the object matches the key.
  39. virtual bool operator()(T* object, const HashKey& key) const {
  40. return (object->hashKey() == key);
  41. }
  42. };
  43. } // namespace nsas
  44. } // namespace isc
  45. #endif // __NSAS_ENTRY_COMPARE_H