Dragonfly  4.3
A text-based game engine
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
df::ResourceManager Class Reference
Inheritance diagram for df::ResourceManager:
Inheritance graph
[legend]
Collaboration diagram for df::ResourceManager:
Collaboration graph
[legend]

Public Member Functions

int startUp ()
 
void shutDown ()
 
int loadSprite (std::string filename, std::string label)
 
int unloadSprite (std::string label)
 
SpritegetSprite (std::string label) const
 
int loadSound (std::string filename, std::string label)
 
int unloadSound (std::string label)
 
SoundgetSound (std::string label)
 
int loadMusic (std::string filename, std::string label)
 
int unloadMusic (std::string label)
 
MusicgetMusic (std::string label)
 
- Public Member Functions inherited from df::Manager
std::string getType () const
 
bool isStarted () const
 
int onEvent (const Event *p_event) const
 
int registerInterest (Object *p_o, std::string event_type)
 
int unregisterInterest (Object *p_o, std::string event_type)
 

Static Public Member Functions

static ResourceManagergetInstance ()
 

Private Member Functions

 ResourceManager (ResourceManager const &)
 
void operator= (ResourceManager const &)
 
 ResourceManager ()
 

Private Attributes

Spritep_sprite [MAX_SPRITES]
 
int m_sprite_count
 
Sound m_sound [MAX_SOUNDS]
 
int m_sound_count
 
Music m_music [MAX_MUSICS]
 
int m_music_count
 

Additional Inherited Members

- Protected Member Functions inherited from df::Manager
void setType (std::string new_type)
 

Constructor & Destructor Documentation

df::ResourceManager::ResourceManager ( ResourceManager const &  )
private

Don't allow copy.

df::ResourceManager::ResourceManager ( )
private

Private since a singleton.

Member Function Documentation

static ResourceManager& df::ResourceManager::getInstance ( )
static

Get the one and only instance of the ResourceManager.

Music* df::ResourceManager::getMusic ( std::string  label)

Find Music with indicated label.

Return pointer to it if found, else NULL.

Sound* df::ResourceManager::getSound ( std::string  label)

Find Sound with indicated label.

Return pointer to it if found, else NULL.

Sprite* df::ResourceManager::getSprite ( std::string  label) const

Find Sprite with indicated label.

Return pointer to it if found, else NULL.

int df::ResourceManager::loadMusic ( std::string  filename,
std::string  label 
)

Associate file with Music.

Return 0 if ok, else -1.

int df::ResourceManager::loadSound ( std::string  filename,
std::string  label 
)

Load sound from file.

Return 0 if ok, else -1.

int df::ResourceManager::loadSprite ( std::string  filename,
std::string  label 
)

Load Sprite from file.

Assign indicated label to Sprite. Return 0 if ok, else -1.

void df::ResourceManager::operator= ( ResourceManager const &  )
private

Don't allow assignment.

void df::ResourceManager::shutDown ( )
virtual

Shut down manager, freeing up any allocated Sprites, Music and Sounds.

Reimplemented from df::Manager.

int df::ResourceManager::startUp ( )
virtual

Get ResourceManager ready to manage resources.

Reimplemented from df::Manager.

int df::ResourceManager::unloadMusic ( std::string  label)

Remove label for Music with indicated label.

Return 0 if ok, else -1.

int df::ResourceManager::unloadSound ( std::string  label)

Remove Sound with indicated label.

Return 0 if ok, else -1.

int df::ResourceManager::unloadSprite ( std::string  label)

Unload Sprite with indicated label.

Return 0 if ok, else -1.

Member Data Documentation

Music df::ResourceManager::m_music[MAX_MUSICS]
private

Array of music buffers.

int df::ResourceManager::m_music_count
private

Count of number of loaded musics.

Sound df::ResourceManager::m_sound[MAX_SOUNDS]
private

Array of sound buffers.

int df::ResourceManager::m_sound_count
private

Count of number of loaded sounds.

int df::ResourceManager::m_sprite_count
private

Count of number of loaded sprites.

Sprite* df::ResourceManager::p_sprite[MAX_SPRITES]
private

Array of (pointers to) Sprites.