AlbumTrack.h 1.54 KB
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1
2
3
4
5
6
7
#ifndef ALBUMTRACK_H
#define ALBUMTRACK_H

#include <sqlite3.h>
#include <string>

#include "IAlbumTrack.h"
8
#include "IMediaLibrary.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
9
#include "Cache.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
10
11

class Album;
12
class AlbumTrack;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
13

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
14
15
16
17
18
19
namespace policy
{
struct AlbumTrackTable
{
    static const std::string Name;
    static const std::string CacheColumn;
20
    static unsigned int AlbumTrack::*const PrimaryKey;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
21
22
23
24
};
}

class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
25
{
26
27
    private:
        typedef Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable> _Cache;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
28
    public:
29
        AlbumTrack( sqlite3* dbConnection, sqlite3_stmt* stmt );
30
        AlbumTrack( const std::string& title, unsigned int trackNumber, unsigned int albumId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
31

32
        virtual unsigned int id() const;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
33
34
        virtual const std::string& genre();
        virtual const std::string& title();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
35
        virtual unsigned int trackNumber();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
36
        virtual std::shared_ptr<IAlbum> album();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
37

38
        static bool createTable( sqlite3* dbConnection );
39
40
        static AlbumTrackPtr create(sqlite3* dbConnection, unsigned int albumId,
                                     const std::string& name, unsigned int trackNb );
41

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
42
43
44
45
46
47
48
49
    private:
        sqlite3* m_dbConnection;
        unsigned int m_id;
        std::string m_title;
        std::string m_genre;
        unsigned int m_trackNumber;
        unsigned int m_albumId;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50
51
52
        std::shared_ptr<Album> m_album;

        friend class Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable>;
53
        friend class policy::AlbumTrackTable;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
54
55
56
};

#endif // ALBUMTRACK_H