review the asset dependency handling in AssetManager
This commit is contained in:
parent
3e9c337ac0
commit
fc0cefcadc
9 changed files with 35 additions and 28 deletions
|
|
@ -48,24 +48,28 @@ namespace asset {
|
|||
|
||||
|
||||
Asset::Ident::Ident(const string& n, const Category& cat, const string& o, const uint ver)
|
||||
: name(util::sanitise (n)),
|
||||
category(cat), org(o), version(ver)
|
||||
{ }
|
||||
: name(util::sanitise (n))
|
||||
, category(cat)
|
||||
, org(o)
|
||||
, version(ver)
|
||||
{ }
|
||||
|
||||
|
||||
/** Asset is a Interface class; usually, objects of
|
||||
* concrete subclasses are created via specialized Factories
|
||||
* concrete subclasses are created via specialised Factories
|
||||
*/
|
||||
Asset::Asset (const Ident& idi)
|
||||
: ident(idi), id(AssetManager::reg (this, idi)), enabled(true)
|
||||
{
|
||||
TRACE (assetmem, "ctor Asset(id=%lu) : adr=%p %s", size_t(id), this, cStr(this->ident) );
|
||||
}
|
||||
: ident(idi)
|
||||
, id(AssetManager::reg (this, idi))
|
||||
, enabled(true)
|
||||
{
|
||||
TRACE (assetmem, "ctor Asset(id=%lu) : adr=%p %s", size_t(id), this, cStr(this->ident) );
|
||||
}
|
||||
|
||||
Asset::~Asset ()
|
||||
{
|
||||
TRACE (assetmem, "dtor Asset(id=%lu) : adr=%p", size_t(id), this );
|
||||
}
|
||||
{
|
||||
TRACE (assetmem, "dtor Asset(id=%lu) : adr=%p", size_t(id), this );
|
||||
}
|
||||
|
||||
|
||||
Asset::Ident::operator string () const
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@ namespace mobject {
|
|||
namespace session {
|
||||
|
||||
class Track;
|
||||
typedef MORef<Track> RTrack;
|
||||
}}
|
||||
|
||||
|
||||
namespace asset {
|
||||
|
||||
|
||||
typedef mobject::MORef<mobject::session::Track> RTrack;
|
||||
|
||||
/**
|
||||
* TODO type comment
|
||||
|
|
@ -78,6 +78,7 @@ namespace asset {
|
|||
class Sequence
|
||||
: public Struct
|
||||
{
|
||||
typedef mobject::session::RTrack RTrack;
|
||||
|
||||
public:
|
||||
void detach() { TODO("Session-Sequence registration"); }
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ using mobject::Session;
|
|||
using mobject::MObject;
|
||||
using mobject::session::Scope;
|
||||
using mobject::session::match_specificTrack;
|
||||
using mobject::session::RBinding;
|
||||
using mobject::session::RTrack;
|
||||
|
||||
using lib::Symbol;
|
||||
using util::isnil;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
#include "proc/mobject/mobject-ref.hpp"
|
||||
//#include "proc/mobject/session/binding.hpp" ////TODO avoidable??
|
||||
//#include "lib/p.hpp"
|
||||
#include "lib/element-tracker.hpp"
|
||||
|
||||
|
||||
//#include <vector>
|
||||
|
|
@ -70,12 +71,12 @@ namespace mobject {
|
|||
namespace session {
|
||||
|
||||
class Binding;
|
||||
typedef MORef<Binding> RBinding;
|
||||
}}
|
||||
|
||||
|
||||
namespace asset {
|
||||
|
||||
typedef mobject::MORef<mobject::session::Binding> RBinding; ////TODO why defining this into namespace asset? shouldn't it go into mobject::session ??
|
||||
|
||||
// using lumiera::P;
|
||||
|
||||
|
|
@ -85,6 +86,8 @@ namespace asset {
|
|||
class Timeline
|
||||
: public Struct
|
||||
{
|
||||
typedef mobject::session::RBinding RBinding;
|
||||
|
||||
RBinding boundSeqence_;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -103,11 +103,11 @@ namespace asset {
|
|||
/**
|
||||
* registers an asset object in the internal DB, providing its unique key.
|
||||
* This includes creating the smart ptr in charge of the asset's lifecycle
|
||||
* @throw error::Invalid in case of invalid identity spec
|
||||
*/
|
||||
template<class KIND>
|
||||
ID<KIND>
|
||||
AssetManager::reg (KIND* obj, const Asset::Ident& idi)
|
||||
throw(lumiera::error::Invalid)
|
||||
{
|
||||
AssetManager& _aMang (AssetManager::instance());
|
||||
DB& registry (_aMang.registry);
|
||||
|
|
@ -123,14 +123,13 @@ namespace asset {
|
|||
}
|
||||
|
||||
|
||||
/** find and return the object registered with the given ID.
|
||||
* @throws Invalid if nothing is found or if the actual KIND
|
||||
* of the stored object differs and can't be casted.
|
||||
/** @note the KIND of asset needs to be assignable by the actual stored asset
|
||||
* @throw error::Invalid if nothing is found or if the actual KIND
|
||||
* of the stored object differs and can't be casted.
|
||||
*/
|
||||
template<class KIND>
|
||||
P<KIND>
|
||||
AssetManager::getAsset (const ID<KIND>& id)
|
||||
throw(lumiera::error::Invalid)
|
||||
{
|
||||
if (P<KIND> obj = registry.get (id))
|
||||
return obj;
|
||||
|
|
@ -204,7 +203,7 @@ namespace asset {
|
|||
AssetManager::remove (IDA id)
|
||||
{
|
||||
PAsset asset = getAsset (id);
|
||||
for_each (asset->dependants, detach_child_recursively());
|
||||
for_each (asset->dependants, detach_child_recursively()); /////
|
||||
asset->unlink();
|
||||
registry.del(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,13 @@
|
|||
*/
|
||||
|
||||
/** @file assetmanager.hpp
|
||||
** Proc-Layer Interface: Asset Lookup and Organization.
|
||||
** Proc-Layer Interface: Asset Lookup and Organisation.
|
||||
** Declares the AssetManager interface used to access individual
|
||||
** Asset instances.
|
||||
**
|
||||
** These classes are placed into namespace asset and proc_interface.
|
||||
** These classes are placed into namespace asset and proc_interface.
|
||||
**
|
||||
** @todo 10/10 meanwhile I'm unhappy with some aspects of this implementation //////////////TICKET #691
|
||||
**
|
||||
** @see asset.hpp
|
||||
** @see mobject.hpp
|
||||
|
|
@ -79,7 +81,7 @@ namespace asset {
|
|||
|
||||
/** find and return corresponding object */
|
||||
template<class KIND>
|
||||
P<KIND> getAsset (const ID<KIND>& id) throw(lumiera::error::Invalid);
|
||||
P<KIND> getAsset (const ID<KIND>& id);
|
||||
|
||||
|
||||
/** @return true if the given id is registered in the internal asset DB */
|
||||
|
|
@ -102,8 +104,8 @@ namespace asset {
|
|||
* @internal used by the Asset base class ctor to create Asset::id.
|
||||
*/
|
||||
template<class KIND>
|
||||
static ID<KIND> reg (KIND* obj, const Asset::Ident& idi)
|
||||
throw(lumiera::error::Invalid);
|
||||
static ID<KIND>
|
||||
reg (KIND* obj, const Asset::Ident& idi);
|
||||
|
||||
/** deleter function used by the Asset smart pointers to delete Asset objects */
|
||||
static void destroy (Asset* aa) { delete aa; }
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ namespace test {
|
|||
// using asset::PTimeline;
|
||||
using asset::PSequence;
|
||||
using asset::Sequence;
|
||||
using asset::RTrack;
|
||||
|
||||
// using lumiera::Time;
|
||||
using lumiera::Query;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ namespace test {
|
|||
|
||||
using asset::PTimeline;
|
||||
using asset::PSequence;
|
||||
using asset::RTrack;
|
||||
|
||||
using lumiera::Time;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,6 @@ namespace test {
|
|||
using asset::PTimeline;
|
||||
using asset::Sequence;
|
||||
using asset::PSequence;
|
||||
using asset::RBinding;
|
||||
using asset::RTrack;
|
||||
using asset::Pipe;
|
||||
|
||||
using lumiera::Query;
|
||||
|
|
|
|||
Loading…
Reference in a new issue