Artist.h 1.13 KB
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#pragma once

#include "database/Cache.h"
#include "IArtist.h"
#include "IMediaLibrary.h"

class Artist;

namespace policy
{
struct ArtistTable
{
    static const std::string Name;
    static const std::string CacheColumn;
    static unsigned int Artist::*const PrimaryKey;
};
}

class Artist : public IArtist, public Cache<Artist, IArtist, policy::ArtistTable>
{
private:
    using _Cache = Cache<Artist, IArtist, policy::ArtistTable>;

public:
    Artist( DBConnection dbConnection, sqlite3_stmt* stmt );
    Artist( const std::string& name );

    virtual unsigned int id() const override;
    virtual const std::string &name() const override;
    virtual const std::string& shortBio() const override;
    virtual bool setShortBio( const std::string& shortBio ) override;
    virtual std::vector<AlbumPtr> albums() const override;

    static bool createTable( DBConnection dbConnection );
    static ArtistPtr create( DBConnection dbConnection, const std::string& name );

private:
    DBConnection m_dbConnection;
    unsigned int m_id;
    std::string m_name;
    std::string m_shortBio;

    friend _Cache;
    friend struct policy::ArtistTable;
};