]> git.tdb.fi Git - libs/datafile.git/blob - source/collectionsource.h
398f7942c85c6260d514796beac77146b5cc7d32
[libs/datafile.git] / source / collectionsource.h
1 #ifndef COLLECTIONSOURCE_H_
2 #define COLLECTIONSOURCE_H_
3
4 #include <list>
5 #include <string>
6 #include <msp/io/seekable.h>
7
8 namespace Msp {
9 namespace DataFile {
10
11 class Collection;
12 class CollectionItemTypeBase;
13
14 /**
15 Provides automatically loadable objects for collections.  This is a base class;
16 see DirectorySource and PackSource for concrete classes.
17 */
18 class CollectionSource
19 {
20 public:
21         typedef std::list<std::string> NameList;
22
23 protected:
24         CollectionSource() { }
25
26 public:
27         /** Determines */
28         virtual bool is_loadable(const CollectionItemTypeBase &type, const std::string &name) const = 0;
29
30         /** Returns the names of loadable objects of a specific type.  Implementors
31         should use the keyword and/or suffixes of the type to  */
32         virtual NameList get_names(const CollectionItemTypeBase &type) const = 0;
33
34         virtual void load(Collection &, const CollectionItemTypeBase &, const std::string &) const = 0;
35
36         /** Opens a file from the source.  The caller is responsible for deleting
37         the returned object when done with it. */
38         virtual IO::Seekable *open(const std::string &) const = 0;
39 };
40
41 } // namespace DataFile
42 } // namespace Msp
43
44 #endif