// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

// $Id$

#ifndef __NSAS_ENTRY_COMPARE_H
#define __NSAS_ENTRY_COMPARE_H

#include "hash_key.h"
#include "hash_table.h"

namespace isc {
namespace nsas {

/// \brief Hash Table Comparison Object
///
/// The HashTable class requires a comparison object that checks if an object
/// matches a hash key.  This check can be generalised for objects derived from
/// NsasEntry, as they all have the hashKey() method; this class takes
/// advantage of that.
template <typename T>
class NsasEntryCompare : public HashTableCompare<T> {
public:

    // The default constructor is OK for this class.

    /// \brief Comparison Function
    ///
    /// Checks the hash key given against the hash key provided by the NSAS
    /// element.
    ///
    /// \param object Pointer to the object
    /// \param key Hash key to compare against.
    ///
    /// \return true if the object matches the key.
    virtual bool operator()(T* object, const HashKey& key) const {
        return (object->hashKey() == key);
    }
};

} // namespace nsas
} // namespace isc

#endif // __NSAS_ENTRY_COMPARE_H
