]> git.tdb.fi Git - libs/datafile.git/blob - source/collectionsource.h
Cosmetic changes
[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() = default;
25 public:
26         virtual ~CollectionSource() = default;
27
28         /// Determines whether an object is available from this source.
29         virtual bool is_loadable(const CollectionItemTypeBase &type, const std::string &name) const = 0;
30
31         /** Returns the names of available objects of a specific type.  Implementors
32         should use type.match_name to check which names are acceptable. */
33         virtual NameList get_names(const CollectionItemTypeBase &type) const = 0;
34
35         /// Loads an item into a collection.
36         virtual void load(Collection &, const CollectionItemTypeBase &, const std::string &) const = 0;
37
38         /** Opens a raw resource.  The caller is responsible for deleting the
39         returned object when done with it. */
40         virtual IO::Seekable *open(const std::string &) const = 0;
41 };
42
43 } // namespace DataFile
44 } // namespace Msp
45
46 #endif