AlbumTrack.h 1.83 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"
9
#include "database/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( DBConnection 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
        virtual const std::string& genre();
34
        virtual bool setGenre( const std::string& genre );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
35
        virtual const std::string& title();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
36
        virtual unsigned int trackNumber();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
37
        virtual std::shared_ptr<IAlbum> album();
38
        virtual bool destroy();
39
40
        virtual bool addArtist( ArtistPtr artist ) override;
        virtual std::vector<ArtistPtr> artists() const override;
41
        virtual std::vector<FilePtr> files();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
42

43
44
        static bool createTable( DBConnection dbConnection );
        static AlbumTrackPtr create( DBConnection dbConnection, unsigned int albumId,
45
                                     const std::string& name, unsigned int trackNb );
46

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
47
    private:
48
        DBConnection m_dbConnection;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
49
50
51
52
53
54
        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
55
56
57
        std::shared_ptr<Album> m_album;

        friend class Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable>;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
58
        friend struct policy::AlbumTrackTable;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
59
60
61
};

#endif // ALBUMTRACK_H