#include <assetmanager.hpp>

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< PcAsset > | listContent () 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< Asset > | getID (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::DB & | registry |
Friends | |
| class | lumiera::singleton::StaticCreate< AssetManager > |
Definition at line 65 of file assetmanager.hpp.
| P< KIND > asset::AssetManager::getAsset | ( | const ID< KIND > & | id | ) | throw (lumiera::error::Invalid) [inline] |
find and return the object registered with the given ID.
| 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 }


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 }

| bool asset::AssetManager::known | ( | IDA | id | ) |
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


| 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 }

| 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 }

| 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 }


Singleton< AssetManager > asset::AssetManager::instance [static] |
Implemented as singleton.
Definition at line 71 of file assetmanager.hpp.
Referenced by asset::ProcPatt::newCopy(), asset::StructFactory::operator()(), asset::test::TestAsset< A >::ptrFromThis(), reg(), asset::Asset::unlink(), and wrap().
1.5.5