The Nebula Device 3: Resources::ResourceDictionary Class Reference

The Nebula Device 3

Resources::ResourceDictionary Class Reference

#include <resourcedictionary.h>

Inheritance diagram for Resources::ResourceDictionary:

Core::RefCounted

Detailed Description

The resource dictionary singleton keeps information about file resources so that the actual resource doesn't have to be loaded first to check its attributes. Resource dictionaries are created by asset tools during asset export.

The resource dictionary file format is as follows:

Header: FourCC 'RDIC' - 4 bytes magic number uint version - 4 byte version uint numEntries - 4 byte number of entries

Version 0001 entry (every entry is 128 bytes): uint dataSize - size of the data block of the resource uchar[124] name - 120 bytes block with the resource id, MUST BE 0-TERMINATED!!

Todo:
: ResourceDictionary should be the base to switch to numerical resource id's later on. During asset export, an offline-dictionary is kept which associated actual filenames with numerical id's, and the asset export tools write those numerical ids in place where a string resource name would be used. For now it's just a lookup-table for the resource size, which is only really useful for console-platforms (since on those platforms the application has more control over the resource loading process as compared to PC-APIs).
(C) 2008 Radon Labs GmbH

Public Member Functions

 ResourceDictionary ()
 constructor
virtual ~ResourceDictionary ()
 destructor
void SetURI (const IO::URI &uri)
 set the dictionary file URI
const IO::URIGetURI () const
 get the dictionary file URI
bool Load ()
 load resource dictionary from URI
void Unload ()
 unload the current resource dictionary
bool IsValid () const
 return true if currently loaded (dictionary contains entries)
bool HasEntry (const ResourceId &resId) const
 test if a resource is in the dictionary
const EntryGetEntry (const ResourceId &resId) const
 get the resource dictionary entry of a 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!)

Data Structures

class  Entry
 a resource dictionary entry More...

Member Function Documentation

bool Resources::ResourceDictionary::Load (  ) 

load resource dictionary from URI

NOTE: we assume that the dictionary file is already in host byte order!

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.