1 #include "collection.h"
8 Collection::~Collection()
10 for(TypeList::iterator i = types.begin(); i!=types.end(); ++i)
14 const Variant &Collection::get_var(const string &name, const CollectionItemTypeBase *type)
16 ItemMap::iterator i = items.find(name);
23 if(type->can_create())
25 type->create_item(*this, name);
26 loaded = items.count(name);
28 for(SourceList::iterator j=sources.begin(); (!loaded && j!=sources.end()); ++j)
30 (*j)->load(*this, *type, name);
31 loaded = items.count(name);
35 return get_item(items, name);
38 void Collection::add_source(CollectionSource &s)
40 sources.push_back(&s);
44 Collection::Loader::Loader(Collection &c):
47 for(TypeList::const_iterator i = coll.types.begin(); i!=coll.types.end(); ++i)
48 (*i)->add_to_loader(*this);
52 CollectionItemTypeBase::CollectionItemTypeBase():
56 CollectionItemTypeBase::~CollectionItemTypeBase()
61 void CollectionItemTypeBase::set_keyword(const string &k)
68 void CollectionItemTypeBase::add_suffix(const string &s)
70 suffixes.push_back(s);
73 bool CollectionItemTypeBase::match_name(const string &name) const
75 for(vector<string>::const_iterator i=suffixes.begin(); i!=suffixes.end(); ++i)
76 if(name.size()>i->size() && !name.compare(name.size()-i->size(), string::npos, *i))
81 } // namespace DataFile