util.resourcemanager - ICE 0.1 API documentation

ICE 0.1 API documentation

# util.resourcemanager

Loads and provides access to resources of various types.

abstract interface GenericResourceManager;

  Common interface for resource managers.

  Must be downcasted to get the resource manager itself (due to the template/virtual incompatibility).

  const pure nothrow @safe bool managesType(T)();

    Does this resource manager manage specified type?

    If true, the manager can be downcasted to ResourceManager!T.

  protected abstract const pure nothrow @safe bool managesType_(TypeInfo typeInfo);

    Implementation of managesType().

enum LoadStrategy;

  Governs how the manager loads its resources.

  AggressivePreload

    Preload any found resources as early as possible.

  OnDemand

    Load a resource only when it's about to be used.

struct ResourceID(T);

  ID for fast repeated access to a resource.

  this(string path);

    Construct a ResourceIndex for a resource with specified virtual filesystem path.

class ResourceManager(T): GenericResourceManager;

  Concrete resource manager managing resources of type T.

  alias ResourceFilter;

    Accepts a files range and returns files of this resource type.

  alias ResourceLoader;

    Loads a resource from file. Returns true on successm false on failure.

  ResourceLoader resourceLoader_;

    Resource loader used.

  this(VFSDir gameDir, ResourceLoader resourceLoader, string fileGlob);

    Construct a ResourceLoader using a glob pattern to filter resources.

    Parameters:

    VFSDir gameDir | Game data directory to load resources from.
    ResourceLoader resourceLoader | Delegate that loads a resource from file, and returns true on success, false on failure. The passed file might be NULL if the file was not found. This allows the delegate to load the backup resource (or just fail by returning false).
    string fileGlob | Glob pattern determining which files to load.

  this(VFSDir gameDir, ResourceLoader resourceLoader, ResourceFilter resourceFilter);

    Construct a ResourceLoader using a delegate to filter resources.

    Parameters:

    VFSDir gameDir | Game data directory to load resources from.
    ResourceLoader resourceLoader | Delegate that loads a resource from file, and returns true on success, false on failure. The passed file might be NULL if the file was not found. This allows the delegate to load the backup resource (or just fail by returning false).
    fileGlob | Delegate taking a VFSFiles range and returning an array of files to load.

  void loadStrategy(const LoadStrategy rhs);

    Set the loading strategy to control resource loading.

  T* getResource(string path);

    Get a resource which is in file with specified path.

    Parameters:

    string path | Path of the resource file.

    Returns:
    Pointer to the resource if found, null otherwise.
  T* getResource(ref ResourceID!(T) id);

    Get a resource with specified resource ID. This is faster when accessing a resource more than once.

    Parameters:

    ResourceID!(T) id | ID to use.

    Returns:
    Pointer to the resource if found, null otherwise.
  void clear();

    Delete all loaded resources.

  void preloadAll();

    Preload all resources of this type found in the gameDir_.

  bool loaderWrapper(string name, out T result);

    Wraps the loader delegate in a function usable by LazyArray.

Copyright © Ferdinand Majerech 2011. | Page generated by AutoDDoc and Ddoc.