PixelLightAPI  .
Public Member Functions | Static Public Member Functions | Protected Member Functions
PLCore::LoadableManager Class Reference

Loadable manager. More...

#include <LoadableManager.h>

List of all members.

Public Member Functions

uint32 GetNumOfTypes ()
 Returns the number of loadable types.
LoadableTypeGetTypeByIndex (uint32 nIndex)
 Returns a loadable type by using an index.
LoadableTypeGetTypeByName (const String &sName)
 Returns a loadable type by using it's name.
LoadableTypeGetTypeByExtension (const String &sExtension)
 Returns a loadable type by using a loadable extension.
PLCORE_API void GetTypesByExtension (const String &sExtension, Array< LoadableType * > &lstTypes)
 Returns loadable types by using a loadable extension.
uint32 GetNumOfLoaders ()
 Returns the number of loaders.
LoaderGetLoaderByIndex (uint32 nIndex)
 Returns a loader by using an index.
LoaderGetLoaderByExtension (const String &sExtension)
 Returns a loader by using a loadable extension.
PLCORE_API void GetLoadersByExtension (const String &sExtension, Array< Loader * > &lstLoaders)
 Returns loaders by using a loadable extension.
uint32 GetNumOfFormats ()
 Returns the number of supported formats.
String GetFormat (uint32 nIndex)
 Returns a supported format.
PLCORE_API bool IsFormatLoadSupported (const String &sExtension, const String &sType="")
 Returns whether loading is supported for the given format.
PLCORE_API bool IsFormatSaveSupported (const String &sExtension, const String &sType="")
 Returns whether saving is supported for the given format.
uint32 GetNumOfBaseDirs () const
 Returns the number of base directories.
String GetBaseDir (uint32 nNum) const
 Returns one of the base directories.
PLCORE_API bool IsBaseDir (const String &sPath) const
 Checks whether the given path is a base directory.
PLCORE_API bool AddBaseDir (const String &sPath)
 Adds a base directory.
PLCORE_API bool SetBaseDirPriority (const String &sFirstPath, const String &sSecondPath)
 Set the priority of base directories.
PLCORE_API bool RemoveBaseDir (const String &sPath)
 Remove a base directory.
PLCORE_API bool RemoveBaseDir (uint32 nNum)
 Remove a base directory.
bool ClearBaseDirs ()
 Removes all base directories.
PLCORE_API String GetRelativeFilename (const String &sFilename)
 Gets the relative version of an absolute filename.
PLCORE_API bool ScanPackages (const String &sPath, const String &sExtension="*.zip")
 Scan a directory for data packages and add them as base paths to the loadable manager.
PLCORE_API bool OpenFile (File &cFile, const String &sFilename, bool bCreate=false, String::EFormat nStringFormat=String::ASCII) const
 Opens a file by using base directories.
PLCORE_API String LoadStringFromFile (const String &sFilename, String::EFormat nStringFormat=String::ASCII) const
 Loads in a string by using a file.

Static Public Member Functions

static PLCORE_API LoadableManagerGetInstance ()
static PLCORE_API bool HasInstance ()

Protected Member Functions

PLCORE_API LoadableManager ()
 Constructor.
virtual PLCORE_API ~LoadableManager ()
 Destructor.

Detailed Description

Loadable manager.

Remarks:
A loadable class is for instance an image that can be loaded & saved in multiple ways/formats. Such a loadable is registered within this manager as a 'loadable type'. Each loadable type can have multiple loaders which load/save the loadable within a concrete way/format.

Example:

Note:
  • An empty string is also a valid base directory and represents the current system directory (see System::GetCurrentDir())

Constructor & Destructor Documentation

PLCORE_API PLCore::LoadableManager::LoadableManager ( ) [protected]
virtual PLCORE_API PLCore::LoadableManager::~LoadableManager ( ) [protected, virtual]

Destructor.


Member Function Documentation

static PLCORE_API LoadableManager* PLCore::LoadableManager::GetInstance ( ) [static]
static PLCORE_API bool PLCore::LoadableManager::HasInstance ( ) [static]

Returns the number of loadable types.

Returns:
The number of loadable types

Returns a loadable type by using an index.

Parameters:
[in]nIndexLoadable type index
Returns:
The requested loadable type, a null pointer on error

Returns a loadable type by using it's name.

Parameters:
[in]sNameLoadable type name
Returns:
The requested loadable type, a null pointer on error

Returns a loadable type by using a loadable extension.

Parameters:
[in]sExtensionExtension of loadable
Returns:
The requested loadable type (first found if there are multiple candidates), a null pointer on error
PLCORE_API void PLCore::LoadableManager::GetTypesByExtension ( const String sExtension,
Array< LoadableType * > &  lstTypes 
)

Returns loadable types by using a loadable extension.

Parameters:
[in]sExtensionExtension of loadable
[out]lstTypesReceives the list of matching loadable types (list is not cleared before new entries are added), there can be multiple candidates

Returns the number of loaders.

Returns:
The number of loaders
Loader * PLCore::LoadableManager::GetLoaderByIndex ( uint32  nIndex) [inline]

Returns a loader by using an index.

Parameters:
[in]nIndexLoader index
Returns:
The requested loader, a null pointer on error
Loader * PLCore::LoadableManager::GetLoaderByExtension ( const String sExtension) [inline]

Returns a loader by using a loadable extension.

Returns a loader by using a extension.

Parameters:
[in]sExtensionExtension of loadable
Returns:
The requested loader (first found if there are multiple candidates), a null pointer on error
PLCORE_API void PLCore::LoadableManager::GetLoadersByExtension ( const String sExtension,
Array< Loader * > &  lstLoaders 
)

Returns loaders by using a loadable extension.

Parameters:
[in]sExtensionExtension of loadable
[out]lstLoadersReceives the list of matching loaders (list is not cleared before new entries are added), there can be multiple candidates

Returns the number of supported formats.

Returns:
The number of supported formats
String PLCore::LoadableManager::GetFormat ( uint32  nIndex) [inline]

Returns a supported format.

Parameters:
[in]nIndexFormat index
Returns:
The requested supported format, empty string on error
PLCORE_API bool PLCore::LoadableManager::IsFormatLoadSupported ( const String sExtension,
const String sType = "" 
)

Returns whether loading is supported for the given format.

Parameters:
[in]sExtensionExtension of the format
[in]sTypeRequired loadable type, if empty string ignore loadable type
Returns:
'true' if loading is supported for the given format, else 'false'
PLCORE_API bool PLCore::LoadableManager::IsFormatSaveSupported ( const String sExtension,
const String sType = "" 
)

Returns whether saving is supported for the given format.

Parameters:
[in]sExtensionExtension of the format
[in]sTypeRequired loadable type, if empty string ignore loadable type
Returns:
'true' if saving is supported for the given format, else 'false'
uint32 PLCore::LoadableManager::GetNumOfBaseDirs ( ) const [inline]

Returns the number of base directories.

Returns:
Number of base directories
String PLCore::LoadableManager::GetBaseDir ( uint32  nNum) const [inline]

Returns one of the base directories.

Parameters:
[in]nNumNumber of the base directory to get
Returns:
Path of the base directory or empty string
PLCORE_API bool PLCore::LoadableManager::IsBaseDir ( const String sPath) const

Checks whether the given path is a base directory.

Parameters:
[in]sPathPath to the base directory
Returns:
'true', if the given path is a base directory, else 'false'
PLCORE_API bool PLCore::LoadableManager::AddBaseDir ( const String sPath)

Adds a base directory.

Parameters:
[in]sPathPath to the base directory
Returns:
'true', if all went fine, else 'false'
PLCORE_API bool PLCore::LoadableManager::SetBaseDirPriority ( const String sFirstPath,
const String sSecondPath 
)

Set the priority of base directories.

Parameters:
[in]sFirstPathPath to the first base directory
[in]sSecondPathPath to the second base directory
Returns:
'true', if all went fine, else 'false'
Remarks:
This function changes the order of the two base dirs so that sSecondPath comes right after sFirstPath.
PLCORE_API bool PLCore::LoadableManager::RemoveBaseDir ( const String sPath)

Remove a base directory.

Parameters:
[in]sPathBase directory to remove
Returns:
'true', if all went fine, else 'false'
PLCORE_API bool PLCore::LoadableManager::RemoveBaseDir ( uint32  nNum)

Remove a base directory.

Parameters:
[in]nNumNumber of the base directory to remove
Returns:
'true', if all went fine, else 'false'

Removes all base directories.

Returns:
'true', if all went fine, else 'false'
PLCORE_API String PLCore::LoadableManager::GetRelativeFilename ( const String sFilename)

Gets the relative version of an absolute filename.

Parameters:
[in]sFilenameAbsolute filename to get the relative version from
Returns:
Relative filename, empty string on error (maybe unknown loadable type?)
Note:
  • This function only checks whether there's a loadable type for the given file type, if so, the request is given to this loadable type
See also:
PLCORE_API bool PLCore::LoadableManager::ScanPackages ( const String sPath,
const String sExtension = "*.zip" 
)

Scan a directory for data packages and add them as base paths to the loadable manager.

Parameters:
[in]sPathDirectory to search in
[in]sExtensionExtension of the archives to add (e.g. 'zip' or 'pak')
Returns:
'true' if all went fine, else 'false'
PLCORE_API bool PLCore::LoadableManager::OpenFile ( File cFile,
const String sFilename,
bool  bCreate = false,
String::EFormat  nStringFormat = String::ASCII 
) const

Opens a file by using base directories.

Parameters:
[in]cFileFile object
[in]sFilenameFilename of the file to open
[in]bCreateCreate the file if it doesn't exist?
[in]nStringFormatString encoding format to use when dealing with string functions (not supported by all file implementations)
Returns:
'true' if all went fine, else 'false'
Note:
  • It's not recommended to use Unicode by because internally wchar_t is used and this data type has not the same size on every platform (use ASCII or UTF8 instead)
PLCORE_API String PLCore::LoadableManager::LoadStringFromFile ( const String sFilename,
String::EFormat  nStringFormat = String::ASCII 
) const

Loads in a string by using a file.

Parameters:
[in]sFilenameName of the file to read the string from
[in]nStringFormatString encoding format to use when dealing with string functions (not supported by all file implementations)
Returns:
The read string, empty string on error or if the file is just empty
Note:
  • The file is opened by using base directories
  • It's not recommended to use Unicode by because internally wchar_t is used and this data type has not the same size on every platform (use ASCII or UTF8 instead)

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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:28
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported