}
};
-protected:
template<typename T, bool = NeedsCollection<typename T::Loader>::value>
class ItemLoader;
template<typename T>
T &get(const std::string &name) const
{
- return extract<T>(get_item(items, name));
+ return extract<typename RemoveConst<T>::Type>(get_item(items, name));
}
/** Gets a typed object from the collection. If the name is not found,
template<typename T>
T &get(const std::string &name)
{
- return extract<T>(get_var(name, get_type<T>()));
+ typedef typename RemoveConst<T>::Type NCT;
+ return extract<NCT>(get_var(name, get_type<NCT>()));
}
private:
template<typename T>
CollectionItemType<T> &add_type();
+private:
/// Returns the descriptor for a type, or null if one isn't defined.
template<typename T>
CollectionItemTypeBase *get_type() const;
/// Returns the descriptor for an item, or null if it's of an unknown type.
CollectionItemTypeBase *get_type_for_item(const Variant &) const;
+protected:
void add_source(CollectionSource &);
+private:
void gather_names_from_sources(std::list<std::string> &, const CollectionItemTypeBase &) const;
void load_items_from_sources(const CollectionItemTypeBase &);
template<typename T>
T &Collection::extract(const Variant &var) const
{
- typedef RefPtr<typename RemoveConst<T>::Type> RPNCT;
-
- if(!var.check_type<RPNCT>())
+ if(!var.check_type<RefPtr<T> >())
if(CollectionItemTypeBase *type = get_type_for_item(var))
if(T *item = type->extract<T>(var))
return *item;
- return *var.value<RPNCT>();
+ return *var.value<RefPtr<T> >();
}
template<typename T>
CollectionItemTypeBase *Collection::get_type() const
{
for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j)
- if(dynamic_cast<CollectionItemType<typename RemoveConst<T>::Type> *>(*j))
+ if(dynamic_cast<CollectionItemType<T> *>(*j))
return *j;
for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j)
if((*j)->can_extract<T>())