AlbumTrack.h 1.71 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( 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
39
        virtual bool destroy();
        virtual bool files( std::vector<FilePtr>& files );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40

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

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

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

#endif // ALBUMTRACK_H