Skip to main content
added 775 characters in body
Source Link
mbx
  • 221
  • 6
  • 9

You initialization is lazy, so there is no need for an explicit Initialize. A Release Method would be one option to clean the memory after usage and setting pool to NULL again. I guess your code is intended for single thread only so there are no real problems. Another option would be to use instances a your (then modified) class. In that way you give the user the control to use different Caches for different usages. The Cache deletes if it goes out of scope (local use) or if the user explicitly wants to.

Personally I think it's rarely a good design to use Classes in a static way. If you find it neccessary to limit the number of instances, why not making it a Singleton instance?

BTW I'd suggest a typedef for std::map<std::string, BITMAP*> and std::pair<std::string, BITMAP*> making the code a bit more readable.

I'd suggest a typedef for std::map<std::string, BITMAP*>.

You initialization is lazy, so there is no need for an explicit Initialize. A Release Method would be one option to clean the memory after usage and setting pool to NULL again. I guess your code is intended for single thread only so there are no real problems. Another option would be to use instances a your (then modified) class. In that way you give the user the control to use different Caches for different usages. The Cache deletes if it goes out of scope (local use) or if the user explicitly wants to.

Personally I think it's rarely a good design to use Classes in a static way. If you find it neccessary to limit the number of instances, why not making it a Singleton instance?

BTW I'd suggest a typedef for std::map<std::string, BITMAP*> and std::pair<std::string, BITMAP*> making the code a bit more readable.

Source Link
mbx
  • 221
  • 6
  • 9

I'd suggest a typedef for std::map<std::string, BITMAP*>.