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

9
#include "database/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
    public:
29
        Album( DBConnection dbConnection, sqlite3_stmt* stmt );
30
        Album( const std::string& title );
31

32
        virtual unsigned int id() const;
33
        virtual const std::string& title() const;
34 35 36 37 38 39 40
        virtual time_t releaseDate() const;
        virtual bool setReleaseDate( time_t date );
        virtual const std::string& shortSummary() const;
        virtual bool setShortSummary( const std::string& summary );
        virtual const std::string& artworkUrl() const;
        virtual bool setArtworkUrl( const std::string& artworkUrl );
        virtual time_t lastSyncDate() const;
41
        virtual std::vector<std::shared_ptr<IAlbumTrack> > tracks() const;
42
        virtual AlbumTrackPtr addTrack( const std::string& title, unsigned int trackNb );
43 44 45 46

        virtual std::vector<ArtistPtr> artists() const override;
        virtual bool addArtist( ArtistPtr artist ) override;

47
        virtual bool destroy();
48

49
        static bool createTable( DBConnection dbConnection );
50
        static AlbumPtr create(DBConnection dbConnection, const std::string& title );
51 52

    protected:
53
        DBConnection m_dbConnection;
54
        unsigned int m_id;
55
        std::string m_title;
56
        unsigned int m_releaseDate;
57 58 59 60
        std::string m_shortSummary;
        std::string m_artworkUrl;
        time_t m_lastSyncDate;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
61
        friend class Cache<Album, IAlbum, policy::AlbumTable>;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
62
        friend struct policy::AlbumTable;
63 64 65
};

#endif // ALBUM_H