Album.h 1.54 KB
Newer Older
1 2 3
#ifndef ALBUM_H
#define ALBUM_H

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
4
#include <memory>
5 6
#include <sqlite3.h>

7 8
#include "IMediaLibrary.h"

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

12 13
class Album;

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

class Album : public IAlbum, public Cache<Album, IAlbum, policy::AlbumTable>
25
{
26 27
    private:
        typedef Cache<Album, IAlbum, policy::AlbumTable> _Cache;
28 29
    public:
        Album( sqlite3* dbConnection, sqlite3_stmt* stmt );
30
        Album( const std::string& id3tag );
31

32
        unsigned int id() const;
33 34 35 36 37
        virtual const std::string& name();
        virtual unsigned int releaseYear();
        virtual const std::string& shortSummary();
        virtual const std::string& artworkUrl();
        virtual time_t lastSyncDate();
38 39 40
        virtual bool tracks( std::vector<std::shared_ptr<IAlbumTrack>>& tracks );
        virtual AlbumTrackPtr addTrack( const std::string& name, unsigned int trackNb );

41

42
        static bool createTable( sqlite3* dbConnection );
43
        static AlbumPtr create( sqlite3* dbConnection, const std::string& id3Tag );
44 45 46 47 48 49 50 51 52

    protected:
        sqlite3* m_dbConnection;
        unsigned int m_id;
        std::string m_name;
        unsigned int m_releaseYear;
        std::string m_shortSummary;
        std::string m_artworkUrl;
        time_t m_lastSyncDate;
53
        std::string m_id3tag;
54

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
55
        friend class Cache<Album, IAlbum, policy::AlbumTable>;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
56
        friend struct policy::AlbumTable;
57 58 59
};

#endif // ALBUM_H