The Nebula Device 3: Resources::SharedResourceServer Class Reference

The Nebula Device 3

Resources::SharedResourceServer Class Reference

#include <sharedresourceserver.h>

Inheritance diagram for Resources::SharedResourceServer:

Core::RefCounted


Detailed Description

The SharedResourceServer manages the pool of shared resources.

(C) 2007 Radon Labs GmbH

Public Member Functions

 SharedResourceServer ()
 constructor
virtual ~SharedResourceServer ()
 destructor
bool Open ()
 open the resource server
void Close ()
 close the resource server, discards resources
bool IsOpen () const
 return true if resource server is open
bool HasSharedResource (const ResourceId &id) const
 return true if a shared resource exists
const Ptr< Resource > & LookupSharedResource (const ResourceId &id) const
 lookup a shared resource
Ptr< ResourceCreateSharedResource (const ResourceId &id, const Core::Rtti &resClass)
 create and register a shared resource
Ptr< ResourceCreateSharedResource (const ResourceId &id, const Core::Rtti &resClass, const Core::Rtti &loaderClass)
 create and register shared resource with associated loader
Ptr< ResourceCreateSharedResource (const ResourceId &id, const Core::Rtti &resClass, const Core::Rtti &loaderClass, const Core::Rtti &saverClass)
 create and register shared resource with associated loader and saver
void RegisterSharedResource (const Ptr< Resource > &res)
 register an existing resource object as shared resource
void UnregisterSharedResource (const Ptr< Resource > &res)
 unregister a shared resource (necessary for managing the use count)
void UnregisterSharedResource (const ResourceId &id)
 unregister a shared resource by resource name
const
Util::Dictionary
< ResourceId, Ptr
< Resource > > & 
GetSharedResources () const
 read-only access to shared resources
Util::Array< Ptr
< Resource > > 
GetSharedResourcesByType (const Core::Rtti &type) const
 get shared resources by type (slow)
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

Ptr< Resource > Resources::SharedResourceServer::CreateSharedResource ( const ResourceId resId,
const Core::Rtti resClass 
)

create and register a shared resource

Create a shared resource object. If the resource already exists, its use count will be increased and the resource will be returned. If the resource doesn't exist yet, a new resource object will be created and registered as shared resource. Please note that you must call UnregisterSharedResource() when the resource is no longer needed in order to manage the use count properly.

Ptr< Resource > Resources::SharedResourceServer::CreateSharedResource ( const ResourceId resId,
const Core::Rtti resClass,
const Core::Rtti loaderClass 
)

create and register shared resource with associated loader

Create and register a shared resource object with attached resource loader.

Ptr< Resource > Resources::SharedResourceServer::CreateSharedResource ( const ResourceId resId,
const Core::Rtti resClass,
const Core::Rtti loaderClass,
const Core::Rtti saverClass 
)

create and register shared resource with associated loader and saver

Create a shared resource object with attached resource loader and saver.

void Resources::SharedResourceServer::RegisterSharedResource ( const Ptr< Resource > &  res  ) 

register an existing resource object as shared resource

Register an existing resource object as shared resource. If the resource already has been registered, an assertion will be thrown. This will increment the use count of the resource by one.

void Resources::SharedResourceServer::UnregisterSharedResource ( const Ptr< Resource > &  res  ) 

unregister a shared resource (necessary for managing the use count)

Unregister a shared resource. This will decrement the use count of the resource. If the use count has reached zero, the resource will be discarded (unloaded and removed from the shared resource pool).

void Resources::SharedResourceServer::UnregisterSharedResource ( const ResourceId id  ) 

unregister a shared resource by resource name

Unregister a shared resource by resource id.

Array< Ptr< Resource > > Resources::SharedResourceServer::GetSharedResourcesByType ( const Core::Rtti type  )  const

get shared resources by type (slow)

Returns an array of shared resources by type. This is a slow method.

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.