ResourceManager.h
Go to the documentation of this file.00001 00010 #ifndef __ResourceManager_H__ 00011 #define __ResourceManager_H__ 00012 00013 // Includes 00014 #include "Singleton.h" 00015 #include "StringId.h" 00016 #include "HashTable.h" 00017 #include "HashTableKey_Pointer.h" 00018 00019 // Forward declares 00020 class BitmapStrip; 00021 class Font; 00022 class Sound; 00023 class Image; 00024 class Filename; 00025 class Bitmap; 00026 00027 00028 // ResourceManager 00029 class ResourceManager:public Singleton<ResourceManager> 00030 { 00031 public: 00032 ResourceManager(); 00033 virtual ~ResourceManager(); 00034 00035 void LoadBitmapStrip( 00036 const Filename& filename, 00037 int celCount = 1 00038 ); 00039 00040 void UnloadBitmapStrip( 00041 const Filename& filename 00042 ); 00043 00044 void LoadFont( 00045 const Filename& filename 00046 ); 00047 00048 void UnloadFont( 00049 const Filename& filename 00050 ); 00051 00052 void LoadSound( 00053 const Filename& filename 00054 ); 00055 00056 void UnloadSound( 00057 const Filename& filename 00058 ); 00059 private: 00060 friend class Resource_BitmapStrip; 00061 friend class Resource_Font; 00062 friend class Resource_Sound; 00063 00064 const BitmapStrip* GetBitmapStrip( 00065 StringId filename, 00066 int celCount = 1 00067 ); 00068 00069 const BitmapStrip* GetBitmapStrip( 00070 const Image& image 00071 ); 00072 00073 const BitmapStrip* GetBitmapStrip( 00074 const Bitmap* bitmap 00075 ); 00076 00077 const Font* GetFont( 00078 StringId filename 00079 ); 00080 00081 const Sound* GetSound( 00082 StringId filename 00083 ); 00084 00085 void IncreaseReferenceCount( 00086 const BitmapStrip* bitmapStrip 00087 ); 00088 00089 void DecreaseReferenceCount( 00090 const BitmapStrip* bitmapStrip 00091 ); 00092 00093 void IncreaseReferenceCount( 00094 const Font* font 00095 ); 00096 00097 void DecreaseReferenceCount( 00098 const Font* font 00099 ); 00100 00101 void IncreaseReferenceCount( 00102 const Sound* sound 00103 ); 00104 00105 void DecreaseReferenceCount( 00106 const Sound* sound 00107 ); 00108 00109 struct BitmapStripEntry 00110 { 00111 StringId filename; 00112 const BitmapStrip* bitmapStrip; 00113 int referenceCount; 00114 }; 00115 00116 BitmapStripEntry* GetBitmapStripEntry( 00117 const BitmapStrip* bitmapStrip 00118 ); 00119 00120 struct FontEntry 00121 { 00122 StringId filename; 00123 const Font* font; 00124 int referenceCount; 00125 }; 00126 00127 FontEntry* GetFontEntry( 00128 const Font* font 00129 ); 00130 00131 struct SoundEntry 00132 { 00133 StringId filename; 00134 const Sound* sound; 00135 int referenceCount; 00136 }; 00137 00138 SoundEntry* GetSoundEntry( 00139 const Sound* sound 00140 ); 00141 00142 00143 private: 00144 HashTable<HashTableKey_Pointer,BitmapStripEntry*> bitmapStrips_; 00145 HashTable<HashTableKey_Pointer,FontEntry*> fonts_; 00146 HashTable<HashTableKey_Pointer,SoundEntry*> sounds_; 00147 }; 00148 00149 #define siResourceManager ResourceManager::GetInstance() 00150 00151 #endif /* __ResourceManager_H__ */ 00152 00153
Reproduction/republishing of any material on this site without permission is strictly prohibited.
