Album.h 1.4 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"

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
12 13 14 15 16 17 18 19 20 21
namespace policy
{
struct AlbumTable
{
    static const std::string Name;
    static const std::string CacheColumn;
};
}

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

29
        unsigned int id() const;
30 31 32 33 34
        virtual const std::string& name();
        virtual unsigned int releaseYear();
        virtual const std::string& shortSummary();
        virtual const std::string& artworkUrl();
        virtual time_t lastSyncDate();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
35
        virtual const std::vector<std::shared_ptr<IAlbumTrack>>& tracks();
36

37
        static bool createTable( sqlite3* dbConnection );
38
        static AlbumPtr create( sqlite3* dbConnection, const std::string& id3Tag );
39 40 41 42 43 44 45 46 47

    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;
48
        std::string m_id3tag;
49

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50 51 52
        std::vector<std::shared_ptr<IAlbumTrack>>* m_tracks;

        friend class Cache<Album, IAlbum, policy::AlbumTable>;
53 54 55
};

#endif // ALBUM_H