X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdirectorycollection.h;h=e9a946332c767d0831afced78f4f981c593037cc;hb=eed15dceed29d1bb378082e08114ea81005203c1;hp=93f93545b589708f312fce6d87c1330de8f79ac3;hpb=a4091f14dfbf4d5f822fa26740a7b3f305c449e6;p=libs%2Fdatafile.git diff --git a/source/directorycollection.h b/source/directorycollection.h index 93f9354..e9a9463 100644 --- a/source/directorycollection.h +++ b/source/directorycollection.h @@ -13,6 +13,9 @@ A Collection that can automatically load items from files in a directory. class DirectoryCollection: public Collection { private: + template::value> + class ItemLoader; + std::list dirs; public: @@ -36,16 +39,38 @@ private: if(lookup_file(name, file)) { RefPtr item = new T; - load(*item, file.str()); + ItemLoader ldr(*item, *this); + IO::BufferedFile in(file.str()); + Parser parser(in, file.str()); + ldr.load(parser); return item.release(); } else return 0; } +protected: bool lookup_file(const std::string &, FS::Path &) const; }; +template +class DirectoryCollection::ItemLoader: public T::Loader +{ +public: + ItemLoader(T &o, Collection &): + T::Loader(o) + { } +}; + +template +class DirectoryCollection::ItemLoader: public T::Loader +{ +public: + ItemLoader(T &o, Collection &c): + T::Loader(o, dynamic_cast(c)) + { } +}; + } // namespace DataFile } // namespace Msp