X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcollection.h;h=a0717cfd8fc44746f1f59c215c2a14ab2ce1f043;hb=refs%2Fheads%2Fwip;hp=98a08b6757a2c3eeed121c4c262e79248d57af02;hpb=e14c01b5775dd2e324b16ff49498db9b9113c523;p=libs%2Fdatafile.git diff --git a/source/collection.h b/source/collection.h index 98a08b6..a0717cf 100644 --- a/source/collection.h +++ b/source/collection.h @@ -9,6 +9,7 @@ #include "collectionsource.h" #include "loader.h" #include "meta.h" +#include "mspdatafile_api.h" /* XXX This file is a big mess with too many things in it. However, the dependencies between those things make it difficult to split up. */ @@ -51,7 +52,7 @@ that are not present. Items retrieted from the fallback collection are shared between the collections, and are only deleted when all collections in the chain have been destroyed. */ -class Collection: private NonCopyable +class MSPDATAFILE_API Collection: private NonCopyable { public: /** @@ -396,7 +397,7 @@ private: template struct Extractor: CollectionItemTypeBase::Extractor { - virtual B &extract(const Variant &var) const + B &extract(const Variant &var) const override { return *var.value >(); } }; @@ -451,19 +452,19 @@ public: return *this; } - virtual bool is_same_type(const CollectionItemTypeBase &other) const + bool is_same_type(const CollectionItemTypeBase &other) const override { return dynamic_cast *>(&other); } - virtual bool check_item_type(const Variant &var) const + bool check_item_type(const Variant &var) const override { return var.check_type >(); } - virtual void add_to_loader(Collection::Loader &) const + void add_to_loader(Collection::Loader &) const override { } - virtual bool can_create() const + bool can_create() const override { return static_cast(create_func); } - virtual void create_item(Collection &coll, const std::string &name) const + void create_item(Collection &coll, const std::string &name) const override { if(!create_func) throw std::runtime_error("no creator"); @@ -472,12 +473,12 @@ public: coll.add(name, obj); } - virtual void load_item(Collection &, Parser &, const std::string &) const + void load_item(Collection &, Parser &, const std::string &) const override { throw std::runtime_error("this type cannot be loaded"); } - virtual void notify_item(const std::string &name, const Variant &var) const + void notify_item(const std::string &name, const Variant &var) const override { RefPtr obj = var.value >(); for(const auto &n: notify_funcs) @@ -490,10 +491,10 @@ template class LoadableCollectionItemType: public CollectionItemType { public: - virtual void add_to_loader(Collection::Loader &loader) const + void add_to_loader(Collection::Loader &loader) const override { loader.add(this->kwd, &Collection::Loader::item); } - virtual void load_item(Collection &coll, Parser &parser, const std::string &name) const + void load_item(Collection &coll, Parser &parser, const std::string &name) const override { RefPtr obj = new T; Collection::ItemLoader ldr(*obj, coll);