- /** Checks whether a name exists in the collection. Does not care about the
- type of the object. */
- bool contains(const std::string &n) const;
+private:
+ template<typename T>
+ unsigned get_status(const std::string &name) const
+ {
+ ItemMap::const_iterator i = items.find(name);
+ if(i==items.end())
+ return false;
+
+ typedef RefPtr<typename RemoveConst<T>::Type> RPNCT;
+ if(!i->second.check_type<RPNCT>())
+ return false;
+
+ T *ptr = i->second.value<RPNCT>().get();
+ return ptr ? 1 : 2;
+ }
+
+public:
+ /// Checks whether a typed object exists and is loaded in the collection.
+ template<typename T>
+ bool contains(const std::string &name) const
+ { return get_status<T>(name)==1; }
+
+ /** Checks whether a typed object exists in the collection, as either a
+ loaded or future object. */
+ template<typename T>
+ bool contains(const std::string &name)
+ { return get_status<T>(name)>0; }