X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcollection.cpp;fp=source%2Fcollection.cpp;h=070991948d33d7315074ec6bb480cc06344d45cc;hb=a5d5fa04bcbe360fc55fdb25b45937b29fb5c9cd;hp=fbe894a8bb4b073c0baa227655bd2d3ecf3781e3;hpb=af043eaec121bbd6f5e3ad36059c281f1b20bf8f;p=libs%2Fdatafile.git diff --git a/source/collection.cpp b/source/collection.cpp index fbe894a..0709919 100644 --- a/source/collection.cpp +++ b/source/collection.cpp @@ -5,6 +5,10 @@ using namespace std; namespace Msp { namespace DataFile { +Collection::Collection(): + fallback(0) +{ } + Collection::~Collection() { for(TypeList::iterator i = types.begin(); i!=types.end(); ++i) @@ -30,6 +34,16 @@ const Variant &Collection::get_var(const string &name, const CollectionItemTypeB (*j)->load(*this, *type, name); loaded = items.count(name); } + if(!loaded && fallback) + { + for(TypeList::const_iterator j=fallback->types.begin(); j!=fallback->types.end(); ++j) + if((*j)->is_same_type(*type)) + { + if(fallback->get_status(name, **j)) + return fallback->get_var(name, *j); + break; + } + } } return get_item(items, name); @@ -99,6 +113,11 @@ void Collection::load_items_from_sources(const CollectionItemTypeBase &type) } } +void Collection::set_fallback(Collection *f) +{ + fallback = f; +} + Collection::Loader::Loader(Collection &c): coll(c)