/** \file
 *
 *  Contains the MapEntry class declaration.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef MAPENTRY_H_
#define MAPENTRY_H_

/**
 *  Wraps an key/value pair in a FastMap
 *
 *  \ingroup utils
 */
template <typename S, typename T>
class MapEntry
{
public:
    MapEntry( S& key, T item, bool deleteOnCleanup = false )
        : key_( key ),
          item_( item ),
          deleteOnCleanup_( deleteOnCleanup )
    {}
    ;
    virtual ~MapEntry()
    {
        if( deleteOnCleanup_ && NULL != item_ )
        {
            delete item_;
        }
    }
    ;
    virtual S& getKey()
    {
        return key_;
    };
    virtual T getItem()
    {
        return item_;
    };
    virtual void setItem( T item )
    {
        item_ = item;
    };
private:
    // Note that the copy constructor below is private and not given a body.
    // Any attempt to call it will return a compiler error.
    MapEntry( const MapEntry& old ); // disallow copy constructor
    S key_;
    T item_;
    bool deleteOnCleanup_;
};

#endif /*MAPENTRY_H_*/
