173 : mCreator(0), mHandle(0), mLoadingState(LOADSTATE_UNLOADED),
174 mIsBackgroundLoaded(false), mSize(0), mIsManual(0), mLoader(0)
259 virtual void prepare(
bool backgroundThread =
false);
271 virtual void load(
bool backgroundThread =
false);
284 return !mIsManual || mLoader;
327 return (mLoadingState.
get() == LOADSTATE_PREPARED);
335 return (mLoadingState.
get() == LOADSTATE_LOADED);
343 return (mLoadingState.
get() == LOADSTATE_LOADING);
350 return mLoadingState.
get();
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Interface describing a manual resource loader.
virtual ~ManualResourceLoader()
virtual void prepareResource(Resource *resource)
Called when a resource wishes to load.
virtual void loadResource(Resource *resource)=0
Called when a resource wishes to prepare.
Defines a generic resource handler.
virtual OGRE_DEPRECATED void backgroundPreparingComplete(Resource *)
Callback to indicate that background preparing has completed.
virtual void preparingComplete(Resource *)
Called whenever the resource finishes preparing (paging into memory).
virtual void unloadingComplete(Resource *)
Called whenever the resource has been unloaded.
virtual void loadingComplete(Resource *)
Called whenever the resource finishes loading.
virtual OGRE_DEPRECATED void backgroundLoadingComplete(Resource *)
Callback to indicate that background loading has completed.
Abstract class representing a loadable resource (e.g.
Resource(ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual=false, ManualResourceLoader *loader=0)
Standard constructor.
virtual size_t getSize(void) const
Retrieves info about the size of the resource.
virtual const String & getName(void) const
Gets resource name.
virtual bool isPrepared(void) const
Returns true if the Resource has been prepared, false otherwise.
LoadingState
Enum identifying the loading state of the resource.
@ LOADSTATE_PREPARED
Fully prepared.
@ LOADSTATE_UNLOADED
Not loaded.
@ LOADSTATE_UNLOADING
Currently unloading.
@ LOADSTATE_LOADED
Fully loaded.
@ LOADSTATE_LOADING
Loading is in progress.
virtual ~Resource()
Virtual destructor.
virtual void postLoadImpl(void)
Internal hook to perform actions after the load process, but before the resource has been marked as f...
ManualResourceLoader * mLoader
Optional manual loader; if provided, data is loaded from here instead of a file.
bool mIsManual
Is this file manually loaded?
String mName
Unique name of the resource.
virtual LoadingState getLoadingState() const
Returns the current loading state.
virtual ResourceHandle getHandle(void) const
OGRE_MUTEX(mListenerListMutex)
ResourceHandle mHandle
Numeric handle for more efficient look up than name.
virtual void preUnloadImpl(void)
Internal hook to perform actions before the unload process.
String mOrigin
Origin of this resource (e.g. script name) - optional.
virtual void prepare(bool backgroundThread=false)
Prepares the resource for load, if it is not already.
virtual void escalateLoading()
Escalates the loading of a background loaded resource.
virtual const String & getGroup(void) const
Gets the group which this resource is a member of.
size_t mStateCount
State count, the number of times this resource has changed state.
virtual bool isLoading() const
Returns whether the resource is currently in the process of background loading.
virtual void removeListener(Listener *lis)
Remove a listener on this resource.
virtual void _notifyOrigin(const String &origin)
Notify this resource of it's origin.
String mGroup
The name of the resource group.
virtual void _fireUnloadingComplete(void)
Firing of unloading complete event.
virtual size_t calculateSize(void) const
Calculate the size of a resource; this will only be called after 'load'.
virtual void addListener(Listener *lis)
Register a listener on this resource.
virtual void prepareImpl(void)
Internal implementation of the meat of the 'prepare' action.
virtual bool isBackgroundLoaded(void) const
Returns whether this Resource has been earmarked for background loading.
virtual void load(bool backgroundThread=false)
Loads the resource, if it is not already.
volatile bool mIsBackgroundLoaded
Is this resource going to be background loaded? Only applicable for multithreaded.
set< Listener * >::type ListenerList
virtual ResourceManager * getCreator(void)
Gets the manager which created this resource.
virtual bool isLoaded(void) const
Returns true if the Resource has been loaded, false otherwise.
virtual void _firePreparingComplete(bool wasBackgroundLoaded)
Firing of preparing complete event.
ResourceManager * mCreator
Creator.
virtual void _fireLoadingComplete(bool wasBackgroundLoaded)
Firing of loading complete event.
virtual bool isReloadable(void) const
Returns true if the Resource is reloadable, false otherwise.
virtual bool isManuallyLoaded(void) const
Is this resource manually loaded?
virtual void unloadImpl(void)=0
Internal implementation of the 'unload' action; called regardless of whether this resource is being l...
ListenerList mListenerList
AtomicScalar< LoadingState > mLoadingState
Is the resource currently loaded?
virtual void unload(void)
Unloads the resource; this is not permanent, the resource can be reloaded later if required.
virtual void unprepareImpl(void)
Internal function for undoing the 'prepare' action.
virtual void changeGroupOwnership(const String &newGroup)
Change the resource group ownership of a Resource.
virtual void postUnloadImpl(void)
Internal hook to perform actions after the unload process, but before the resource has been marked as...
virtual const String & getOrigin(void) const
Get the origin of this resource, e.g.
virtual void reload(void)
Reloads the resource, if it is already loaded.
virtual void preLoadImpl(void)
Internal hook to perform actions before the load process, but after the resource has been marked as '...
virtual size_t getStateCount() const
Returns the number of times this resource has changed state, which generally means the number of time...
virtual void setBackgroundLoaded(bool bl)
Tells the resource whether it is background loaded or not.
virtual void touch(void)
'Touches' the resource to indicate it has been used.
virtual void loadImpl(void)=0
Internal implementation of the meat of the 'load' action, only called if this resource is not being l...
Resource()
Protected unnamed constructor to prevent default construction.
virtual void _dirtyState()
Manually mark the state of this resource as having been changed.
size_t mSize
The size of the resource in bytes.
Class defining the common interface which classes can use to present a reflection-style,...
SharedPtr< Resource > ResourcePtr
Shared pointer to a Resource.
unsigned long long int ResourceHandle