blob: 17f99f29afc7871c4332c07e7e8fe08831ae8393 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef MUSIC_H
#define MUSIC_H
#include "http_connection.h"
#include <boost/filesystem.hpp>
#include <vector>
#include <iostream>
namespace fs = boost::filesystem;
//! Generalized abstract class for music content.
class MusicListing {
public:
typedef boost::shared_ptr<MusicListing> p;
fs::path path;
//! Render the content for HTTP transport.
virtual void render(HTTP::Connection::p req) = 0;
};
//! Represents a track.
class MusicTrack : public MusicListing {
public:
MusicTrack(const fs::path path);
virtual void render(HTTP::Connection::p req);
};
// Forward declaration for MusicDirectory::update()
class Database;
//! Represents a directory.
class MusicDirectory : public MusicListing {
public:
typedef boost::shared_ptr<MusicDirectory> p;
typedef std::vector<fs::path> PathListings;
PathListings directories;
PathListings tracks;
MusicDirectory(const fs::path root);
virtual void render(HTTP::Connection::p req);
void update(Database& db);
};
namespace music {
extern fs::path root_directory;
void init(std::string root);
MusicListing::p get(const HTTP::Connection::PathList& path);
MusicListing::p get(const std::string& path);
MusicDirectory::p get_directory(const std::string& path);
std::vector<MusicListing::p> find(std::map<std::string, std::string> search);
std::vector<MusicListing::p> find(std::string search);
void begin_update(const std::string path);
};
#endif
|