]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/collectionsource.h
Redesign automatic object loading
[libs/datafile.git] / source / collectionsource.h
diff --git a/source/collectionsource.h b/source/collectionsource.h
new file mode 100644 (file)
index 0000000..61bb115
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef COLLECTIONSOURCE_H_
+#define COLLECTIONSOURCE_H_
+
+#include <list>
+#include <string>
+
+namespace Msp {
+namespace DataFile {
+
+class Collection;
+class CollectionItemTypeBase;
+
+/**
+Provides automatically loadable objects for collections.  This is a base class;
+see DirectorySource and PackSource for concrete classes.
+*/
+class CollectionSource
+{
+public:
+       typedef std::list<std::string> NameList;
+
+protected:
+       CollectionSource() { }
+
+public:
+       /** Determines */
+       virtual bool is_loadable(const CollectionItemTypeBase &type, const std::string &name) const = 0;
+
+       /** Returns the names of loadable objects of a specific type.  Implementors
+       should use the keyword and/or suffixes of the type to  */
+       virtual NameList get_names(const CollectionItemTypeBase &type) const = 0;
+
+       virtual void load(Collection &, const CollectionItemTypeBase &, const std::string &) const = 0;
+};
+
+} // namespace DataFile
+} // namespace Msp
+
+#endif