The Nebula Device 3: Resources::ManagedResource Class Reference

The Nebula Device 3

Resources::ManagedResource Class Reference

#include <managedresource.h>

Inheritance diagram for Resources::ManagedResource:

Core::RefCounted Models::ManagedModel Resources::ManagedMesh Resources::ManagedTexture

Detailed Description

ManagedResources are wrappers around actual resource objects and are created and managed by the ResourceManager singleton. The actual resource object contained in a ManagedResource may change any time because of the resource management performed by the ResourceManager. During rendering, the resource client writes render-statistics back into the ManagedResource which the resource manager uses as hints for resource management (for instance, if an object is appears very small on screen, the ResourceManager can use this information to drop higher resolution mip levels freeing up valuable memory for other textures).

(C) 2007 Radon Labs GmbH

Public Types

enum  Priority
 priority levels

Public Member Functions

 ManagedResource ()
 constructor
virtual ~ManagedResource ()
 destructor
void ClearRenderStats ()
 clear render statistics
void UpdateRenderStats (float lod)
 update render statistics (called by client)
void UpdateRenderStats (const Math::float2 &screenSpaceSize)
 update render statistics (called by client)
void SetResourceId (const ResourceId &id)
 set resource id
const ResourceIdGetResourceId () const
 get resource id
void SetResourceType (const Core::Rtti *rtti)
 set contained resource type
const Core::RttiGetResourceType () const
 get contained resource type
void IncrClientCount ()
 increment client count
void DecrClientCount ()
 decrement client count
SizeT GetClientCount () const
 get current client count
SizeT GetRenderCount () const
 get render count for this frame (number of calls to UpdateRenderStats()
float GetResourceStreamingLevelOfDetail () const
 get resourceStreamingLevelOfDetail for this frame
const Math::float2GetMaxScreenSpaceSize () const
 get maximum screen space size this frame
void SetPriority (Priority p)
 set current priority
Priority GetPriority () const
 get the current priority
Resource::State GetState () const
 get current resource loading state (Initial, Pending, Loaded, Failed, Cancelled)
const Ptr< Resource > & GetLoadedResource () const
 get contained resource or placeholder if resource is invalid or not loaded
const Ptr< Resource > & GetResource () const
 get contained resource (may return 0)
bool IsPlaceholder () const
 return true if the placeholder resource would be returned
void Clear ()
 clear the contained resource
bool IsAutoManaged () const
 returns true if autoManaged
void SetAutoManaged (const bool autoManaged)
 sets autoManaged-flag
IndexT GetLastFrameId () const
 returns frameId this resource was latest referenced to
void SetFrameId (const SizeT frameId)
 sets the frameId the resource was latest used at
void SetResource (const Ptr< Resource > &resource)
 set actual resource
void SetPlaceholder (const Ptr< Resource > &placeholder)
 set place holder resource
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Member Function Documentation

void Resources::ManagedResource::ClearRenderStats (  ) 

clear render statistics

This method resets the current render stats and is usually called during the Prepare() method of the ResourceManager (before rendering is started for the current frame).

void Resources::ManagedResource::UpdateRenderStats ( float  lod  ) 

update render statistics (called by client)

This method is called by the resource client during rendering to write back render statistics. If the resource isn't rendered, the method MUST NOT be called. If the resource is rendered, the client must provide a screen space size guesstimate which will be used by the ResourceMapper to bump or drop the lod of the resource.

void Resources::ManagedResource::UpdateRenderStats ( const Math::float2 screenSpaceSize  ) 

update render statistics (called by client)

This method is called by the resource client during rendering to write back render statistics. If the resource isn't rendered, the method MUST NOT be called. If the resource is rendered, the client must provide a screen space size guesstimate which will be used by the ResourceMapper to bump or drop the lod of the resource.

int Core::RefCounted::GetRefCount (  )  const [inline, inherited]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline, inherited]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline, inherited]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline, inherited]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline, inherited]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static, inherited]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.