Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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) More...
const char * | getFileName () const
| Returns the actual file name (without the path) More...
Resource & | operator= (ResourceObject *p)
Resource & | operator= (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...
Resource<TerrainFile> terrRes;
terrRes = ResourceManager->load(fileName);
if(!bool(terrRes))
Con::errorf(ConsoleLogEntry::General, "Terraformer::terrainFile - invalid terrain file '%s'.", fileName);

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

See also
  ResManager

## Constructor & Destructor Documentation

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 | ( | ResourceObject * | p | ) |
| inline

Resource | ( | const Resource< T > & | res | ) |
| inline

~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

U32 getCRC | ( |  | ) |
| inline

const char* getFileName | ( |  | ) | const
| inline

Returns the actual file name (without the path)

const char* getFilePath | ( |  | ) | const
| inline

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

bool isNull | ( |  | ) | const
| inline

operator bool | ( |  | ) | const
| inline

operator const T * | ( |  | ) | const
| inline

operator T * | ( |  | ) | const
| inline

T& operator* | ( |  | ) |
| inline

const T& operator* | ( |  | ) | const
| inline

T* operator-> | ( |  | ) |
| inline

const T* operator-> | ( |  | ) | const
| inline

Resource& operator= | ( | ResourceObject * | p | ) |
| inline

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

void purge | ( |  | ) |
| inline

void unlock | ( |  | ) |
| inline

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

- io/resource/resourceManager.h