ImageCache.h 867 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2009-2011, Andrea Anzani. All rights reserved.
  3. * Distributed under the terms of the MIT License.
  4. */
  5. #ifndef _IMAGE_CACHE_H
  6. #define _IMAGE_CACHE_H
  7. #include <SupportDefs.h>
  8. #include <String.h>
  9. #include <libsupport/KeyMap.h>
  10. class BBitmap;
  11. class ImageCache {
  12. public:
  13. static ImageCache* Get();
  14. /* Returns the image corresponding to the which constant */
  15. BBitmap* GetImage(const char* keyName);
  16. void AddImage(BString name, BBitmap* which);
  17. void DeleteImage(BString name);
  18. /* Frees the singleton instance of the cache, must be
  19. * called when the application quits.
  20. */
  21. static void Release();
  22. protected:
  23. ImageCache();
  24. ~ImageCache();
  25. private:
  26. void _LoadResource(int identifier, const char* key);
  27. static ImageCache* fInstance;
  28. KeyMap<BString, BBitmap*> fBitmaps;
  29. };
  30. #endif // _IMAGE_CACHE_H