]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/directorycollection.h
Redesign automatic object loading
[libs/datafile.git] / source / directorycollection.h
diff --git a/source/directorycollection.h b/source/directorycollection.h
deleted file mode 100644 (file)
index a796054..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef MSP_DATAFILE_DIRECTORYCOLLECTION_H_
-#define MSP_DATAFILE_DIRECTORYCOLLECTION_H_
-
-#include <msp/fs/path.h>
-#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<FS::Path> 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<typename T>
-       CollectionItemType<T> &add_type()
-       {
-               return Collection::add_type<T>().creator(&DirectoryCollection::create<T>);
-       }
-
-private:
-       template<typename T>
-       T *create(const std::string &name)
-       {
-               FS::Path file;
-               if(lookup_file(name, file))
-               {
-                       RefPtr<T> item = new T;
-                       ItemLoader<T> 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