Chat-O-Matic/application/ImageCache.h

44 lines
867 B
C
Raw Normal View History

/*
2011-12-03 16:38:03 -06:00
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
* Distributed under the terms of the MIT License.
*/
2010-05-20 16:31:55 -05:00
#ifndef _IMAGE_CACHE_H
#define _IMAGE_CACHE_H
#include <SupportDefs.h>
#include <String.h>
2010-05-08 14:35:28 -05:00
#include <libsupport/KeyMap.h>
2010-05-20 16:31:55 -05:00
class BBitmap;
2010-05-20 16:31:55 -05:00
class ImageCache {
public:
static ImageCache* Get();
2010-05-20 16:31:55 -05:00
/* Returns the image corresponding to the which constant */
BBitmap* GetImage(const char* keyName);
void AddImage(BString name, BBitmap* which);
void DeleteImage(BString name);
2010-05-20 16:31:55 -05:00
/* Frees the singleton instance of the cache, must be
* called when the application quits.
*/
2010-05-20 16:31:55 -05:00
static void Release();
2010-05-20 16:31:55 -05:00
protected:
ImageCache();
~ImageCache();
2010-05-20 16:31:55 -05:00
private:
void _LoadResource(int identifier, const char* key);
2010-05-20 16:31:55 -05:00
static ImageCache* fInstance;
KeyMap<BString, BBitmap*> fBitmaps;
};
2010-05-20 16:31:55 -05:00
#endif // _IMAGE_CACHE_H