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 CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const
40 for(TypeList::const_iterator i=types.begin(); i!=types.end(); ++i)
41 if((*i)->check_item_type(var))
46 void Collection::add_source(CollectionSource &s)
48 sources.push_back(&s);
52 Collection::Loader::Loader(Collection &c):
55 for(TypeList::const_iterator i = coll.types.begin(); i!=coll.types.end(); ++i)
56 (*i)->add_to_loader(*this);
60 CollectionItemTypeBase::~CollectionItemTypeBase()
62 for(vector<ExtractorBase *>::iterator i=extractors.begin(); i!=extractors.end(); ++i)
66 void CollectionItemTypeBase::set_keyword(const string &k)
73 void CollectionItemTypeBase::add_suffix(const string &s)
75 suffixes.push_back(s);
78 bool CollectionItemTypeBase::match_name(const string &name) const
80 for(vector<string>::const_iterator i=suffixes.begin(); i!=suffixes.end(); ++i)
81 if(name.size()>i->size() && !name.compare(name.size()-i->size(), string::npos, *i))
86 } // namespace DataFile