Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfx::ResourceBase Class Referenceabstract

ResourceBase is an internal abstract base class for managed resources. More...

#include "resourcebase.h"

Inheritance diagram for ion::gfx::ResourceBase:

Public Member Functions

 ResourceBase (const ResourceHolder *holder, ResourceKey key)
 The constructor accepts a holder parameter to simplify control flow during construction. More...
 
virtual ~ResourceBase ()
 
const ResourceHolderGetHolder () const
 Retrieve the holder for which this resource was created. More...
 
ResourceKey GetKey () const
 Retrieve a key that disambiguates between multiple resources created for the same holder by the same resource manager. More...
 
virtual void OnDestroyed ()=0
 Each derived class must define these to acquire and release its resource. More...
 
virtual void OnChanged (const int bit)=0
 Informs the resource that something has changed and that it needs to update itself. More...
 
virtual size_t GetGpuMemoryUsed () const =0
 Returns the amount of GPU memory in bytes that this resource uses. More...
 

Friends

class ResourceHolder
 

Detailed Description

ResourceBase is an internal abstract base class for managed resources.

For example, it allows scene graph objects to contain managed OpenGL resources without having to know anything about them.

Definition at line 36 of file resourcebase.h.

Constructor & Destructor Documentation

ion::gfx::ResourceBase::ResourceBase ( const ResourceHolder holder,
ResourceKey  key 
)
inlineexplicit

The constructor accepts a holder parameter to simplify control flow during construction.

However, the value returned by GetHolder() is managed by the ResourceHolder, not by the ResourceManager.

Definition at line 41 of file resourcebase.h.

virtual ion::gfx::ResourceBase::~ResourceBase ( )
inlinevirtual

Definition at line 44 of file resourcebase.h.

Member Function Documentation

virtual size_t ion::gfx::ResourceBase::GetGpuMemoryUsed ( ) const
pure virtual

Returns the amount of GPU memory in bytes that this resource uses.

Note that this may be zero, in particular if the Resource has never been drawn. The count does not include the memory used to hold simple state (e.g., the OpenGL id) only memory used by objects such as textures, framebuffers, and buffer objects.

const ResourceHolder* ion::gfx::ResourceBase::GetHolder ( ) const
inline

Retrieve the holder for which this resource was created.

Definition at line 47 of file resourcebase.h.

ResourceKey ion::gfx::ResourceBase::GetKey ( ) const
inline

Retrieve a key that disambiguates between multiple resources created for the same holder by the same resource manager.

Definition at line 51 of file resourcebase.h.

Referenced by ion::gfx::ResourceHolder::SetResource().

virtual void ion::gfx::ResourceBase::OnChanged ( const int  bit)
pure virtual

Informs the resource that something has changed and that it needs to update itself.

Referenced by ion::gfx::ResourceHolder::SetResource().

virtual void ion::gfx::ResourceBase::OnDestroyed ( )
pure virtual

Each derived class must define these to acquire and release its resource.

It must be safe to call these multiple times. Invoked before a resource is released. If this is called when holder_ is null, it means this resource's holder is being destroyed. If holder_ is non-null, it means the resource is destroyed for another reason and should remove itself from the holder.

Friends And Related Function Documentation

friend class ResourceHolder
friend

Definition at line 77 of file resourcebase.h.


The documentation for this class was generated from the following file: