X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fcollection.h;h=06b8e348cbe3d2a7e16ce2735971802efa73a863;hp=5f0650c6761043977e85a33e55c6854d25b1703f;hb=43b8dee0bf05dee1b4a07cc001fae0c81ec53a2f;hpb=7feeeacf8fa3eae889cb256c42ada615c4761eec diff --git a/source/collection.h b/source/collection.h index 5f0650c..06b8e34 100644 --- a/source/collection.h +++ b/source/collection.h @@ -83,7 +83,7 @@ public: private: typedef std::map ItemMap; typedef std::list TypeList; - typedef std::list SourceList; + typedef std::list SourceList; TypeList types; ItemMap items; @@ -255,13 +255,16 @@ private: template CollectionItemTypeBase *get_type() const; + /// Gets a descriptor with the same type as another descriptor. + CollectionItemTypeBase *get_type(const CollectionItemTypeBase &) 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: /** Adds a source for automatically loading items. Sources are consulted in the order they are added. */ - void add_source(CollectionSource &); + void add_source(const CollectionSource &); public: /** Opens a raw resource, without interpreting it as object data. Null is @@ -281,6 +284,8 @@ protected: /** Sets a fallback collection, which will be consulted if an item is not found. */ void set_fallback(Collection *); + + Collection *get_fallback() const { return fallback; } }; template @@ -380,7 +385,7 @@ private: Creator(FuncPtr f): func(f) { } virtual T *create(Collection &coll, const std::string &name) const - { return (static_cast(coll).*func)(name); } + { return (dynamic_cast(coll).*func)(name); } }; template