asset::AssetManager Class Reference

Facade for the Asset subsystem.

#include <assetmanager.hpp>

Collaboration diagram for asset::AssetManager:

Collaboration graph
[legend]

List of all members.

Public Member Functions

template<class KIND>
P< KIND > getAsset (const ID< KIND > &id) throw (lumiera::error::Invalid)
 find and return corresponging object
bool known (IDA id, const Category &cat)
bool known (IDA id)
list< PcAssetlistContent () const
 extract a sorted list of all registered Assets
void remove (IDA id)
 remove the given asset from the internal DB.

Static Public Member Functions

static ID< AssetgetID (const Asset::Ident &)
 provide the unique ID for given Asset::Ident tuple
template<class KIND>
static P< KIND > wrap (const KIND &asset)
 retrieve the registerd smart-ptr for any asset

Static Public Attributes

static lumiera::Singleton
< AssetManager
instance
 get at the system-wide asset manager instance.

Protected Member Functions

friend Asset::Asset (const Asset::Ident &idi)

Static Protected Member Functions

static void destroy (Asset *aa)
 deleter function used by the Asset smart pointers to delete Asset objects
template<class KIND>
static ID< KIND > reg (KIND *obj, const Asset::Ident &idi) throw (lumiera::error::Invalid)
 registers an asset object in the internal DB, providing its unique key.

Private Attributes

asset::DBregistry

Friends

class lumiera::singleton::StaticCreate< AssetManager >


Detailed Description

Definition at line 65 of file assetmanager.hpp.


Member Function Documentation

template<class KIND>
P< KIND > asset::AssetManager::getAsset ( const ID< KIND > &  id  )  throw (lumiera::error::Invalid) [inline]

find and return the object registered with the given ID.

Exceptions:
Invalid if nothing is found or if the actual KIND of the stored object differs and can't be casted.

Definition at line 134 of file assetmanager.cpp.

References asset::DB::get(), and known().

Referenced by remove().

00136   {
00137     if (P<KIND> obj = registry.get (id))
00138       return obj;
00139     else
00140       if (known (id))    // provide Ident tuple of existing Asset 
00141         throw WrongKind (registry.get(ID<Asset>(id))->ident);
00142       else
00143         throw UnknownID (id);
00144   }

Here is the call graph for this function:

Here is the caller graph for this function:

bool asset::AssetManager::known ( IDA  id,
const Category cat 
)

Returns:
true if the given id is registered with the given Category

true if the given id is registered with the given Category

Definition at line 179 of file assetmanager.cpp.

References asset::DB::get().

00180   {
00181     PAsset pA = registry.get (id);
00182     return ( pA && pA->ident.category.isWithin(cat));
00183   }

Here is the call graph for this function:

bool asset::AssetManager::known ( IDA  id  ) 

Returns:
true if the given id is registered in the internal asset DB

true if the given id is registered in the internal asset DB

Definition at line 168 of file assetmanager.cpp.

References asset::DB::get().

Referenced by getAsset(), and wrap().

00169   {
00170     return ( registry.get (ID<Asset>(id)) );
00171   }       // query most general Asset ID-kind and use implicit 

Here is the call graph for this function:

Here is the caller graph for this function:

template<class KIND>
ID< KIND > asset::AssetManager::reg ( KIND *  obj,
const Asset::Ident idi 
) throw (lumiera::error::Invalid) [inline, static, protected]

For internal use only.

used by the Asset base class ctor to create Asset::id.

This includes creating the smart ptr in charge of the asset's lifecycle

Definition at line 112 of file assetmanager.cpp.

References destroy(), getID(), instance, asset::DB::put(), and registry.

00114   {
00115     AssetManager& _aMang (AssetManager::instance());
00116     TODO ("check validity of Ident Category");
00117     ID<KIND> asset_id (getID (idi));
00118     
00119     Thread::Lock<DB> guard   SIDEEFFECT;
00120     TODO ("handle duplicate Registrations");
00121     P<KIND> smart_ptr (obj, &destroy);
00122 
00123     _aMang.registry.put (asset_id, smart_ptr);
00124     return asset_id;
00125   }

Here is the call graph for this function:

void asset::AssetManager::remove ( IDA  id  ) 

remove the given asset from the internal DB together with all its dependants

together with all its dependants

Definition at line 203 of file assetmanager.cpp.

References asset::DB::del(), and getAsset().

00204   {
00205     PAsset asset = getAsset (id);
00206     for_each (asset->dependants, detach_child_recursively());
00207     asset->unlink();
00208     registry.del(id);
00209   }

Here is the call graph for this function:

template<class KIND>
P< KIND > asset::AssetManager::wrap ( const KIND &  asset  )  [inline, static]

convienience shortcut for fetching the registered smart-ptr which is in charge of the given asset instance.

By querying directly asset.id (of type ID<Asset>), the call to registry.get() can bypass the dynamic cast, because the type of the asset is explicitely given by type KIND.

Definition at line 154 of file assetmanager.cpp.

References instance, and known().

Referenced by asset::Asset::defineDependency(), mobject::session::Clip::findClipAsset(), asset::Clip::getClipAsset(), and mobject::session::Clip::getMedia().

00155   {
00156     ENSURE (instance().known(asset.id), 
00157             "unregistered asset instance encountered.");
00158     return static_pointer_cast<KIND,Asset>
00159             (instance().registry.get (asset.id));
00160   }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation


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

Generated on Sat Aug 16 18:10:40 2008 for Lumiera by  doxygen 1.5.5