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

Plug in AlbumTrack

parent ca1d7d4f
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "IDescription.h" #include "IDescription.h"
class ITrack; class IAlbumTrack;
class IAlbum class IAlbum
{ {
...@@ -16,7 +16,7 @@ class IAlbum ...@@ -16,7 +16,7 @@ class IAlbum
virtual unsigned int releaseYear() = 0; virtual unsigned int releaseYear() = 0;
virtual const std::string& shortSummary() = 0; virtual const std::string& shortSummary() = 0;
virtual const std::string& artworkUrl() = 0; virtual const std::string& artworkUrl() = 0;
virtual const std::vector<ITrack*>& tracks() = 0; virtual const std::vector<IAlbumTrack*>& tracks() = 0;
}; };
#endif // IALBUM_H #endif // IALBUM_H
#include "Album.h" #include "Album.h"
#include "AlbumTrack.h"
#include "SqliteTools.h" #include "SqliteTools.h"
...@@ -43,9 +44,14 @@ time_t Album::lastSyncDate() ...@@ -43,9 +44,14 @@ time_t Album::lastSyncDate()
return m_lastSyncDate; return m_lastSyncDate;
} }
const std::vector<ITrack*>&Album::tracks() const std::vector<IAlbumTrack*>&Album::tracks()
{ {
if ( m_tracks == NULL )
{
const char* req = "SELECT * FROM AlbumTrack WHERE id_album = ?";
SqliteTools::fetchAll<AlbumTrack>( m_dbConnection, req, m_id, m_tracks );
}
return *m_tracks;
} }
bool Album::CreateTable(sqlite3* dbConnection) bool Album::CreateTable(sqlite3* dbConnection)
......
...@@ -16,7 +16,7 @@ class Album : public IAlbum ...@@ -16,7 +16,7 @@ class Album : public IAlbum
virtual const std::string& shortSummary(); virtual const std::string& shortSummary();
virtual const std::string& artworkUrl(); virtual const std::string& artworkUrl();
virtual time_t lastSyncDate(); virtual time_t lastSyncDate();
virtual const std::vector<ITrack*>& tracks(); virtual const std::vector<IAlbumTrack*>& tracks();
static bool CreateTable( sqlite3* dbConnection ); static bool CreateTable( sqlite3* dbConnection );
static Album* fetch( sqlite3* dbConnection, unsigned int albumTrackId ); static Album* fetch( sqlite3* dbConnection, unsigned int albumTrackId );
...@@ -30,6 +30,7 @@ class Album : public IAlbum ...@@ -30,6 +30,7 @@ class Album : public IAlbum
std::string m_artworkUrl; std::string m_artworkUrl;
time_t m_lastSyncDate; time_t m_lastSyncDate;
std::vector<IAlbumTrack*>* m_tracks;
}; };
#endif // ALBUM_H #endif // ALBUM_H
...@@ -17,7 +17,7 @@ ShowEpisode::ShowEpisode( sqlite3* dbConnection, sqlite3_stmt* stmt ) ...@@ -17,7 +17,7 @@ ShowEpisode::ShowEpisode( sqlite3* dbConnection, sqlite3_stmt* stmt )
} }
const std::string&ShowEpisode::artworkUrl() const std::string& ShowEpisode::artworkUrl()
{ {
return m_artworkUrl; return m_artworkUrl;
} }
...@@ -76,5 +76,5 @@ bool ShowEpisode::createTable(sqlite3* dbConnection) ...@@ -76,5 +76,5 @@ bool ShowEpisode::createTable(sqlite3* dbConnection)
"show_id UNSIGNED INT," "show_id UNSIGNED INT,"
"FOREIGN KEY(show_id) REFERENCES Show(id_show)" "FOREIGN KEY(show_id) REFERENCES Show(id_show)"
")"; ")";
SqliteTools::createTable( dbConnection, req ); return SqliteTools::createTable( dbConnection, req );
} }
Supports Markdown
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