Album.h 1.86 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
    public:
29
        Album( DBConnection dbConnection, sqlite3_stmt* stmt );
30
        Album( const std::string& id3tag );
31

32
        virtual unsigned int id() const;
33 34 35 36 37 38 39 40 41 42
        virtual const std::string& name() const;
        virtual bool setName( const std::string& name );
        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;
        virtual bool tracks( std::vector<std::shared_ptr<IAlbumTrack>>& tracks ) const;
43
        virtual AlbumTrackPtr addTrack( const std::string& name, unsigned int trackNb );
44
        virtual bool destroy();
45

46 47
        static bool createTable( DBConnection dbConnection );
        static AlbumPtr create( DBConnection dbConnection, const std::string& id3Tag );
48 49

    protected:
50
        DBConnection m_dbConnection;
51 52
        unsigned int m_id;
        std::string m_name;
53
        unsigned int m_releaseDate;
54 55 56
        std::string m_shortSummary;
        std::string m_artworkUrl;
        time_t m_lastSyncDate;
57
        std::string m_id3tag;
58

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

#endif // ALBUM_H