28#ifndef _ResourceManager_H__
29#define _ResourceManager_H__
63 std::pair<bool, T> ret;
71 ret.second =
mItems.front();
167 const String& group,
bool isManual =
false,
359 return !getResourceByName(name).isNull();
364 return !getByHandle(handle).isNull();
398 const String& group,
bool isManual =
false,
400 bool backgroundThread =
false);
418 const String& group,
bool isManual =
false,
420 bool backgroundThread =
false);
453 { (void)stream; (void)groupName; }
#define OGRE_LOCK_AUTO_MUTEX
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Interface describing a manual resource loader.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Template class describing a simple pool of items.
virtual std::pair< bool, T > removeItem()
Get the next item from the pool.
virtual void addItem(const T &i)
Add a new item to the pool.
virtual void clear()
Clear the pool.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Definition of a pool of resources, which users can use to reuse similar resources many times without ...
const String & getName() const
Get the name of the pool.
void clear()
Clear the pool.
ResourcePool(const String &name)
Defines a generic resource handler.
void destroyResourcePool(const String &name)
Destroy a resource pool.
virtual void addImpl(ResourcePtr &res)
Add a newly created resource to the manager (note weak reference)
virtual const StringVector & getScriptPatterns(void) const
Gets the file patterns which should be used to find scripts for this ResourceManager.
ResourcePoolMap mResourcePoolMap
ResourcePool * getResourcePool(const String &name)
Create a resource pool, or reuse one that already exists.
virtual void reloadUnreferencedResources(bool reloadableOnly=true)
Caused all currently loaded but not referenced by any other object resources to be reloaded.
map< ResourceHandle, ResourcePtr >::type ResourceHandleMap
virtual ~ResourceManager()
virtual void unload(const String &name)
Unloads a single resource by name.
AtomicScalar< ResourceHandle > mNextHandle
In bytes.
ResourceWithGroupMap mResourcesWithGroup
virtual void _notifyResourceTouched(Resource *res)
Notify this manager that a resource which it manages has been 'touched', i.e.
virtual Real getLoadingOrder(void) const
Gets the relative loading order of resources of this type.
StringVector mScriptPatterns
Patterns to use to look for scripts if supported (e.g. *.overlay)
virtual ResourceCreateOrRetrieveResult createOrRetrieve(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0)
Create a new resource, or retrieve an existing one with the same name if it already exists.
ResourceMapIterator getResourceIterator(void)
Returns an iterator over all resources in this manager.
MapIterator< ResourceHandleMap > ResourceMapIterator
virtual void _notifyResourceUnloaded(Resource *res)
Notify this manager that a resource which it manages has been unloaded.
const String & getResourceType(void) const
Gets a string identifying the type of resource this manager handles.
HashMap< String, ResourcePtr > ResourceMap
virtual ResourcePtr getResourceByName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Retrieves a pointer to a resource by name, or null if the resource does not exist.
virtual void removeUnreferencedResources(bool reloadableOnly=true)
Remove all resources which are not referenced by any other object.
virtual void removeAll(void)
Removes all resources.
void destroyAllResourcePools()
destroy all pools
virtual void unloadUnreferencedResources(bool reloadableOnly=true)
Unload all resources which are not referenced by any other object.
virtual Resource * createImpl(const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, const NameValuePairList *createParams)=0
Create a new resource instance compatible with this manager (no custom parameters are populated at th...
virtual void removeImpl(ResourcePtr &res)
Remove a resource from this manager; remove it from the lists.
virtual void parseScript(DataStreamPtr &stream, const String &groupName)
Parse the definition of a set of resources from a script file.
virtual void checkUsage(void)
Checks memory usage and pages out if required.
virtual void reloadAll(bool reloadableOnly=true)
Caused all currently loaded resources to be reloaded.
virtual void remove(ResourcePtr &r)
Remove a single resource.
String mResourceType
String identifying the resource type this manager handles.
virtual void unload(ResourceHandle handle)
Unloads a single resource by handle.
virtual bool resourceExists(const String &name)
Returns whether the named resource exists in this manager.
virtual size_t getMemoryUsage(void) const
Gets the current memory usage, in bytes.
virtual void setVerbose(bool v)
Sets whether this manager and its resources habitually produce log output.
virtual void setMemoryBudget(size_t bytes)
Set a limit on the amount of memory this resource handler may use.
void destroyResourcePool(ResourcePool *pool)
Destroy a resource pool.
AtomicScalar< size_t > mMemoryUsage
virtual ResourcePtr getByHandle(ResourceHandle handle)
Retrieves a pointer to a resource by handle, or null if the resource does not exist.
virtual void remove(const String &name)
Remove a single resource by name.
virtual void remove(ResourceHandle handle)
Remove a single resource by handle.
virtual size_t getMemoryBudget(void) const
Get the limit on the amount of memory this resource handler may use.
virtual void unloadAll(bool reloadableOnly=true)
Unloads all resources.
virtual ResourcePtr createResource(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0)
Creates a new blank resource, but does not immediately load it.
Real mLoadOrder
Loading order relative to other managers, higher is later.
virtual ResourcePtr load(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *loadParams=0, bool backgroundThread=false)
Generic load method, used to create a Resource specific to this ResourceManager without using one of ...
virtual bool resourceExists(ResourceHandle handle)
Returns whether a resource with the given handle exists in this manager.
ResourceHandle getNextHandle(void)
Allocates the next handle.
virtual ResourcePtr prepare(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *loadParams=0, bool backgroundThread=false)
Generic prepare method, used to create a Resource specific to this ResourceManager without using one ...
HashMap< String, ResourceMap > ResourceWithGroupMap
virtual void _notifyResourceLoaded(Resource *res)
Notify this manager that a resource which it manages has been loaded.
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
ResourceHandleMap mResourcesByHandle
virtual bool getVerbose(void)
Gets whether this manager and its resources habitually produce log output.
map< String, ResourcePool * >::type ResourcePoolMap
Abstract class representing a loadable resource (e.g.
Abstract class defining the interface used by classes which wish to perform script loading to define ...
vector< String >::type StringVector
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
float Real
Software floating point type.
unsigned long long int ResourceHandle