This is the manager responsible for the loading and unloading of files. More...
#include <resourcemanager.h>
Public Types | |
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::DataStreamPtr > | DataStreamContainer |
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::DataStreamPtr > | NamedDataStreamContainer |
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_AudioManager = 1, MT_AnimationManager, MT_CollisionShapeManager, MT_CompositorManager, MT_GraphicsManager, MT_EventManager, MT_InputManager, MT_LogManager, MT_MaterialManager, MT_MeshManager, MT_NetworkManager, MT_ResourceManager, MT_ScriptingManager, MT_UIManager, MT_ActorManager = 100, MT_AreaEffectManager, MT_CameraManager, MT_DebrisManager, MT_PagingManager, MT_PhysicsManager, MT_SceneManager, MT_SoundScapeManager, MT_TerrainManager, MT_VehicleManager, MT_UserCreated = 512 } |
Public Member Functions | |
ResourceManager (const String &EngineDataPath=".", const ArchiveType ArchType=AT_FileSystem, int ArgCount=0, char **ArgVars=NULL) | |
Class constructor. More... | |
ResourceManager (XML::Node &XMLNode) | |
XML constructor. More... | |
virtual | ~ResourceManager () |
void | AddAssetLocation (const String &Location, const ArchiveType Type, const String &Group, const bool Recursive=false) |
Adds a location for graphical resources. More... | |
void | CreateAssetGroup (const String &GroupName) |
Creates an 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 &AssetGroup, void *Buffer, const UInt32 BufferSize) |
Creates a named stream from a memory buffer and adds it to the named AssetGroup. More... | |
bool | CreateDirectoryPath (const String &DirectoryPath) |
Creates all directories that do not exist in the provided path. More... | |
void | DeclareAsset (const String &Name, const String &Type, const String &Group) |
Prepares the asset for use. More... | |
virtual void | Deinitialize () |
Removes this manager from any necessary configuration so it can be safely disposed of. More... | |
void | DestroyAssetGroup (const String &GroupName) |
Destroys an asset group, unloading all of it's resources. More... | |
String | GetAssetPath (const String &FileName, const String &Group) |
Gets the actual path to an asset. More... | |
String | GetCommonUserDataDir () const |
Gets the path to the directory intended for game saves and user profile data for all users. More... | |
String | GetCurrentUserDataDir () const |
Gets the path to the directory intended for game saves and user profile data for the current user. More... | |
String | GetEngineDataDirectory () const |
Get the pathname where engine data is stored. More... | |
String | GetExecutableDir () const |
Get the Path to the current executable, in a fast way if possible. More... | |
String | GetExecutableDirFromArg () const |
Uses the main parameters stored on an instance of Mezzanine::ResourceManager to attempt determine executable directory. 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... | |
String | GetLocalAppDataDir () const |
Gets the path to the directory intended for game and engine config data that is not meant to be shared. More... | |
String | GetPluginExtension () const |
Gets the dot-and-extention of this platforms plugins. More... | |
ResourceInputStream * | GetResourceStream (const String &FileName) |
Get a stream to read from the specified file. More... | |
String | GetShareableAppDataDir () const |
Gets the path to the directory intended for game and engine config data that is allowed to be shared. More... | |
void | InitAssetGroup (const String &Name) |
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 &AssetGroup) |
Opens a stream to an asset in an AssetGroup. More... | |
String | ResolveDataPathFromString (const String &PathVar) |
Resolves a string describing one of the platform data paths to the actual path it is. More... | |
void | SetMainArgs (int ArgCount, char **ArgVars) |
Store the Main arguments for later use. More... | |
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... | |
bool | IsInitialized () const |
Gets whether or not this manager has been initialized. More... | |
Public Member Functions inherited from Mezzanine::Singleton< ResourceManager > | |
Singleton () | |
Class constructor. | |
~Singleton () | |
Class destructor. | |
Static Public Member Functions | |
static String | BaseName (const String &FileName) |
Get the filename portion of a string. More... | |
static void | ChangeDirectory (const String &ChangeTo) |
Change directory, to the directory indicated. More... | |
static bool | CreateDirectory (const String &DirectoryPath) |
Creates a single new directory. More... | |
static String | DirName (const String &FileName) |
Get the directory portion of a string. More... | |
static bool | DoesDirectoryExist (const String &DirectoryPath) |
Checks to see if the given path exists and if it is a folder. More... | |
static ArchiveType | GetArchiveTypeFromString (const String &FromString) |
Gets an ArchiveType from a string. More... | |
static StringSet | GetDirContents (const String &Dir=".") |
Get a Listing of the files and subdirectories in a directory. More... | |
static char | GetDirectorySeparator () |
Get the character used to separate directories. More... | |
static String | GetExecutableDir (int ArgCount, char **ArgVars) |
Get the Path to the current executable, fast from Args if Possible or from a system call otherwise. More... | |
static String | GetExecutableDirFromArg (int ArgCount, char **ArgVars) |
Attempt to get the executable directory from the a set of variables like those passed into Main. More... | |
static String | GetExecutableDirFromSystem () |
Used a system call to get the curent Directory the executable is in. This make an external system call and is likely slower than GetExecutableDirFromArg. More... | |
static char | GetPathSeparator () |
Get the character used to separate entries in the system PATH. More... | |
static String | GetStringFromArchiveType (const Mezzanine::ArchiveType ArchType) |
Gets a string that describes an ArchiveType. More... | |
static StringVector | GetSystemPATH (const String &PATH=String(getenv("PATH"))) |
Get the $PATH or PATH% split and order for easy checking of how the OS does it. More... | |
static String | GetWorkingDirectory () |
Get the working directory as a Mezzanine::String. More... | |
static void | RemoveDirectory (const String &DirectoryPath) |
Remove an empty directory. More... | |
static String | Which (String ExecutableName) |
Search the system path the same way most systems do to find an executable. 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 bool | SingletonValid () |
Checks to see if the singleton pointer is valid. More... | |
Protected Member Functions | |
void | AddAssetGroupName (String Name) |
Adds an asset group name to the list of known AssetGroups. More... | |
Protected Attributes | |
int | ArgC |
ArgC as it was passed into Main. More... | |
char ** | ArgV |
ArgC as it was passed into Main. More... | |
DataStreamContainer | DataStreams |
A container storing all un-named, un-grouped data streams known by the resource system. More... | |
std::vector < ResourceInputStream * > | DeleteList |
A vector of Pointers to streams created to delete periodically. More... | |
String | EngineDataDir |
The location of engine data. More... | |
NamedDataStreamContainer | NamedDataStreams |
A container storing all named but un-grouped data streams known by the resource system. More... | |
Ogre::ResourceGroupManager * | OgreResource |
Encapsulates the functionality of the ogre resource group manager. More... | |
std::vector< String > | ResourceGroups |
A vector of all the known internal Asset Groups. More... | |
Protected Attributes inherited from Mezzanine::ManagerBase | |
bool | Initialized |
Simple bool indicating whether or not this manager has been initialized. More... | |
Entresol * | TheEntresol |
The actual pointer to the Entresol core class. More... | |
Additional Inherited Members | |
Static Protected Attributes inherited from Mezzanine::Singleton< ResourceManager > | |
static ResourceManager * | SingletonPtr |
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.
Mezzanine::ResourceManager::ResourceManager | ( | const String & | EngineDataPath = "." , |
const ArchiveType | ArchType = AT_FileSystem , |
||
int | ArgCount = 0 , |
||
char ** | ArgVars = NULL |
||
) |
Class constructor.
Standard manager constructor.
EngineDataPath | The directory for engine specific data. |
ArchiveType | The name of the type of archive at this path. |
ArgCount | How many arguments will be passed in ArgVars. Defaults to 0 |
ArgVars | A pointer to an array, with ArgCount elements, of char* which point to null terminated c strings. Defaults to NULL. |
Definition at line 99 of file resourcemanager.cpp.
Mezzanine::ResourceManager::ResourceManager | ( | XML::Node & | XMLNode) |
XML constructor.
XMLNode | The node of the xml document to construct from. |
Definition at line 107 of file resourcemanager.cpp.
|
virtual |
Class Destructor.
Definition at line 113 of file resourcemanager.cpp.
|
protected |
Adds an asset group name to the list of known AssetGroups.
Definition at line 564 of file resourcemanager.cpp.
void Mezzanine::ResourceManager::AddAssetLocation | ( | const String & | Location, |
const ArchiveType | Type, | ||
const String & | Group, | ||
const bool | 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).
Location | The location on the file system the asset can be found. |
Type | The kind of file system the location can be found in. Options are: filesystem, zip. |
Group | The name of the group the resources at this location belong to. If the group does not exist it will be created. |
Recursive | Whether or not to search sub-directories. |
Definition at line 574 of file resourcemanager.cpp.
Get the filename portion of a string.
FileName | A whole path and filename |
Definition at line 204 of file resourcemanager.cpp.
|
static |
Change directory, to the directory indicated.
ChangeTo | The new directory to work from. |
Definition at line 344 of file resourcemanager.cpp.
void Mezzanine::ResourceManager::CreateAssetGroup | ( | const String & | GroupName) |
Creates an asset group.
GroupName | The name to be given to the created asset group. |
Definition at line 580 of file resourcemanager.cpp.
Resource::DataStreamPtr Mezzanine::ResourceManager::CreateDataStream | ( | void * | Buffer, |
const UInt32 | BufferSize | ||
) |
Creates a stream from a memory buffer.
Buffer | A pointer to the memory to stream from. |
BufferSize | The size of the provided buffer in bytes. |
Definition at line 537 of file resourcemanager.cpp.
Resource::DataStreamPtr Mezzanine::ResourceManager::CreateDataStream | ( | const String & | AssetName, |
void * | Buffer, | ||
const UInt32 | BufferSize | ||
) |
Creates a named stream from a memory buffer.
AssetName | The name to be given to the created stream. |
Buffer | A pointer to the memory to stream from. |
BufferSize | The size of the provided buffer in bytes. |
Definition at line 544 of file resourcemanager.cpp.
Resource::DataStreamPtr Mezzanine::ResourceManager::CreateDataStream | ( | const String & | AssetName, |
const String & | AssetGroup, | ||
void * | Buffer, | ||
const UInt32 | BufferSize | ||
) |
Creates a named stream from a memory buffer and adds it to the named AssetGroup.
AssetName | The name to be given to the created stream. |
AssetGroup | The name of the AssetGroup this stream will be added to. |
Buffer | A pointer to the memory to stream from. |
BufferSize | The size of the provided buffer in bytes. |
Definition at line 551 of file resourcemanager.cpp.
|
static |
Creates a single new directory.
DirectoryPath | The path for the newly created directory. |
Definition at line 130 of file resourcemanager.cpp.
bool Mezzanine::ResourceManager::CreateDirectoryPath | ( | const String & | DirectoryPath) |
Creates all directories that do not exist in the provided path.
DirectoryPath | The path for the newly created directory or directories. |
Definition at line 358 of file resourcemanager.cpp.
void Mezzanine::ResourceManager::DeclareAsset | ( | const String & | Name, |
const String & | Type, | ||
const String & | Group | ||
) |
Prepares the asset for use.
This function can be thought of as a preloader. This will prepare the defined asset located on the disk for use.
Name | Name of the file/asset to be 'prepared'. |
Type | The type of asset that the file is. Options are: Font, GpuProgram, HighLevelGpuProgram, Material, Mesh, Skeleton, Texture. |
Group | Name of the group the asset belongs to. |
Definition at line 608 of file resourcemanager.cpp.
|
virtual |
Removes this manager from any necessary configuration so it can be safely disposed of.
Implements Mezzanine::ManagerBase.
Definition at line 667 of file resourcemanager.cpp.
void Mezzanine::ResourceManager::DestroyAssetGroup | ( | const String & | GroupName) |
Destroys an asset group, unloading all of it's resources.
GroupName | The name of the asset group to destroy. |
Definition at line 586 of file resourcemanager.cpp.
Get the directory portion of a string.
FileName | A whole path and filename |
Definition at line 190 of file resourcemanager.cpp.
|
static |
Checks to see if the given path exists and if it is a folder.
DirectoryPath | A String containing the path to test. |
On | Error this might throw a Mezzanine::IOException with detail about why it failed |
Definition at line 168 of file resourcemanager.cpp.
|
static |
Gets an ArchiveType from a string.
FromString | The string to be converted to an archive type. |
Definition at line 686 of file resourcemanager.cpp.
Gets the actual path to an asset.
FileName | The name of the file to search for. |
Group | The asset group to search in for the file. |
Definition at line 621 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetCommonUserDataDir | ( | ) | const |
Gets the path to the directory intended for game saves and user profile data for all users.
Definition at line 500 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetCurrentUserDataDir | ( | ) | const |
Gets the path to the directory intended for game saves and user profile data for the current user.
Definition at line 482 of file resourcemanager.cpp.
Get a Listing of the files and subdirectories in a directory.
This follows normal command line conventions, "." is the current directory, ".." is the parent directory. To access the file system root you will need to use a leading "c:/", "c:\\", or "/" as appropriate for the operating system the software will run on.
Dir | The directory to check. |
Definition at line 386 of file resourcemanager.cpp.
|
static |
Get the character used to separate directories.
Definition at line 218 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetEngineDataDirectory | ( | ) | const |
Get the pathname where engine data is stored.
Definition at line 418 of file resourcemanager.cpp.
|
static |
Get the Path to the current executable, fast from Args if Possible or from a system call otherwise.
ArgCount | How many arguments will be passed in ArgVars. |
ArgVars | A pointer to an array, with ArgCount elements, of char* which point to null terminated c strings. |
Definition at line 330 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetExecutableDir | ( | ) | const |
Get the Path to the current executable, in a fast way if possible.
Definition at line 341 of file resourcemanager.cpp.
|
static |
Attempt to get the executable directory from the a set of variables like those passed into Main.
This is the fastest way to get the Executable location, but might not work on all platforms.
ArgCount | How many arguments will be passed in ArgVars. |
ArgVars | A pointer to an array, with ArgCount elements, of char* which point to null terminated c strings. |
Definition at line 272 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetExecutableDirFromArg | ( | ) | const |
Uses the main parameters stored on an instance of Mezzanine::ResourceManager to attempt determine executable directory.
Definition at line 298 of file resourcemanager.cpp.
|
static |
Used a system call to get the curent Directory the executable is in. This make an external system call and is likely slower than GetExecutableDirFromArg.
Definition at line 301 of file resourcemanager.cpp.
|
virtual |
This Allows any manager name to be sent to a stream. Primarily used for logging.
Implements Mezzanine::ManagerBase.
Definition at line 702 of file resourcemanager.cpp.
|
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.
Implements Mezzanine::ManagerBase.
Definition at line 699 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetLocalAppDataDir | ( | ) | const |
Gets the path to the directory intended for game and engine config data that is not meant to be shared.
Definition at line 437 of file resourcemanager.cpp.
|
static |
Get the character used to separate entries in the system PATH.
Definition at line 227 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetPluginExtension | ( | ) | const |
Gets the dot-and-extention of this platforms plugins.
Definition at line 637 of file resourcemanager.cpp.
ResourceInputStream * Mezzanine::ResourceManager::GetResourceStream | ( | const String & | FileName) |
Get a stream to read from the specified file.
The returned ResourceInputStream is the Caller's responsibility to deal with. If it is not deleted it is a memory leak.
FileName | The name of the File you want to stream data from. |
Definition at line 648 of file resourcemanager.cpp.
String Mezzanine::ResourceManager::GetShareableAppDataDir | ( | ) | const |
Gets the path to the directory intended for game and engine config data that is allowed to be shared.
Definition at line 464 of file resourcemanager.cpp.
|
static |
Gets a string that describes an ArchiveType.
ArchType | A ArchiveType That you want to log or pass to Ogre, or just need a String that represents it. |
Definition at line 672 of file resourcemanager.cpp.
|
static |
Get the $PATH or PATH% split and order for easy checking of how the OS does it.
PATH | Defaults to the PATH environment variable. But any value like a system path will be split the return of GetPathSeparator(). |
Definition at line 236 of file resourcemanager.cpp.
|
static |
Get the working directory as a Mezzanine::String.
Definition at line 406 of file resourcemanager.cpp.
void Mezzanine::ResourceManager::InitAssetGroup | ( | const String & | Name) |
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.
Name | Name of the asset group. |
Definition at line 613 of file resourcemanager.cpp.
|
virtual |
Configures this manager for use prior to entering the main loop.
Implements Mezzanine::ManagerBase.
Definition at line 662 of file resourcemanager.cpp.
Resource::DataStreamPtr Mezzanine::ResourceManager::OpenAssetStream | ( | const String & | AssetName, |
const String & | AssetGroup | ||
) |
Opens a stream to an asset in an AssetGroup.
AssetName | The identity of the asset to be opened (commonly a file name). |
AssetGroup | The name of the AssetGroup where the Asset can be found. |
Definition at line 521 of file resourcemanager.cpp.
|
static |
Remove an empty directory.
DirectoryPath | Directory to remove. |
On | Error this might throw a Mezzanine::IOException with details about why it failed. |
Definition at line 180 of file resourcemanager.cpp.
Resolves a string describing one of the platform data paths to the actual path it is.
PathVar | String containing the name of the path variable. |
Definition at line 423 of file resourcemanager.cpp.
void Mezzanine::ResourceManager::SetMainArgs | ( | int | ArgCount, |
char ** | ArgVars | ||
) |
Store the Main arguments for later use.
ArgCount | How many arguments will be passed in ArgVars. |
ArgVars | A pointer to an array, with ArgCount elements, of char* which point to null terminated c strings. |
Definition at line 121 of file resourcemanager.cpp.
Search the system path the same way most systems do to find an executable.
ExecutableName | The executable to look for. |
Definition at line 257 of file resourcemanager.cpp.
|
protected |
ArgC as it was passed into Main.
This cannot be set statically, it must wait for main(int, char**) to be initialized, then call the appropriate function to set this.
Definition at line 116 of file resourcemanager.h.
|
protected |
ArgC as it was passed into Main.
This cannot be set statically, it must wait for main(int, char**) to be initialized, then call the appropriate function to set this.
Definition at line 120 of file resourcemanager.h.
|
protected |
A container storing all un-named, un-grouped data streams known by the resource system.
Definition at line 101 of file resourcemanager.h.
|
protected |
A vector of Pointers to streams created to delete periodically.
Definition at line 108 of file resourcemanager.h.
|
protected |
The location of engine data.
Definition at line 97 of file resourcemanager.h.
|
protected |
A container storing all named but un-grouped data streams known by the resource system.
Definition at line 104 of file resourcemanager.h.
|
protected |
Encapsulates the functionality of the ogre resource group manager.
Definition at line 94 of file resourcemanager.h.
|
protected |
A vector of all the known internal Asset Groups.
Definition at line 111 of file resourcemanager.h.