From af043eaec121bbd6f5e3ad36059c281f1b20bf8f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 6 Dec 2012 23:44:11 +0200 Subject: [PATCH] Some minor fixes in Collection Move RemoveConst invovations close to the public interface to reduce the number of template function instantiations. Correct access specifiers. --- source/collection.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/collection.h b/source/collection.h index d5853f2..bbde9f9 100644 --- a/source/collection.h +++ b/source/collection.h @@ -75,7 +75,6 @@ public: } }; -protected: template::value> class ItemLoader; @@ -119,7 +118,7 @@ public: template T &get(const std::string &name) const { - return extract(get_item(items, name)); + return extract::Type>(get_item(items, name)); } /** Gets a typed object from the collection. If the name is not found, @@ -128,7 +127,8 @@ public: template T &get(const std::string &name) { - return extract(get_var(name, get_type())); + typedef typename RemoveConst::Type NCT; + return extract(get_var(name, get_type())); } private: @@ -247,6 +247,7 @@ protected: template CollectionItemType &add_type(); +private: /// Returns the descriptor for a type, or null if one isn't defined. template CollectionItemTypeBase *get_type() const; @@ -254,8 +255,10 @@ protected: /// 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 &, const CollectionItemTypeBase &) const; void load_items_from_sources(const CollectionItemTypeBase &); @@ -452,14 +455,12 @@ public: template T &Collection::extract(const Variant &var) const { - typedef RefPtr::Type> RPNCT; - - if(!var.check_type()) + if(!var.check_type >()) if(CollectionItemTypeBase *type = get_type_for_item(var)) if(T *item = type->extract(var)) return *item; - return *var.value(); + return *var.value >(); } template @@ -474,7 +475,7 @@ template CollectionItemTypeBase *Collection::get_type() const { for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j) - if(dynamic_cast::Type> *>(*j)) + if(dynamic_cast *>(*j)) return *j; for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j) if((*j)->can_extract()) -- 2.43.0