Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
Mezzanine::Resource::ResourceManager Class Reference

This is the manager responsible for the loading and unloading of files. More...

#include <resourcemanager.h>

+ Inheritance diagram for Mezzanine::Resource::ResourceManager:
+ Collaboration diagram for Mezzanine::Resource::ResourceManager:

Public Types

typedef std::map< String, AssetGroup * > AssetGroupContainer
 Basic container type for AssetGroup storage in this class.
 
typedef AssetGroupContainer::iterator AssetGroupIterator
 Iterator type for AssetGroup instances stored in this class.
 
typedef AssetGroupContainer::const_iterator ConstAssetGroupIterator
 Const Iterator type for AssetGroup instances stored in this class.
 
typedef DataStreamContainer::const_iterator ConstDataStreamIterator
 Const Iterator type for DataStream instances stored by this class.
 
typedef NamedDataStreamContainer::const_iterator ConstNamedDataStreamIterator
 Const Iterator type for named DataStream instances stored by this class.
 
typedef std::vector< Resource::DataStreamPtrDataStreamContainer
 Basic container type for DataStream storage by this class.
 
typedef DataStreamContainer::iterator DataStreamIterator
 Iterator type for DataStream instances stored by this class.
 
typedef std::map< String, Resource::DataStreamPtrNamedDataStreamContainer
 Basic container type for named DataStream storage by this class.
 
typedef NamedDataStreamContainer::iterator NamedDataStreamIterator
 Iterator type for named DataStream instances stored by this class.
 
- Public Types inherited from Mezzanine::ManagerBase
enum  ManagerType {
  MT_Undefined = 0, MT_AudioManager = 1, MT_AnimationManager = 2, MT_CollisionShapeManager = 3,
  MT_CompositorManager = 4, MT_GraphicsManager = 5, MT_EventManager = 6, MT_InputManager = 7,
  MT_LogManager = 8, MT_MaterialManager = 9, MT_MeshManager = 10, MT_NetworkManager = 11,
  MT_ResourceManager = 12, MT_ScriptingManager = 13, MT_TextureManager = 14, MT_UIManager = 15,
  MT_ActorManager = 101, MT_AreaEffectManager = 102, MT_DebrisManager = 103, MT_PagingManager = 104,
  MT_PhysicsManager = 105, MT_SceneManager = 106, MT_SoundScapeManager = 107, MT_TerrainManager = 108,
  MT_VehicleManager = 109, MT_UserCreated = 512
}
 A listing of Manager Types. More...
 

Public Member Functions

 ResourceManager (const String &EngineDataPath=".", const ArchiveType ArchType=AT_FileSystem)
 Class constructor. More...
 
 ResourceManager (const XML::Node &XMLNode)
 XML constructor. More...
 
virtual ~ResourceManager ()
 
void AddAssetLocation (const String &Location, const ArchiveType Type, const String &Group, const Boole Recursive=false)
 Adds a location for graphical resources. More...
 
AssetGroupCreateAssetGroup (const String &GroupName)
 Creates a new asset group. More...
 
Resource::DataStreamPtr CreateDataStream (void *Buffer, const UInt32 BufferSize)
 Creates a stream from a memory buffer. More...
 
Resource::DataStreamPtr CreateDataStream (const String &AssetName, void *Buffer, const UInt32 BufferSize)
 Creates a named stream from a memory buffer. More...
 
Resource::DataStreamPtr CreateDataStream (const String &AssetName, const String &GroupName, void *Buffer, const UInt32 BufferSize)
 Creates a named stream from a memory buffer and adds it to the named AssetGroup. More...
 
virtual void Deinitialize ()
 Removes this manager from any necessary configuration so it can be safely disposed of. More...
 
void DestroyAllAssetGroups ()
 Destroys all asset groups being stored by this manager.
 
void DestroyAssetGroup (const String &GroupName)
 Destroys an asset group, unloading all of it's resources. More...
 
void DestroyAssetGroup (AssetGroup *ToBeDestroyed)
 Destroys an asset group, unloading all of it's resources. More...
 
AssetGroupGetAssetGroup (const String &GroupName)
 Gets an AssetGroup by name. More...
 
AssetGroupGetAssetGroupExcept (const String &GroupName)
 Gets an AssetGroup by name.

Exceptions
Ifthe requested AssetGroup is not found this will throw an exception.
More...
 
String GetAssetPath (const String &FileName, const String &Group)
 Gets the actual path to an asset. More...
 
String GetEngineDataDirectory () const
 Get the pathname where engine data is stored. More...
 
virtual String GetImplementationTypeName () const
 This Allows any manager name to be sent to a stream. Primarily used for logging. More...
 
virtual ManagerType GetInterfaceType () const
 This returns the type of this manager. More...
 
AssetGroupGetOrCreateAssetGroup (const String &GroupName)
 Gets an AssetGroup by name. If it does not exist it will be created. More...
 
String GetPluginExtension () const
 Gets the dot-and-extention of this platforms plugins. More...
 
void InitAssetGroup (const String &GroupName)
 Makes a asset group ready to use. More...
 
virtual void Initialize ()
 Configures this manager for use prior to entering the main loop. More...
 
Resource::DataStreamPtr OpenAssetStream (const String &AssetName, const String &GroupName)
 Opens a stream to an asset in an AssetGroup. More...
 
- Public Member Functions inherited from Mezzanine::EntresolManager
 EntresolManager ()
 Class constructor.
 
virtual ~EntresolManager ()
 Class destructor.
 
- Public Member Functions inherited from Mezzanine::ManagerBase
 ManagerBase ()
 Class constructor.
 
virtual ~ManagerBase ()
 Class destructor.
 
virtual String GetInterfaceTypeAsString () const
 Gets a string of the interface type of this manager. More...
 
Boole IsInitialized () const
 Gets whether or not this manager has been initialized. More...
 
- Public Member Functions inherited from Mezzanine::Singleton< ResourceManager >
 ~Singleton ()
 Class destructor.
 

Static Public Member Functions

static Resource::ArchiveType GetArchiveTypeFromString (const String &FromString)
 Gets an ArchiveType from a string. More...
 
static String GetStringFromArchiveType (const Resource::ArchiveType ArchType)
 Gets a string that describes an ArchiveType. More...
 
- Static Public Member Functions inherited from Mezzanine::ManagerBase
static String GetTypeAsString (const ManagerType &ManagerType)
 Gets the string form of the type of manager. More...
 
static ManagerType GetTypeFromString (const String &ManagerName)
 Gets the type of manager requested from a string. More...
 
- Static Public Member Functions inherited from Mezzanine::Singleton< ResourceManager >
static ResourceManager * GetSingletonPtr ()
 Fetches a pointer to the singleton. More...
 
static Boole SingletonValid ()
 Checks to see if the singleton pointer is valid. More...
 

Static Public Attributes

static const String ImplementationName = "DefaultResourceManager"
 A String containing the name of this manager implementation.
 
static const ManagerBase::ManagerType InterfaceType = ManagerBase::MT_ResourceManager
 A ManagerType enum value used to describe the type of interface/functionality this manager provides.
 

Protected Attributes

AssetGroupContainer AssetGroups
 Container storing all of the asset groups created and managed by this manager. More...
 
String EngineDataDir
 The location of engine data. More...
 
Ogre::ResourceGroupManager * OgreResource
 Encapsulates the functionality of the ogre resource group manager. More...
 
- Protected Attributes inherited from Mezzanine::ManagerBase
Boole Initialized
 Simple Boole indicating whether or not this manager has been initialized. More...
 
EntresolTheEntresol
 The actual pointer to the Entresol core class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mezzanine::Singleton< ResourceManager >
 Singleton ()
 Class constructor.
 
- Static Protected Attributes inherited from Mezzanine::Singleton< ResourceManager >
static ResourceManager * SingletonPtr
 The one and only pointer to the single object. More...
 

Detailed Description

This is the manager responsible for the loading and unloading of files.

This class is responsible for the reading and writing of files of all kinds, be it graphical meshes, physics data, or XMl files.

Definition at line 76 of file resourcemanager.h.

Constructor & Destructor Documentation

Mezzanine::Resource::ResourceManager::ResourceManager ( const String EngineDataPath = ".",
const ArchiveType  ArchType = AT_FileSystem 
)

Class constructor.

Standard manager constructor.

Parameters
EngineDataPathThe directory for engine specific data.
ArchiveTypeThe name of the type of archive at this path.

Definition at line 70 of file resourcemanager.cpp.

Mezzanine::Resource::ResourceManager::ResourceManager ( const XML::Node XMLNode)

XML constructor.

Parameters
XMLNodeThe node of the xml document to construct from.
Todo:
This class currently doesn't initialize anything from XML, if that changes this constructor needs to be expanded.

Definition at line 78 of file resourcemanager.cpp.

Mezzanine::Resource::ResourceManager::~ResourceManager ( )
virtual

Class Destructor.

Definition at line 85 of file resourcemanager.cpp.

Member Function Documentation

void Mezzanine::Resource::ResourceManager::AddAssetLocation ( const String Location,
const ArchiveType  Type,
const String Group,
const Boole  Recursive = false 
)

Adds a location for graphical resources.

This function will add a location on the disk to find files needed to create and manipulate graphical objects. Once an asset is added it must be initalized using ResourceManager::InitResourceGroup(String Group).

Parameters
LocationThe location on the file system the asset can be found.
TypeThe kind of file system the location can be found in.
Options are: filesystem, zip.
GroupThe name of the group the resources at this location belong to. If the group does not exist it will be created.
RecursiveWhether or not to search sub-directories.

Definition at line 109 of file resourcemanager.cpp.

AssetGroup * Mezzanine::Resource::ResourceManager::CreateAssetGroup ( const String GroupName)

Creates a new asset group.

Parameters
GroupNameThe name to be given to the created asset group.
Returns
Returns a pointer to the created AssetGroup.

Definition at line 115 of file resourcemanager.cpp.

Resource::DataStreamPtr Mezzanine::Resource::ResourceManager::CreateDataStream ( void *  Buffer,
const UInt32  BufferSize 
)

Creates a stream from a memory buffer.

Note
The created stream will take ownership of the buffer you provide. If you want it to have a separate buffer then create a copy and pass that in.
Parameters
BufferA pointer to the memory to stream from.
BufferSizeThe size of the provided buffer in bytes.
Returns
Returns a CountedPtr to the stream to the provided buffer.

Definition at line 97 of file resourcemanager.cpp.

Resource::DataStreamPtr Mezzanine::Resource::ResourceManager::CreateDataStream ( const String AssetName,
void *  Buffer,
const UInt32  BufferSize 
)

Creates a named stream from a memory buffer.

Note
The created stream will take ownership of the buffer you provide. If you want it to have a separate buffer then create a copy and pass that in.
Parameters
AssetNameThe name to be given to the created stream.
BufferA pointer to the memory to stream from.
BufferSizeThe size of the provided buffer in bytes.
Returns
Returns a CountedPtr to the stream to the provided buffer.

Definition at line 100 of file resourcemanager.cpp.

Resource::DataStreamPtr Mezzanine::Resource::ResourceManager::CreateDataStream ( const String AssetName,
const String GroupName,
void *  Buffer,
const UInt32  BufferSize 
)

Creates a named stream from a memory buffer and adds it to the named AssetGroup.

Note
The created stream will take ownership of the buffer you provide. If you want it to have a separate buffer then create a copy and pass that in.
Parameters
AssetNameThe name to be given to the created stream.
GroupNameThe name of the AssetGroup this stream will be added to.
BufferA pointer to the memory to stream from.
BufferSizeThe size of the provided buffer in bytes.
Returns
Returns a CountedPtr to the stream to the provided buffer.

Definition at line 103 of file resourcemanager.cpp.

void Mezzanine::Resource::ResourceManager::Deinitialize ( )
virtual

Removes this manager from any necessary configuration so it can be safely disposed of.

Implements Mezzanine::ManagerBase.

Definition at line 223 of file resourcemanager.cpp.

void Mezzanine::Resource::ResourceManager::DestroyAssetGroup ( const String GroupName)

Destroys an asset group, unloading all of it's resources.

Parameters
GroupNameThe name of the asset group to destroy.

Definition at line 154 of file resourcemanager.cpp.

void Mezzanine::Resource::ResourceManager::DestroyAssetGroup ( AssetGroup ToBeDestroyed)

Destroys an asset group, unloading all of it's resources.

Parameters
ToBeDestroyedA pointer to the asset group to be destroyed.

Definition at line 163 of file resourcemanager.cpp.

Resource::ArchiveType Mezzanine::Resource::ResourceManager::GetArchiveTypeFromString ( const String FromString)
static

Gets an ArchiveType from a string.

Parameters
FromStringThe string to be converted to an archive type.
Returns
Returns a ArchiveType corresponding to the string provided, or AT_Invalid if it is invalid.

Definition at line 242 of file resourcemanager.cpp.

AssetGroup * Mezzanine::Resource::ResourceManager::GetAssetGroup ( const String GroupName)

Gets an AssetGroup by name.

Parameters
GroupNameThe name of the AssetGroup to retrieve.
Returns
Returns a pointer to the specified group, or NULL if it does not exist.

Definition at line 136 of file resourcemanager.cpp.

AssetGroup * Mezzanine::Resource::ResourceManager::GetAssetGroupExcept ( const String GroupName)

Gets an AssetGroup by name.

Exceptions
Ifthe requested AssetGroup is not found this will throw an exception.

Parameters
GroupNameThe name of the AssetGroup to retrieve.
Returns
Returns a pointer to the specified group.

Definition at line 145 of file resourcemanager.cpp.

String Mezzanine::Resource::ResourceManager::GetAssetPath ( const String FileName,
const String Group 
)

Gets the actual path to an asset.

Note
This function currently only returns the first match, and doesn't check for multiple matches.
Parameters
FileNameThe name of the file to search for.
GroupThe asset group to search in for the file.
Returns
Returns a string containing the path to the file.

Definition at line 186 of file resourcemanager.cpp.

String Mezzanine::Resource::ResourceManager::GetEngineDataDirectory ( ) const

Get the pathname where engine data is stored.

Returns
A String that contains the path to where the engine data is stored.

Definition at line 202 of file resourcemanager.cpp.

String Mezzanine::Resource::ResourceManager::GetImplementationTypeName ( ) const
virtual

This Allows any manager name to be sent to a stream. Primarily used for logging.

Returns
This returns a String that contains the name.

Implements Mezzanine::ManagerBase.

Definition at line 258 of file resourcemanager.cpp.

ManagerBase::ManagerType Mezzanine::Resource::ResourceManager::GetInterfaceType ( ) const
virtual

This returns the type of this manager.

This is intended to make using and casting from Manager base easier. With this is is possible to cast from ManagerBase to the correct Manager Type.

Returns
This returns a ManagerTypeName to identify what this can be safely cast to.

Implements Mezzanine::ManagerBase.

Definition at line 255 of file resourcemanager.cpp.

AssetGroup * Mezzanine::Resource::ResourceManager::GetOrCreateAssetGroup ( const String GroupName)

Gets an AssetGroup by name. If it does not exist it will be created.

Parameters
GroupNameThe name of the group to create or retrieve.
Returns
Returns a pointer to the requested AssetGroup.

Definition at line 127 of file resourcemanager.cpp.

String Mezzanine::Resource::ResourceManager::GetPluginExtension ( ) const

Gets the dot-and-extention of this platforms plugins.

Returns
Returns the platform appropriate extention for plugin files.

Definition at line 207 of file resourcemanager.cpp.

String Mezzanine::Resource::ResourceManager::GetStringFromArchiveType ( const Resource::ArchiveType  ArchType)
static

Gets a string that describes an ArchiveType.

Parameters
ArchTypeA ArchiveType That you want to log or pass to Ogre, or just need a String that represents it.
Returns
A String that represents the ArchiveType passed.

Definition at line 228 of file resourcemanager.cpp.

void Mezzanine::Resource::ResourceManager::InitAssetGroup ( const String GroupName)

Makes a asset group ready to use.

After adding all of your assets and declaring them as nessessary, this function is the final step. After calling this function any and all assets within the defined group will be ready to use. Do not initialize any more groups then you need to however, as that will take up memory and drop performance.

Parameters
GroupNameName of the asset group.

Definition at line 175 of file resourcemanager.cpp.

void Mezzanine::Resource::ResourceManager::Initialize ( )
virtual

Configures this manager for use prior to entering the main loop.

Implements Mezzanine::ManagerBase.

Definition at line 218 of file resourcemanager.cpp.

Resource::DataStreamPtr Mezzanine::Resource::ResourceManager::OpenAssetStream ( const String AssetName,
const String GroupName 
)

Opens a stream to an asset in an AssetGroup.

Parameters
AssetNameThe identity of the asset to be opened (commonly a file name).
GroupNameThe name of the AssetGroup where the Asset can be found.

Definition at line 94 of file resourcemanager.cpp.

Member Data Documentation

AssetGroupContainer Mezzanine::Resource::ResourceManager::AssetGroups
protected

Container storing all of the asset groups created and managed by this manager.

Definition at line 106 of file resourcemanager.h.

String Mezzanine::Resource::ResourceManager::EngineDataDir
protected

The location of engine data.

Definition at line 109 of file resourcemanager.h.

Ogre::ResourceGroupManager* Mezzanine::Resource::ResourceManager::OgreResource
protected

Encapsulates the functionality of the ogre resource group manager.

Definition at line 112 of file resourcemanager.h.


The documentation for this class was generated from the following files: