random_racer::ResourceManager Class Reference

This Singleton ResourceManager guarantees that you load/open (for exmple Images) from the right direction and chaches the loaded Files in an Dictionary. More...

#include <ResourceManager.h>

Inheritance diagram for random_racer::ResourceManager:

Inheritance graph
[legend]
List of all members.

Public Member Functions

void setArgv (const std::string &argv)
 Sets the File Path depending on the parameter argv, which has to be argv[0] from the main App.
VRS::SO< VRS::Image > loadImage (const std::string &imageName)
 Loads an Image and insert it to the Dictionary.
VRS::SO< VRS::ImageTexture2DGL > loadTexture2D (const std::string &imageName, bool pow2, bool noException)
 Loads and Image and change it to an 2D-Texture.
VRS::SO< VRS::Font > loadFont (const std::string &fontName, VRS::Font::FontType fontType=VRS::Font::POLYGON)
 Loads an Font specified by the Parameter.
VRS::SO< VRS::ImageCubeMapTextureGL > loadCubeTexture (const std::string &imageName, const std::string &format)
 Loads 6 Images and generates a Cube Map.
std::string getPathOfFile (const std::string &fileName)
 Returns an String with the absolute File Path.
VRS::SO< VRS::SceneThing > load3ds (const std::string &fileName)
 Loads an 3ds File and returns a SceneThing, in the Car Class we will restructure it to an Scengraph see the Header.
bool freeResource (const std::string &name)
 Erases the Entry of the Dictionary (ResourceRegistry) specifeid by the name.
void freeAllResources ()
 Clears the whole Dictionary (ResourceRegistry).

Static Public Member Functions

static VRS::SO< ResourceManagerget ()
 This returns the singleton ResourceManager Object, when used the first time this creates the initial ResourceManager.

Private Types

enum  ResourceType { ImageType, TextureType, FontType, CubeType }
 This Enum is a List of all ObjectTypes which we can store in the ResourceContainer. More...

Private Member Functions

 ResourceManager ()
 The ctor is private, use get() to obtain the object.
virtual ~ResourceManager ()
 dtor

Private Attributes

std::string m_fileDir
 Stores the actual File Path where all the Data (Textures, Font, .
std::string m_homeDir
 Stores the Home Path for the Random Racer Game Stuff (for example autoexec File).
VRS::NonPersistentDictionary<
std::string, ResourceContainer
m_resourceRegistry
 Holds to an Ressource Name (for example an Image) the Resource Data.

Static Private Attributes

static VRS::SO< ResourceManagers_instance
 Stores the Singleton.

Classes

struct  ResourceContainer
 The ResourceContainer stores the Typ of the Object and an Pointer to this object. More...

Detailed Description

This Singleton ResourceManager guarantees that you load/open (for exmple Images) from the right direction and chaches the loaded Files in an Dictionary.

Definition at line 26 of file ResourceManager.h.


Member Enumeration Documentation

enum random_racer::ResourceManager::ResourceType [private]

This Enum is a List of all ObjectTypes which we can store in the ResourceContainer.

Enumerator:
ImageType 
TextureType 
FontType 
CubeType 

Definition at line 60 of file ResourceManager.h.


Constructor & Destructor Documentation

random_racer::ResourceManager::ResourceManager (  )  [private]

The ctor is private, use get() to obtain the object.

Definition at line 26 of file ResourceManager.cpp.

References m_fileDir, and m_homeDir.

Referenced by get().

Here is the caller graph for this function:

random_racer::ResourceManager::~ResourceManager (  )  [private, virtual]

dtor

Definition at line 55 of file ResourceManager.cpp.


Member Function Documentation

void random_racer::ResourceManager::setArgv ( const std::string &  argv  ) 

Sets the File Path depending on the parameter argv, which has to be argv[0] from the main App.

Definition at line 60 of file ResourceManager.cpp.

References m_fileDir.

SO< ResourceManager > random_racer::ResourceManager::get (  )  [static]

This returns the singleton ResourceManager Object, when used the first time this creates the initial ResourceManager.

Definition at line 78 of file ResourceManager.cpp.

References ResourceManager(), and s_instance.

Referenced by random_racer::Console::autoexec(), random_racer::BuggyCar::BuggyCar(), random_racer::BuggyFunCar::BuggyFunCar(), random_racer::Console::Console(), random_racer::MainApplication::MainApplication(), random_racer::MeshBeautifier::MeshBeautifier(), random_racer::Presenter::switchTexture(), and random_racer::MeshBeautifier::terLoadTextureCommand().

Here is the call graph for this function:

Here is the caller graph for this function:

SO< Image > random_racer::ResourceManager::loadImage ( const std::string &  imageName  ) 

Loads an Image and insert it to the Dictionary.

If the Image is already loaded the function return the image from the Dictionary.

Definition at line 87 of file ResourceManager.cpp.

References ImageType, m_fileDir, m_resourceRegistry, random_racer::ResourceManager::ResourceContainer::sharedObject, and random_racer::ResourceManager::ResourceContainer::type.

SO< ImageTexture2DGL > random_racer::ResourceManager::loadTexture2D ( const std::string &  imageName,
bool  pow2,
bool  noException 
)

Loads and Image and change it to an 2D-Texture.

Insert it into the Dictionary and if it already loaded, return the Texture from the Dictionary.

Parameters:
pow2 if set True the Imge will be enlarge to the Power of two
noException if set true the functin will return a Null pointer if there is an Error

Definition at line 113 of file ResourceManager.cpp.

References m_fileDir, m_resourceRegistry, random_racer::ResourceManager::ResourceContainer::sharedObject, TextureType, and random_racer::ResourceManager::ResourceContainer::type.

VRS::SO<VRS::Font> random_racer::ResourceManager::loadFont ( const std::string &  fontName,
VRS::Font::FontType  fontType = VRS::Font::POLYGON 
)

Loads an Font specified by the Parameter.

Stores it in the Dictionary and returns the Font from the Dictionary if it already exists.

SO< ImageCubeMapTextureGL > random_racer::ResourceManager::loadCubeTexture ( const std::string &  imageName,
const std::string &  format 
)

Loads 6 Images and generates a Cube Map.

Parameters:
imageName specify the name of the Image (_front, _back, ... will be added to the path)
format specify the FormatType of the Images (for example: ".png")

Definition at line 183 of file ResourceManager.cpp.

References CubeType, m_fileDir, m_resourceRegistry, random_racer::ResourceManager::ResourceContainer::sharedObject, and random_racer::ResourceManager::ResourceContainer::type.

std::string random_racer::ResourceManager::getPathOfFile ( const std::string &  fileName  ) 

Returns an String with the absolute File Path.

Definition at line 227 of file ResourceManager.cpp.

References m_homeDir.

SO< SceneThing > random_racer::ResourceManager::load3ds ( const std::string &  fileName  ) 

Loads an 3ds File and returns a SceneThing, in the Car Class we will restructure it to an Scengraph see the Header.

Definition at line 233 of file ResourceManager.cpp.

References m_fileDir.

bool random_racer::ResourceManager::freeResource ( const std::string &  name  ) 

Erases the Entry of the Dictionary (ResourceRegistry) specifeid by the name.

Definition at line 248 of file ResourceManager.cpp.

References m_resourceRegistry.

void random_racer::ResourceManager::freeAllResources (  ) 

Clears the whole Dictionary (ResourceRegistry).

Definition at line 257 of file ResourceManager.cpp.

References m_resourceRegistry.


Member Data Documentation

SO< ResourceManager > random_racer::ResourceManager::s_instance [static, private]

Stores the Singleton.

Definition at line 31 of file ResourceManager.h.

Referenced by get().

std::string random_racer::ResourceManager::m_fileDir [private]

Stores the actual File Path where all the Data (Textures, Font, .

..) is.

Definition at line 46 of file ResourceManager.h.

Referenced by load3ds(), loadCubeTexture(), loadImage(), loadTexture2D(), ResourceManager(), and setArgv().

std::string random_racer::ResourceManager::m_homeDir [private]

Stores the Home Path for the Random Racer Game Stuff (for example autoexec File).

For Apple: Home + /Library/Application Support/Random Racer For Linux: Home + /.random_racer

Definition at line 54 of file ResourceManager.h.

Referenced by getPathOfFile(), and ResourceManager().

VRS::NonPersistentDictionary<std::string, ResourceContainer> random_racer::ResourceManager::m_resourceRegistry [private]

Holds to an Ressource Name (for example an Image) the Resource Data.

Definition at line 76 of file ResourceManager.h.

Referenced by freeAllResources(), freeResource(), loadCubeTexture(), loadImage(), and loadTexture2D().


The documentation for this class was generated from the following files:
Generated on Fri May 11 21:02:13 2007 for Random Racer by  doxygen 1.5.1