/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   ImageCache class.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef FX_IMAGE_CACHE_HH
#define FX_IMAGE_CACHE_HH 1

#define GET_IMAGE_CACHE() (fx::ImageCache::GetInstance())

#include <map>
#include <osg/Image>
#include "base/singleton.hh"

namespace fx {

typedef osg::Image Image;

////////////////////////////////////////////////////////////////////////////////
/// @brief Cache of images files (for texture objects).
///
/// Similar to graph::ModelCache.
///
class ImageCache
{
PREVENT_COPYING(ImageCache)
private:
                            ImageCache( void );
                            ~ImageCache();

public:
                            DEFINE_GetInstance( ImageCache )  // Singleton
    RefPtr<osg::Image>      LoadImage( const string& filename );

private:
    typedef std::map<string,RefPtr<Image> > ImageMap;
    CLASS_VAR ImageCache*   msInstance;
    ImageMap                mImageMap;      ///< maps filename and osg::Image
};

} // namespace fx

#endif // FX_IMAGE_CACHE_HH
