Commit cad96099 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

IAlbumTrack: Add getters for the linked entities ID

So that a caller interested in in the ID doesn't have to fetch the
entire entity
parent af5499c2
...@@ -43,9 +43,12 @@ class IAlbumTrack ...@@ -43,9 +43,12 @@ class IAlbumTrack
* @return * @return
*/ */
virtual ArtistPtr artist() const = 0; virtual ArtistPtr artist() const = 0;
virtual int64_t artistId() const = 0;
virtual GenrePtr genre() = 0; virtual GenrePtr genre() = 0;
virtual int64_t genreId() const = 0;
virtual unsigned int trackNumber() = 0; virtual unsigned int trackNumber() = 0;
virtual AlbumPtr album() = 0; virtual AlbumPtr album() = 0;
virtual int64_t albumId() const = 0;
virtual MediaPtr media() = 0; virtual MediaPtr media() = 0;
/** /**
* @return Which disc this tracks appears on (or 0 if unspecified) * @return Which disc this tracks appears on (or 0 if unspecified)
......
...@@ -86,6 +86,11 @@ ArtistPtr AlbumTrack::artist() const ...@@ -86,6 +86,11 @@ ArtistPtr AlbumTrack::artist() const
return m_artist.get(); return m_artist.get();
} }
int64_t AlbumTrack::artistId() const
{
return m_artistId;
}
void AlbumTrack::createTable( sqlite::Connection* dbConnection ) void AlbumTrack::createTable( sqlite::Connection* dbConnection )
{ {
const std::string req = "CREATE TABLE IF NOT EXISTS " + policy::AlbumTrackTable::Name + "(" const std::string req = "CREATE TABLE IF NOT EXISTS " + policy::AlbumTrackTable::Name + "("
...@@ -193,6 +198,11 @@ GenrePtr AlbumTrack::genre() ...@@ -193,6 +198,11 @@ GenrePtr AlbumTrack::genre()
return m_genre.get(); return m_genre.get();
} }
int64_t AlbumTrack::genreId() const
{
return m_genreId;
}
bool AlbumTrack::setGenre( std::shared_ptr<Genre> genre ) bool AlbumTrack::setGenre( std::shared_ptr<Genre> genre )
{ {
// We need to fetch the old genre entity now, in case it gets deleted through // We need to fetch the old genre entity now, in case it gets deleted through
...@@ -247,6 +257,11 @@ std::shared_ptr<IAlbum> AlbumTrack::album() ...@@ -247,6 +257,11 @@ std::shared_ptr<IAlbum> AlbumTrack::album()
return m_album.get().lock(); return m_album.get().lock();
} }
int64_t AlbumTrack::albumId() const
{
return m_albumId;
}
std::shared_ptr<IMedia> AlbumTrack::media() std::shared_ptr<IMedia> AlbumTrack::media()
{ {
auto lock = m_media.lock(); auto lock = m_media.lock();
......
...@@ -60,11 +60,14 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy ...@@ -60,11 +60,14 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
virtual int64_t id() const override; virtual int64_t id() const override;
virtual ArtistPtr artist() const override; virtual ArtistPtr artist() const override;
virtual int64_t artistId() const override;
virtual GenrePtr genre() override; virtual GenrePtr genre() override;
virtual int64_t genreId() const override;
bool setGenre( std::shared_ptr<Genre> genre ); bool setGenre( std::shared_ptr<Genre> genre );
virtual unsigned int trackNumber() override; virtual unsigned int trackNumber() override;
virtual unsigned int discNumber() const override; virtual unsigned int discNumber() const override;
virtual std::shared_ptr<IAlbum> album() override; virtual std::shared_ptr<IAlbum> album() override;
virtual int64_t albumId() const override;
virtual std::shared_ptr<IMedia> media() override; virtual std::shared_ptr<IMedia> media() override;
static void createTable( sqlite::Connection* dbConnection ); static void createTable( sqlite::Connection* dbConnection );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment