]> git.tdb.fi Git - libs/datafile.git/blob - source/directorysource.h
Add an API to open files from a collection's sources
[libs/datafile.git] / source / directorysource.h
1 #ifndef MSP_DATAFILE_DIRECTORYSOURCE_H_
2 #define MSP_DATAFILE_DIRECTORYSOURCE_H_
3
4 #include <msp/fs/path.h>
5 #include "collectionsource.h"
6
7 namespace Msp {
8 namespace DataFile {
9
10 /**
11 A source that load items from files in a directory.
12 */
13 class DirectorySource: public CollectionSource
14 {
15 private:
16         typedef std::map<std::string, FS::Path> ObjectMap;
17
18         ObjectMap objects;
19
20 public:
21         void add_directory(const FS::Path &);
22
23         virtual bool is_loadable(const CollectionItemTypeBase &, const std::string &) const;
24         virtual NameList get_names(const CollectionItemTypeBase &) const;
25         virtual void load(Collection &, const CollectionItemTypeBase &, const std::string &) const;
26         virtual IO::Seekable *open(const std::string &) const;
27
28         bool lookup_file(const std::string &, FS::Path &) const;
29 };
30
31 } // namespace DataFile
32 } // namespace Msp
33
34 #endif