C# Класс Axiom.Core.ResourceManager

Defines a generic resource handler.
A resource manager is responsible for managing a pool of resources of a particular type. It must index them, look them up, load and destroy them. It may also need to stay within a defined memory budget, and temporarily unload some resources if it needs to stay within this budget. Resource managers use a priority system to determine what can be unloaded, and a Least Recently Used (LRU) policy within resources of the same priority. Resources can be loaded using the generalized load interface, and they can be unloaded and removed. In addition, each subclass of ResourceManager will likely define custom 'load' methods which take explicit parameters depending on the kind of resource being created. Resources can be loaded and unloaded through the Resource class, but they can only be removed (and thus eventually destroyed) using their parent ResourceManager.
Наследование: DisposableObject, IScriptLoader
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Create ( string name, string group ) : Axiom.Core.Resource

Creates a new blank resource, but does not immediately load it.

Resource managers handle disparate types of resources. This method returns a pointer to a valid new instance of the kind of resource managed here. The caller should complete the details of the returned resource and call ResourceManager.Load to load the resource. Note that it is the CALLERS responsibility to destroy this object when it is no longer required (after calling ResourceManager.Unload if it had been loaded). If you want to get at the detailed interface of this resource, you'll have to cast the result to the subclass you know you're creating.

Create ( string name, string group, NameValuePairList createParams ) : Axiom.Core.Resource
Create ( string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList createParams ) : Axiom.Core.Resource
CreateOrRetrieve ( string name, string group ) : Tuple,Axiom.Math
CreateOrRetrieve ( string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList paramaters ) : Tuple,Axiom.Math
GetByHandle ( System.UInt64 handle ) : Axiom.Core.Resource
GetByName ( string name ) : Axiom.Core.Resource
Load ( string name, string group ) : Axiom.Core.Resource

Generic load method, used to create a Resource specific to this ResourceManager without using one of the specialised 'load' methods (containing per-Resource-type parameters).

Load ( string name, string group, NameValuePairList loadParams ) : Axiom.Core.Resource
Load ( string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList loadParams ) : Axiom.Core.Resource
NotifyResourceLoaded ( Axiom.Core.Resource res ) : void

Notify this manager that a resource which it manages has been loaded.

NotifyResourceTouched ( Axiom.Core.Resource res ) : void

Notify this manager that a resource which it manages has been 'touched', ie used.

NotifyResourceUnloaded ( Axiom.Core.Resource res ) : void

Notify this manager that a resource which it manages has been unloaded.

ParseScript ( Stream stream, string groupName, string fileName ) : void

Parse a script file.

ReloadAll ( ) : void

Causes all currently loaded resources to be reloaded.

Unloaded resources are not removed, they simply free up their memory as much as they can and wait to be reloaded. ResourceGroupManager for unloading of resource groups.

Remove ( Axiom.Core.Resource resource ) : void

Remove a single resource.

Removes a single resource, meaning it will be removed from the list of valid resources in this manager, also causing it to be unloaded. The word 'Destroy' is not used here, since if any other pointers are referring to this resource, it will persist until they have finished with it; however to all intents and purposes it no longer exists and will likely get destroyed imminently. If you do have references to resources hanging around after the ResourceManager is destroyed, you may get problems on destruction of these resources if they were relying on the manager (especially if it is a plugin). If you find you get problems on shutdown in the destruction of resources, try making sure you release all your references before you shutdown OGRE.

Remove ( System.UInt64 handle ) : void
Remove ( string name ) : void
RemoveAll ( ) : void

Removes all resources.

Removes all resources, meaning they will be removed from the list of valid resources in this manager, also causing them to be unloaded. The word 'Destroy' is not used here, since if any other pointers are referring to this resource, it will persist until they have finished with it; however to all intents and purposes it no longer exists and will likely get destroyed imminently. If you do have references to resources hanging around after the ResourceManager is destroyed, you may get problems on destruction of these resources if they were relying on the manager (especially if it is a plugin). If you find you get problems on shutdown in the destruction of resources, try making sure you release all your references before you shutdown Axiom.

ResourceExists ( System.UInt64 handle ) : bool

Returns whether a resource with the given handle exists in this manager

ResourceExists ( string name ) : bool

Returns whether the named resource exists in this manager

Unload ( Resource resource ) : void

Unloads a Resource from the managed resources list, calling it's Unload() method.

This method removes a resource from the list maintained by this manager, and unloads it from memory. It does NOT destroy the resource itself, although the memory used by it will be largely freed up. This would allow you to reload the resource again if you wished.

Unload ( System.UInt64 handle ) : void
Unload ( string name ) : void

Unloads a single resource by name.

Unloaded resources are not removed, they simply free up their memory as much as they can and wait to be reloaded. ResourceGroupManager for unloading of resource groups.

UnloadAll ( ) : void

Unloads all resources.

Unloaded resources are not removed, they simply free up their memory as much as they can and wait to be reloaded. ResourceGroupManager for unloading of resource groups.

this ( System.UInt64 handle ) : Resource

Gets a resource with the given handle.

this ( string name ) : Resource

Gets a reference to the specified named resource.

Защищенные методы

Метод Описание
ResourceManager ( ) : System

Default constructor

_add ( Resource res ) : void

Add a newly created resource to the manager

_create ( string name, System.UInt64 handle, string group, bool isManual, IManualResourceLoader loader, NameValuePairList createParams ) : Resource

Create a new resource instance compatible with this manager (no custom parameters are populated at this point).

_remove ( Resource res ) : void

Remove a resource from this manager; remove it from the lists.

checkUsage ( ) : void

Makes sure we are still within budget.

dispose ( bool disposeManagedResources ) : void

Class level dispose method

When implementing this method in an inherited class the following template should be used; protected override void dispose( bool disposeManagedResources ) { if ( !isDisposed ) { if ( disposeManagedResources ) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose( disposeManagedResources ); }

Описание методов

Create() публичный метод

Creates a new blank resource, but does not immediately load it.
Resource managers handle disparate types of resources. This method returns a pointer to a valid new instance of the kind of resource managed here. The caller should complete the details of the returned resource and call ResourceManager.Load to load the resource. Note that it is the CALLERS responsibility to destroy this object when it is no longer required (after calling ResourceManager.Unload if it had been loaded). If you want to get at the detailed interface of this resource, you'll have to cast the result to the subclass you know you're creating.
public Create ( string name, string group ) : Axiom.Core.Resource
name string The unique name of the resource
group string
Результат Axiom.Core.Resource

Create() публичный метод

public Create ( string name, string group, NameValuePairList createParams ) : Axiom.Core.Resource
name string
group string
createParams NameValuePairList If any parameters are required to create an instance, they should be supplied here as name / value pairs
Результат Axiom.Core.Resource

Create() публичный метод

public Create ( string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList createParams ) : Axiom.Core.Resource
name string
group string
isManual bool /// Is this resource manually loaded? If so, you should really /// populate the loader parameter in order that the load process /// can call the loader back when loading is required. ///
loader IManualResourceLoader /// Pointer to a ManualLoader implementation which will be called /// when the Resource wishes to load (should be supplied if you set /// isManual to true). You can in fact leave this parameter null /// if you wish, but the Resource will never be able to reload if /// anything ever causes it to unload. Therefore provision of a proper /// ManualLoader instance is strongly recommended. ///
createParams NameValuePairList If any parameters are required to create an instance, they should be supplied here as name / value pairs
Результат Axiom.Core.Resource

CreateOrRetrieve() публичный метод

public CreateOrRetrieve ( string name, string group ) : Tuple,Axiom.Math
name string
group string
Результат Tuple,Axiom.Math

CreateOrRetrieve() публичный метод

public CreateOrRetrieve ( string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList paramaters ) : Tuple,Axiom.Math
name string
group string
isManual bool
loader IManualResourceLoader
paramaters NameValuePairList
Результат Tuple,Axiom.Math

GetByHandle() публичный метод

public GetByHandle ( System.UInt64 handle ) : Axiom.Core.Resource
handle System.UInt64
Результат Axiom.Core.Resource

GetByName() публичный метод

public GetByName ( string name ) : Axiom.Core.Resource
name string
Результат Axiom.Core.Resource

Load() публичный метод

Generic load method, used to create a Resource specific to this ResourceManager without using one of the specialised 'load' methods (containing per-Resource-type parameters).
public Load ( string name, string group ) : Axiom.Core.Resource
name string The name of the Resource
group string The resource group to which this resource will belong
Результат Axiom.Core.Resource

Load() публичный метод

public Load ( string name, string group, NameValuePairList loadParams ) : Axiom.Core.Resource
name string The name of the Resource
group string The resource group to which this resource will belong
loadParams NameValuePairList /// Optional pointer to a list of name/value pairs /// containing loading parameters for this type of resource. ///
Результат Axiom.Core.Resource

Load() публичный метод

public Load ( string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList loadParams ) : Axiom.Core.Resource
name string The name of the Resource
group string The resource group to which this resource will belong
isManual bool /// Is the resource to be manually loaded? If so, you should /// provide a value for the loader parameter ///
loader IManualResourceLoader /// The manual loader which is to perform the required actions /// when this resource is loaded; only applicable when you specify true /// for the previous parameter ///
loadParams NameValuePairList /// Optional pointer to a list of name/value pairs /// containing loading parameters for this type of resource. ///
Результат Axiom.Core.Resource

NotifyResourceLoaded() публичный метод

Notify this manager that a resource which it manages has been loaded.
public NotifyResourceLoaded ( Axiom.Core.Resource res ) : void
res Axiom.Core.Resource the resource
Результат void

NotifyResourceTouched() публичный метод

Notify this manager that a resource which it manages has been 'touched', ie used.
public NotifyResourceTouched ( Axiom.Core.Resource res ) : void
res Axiom.Core.Resource the resource
Результат void

NotifyResourceUnloaded() публичный метод

Notify this manager that a resource which it manages has been unloaded.
public NotifyResourceUnloaded ( Axiom.Core.Resource res ) : void
res Axiom.Core.Resource the resource
Результат void

ParseScript() публичный метод

Parse a script file.
public ParseScript ( Stream stream, string groupName, string fileName ) : void
stream Stream reference to a data stream which is the source of the script
groupName string /// The name of a resource group which should be used if any resources /// are created during the parse of this script. ///
fileName string
Результат void

ReloadAll() публичный метод

Causes all currently loaded resources to be reloaded.
Unloaded resources are not removed, they simply free up their memory as much as they can and wait to be reloaded. ResourceGroupManager for unloading of resource groups.
public ReloadAll ( ) : void
Результат void

Remove() публичный метод

Remove a single resource.
Removes a single resource, meaning it will be removed from the list of valid resources in this manager, also causing it to be unloaded. The word 'Destroy' is not used here, since if any other pointers are referring to this resource, it will persist until they have finished with it; however to all intents and purposes it no longer exists and will likely get destroyed imminently. If you do have references to resources hanging around after the ResourceManager is destroyed, you may get problems on destruction of these resources if they were relying on the manager (especially if it is a plugin). If you find you get problems on shutdown in the destruction of resources, try making sure you release all your references before you shutdown OGRE.
public Remove ( Axiom.Core.Resource resource ) : void
resource Axiom.Core.Resource The resource to remove
Результат void

Remove() публичный метод

public Remove ( System.UInt64 handle ) : void
handle System.UInt64 The Handle of the resource to remove
Результат void

Remove() публичный метод

public Remove ( string name ) : void
name string The name of the resource to remove
Результат void

RemoveAll() публичный метод

Removes all resources.
Removes all resources, meaning they will be removed from the list of valid resources in this manager, also causing them to be unloaded. The word 'Destroy' is not used here, since if any other pointers are referring to this resource, it will persist until they have finished with it; however to all intents and purposes it no longer exists and will likely get destroyed imminently. If you do have references to resources hanging around after the ResourceManager is destroyed, you may get problems on destruction of these resources if they were relying on the manager (especially if it is a plugin). If you find you get problems on shutdown in the destruction of resources, try making sure you release all your references before you shutdown Axiom.
public RemoveAll ( ) : void
Результат void

ResourceExists() публичный метод

Returns whether a resource with the given handle exists in this manager
public ResourceExists ( System.UInt64 handle ) : bool
handle System.UInt64 handle of the resource
Результат bool

ResourceExists() публичный метод

Returns whether the named resource exists in this manager
public ResourceExists ( string name ) : bool
name string name of the resource
Результат bool

ResourceManager() защищенный метод

Default constructor
protected ResourceManager ( ) : System
Результат System

Unload() публичный метод

Unloads a Resource from the managed resources list, calling it's Unload() method.
This method removes a resource from the list maintained by this manager, and unloads it from memory. It does NOT destroy the resource itself, although the memory used by it will be largely freed up. This would allow you to reload the resource again if you wished.
public Unload ( Resource resource ) : void
resource Resource
Результат void

Unload() публичный метод

public Unload ( System.UInt64 handle ) : void
handle System.UInt64 Handle of the resource
Результат void

Unload() публичный метод

Unloads a single resource by name.
Unloaded resources are not removed, they simply free up their memory as much as they can and wait to be reloaded. ResourceGroupManager for unloading of resource groups.
public Unload ( string name ) : void
name string Name of the resource.
Результат void

UnloadAll() публичный метод

Unloads all resources.
Unloaded resources are not removed, they simply free up their memory as much as they can and wait to be reloaded. ResourceGroupManager for unloading of resource groups.
public UnloadAll ( ) : void
Результат void

_add() защищенный метод

Add a newly created resource to the manager
protected _add ( Resource res ) : void
res Resource
Результат void

_create() защищенный абстрактный метод

Create a new resource instance compatible with this manager (no custom parameters are populated at this point).
protected abstract _create ( string name, System.UInt64 handle, string group, bool isManual, IManualResourceLoader loader, NameValuePairList createParams ) : Resource
name string The unique name of the resource
handle System.UInt64
group string The name of the resource group to attach this new resource to
isManual bool /// Is this resource manually loaded? If so, you should really /// populate the loader parameter in order that the load process /// can call the loader back when loading is required. ///
loader IManualResourceLoader /// A ManualLoader implementation which will be called /// when the Resource wishes to load (should be supplied if you set /// isManual to true). You can in fact leave this parameter null /// if you wish, but the Resource will never be able to reload if /// anything ever causes it to unload. Therefore provision of a proper /// ManualLoader instance is strongly recommended. ///
createParams NameValuePairList /// If any parameters are required to create an instance, /// they should be supplied here as name / value pairs. These do not need /// to be set on the instance (handled elsewhere), just used if required /// to differentiate which concrete class is created. ///
Результат Resource

_remove() защищенный метод

Remove a resource from this manager; remove it from the lists.
protected _remove ( Resource res ) : void
res Resource
Результат void

checkUsage() защищенный метод

Makes sure we are still within budget.
protected checkUsage ( ) : void
Результат void

dispose() защищенный метод

Class level dispose method
When implementing this method in an inherited class the following template should be used; protected override void dispose( bool disposeManagedResources ) { if ( !isDisposed ) { if ( disposeManagedResources ) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose( disposeManagedResources ); }
protected dispose ( bool disposeManagedResources ) : void
disposeManagedResources bool True if Unmanaged resources should be released.
Результат void

this() публичный метод

Gets a resource with the given handle.
public this ( System.UInt64 handle ) : Resource
handle System.UInt64 Handle of the resource to retrieve.
Результат Resource

this() публичный метод

Gets a reference to the specified named resource.
public this ( string name ) : Resource
name string Name of the resource to retrieve.
Результат Resource