X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdirectorycollection.h;fp=source%2Fdirectorycollection.h;h=0000000000000000000000000000000000000000;hb=b1bc25649c1f22abf940a807d934f1e9bb780c28;hp=a796054b43569d4892e919ec5a337c4daba25409;hpb=6e0e2c78766de3ae57449866b74e111a2af893cf;p=libs%2Fdatafile.git diff --git a/source/directorycollection.h b/source/directorycollection.h deleted file mode 100644 index a796054..0000000 --- a/source/directorycollection.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef MSP_DATAFILE_DIRECTORYCOLLECTION_H_ -#define MSP_DATAFILE_DIRECTORYCOLLECTION_H_ - -#include -#include "collection.h" - -namespace Msp { -namespace DataFile { - -/** -A Collection that can automatically load items from files in a directory. -*/ -class DirectoryCollection: public Collection -{ -private: - std::list dirs; - -public: - DirectoryCollection(); - -protected: - void set_directory(const FS::Path &); - void add_directory(const FS::Path &); - - /** Examines the names of files in the designated directories and adds any - applicable ones as future objects. */ - void load_names(); - - template - CollectionItemType &add_type() - { - return Collection::add_type().creator(&DirectoryCollection::create); - } - -private: - template - T *create(const std::string &name) - { - FS::Path file; - if(lookup_file(name, file)) - { - RefPtr item = new T; - 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; -}; - -} // namespace DataFile -} // namespace Msp - -#endif