Torque2D Reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Resource< T > Class Template Reference

#include <resourceManager.h>

Public Member Functions

 Resource ()
 
 Resource (ResourceObject *p)
 
 Resource (const Resource &res)
 
 ~Resource ()
 
const char * getFilePath () const
 Returns the path of the file (without the actual name)
 
const char * getFileName () const
 Returns the actual file name (without the path)
 
Resourceoperator= (ResourceObject *p)
 
Resourceoperator= (const Resource &r)
 
U32 getCRC ()
 
bool isNull () const
 
 operator bool () const
 
T * operator-> ()
 
T & operator* ()
 
 operator T* () const
 
const T * operator-> () const
 
const T & operator* () const
 
 operator const T * () const
 
void unlock ()
 
void purge ()
 

Detailed Description

template<class T>
class Resource< T >

Wrapper class around a ResourceInstance subclass.

// Loading a resource...
terrRes = ResourceManager->load(fileName);
if(!bool(terrRes))
Con::errorf(ConsoleLogEntry::General, "Terraformer::terrainFile - invalid terrain file '%s'.", fileName);
ResourceObject * load(const char *fileName, bool computeCRC=false)
loads an instance of an object
Definition resourceManager.cc:818
Definition resourceManager.h:234
void errorf(ConsoleLogEntry::Type type, const char *fmt,...)
Definition console.cc:662
@ General
Definition console.h:74

When the Resource<> is destroyed, it frees the lock on the resource.

See also
ResManager

Constructor & Destructor Documentation

◆ Resource() [1/3]

template<class T >
Resource ( )
inline

If assigned a ResourceObject, it's assumed to already have been locked, lock count is incremented only for copies or assignment from another Resource.

◆ Resource() [2/3]

template<class T >
Resource ( ResourceObject p)
inline

◆ Resource() [3/3]

template<class T >
Resource ( const Resource< T > &  res)
inline

◆ ~Resource()

template<class T >
~Resource ( )
inline

Decrements the lock count on this object, and if the lock count is 0 afterwards, adds the object to the timeoutList for deletion on execution of purge().

Member Function Documentation

◆ getCRC()

template<class T >
U32 getCRC ( )
inline

◆ getFileName()

template<class T >
const char * getFileName ( ) const
inline

Returns the actual file name (without the path)

◆ getFilePath()

template<class T >
const char * getFilePath ( ) const
inline

Returns the path of the file (without the actual name)

◆ isNull()

template<class T >
bool isNull ( ) const
inline

◆ operator bool()

template<class T >
operator bool ( ) const
inline

◆ operator const T *()

template<class T >
operator const T * ( ) const
inline

◆ operator T*()

template<class T >
operator T* ( ) const
inline

◆ operator*() [1/2]

template<class T >
T & operator* ( )
inline

◆ operator*() [2/2]

template<class T >
const T & operator* ( ) const
inline

◆ operator->() [1/2]

template<class T >
T * operator-> ( )
inline

◆ operator->() [2/2]

template<class T >
const T * operator-> ( ) const
inline

◆ operator=() [1/2]

template<class T >
Resource & operator= ( const Resource< T > &  r)
inline

◆ operator=() [2/2]

template<class T >
Resource & operator= ( ResourceObject p)
inline

◆ purge()

template<class T >
void purge ( )
inline

◆ unlock()

template<class T >
void unlock ( )
inline

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