Claypool

Courses

Publications

Students

Projects

Service

Downloads

Misc


Dragonfly: ResourceManager.h Source File
Dragonfly 2.2
A text-based game engine

ResourceManager.h

00001 ///
00002 /// The resource manager
00003 ///
00004 
00005 #ifndef __RESOURCE_MANAGER_H__
00006 #define __RESOURCE_MANAGER_H__
00007 
00008 #define MAX_SPRITES 10000
00009 
00010 #include <string>
00011 
00012 using namespace std;
00013 
00014 #include "Manager.h"
00015 #include "Sprite.h"
00016 
00017 // Define delimiters used to parse Sprite files -
00018 // the ResourceManager "knows" the file format.
00019 #define FRAMES_TOKEN "frames"
00020 #define HEIGHT_TOKEN "height"
00021 #define WIDTH_TOKEN "width"
00022 #define COLOR_TOKEN "color"
00023 #define END_FRAME_TOKEN "end"
00024 #define END_SPRITE_TOKEN "eof"
00025 
00026 class ResourceManager : public Manager {
00027 
00028  private:
00029   ResourceManager (ResourceManager const&); ///< Don't allow copy.
00030   void operator=(ResourceManager const&);   ///< Don't allow assignment.
00031   ResourceManager();                        ///< Private since a singleton.
00032 
00033  protected:
00034   Sprite *sprite[MAX_SPRITES];  ///< Array of sprites.
00035   int sprite_count;             ///< Count of number of loaded sprites.
00036 
00037  public:
00038   ~ResourceManager();
00039 
00040   /// Get the one and only instance of the ResourceManager.
00041   static ResourceManager &getInstance();
00042 
00043   /// Load Sprite from file.
00044   /// Assign the indicated label to sprite.
00045   /// Return 0 if ok, else -1.
00046   int loadSprite(string filename, string label);
00047 
00048   /// Unload Sprite with indicated label.
00049   /// Return 0 if ok, else -1.
00050   int unloadSprite(string label);
00051 
00052   /// Find Sprite with indicated label.
00053   /// Return pointer to it if found, else NULL.
00054   Sprite *getSprite(string label);
00055 
00056   int startUp();
00057   void shutDown();
00058 };
00059 
00060 #endif //__RESOURCE_MANAGER_H__
 All Classes Functions Variables Friends