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

Use int64_t for primary keys

parent 3a011c8a
......@@ -31,7 +31,7 @@ class IAlbum
{
public:
virtual ~IAlbum() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& title() const = 0;
/**
* @brief releaseYear returns the release year, or 0 if unknown.
......
......@@ -30,7 +30,7 @@ class IAlbumTrack
public:
virtual ~IAlbumTrack() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
/**
* @brief artist Returns the artist, as tagged in the media.
* This can be different from the associated media's artist.
......
......@@ -31,7 +31,7 @@ class IArtist
{
public:
virtual ~IArtist() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& shortBio() const = 0;
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const = 0;
......
......@@ -29,7 +29,7 @@ class IAudioTrack
{
public:
virtual ~IAudioTrack() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& codec() const = 0;
/**
* @return The bitrate in bits per second
......
......@@ -48,7 +48,7 @@ public:
};
virtual ~IFile() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& mrl() const = 0;
virtual Type type() const = 0;
virtual unsigned int lastModificationDate() const = 0;
......
......@@ -30,7 +30,7 @@ class IGenre
{
public:
virtual ~IGenre() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual std::vector<ArtistPtr> artists( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual std::vector<AlbumTrackPtr> tracks( medialibrary::SortingCriteria sort, bool desc ) const = 0;
......
......@@ -33,7 +33,7 @@ class ILabel
public:
virtual ~ILabel() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual std::vector<MediaPtr> files() = 0;
};
......
......@@ -50,7 +50,7 @@ class IMedia
virtual ~IMedia() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual Type type() = 0;
virtual SubType subType() const = 0;
virtual const std::string& title() const = 0;
......
......@@ -133,11 +133,11 @@ class IMediaLibrary
virtual bool deleteLabel( LabelPtr label ) = 0;
virtual std::vector<MediaPtr> audioFiles( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual std::vector<MediaPtr> videoFiles( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual AlbumPtr album( unsigned int id ) const = 0;
virtual AlbumPtr album( int64_t id ) const = 0;
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual ShowPtr show( const std::string& name ) const = 0;
virtual MoviePtr movie( const std::string& title ) const = 0;
virtual ArtistPtr artist( unsigned int id ) const = 0;
virtual ArtistPtr artist( int64_t id ) const = 0;
/**
* @brief artists List all artists that have at least an album.
* Artists that only appear on albums as guests won't be listed from here, but will be
......@@ -158,7 +158,7 @@ class IMediaLibrary
*/
virtual PlaylistPtr createPlaylist( const std::string& name ) = 0;
virtual std::vector<PlaylistPtr> playlists( medialibrary::SortingCriteria sort, bool desc ) = 0;
virtual bool deletePlaylist( unsigned int playlistId ) = 0;
virtual bool deletePlaylist( int64_t playlistId ) = 0;
/**
* History
......
......@@ -29,7 +29,7 @@ class IMovie
{
public:
virtual ~IMovie() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& title() const = 0;
virtual const std::string& shortSummary() const = 0;
virtual const std::string& artworkMrl() const = 0;
......
......@@ -30,7 +30,7 @@ class IPlaylist
{
public:
virtual ~IPlaylist() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual bool setName( const std::string& name ) = 0;
virtual unsigned int creationDate() const = 0;
......@@ -42,7 +42,7 @@ public:
/// \param media The media to add
/// \return true on success, false on failure.
///
virtual bool append( unsigned int mediaId ) = 0;
virtual bool append( int64_t mediaId ) = 0;
///
/// \brief add Add a media to the playlist at the given position.
/// Valid positions start at 1. 0 means appending.
......@@ -50,7 +50,7 @@ public:
/// \param position The position of this new media
/// \return true on success, false on failure
///
virtual bool add( unsigned int mediaId, unsigned int position ) = 0;
virtual bool add( int64_t mediaId, unsigned int position ) = 0;
///
/// \brief move Change the position of a media
/// \param mediaId The media to move reorder
......@@ -64,11 +64,11 @@ public:
/// [<1,2>, <2,3>, <3,4>]
/// \return true on success, false on failure
///
virtual bool move( unsigned int mediaId, unsigned int position ) = 0;
virtual bool move( int64_t mediaId, unsigned int position ) = 0;
///
/// \brief remove Removes a media from the playlist
/// \param mediaId The media to remove.
/// \return true on success, false on failure
///
virtual bool remove( unsigned int mediaId ) = 0;
virtual bool remove( int64_t mediaId ) = 0;
};
......@@ -29,7 +29,7 @@ class IShow
{
public:
virtual ~IShow() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual time_t releaseDate() const = 0;
virtual const std::string& shortSummary() const = 0;
......
......@@ -32,7 +32,7 @@ class IShowEpisode
public:
virtual ~IShowEpisode(){}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& artworkMrl() const = 0;
virtual unsigned int episodeNumber() const = 0;
virtual const std::string& name() const = 0;
......
......@@ -29,7 +29,7 @@ class IVideoTrack
{
public:
virtual ~IVideoTrack() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& codec() const = 0;
virtual unsigned int width() const = 0;
virtual unsigned int height() const = 0;
......
......@@ -32,7 +32,7 @@
const std::string policy::AlbumTable::Name = "Album";
const std::string policy::AlbumTable::PrimaryKeyColumn = "id_album";
unsigned int Album::* const policy::AlbumTable::PrimaryKey = &Album::m_id;
int64_t Album::* const policy::AlbumTable::PrimaryKey = &Album::m_id;
Album::Album(MediaLibraryPtr ml, sqlite::Row& row)
: m_ml( ml )
......@@ -68,7 +68,7 @@ Album::Album( MediaLibraryPtr ml, const Artist* artist )
{
}
unsigned int Album::id() const
int64_t Album::id() const
{
return m_id;
}
......@@ -411,7 +411,7 @@ std::vector<AlbumPtr> Album::search( MediaLibraryPtr ml, const std::string& patt
return fetchAll<IAlbum>( ml, req, pattern + "*" );
}
std::vector<AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, unsigned int artistId, medialibrary::SortingCriteria sort, bool desc )
std::vector<AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, int64_t artistId, medialibrary::SortingCriteria sort, bool desc )
{
std::string req = "SELECT * FROM " + policy::AlbumTable::Name + " alb "
"WHERE artist_id = ? AND is_present=1 ORDER BY ";
......@@ -436,7 +436,7 @@ std::vector<AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, unsigned int artist
return fetchAll<IAlbum>( ml, req, artistId );
}
std::vector<AlbumPtr> Album::fromGenre(MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc)
std::vector<AlbumPtr> Album::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc)
{
std::string req = "SELECT a.* FROM " + policy::AlbumTable::Name + " a "
"INNER JOIN " + policy::AlbumTrackTable::Name + " att ON att.album_id = a.id_album "
......
......@@ -44,7 +44,7 @@ struct AlbumTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int Album::*const PrimaryKey;
static int64_t Album::*const PrimaryKey;
};
}
......@@ -55,7 +55,7 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
Album( MediaLibraryPtr ml, const std::string& title );
Album( MediaLibraryPtr ml, const Artist* artist );
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual const std::string& title() const override;
virtual unsigned int releaseYear() const override;
/**
......@@ -104,8 +104,8 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
/// \return
///
static std::vector<AlbumPtr> search( MediaLibraryPtr ml, const std::string& pattern );
static std::vector<AlbumPtr> fromArtist( MediaLibraryPtr ml, unsigned int artistId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> fromGenre( MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> fromArtist( MediaLibraryPtr ml, int64_t artistId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
private:
......@@ -113,9 +113,9 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
static std::string orderBy( medialibrary::SortingCriteria sort, bool desc );
protected:
MediaLibraryPtr m_ml;
unsigned int m_id;
int64_t m_id;
std::string m_title;
unsigned int m_artistId;
int64_t m_artistId;
unsigned int m_releaseYear;
std::string m_shortSummary;
std::string m_artworkMrl;
......
......@@ -30,7 +30,7 @@
const std::string policy::AlbumTrackTable::Name = "AlbumTrack";
const std::string policy::AlbumTrackTable::PrimaryKeyColumn = "id_track";
unsigned int AlbumTrack::* const policy::AlbumTrackTable::PrimaryKey = &AlbumTrack::m_id;
int64_t AlbumTrack::* const policy::AlbumTrackTable::PrimaryKey = &AlbumTrack::m_id;
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
......@@ -45,7 +45,7 @@ AlbumTrack::AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isPresent;
}
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int trackNumber, unsigned int albumId, unsigned int discNumber )
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, int64_t mediaId, unsigned int trackNumber, int64_t albumId, unsigned int discNumber )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
......@@ -56,7 +56,7 @@ AlbumTrack::AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int t
{
}
unsigned int AlbumTrack::id() const
int64_t AlbumTrack::id() const
{
return m_id;
}
......@@ -115,7 +115,7 @@ bool AlbumTrack::createTable( DBConnection dbConnection )
sqlite::Tools::executeRequest( dbConnection, triggerReq );
}
std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, unsigned int albumId,
std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, int64_t albumId,
std::shared_ptr<Media> media, unsigned int trackNb,
unsigned int discNumber )
{
......@@ -128,14 +128,14 @@ std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, unsigned int
return self;
}
AlbumTrackPtr AlbumTrack::fromMedia( MediaLibraryPtr ml, unsigned int mediaId )
AlbumTrackPtr AlbumTrack::fromMedia( MediaLibraryPtr ml, int64_t mediaId )
{
static const std::string req = "SELECT * FROM " + policy::AlbumTrackTable::Name +
" WHERE media_id = ?";
return fetch( ml, req, mediaId );
}
std::vector<AlbumTrackPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc )
std::vector<AlbumTrackPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc )
{
std::string req = "SELECT t.* FROM " + policy::AlbumTrackTable::Name + " t"
" INNER JOIN " + policy::MediaTable::Name + " m ON m.id_media = t.media_id"
......
......@@ -44,7 +44,7 @@ struct AlbumTrackTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int AlbumTrack::*const PrimaryKey;
static int64_t AlbumTrack::*const PrimaryKey;
};
}
......@@ -52,9 +52,9 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
{
public:
AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row );
AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int trackNumber, unsigned int albumId , unsigned int discNumber);
AlbumTrack( MediaLibraryPtr ml, int64_t mediaId, unsigned int trackNumber, int64_t albumId, unsigned int discNumber);
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual ArtistPtr artist() const override;
bool setArtist( std::shared_ptr<Artist> artist );
virtual GenrePtr genre() override;
......@@ -65,20 +65,20 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
virtual std::shared_ptr<IMedia> media() override;
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<AlbumTrack> create( MediaLibraryPtr ml, unsigned int albumId,
static std::shared_ptr<AlbumTrack> create( MediaLibraryPtr ml, int64_t albumId,
std::shared_ptr<Media> media, unsigned int trackNb , unsigned int discNumber );
static AlbumTrackPtr fromMedia( MediaLibraryPtr ml, unsigned int mediaId );
static std::vector<AlbumTrackPtr> fromGenre( MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc );
static AlbumTrackPtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
static std::vector<AlbumTrackPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<MediaPtr> search(DBConnection dbConn, const std::string& title );
private:
MediaLibraryPtr m_ml;
unsigned int m_id;
unsigned int m_mediaId;
unsigned int m_artistId;
unsigned int m_genreId;
int64_t m_id;
int64_t m_mediaId;
int64_t m_artistId;
int64_t m_genreId;
unsigned int m_trackNumber;
unsigned int m_albumId;
int64_t m_albumId;
unsigned int m_discNumber;
bool m_isPresent;
......
......@@ -29,7 +29,7 @@
const std::string policy::ArtistTable::Name = "Artist";
const std::string policy::ArtistTable::PrimaryKeyColumn = "id_artist";
unsigned int Artist::*const policy::ArtistTable::PrimaryKey = &Artist::m_id;
int64_t Artist::*const policy::ArtistTable::PrimaryKey = &Artist::m_id;
Artist::Artist( MediaLibraryPtr ml, sqlite::Row& row )
......@@ -53,7 +53,7 @@ Artist::Artist( MediaLibraryPtr ml, const std::string& name )
{
}
unsigned int Artist::id() const
int64_t Artist::id() const
{
return m_id;
}
......
......@@ -36,7 +36,7 @@ struct ArtistTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int Artist::*const PrimaryKey;
static int64_t Artist::*const PrimaryKey;
};
}
......@@ -46,7 +46,7 @@ public:
Artist( MediaLibraryPtr ml, sqlite::Row& row );
Artist( MediaLibraryPtr ml, const std::string& name );
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual const std::string &name() const override;
virtual const std::string& shortBio() const override;
bool setShortBio( const std::string& shortBio );
......@@ -69,7 +69,7 @@ public:
private:
MediaLibraryPtr m_ml;
unsigned int m_id;
int64_t m_id;
std::string m_name;
std::string m_shortBio;
std::string m_artworkMrl;
......
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