PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes
PLCore::Resource< AType > Class Template Reference

Resource template. More...

#include <Resource.h>

Inheritance diagram for PLCore::Resource< AType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Resource (const String &sName="", ResourceManager< AType > *pManager=nullptr)
 Constructor.
ResourceManager< AType > * GetManager () const
 Returns the resource manager using this resource.
String GetName () const
 Returns the unique resource name.
bool IsProtected () const
 Returns whether the resource is protected or not.
void SetProtected (bool bProtected=false)
 Sets whether the resource is protected or not.
int GetID () const
 Returns the ID of the resource within the resource manager.
uint32 GetNumOfHandlers () const
 Returns the number of resource handlers.
ResourceHandler< AType > * GetHandler (uint32 nIndex) const
 Returns a resource handler.
virtual bool Delete (bool bProtectedToo=false)
 Destroys the resource.
virtual bool SetName (const String &sName)
 Sets the resource name.
virtual Resource< AType > & operator= (const Resource< AType > &cSource)
 Copy operator.

Protected Member Functions

virtual ~Resource ()
 Destructor.

Protected Attributes

ResourceManager< AType > * m_pManager
String m_sName
bool m_bProtected
Array< ResourceHandler< AType > * > m_lstHandlers

Detailed Description

template<class AType>
class PLCore::Resource< AType >

Resource template.


Constructor & Destructor Documentation

template<class AType>
PLCore::Resource< AType >::Resource ( const String sName = "",
ResourceManager< AType > *  pManager = nullptr 
)

Constructor.

Parameters:
[in]sNameResource name to set
[in]pManagerResource manager using this resource, can be a null pointer
template<class AType >
PLCore::Resource< AType >::~Resource ( ) [protected, virtual]

Destructor.


Member Function Documentation

template<class AType >
ResourceManager< AType > * PLCore::Resource< AType >::GetManager ( ) const

Returns the resource manager using this resource.

Returns:
Resource manager using this resource or a null pointer
template<class AType >
String PLCore::Resource< AType >::GetName ( ) const

Returns the unique resource name.

Returns:
Unique resource name
Note:
  • Because within a resource manager a resource is managed using it's name, this resource name MUST be unique!
template<class AType >
bool PLCore::Resource< AType >::IsProtected ( ) const

Returns whether the resource is protected or not.

Returns:
'true' if the resource is protected, else 'false'
Note:
  • Protected resource are only removed if their manager is cleared!
template<class AType >
void PLCore::Resource< AType >::SetProtected ( bool  bProtected = false)

Sets whether the resource is protected or not.

Parameters:
[in]bProtectedIs the resource protected?
See also:
template<class AType >
int PLCore::Resource< AType >::GetID ( ) const

Returns the ID of the resource within the resource manager.

Returns:
ID of the resource within the resource manager, -1 if there was an error (maybe this resource is not within a resource manager)
Note:
  • The resource ID isn't fixed, if you remove some resources from the manager it's possible that the resource ID is changed!
template<class AType >
uint32 PLCore::Resource< AType >::GetNumOfHandlers ( ) const

Returns the number of resource handlers.

Returns:
The number of resource handlers
Note:
  • The handlers will be informed if the resource was lost
template<class AType >
ResourceHandler< AType > * PLCore::Resource< AType >::GetHandler ( uint32  nIndex) const

Returns a resource handler.

Parameters:
[in]nIndexIndex of the resource handler to return
Returns:
The requested resource handler, a null pointer on error
template<class AType >
bool PLCore::Resource< AType >::Delete ( bool  bProtectedToo = false) [virtual]

Destroys the resource.

Parameters:
[in]bProtectedTooDo also destroy the resource if it is protected?
Returns:
'true' if all went fine, else 'false' (maybe the resource is protected?)
Note:
  • Whether the resource is destroyed within this function or just added for instance to a kind of 'destruction list' is implementation dependent.
template<class AType >
bool PLCore::Resource< AType >::SetName ( const String sName) [virtual]

Sets the resource name.

Sets the unique resource name.

Parameters:
[in]sNameNew resource name
Returns:
'true' if all went fine, else 'false' (maybe the name is already used)
See also:
Note:
  • Overload this function if it's for instance not allowed to change the name of the resource
template<class AType>
Resource< AType > & PLCore::Resource< AType >::operator= ( const Resource< AType > &  cSource) [virtual]

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
This instance
Note:
  • Manager, handlers and name are not copied

Member Data Documentation

template<class AType>
ResourceManager<AType>* PLCore::Resource< AType >::m_pManager [protected]

Resource manager, can be a null pointer

template<class AType>
String PLCore::Resource< AType >::m_sName [protected]

Resource name

template<class AType>
bool PLCore::Resource< AType >::m_bProtected [protected]

Is the resource protected?

template<class AType>
Array<ResourceHandler<AType>*> PLCore::Resource< AType >::m_lstHandlers [protected]

Resource handler list


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:25
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported