XFcResourceManager class Reference

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XFcResourceManager Class Reference

Resource manager. More...

List of all members.

## Static Public Member Functions

XFCIMPORT INT32 | createResource (XFcResource *aCallback, const UINT32 aSize)
| Creates a new resource with the default resource type.
XFCIMPORT INT32 | createResource (XFcResource *aCallback, const UINT32 aSize, const UINT32 aFlags)
| Creates a new resource with the given resource type.
XFCIMPORT INT | removeResource (const INT32 aId)
| Removes a resource.
XFCIMPORT void | removeResources ()
| Removes all resources which are removable.
XFCIMPORT INT | queryResource (const INT32 aId)
| Queries whether a certain resource is available in memory.
XFCIMPORT INT | evictResource (const INT32 aId)
| Evicts the data of a resource.
XFCIMPORT void | evictResources ()
| Evicts all resources from memory which are removable.
XFCIMPORT INT | preloadResource (const INT32 aId)
| Preloads the data of a resource to memory.
XFCIMPORT void | preloadResources ()
| Tries to preload data of all resources to memory.
XFCIMPORT void * | lockResource (const INT32 aId)
| Locks a resource for use.
XFCIMPORT INT | unlockResource (const INT32 aId)
| Unlocks a resource.

## Detailed Description

Resource manager.

## Member Function Documentation

XFCIMPORT INT32 XFcResourceManager::createResource | ( | XFcResource * | aCallback,
|  | const UINT32 | aSize,
|  | const UINT32 | aFlags
| ) | `[static]`

Creates a new resource with the given resource type.

Creates a new resource whose type is determined by the given flags.

  Different resource types are:
  - Default: resource can be moved and removed.
  - Non-removable: resource can be moved for defragmentation but can not be removed.
  - Non-movable: resource can not be moved nor removed, user might have a direct pointer to data.

Parameters:

  aCallback | Pointer to the resource to be used when callback is needed.
  aSize | Size of memory which should be allocated to the resource in bytes.
  aFlags | Flags for resource type.

Returns:
  Resource id, or -1 in case of an error.

XFCIMPORT INT32 XFcResourceManager::createResource | ( | XFcResource * | aCallback,
|  | const UINT32 | aSize
| ) | `[static]`

Creates a new resource with the default resource type.

Parameters:

  aCallback | Pointer to the resource to be used when callback is needed.
  aSize | Size of memory which should be allocated to the resource in bytes.

Returns:
  Resource id, or -1 in case of an error.

XFCIMPORT INT XFcResourceManager::evictResource | ( | const INT32 | aId | ) | `[static]`

Evicts the data of a resource.

Frees the internal data of a resource, the resource header stays in memory. The internal data will be loaded into memory when the resource is being locked or it can be loaded into memory with the preloadResource()-function.

Parameters:

  aId | Resource id.

Returns:
  1 if the evict succeeds, 0 otherwise.

XFCIMPORT void XFcResourceManager::evictResources | ( |  | ) | `[static]`

| Evicts all resources from memory which are removable. Frees the internal data of all resources, the resource headers stay in memory. The internal data will be loaded into memory when the resource is being locked or it can be loaded into memory with the preloadResource()-function.

XFCIMPORT void* XFcResourceManager::lockResource | ( | const INT32 | aId | ) | `[static]`

Locks a resource for use.

Locks a resource so that it can not be moved nor removed while the lock is on. If the internal data of a resource is not present in memory, a callback is made to the resource so it will be loaded into memory again.

Parameters:

  aId | Resource id.

Returns:
  Pointer to the internal data of a resource, NULL if the resource can not be locked.

XFCIMPORT INT XFcResourceManager::preloadResource | ( | const INT32 | aId | ) | `[static]`

Preloads the data of a resource to memory.

Loads the internal data of a resource into memory. The actual implementation is just a lock and unlock of the resource.

Parameters:

  aId | Resource id

Returns:
  1 if preload succeeds, 0 otherwise

XFCIMPORT void XFcResourceManager::preloadResources | ( |  | ) | `[static]`

| Tries to preload data of all resources to memory. Tries to load the internal data of all resources into memory.

XFCIMPORT INT XFcResourceManager::queryResource | ( | const INT32 | aId | ) | `[static]`

Queries whether a certain resource is available in memory.

Queries whether the internal data of a resource is present in memory. The resource headers stay in memory until the removeResource()-function is called but the internal data might not be if it has been evicted temporarily to free memory.

Parameters:

  aId | Resource id.

Returns:
  1 if the internal data of a resource is present in memory, 0 otherwise.

XFCIMPORT INT XFcResourceManager::removeResource | ( | const INT32 | aId | ) | `[static]`

Removes a resource.

Parameters:

  aId | Resource id.

Returns:
  1 if the removal succeeds, 0 otherwise.

XFCIMPORT void XFcResourceManager::removeResources | ( |  | ) | `[static]`

| Removes all resources which are removable.

XFCIMPORT INT XFcResourceManager::unlockResource | ( | const INT32 | aId | ) | `[static]`

Unlocks a resource.

Unlocks a resource so it can be moved or removed again if needed. The call will fail if the resource id is not valid or the resource is not locked in the first place.

Parameters:

  aId | Resource id.

Returns:
  1 if unlock succeeds, 0 otherwise.

|  | X-Forge Documentation Confidential Copyright © 2002-2003 Fathammer |  | Documentation generated with doxygen by Dimitri van Heesch