Commit 117d49c0 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Don't manually set m_ml when creating entities

parent 00b6f548
......@@ -47,8 +47,9 @@ Album::Album(MediaLibraryPtr ml, sqlite::Row& row)
>> m_isPresent;
}
Album::Album(const std::string& title )
: m_id( 0 )
Album::Album( MediaLibraryPtr ml, const std::string& title )
: m_ml( ml )
, m_id( 0 )
, m_title( title )
, m_artistId( 0 )
, m_releaseYear( ~0u )
......@@ -57,8 +58,9 @@ Album::Album(const std::string& title )
{
}
Album::Album( const Artist* artist )
: m_id( 0 )
Album::Album( MediaLibraryPtr ml, const Artist* artist )
: m_ml( ml )
, m_id( 0 )
, m_artistId( artist->id() )
, m_releaseYear( ~0u )
, m_nbTracks( 0 )
......@@ -319,23 +321,21 @@ bool Album::createTriggers(DBConnection dbConnection)
std::shared_ptr<Album> Album::create( MediaLibraryPtr ml, const std::string& title )
{
auto album = std::make_shared<Album>( title );
auto album = std::make_shared<Album>( ml, title );
static const std::string req = "INSERT INTO " + policy::AlbumTable::Name +
"(id_album, title) VALUES(NULL, ?)";
if ( insert( ml, album, req, title ) == false )
return nullptr;
album->m_ml = ml;
return album;
}
std::shared_ptr<Album> Album::createUnknownAlbum( MediaLibraryPtr ml, const Artist* artist )
{
auto album = std::make_shared<Album>( artist );
auto album = std::make_shared<Album>( ml, artist );
static const std::string req = "INSERT INTO " + policy::AlbumTable::Name +
"(id_album, artist_id) VALUES(NULL, ?)";
if ( insert( ml, album, req, artist->id() ) == false )
return nullptr;
album->m_ml = ml;
return album;
}
......
......@@ -52,8 +52,8 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
{
public:
Album( MediaLibraryPtr ml, sqlite::Row& row );
Album( const std::string& title );
Album( const Artist* artist );
Album( MediaLibraryPtr ml, const std::string& title );
Album( MediaLibraryPtr ml, const Artist* artist );
virtual unsigned int id() const override;
virtual const std::string& title() const override;
......
......@@ -46,8 +46,9 @@ AlbumTrack::AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isPresent;
}
AlbumTrack::AlbumTrack( unsigned int mediaId, unsigned int trackNumber, unsigned int albumId, unsigned int discNumber )
: m_id( 0 )
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int trackNumber, unsigned int albumId, unsigned int discNumber )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
, m_trackNumber( trackNumber )
, m_albumId( albumId )
......@@ -119,12 +120,11 @@ bool AlbumTrack::createTable( DBConnection dbConnection )
std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, unsigned int albumId, const Media& media, unsigned int trackNb, unsigned int discNumber )
{
auto self = std::make_shared<AlbumTrack>( media.id(), trackNb, albumId, discNumber );
auto self = std::make_shared<AlbumTrack>( ml, media.id(), trackNb, albumId, discNumber );
static const std::string req = "INSERT INTO " + policy::AlbumTrackTable::Name
+ "(media_id, track_number, album_id, disc_number) VALUES(?, ?, ?, ?)";
if ( insert( ml, self, req, media.id(), trackNb, albumId, discNumber ) == false )
return nullptr;
self->m_ml = ml;
return self;
}
......
......@@ -52,7 +52,7 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
{
public:
AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row );
AlbumTrack( unsigned int mediaId, unsigned int trackNumber, unsigned int albumId , unsigned int discNumber);
AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int trackNumber, unsigned int albumId , unsigned int discNumber);
virtual unsigned int id() const override;
virtual ArtistPtr artist() const override;
......
......@@ -44,8 +44,9 @@ Artist::Artist( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isPresent;
}
Artist::Artist( const std::string& name )
: m_id( 0 )
Artist::Artist( MediaLibraryPtr ml, const std::string& name )
: m_ml( ml )
, m_id( 0 )
, m_name( name )
, m_nbAlbums( 0 )
, m_isPresent( true )
......@@ -238,12 +239,11 @@ bool Artist::createDefaultArtists( DBConnection dbConnection )
std::shared_ptr<Artist> Artist::create( MediaLibraryPtr ml, const std::string &name )
{
auto artist = std::make_shared<Artist>( name );
auto artist = std::make_shared<Artist>( ml, name );
static const std::string req = "INSERT INTO " + policy::ArtistTable::Name +
"(id_artist, name) VALUES(NULL, ?)";
if ( insert( ml, artist, req, name ) == false )
return nullptr;
artist->m_ml = ml;
return artist;
}
......
......@@ -43,8 +43,8 @@ struct ArtistTable
class Artist : public IArtist, public DatabaseHelpers<Artist, policy::ArtistTable>
{
public:
Artist(MediaLibraryPtr ml, sqlite::Row& row );
Artist( const std::string& name );
Artist( MediaLibraryPtr ml, sqlite::Row& row );
Artist( MediaLibraryPtr ml, const std::string& name );
virtual unsigned int id() const override;
virtual const std::string &name() const override;
......
......@@ -41,10 +41,11 @@ AudioTrack::AudioTrack( MediaLibraryPtr ml, sqlite::Row& row )
>> m_mediaId;
}
AudioTrack::AudioTrack( const std::string& codec, unsigned int bitrate , unsigned int sampleRate,
AudioTrack::AudioTrack( MediaLibraryPtr ml, const std::string& codec, unsigned int bitrate, unsigned int sampleRate,
unsigned int nbChannels, const std::string& language, const std::string& desc,
unsigned int mediaId )
: m_id( 0 )
: m_ml( ml )
, m_id( 0 )
, m_codec( codec )
, m_bitrate( bitrate )
, m_sampleRate( sampleRate )
......@@ -115,9 +116,8 @@ std::shared_ptr<AudioTrack> AudioTrack::create( MediaLibraryPtr ml, const std::s
{
static const std::string req = "INSERT INTO " + policy::AudioTrackTable::Name
+ "(codec, bitrate, samplerate, nb_channels, language, description, media_id) VALUES(?, ?, ?, ?, ?, ?, ?)";
auto track = std::make_shared<AudioTrack>( codec, bitrate, sampleRate, nbChannels, language, desc, mediaId );
auto track = std::make_shared<AudioTrack>( ml, codec, bitrate, sampleRate, nbChannels, language, desc, mediaId );
if ( insert( ml, track, req, codec, bitrate, sampleRate, nbChannels, language, desc, mediaId ) == false )
return nullptr;
track->m_ml = ml;
return track;
}
......@@ -43,7 +43,7 @@ class AudioTrack : public IAudioTrack, public DatabaseHelpers<AudioTrack, policy
{
public:
AudioTrack(MediaLibraryPtr ml, sqlite::Row& row );
AudioTrack(const std::string& codec, unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels, const std::string& language, const std::string& desc , unsigned int mediaId);
AudioTrack( MediaLibraryPtr ml, const std::string& codec, unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels, const std::string& language, const std::string& desc , unsigned int mediaId);
virtual unsigned int id() const override;
virtual const std::string&codec() const override;
......@@ -59,7 +59,7 @@ class AudioTrack : public IAudioTrack, public DatabaseHelpers<AudioTrack, policy
const std::string& language, const std::string& desc, unsigned int mediaId );
private:
MediaLibraryPtr m_ml;
MediaLibraryPtr m_ml;
unsigned int m_id;
std::string m_codec;
unsigned int m_bitrate;
......
......@@ -26,7 +26,7 @@ const std::string policy::DeviceTable::Name = "Device";
const std::string policy::DeviceTable::PrimaryKeyColumn = "id_device";
unsigned int Device::* const policy::DeviceTable::PrimaryKey = &Device::m_id;
Device::Device(MediaLibraryPtr ml, sqlite::Row& row )
Device::Device( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
{
row >> m_id
......@@ -37,8 +37,9 @@ Device::Device(MediaLibraryPtr ml, sqlite::Row& row )
//only be here for sqlite triggering purposes
}
Device::Device( const std::string& uuid, bool isRemovable )
: m_uuid( uuid )
Device::Device( MediaLibraryPtr ml, const std::string& uuid, bool isRemovable )
: m_ml( ml )
, m_uuid( uuid )
, m_isRemovable( isRemovable )
// Assume we can't add an absent device
, m_isPresent( true )
......@@ -78,10 +79,9 @@ std::shared_ptr<Device> Device::create( MediaLibraryPtr ml, const std::string& u
{
static const std::string req = "INSERT INTO " + policy::DeviceTable::Name
+ "(uuid, is_removable, is_present) VALUES(?, ?, ?)";
auto self = std::make_shared<Device>( uuid, isRemovable );
auto self = std::make_shared<Device>( ml, uuid, isRemovable );
if ( insert( ml, self, req, uuid, isRemovable, self->isPresent() ) == false )
return nullptr;
self->m_ml = ml;
return self;
}
......
......@@ -40,7 +40,7 @@ struct DeviceTable
class Device : public DatabaseHelpers<Device, policy::DeviceTable>
{
public:
Device( const std::string& uuid, bool isRemovable );
Device( MediaLibraryPtr ml, const std::string& uuid, bool isRemovable );
Device( MediaLibraryPtr ml, sqlite::Row& row );
unsigned int id() const;
const std::string& uuid() const;
......
......@@ -43,8 +43,9 @@ File::File( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isRemovable;
}
File::File( unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable )
: m_id( 0 )
File::File( MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
, m_mrl( isRemovable == true ? file.name() : file.fullPath() )
, m_type( type )
......@@ -148,14 +149,13 @@ bool File::createTable( DBConnection dbConnection )
std::shared_ptr<File> File::create( MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& fileFs, unsigned int folderId, bool isRemovable )
{
auto self = std::make_shared<File>( mediaId, type, fileFs, folderId, isRemovable );
auto self = std::make_shared<File>( ml, mediaId, type, fileFs, folderId, isRemovable );
static const std::string req = "INSERT INTO " + policy::FileTable::Name +
"(media_id, mrl, type, folder_id, last_modification_date, is_removable) VALUES(?, ?, ?, ?, ?, ?)";
if ( insert( ml, self, req, mediaId, self->m_mrl, type, sqlite::ForeignKey( folderId ),
self->m_lastModificationDate, isRemovable ) == false )
return nullptr;
self->m_ml = ml;
self->m_fullPath = fileFs.fullPath();
return self;
}
......@@ -45,7 +45,7 @@ class File : public IFile, public DatabaseHelpers<File, policy::FileTable>
{
public:
File( MediaLibraryPtr ml, sqlite::Row& row );
File( unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable );
File(MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable );
virtual unsigned int id() const override;
virtual const std::string& mrl() const override;
virtual Type type() const override;
......
......@@ -53,8 +53,9 @@ Folder::Folder( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isRemovable;
}
Folder::Folder( const std::string& path, unsigned int parent, unsigned int deviceId, bool isRemovable )
: m_id( 0 )
Folder::Folder(MediaLibraryPtr ml, const std::string& path, unsigned int parent, unsigned int deviceId, bool isRemovable )
: m_ml( ml )
, m_id( 0 )
, m_path( path )
, m_parent( parent )
, m_isBlacklisted( false )
......@@ -97,12 +98,11 @@ std::shared_ptr<Folder> Folder::create( MediaLibraryPtr ml, const std::string& f
path = utils::file::removePath( fullPath, deviceFs.mountpoint() );
else
path = fullPath;
auto self = std::make_shared<Folder>( path, parentId, device.id(), device.isRemovable() );
auto self = std::make_shared<Folder>( ml, path, parentId, device.id(), device.isRemovable() );
static const std::string req = "INSERT INTO " + policy::FolderTable::Name +
"(path, parent_id, device_id, is_removable) VALUES(?, ?, ?, ?)";
if ( insert( ml, self, req, path, sqlite::ForeignKey( parentId ), device.id(), device.isRemovable() ) == false )
return nullptr;
self->m_ml = ml;
if ( device.isRemovable() == true )
{
self->m_deviceMountpoint = deviceFs.mountpoint();
......
......@@ -54,8 +54,8 @@ struct FolderTable
class Folder : public DatabaseHelpers<Folder, policy::FolderTable>
{
public:
Folder(MediaLibraryPtr ml, sqlite::Row& row );
Folder( const std::string& path, unsigned int parent , unsigned int deviceId , bool isRemovable );
Folder( MediaLibraryPtr ml, sqlite::Row& row );
Folder( MediaLibraryPtr ml, const std::string& path, unsigned int parent , unsigned int deviceId , bool isRemovable );
static bool createTable( DBConnection connection );
static std::shared_ptr<Folder> create( MediaLibraryPtr ml, const std::string& path, unsigned int parentId, Device& device, fs::IDevice& deviceFs );
......
......@@ -40,8 +40,9 @@ Genre::Genre( MediaLibraryPtr ml, sqlite::Row& row )
>> m_name;
}
Genre::Genre( const std::string& name )
: m_name( name )
Genre::Genre( MediaLibraryPtr ml, const std::string& name )
: m_ml( ml )
, m_name( name )
{
}
......@@ -108,10 +109,9 @@ std::shared_ptr<Genre> Genre::create( MediaLibraryPtr ml, const std::string& nam
{
static const std::string req = "INSERT INTO " + policy::GenreTable::Name + "(name)"
"VALUES(?)";
auto self = std::make_shared<Genre>( name );
auto self = std::make_shared<Genre>( ml, name );
if ( insert( ml, self, req, name ) == false )
return nullptr;
self->m_ml = ml;
return self;
}
......
......@@ -42,7 +42,7 @@ class Genre : public IGenre, public DatabaseHelpers<Genre, policy::GenreTable>
{
public:
Genre( MediaLibraryPtr ml, sqlite::Row& row );
Genre( const std::string& name );
Genre( MediaLibraryPtr ml, const std::string& name );
virtual unsigned int id() const;
virtual const std::string& name() const override;
virtual std::vector<ArtistPtr> artists() const override;
......
......@@ -45,7 +45,7 @@ struct HistoryTable
class History : public IHistoryEntry, public DatabaseHelpers<History, policy::HistoryTable>
{
public:
History(MediaLibraryPtr ml, sqlite::Row& row );
History( MediaLibraryPtr ml, sqlite::Row& row );
static bool createTable( DBConnection dbConnection );
static bool insert( DBConnection dbConn, const std::string& mrl );
static std::vector<std::shared_ptr<IHistoryEntry>> fetch( MediaLibraryPtr ml );
......
......@@ -39,8 +39,9 @@ Label::Label(MediaLibraryPtr ml, sqlite::Row& row )
>> m_name;
}
Label::Label( const std::string& name )
: m_id( 0 )
Label::Label( MediaLibraryPtr ml, const std::string& name )
: m_ml( ml )
, m_id( 0 )
, m_name( name )
{
}
......@@ -65,11 +66,10 @@ std::vector<MediaPtr> Label::files()
LabelPtr Label::create( MediaLibraryPtr ml, const std::string& name )
{
auto self = std::make_shared<Label>( name );
auto self = std::make_shared<Label>( ml, name );
const char* req = "INSERT INTO Label VALUES(NULL, ?)";
if ( insert( ml, self, req, self->m_name ) == false )
return nullptr;
self->m_ml = ml;
return self;
}
......
......@@ -46,7 +46,7 @@ class Label : public ILabel, public DatabaseHelpers<Label, policy::LabelTable>
{
public:
Label( MediaLibraryPtr ml, sqlite::Row& row );
Label( const std::string& name );
Label( MediaLibraryPtr ml, const std::string& name );
public:
virtual unsigned int id() const override;
......
......@@ -67,8 +67,9 @@ Media::Media( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isPresent;
}
Media::Media( const std::string& title, Type type )
: m_id( 0 )
Media::Media( MediaLibraryPtr ml, const std::string& title, Type type )
: m_ml( ml )
, m_id( 0 )
, m_type( type )
, m_subType( SubType::Unknown )
, m_duration( -1 )
......@@ -85,13 +86,12 @@ Media::Media( const std::string& title, Type type )
std::shared_ptr<Media> Media::create( MediaLibraryPtr ml, Type type, const fs::IFile& file )
{
auto self = std::make_shared<Media>( file.name(), type );
auto self = std::make_shared<Media>( ml, file.name(), type );
static const std::string req = "INSERT INTO " + policy::MediaTable::Name +
"(type, insertion_date, title) VALUES(?, ?, ?)";
if ( insert( ml, self, req, type, self->m_insertionDate, self->m_title ) == false )
return nullptr;
self->m_ml = ml;
return self;
}
......
......@@ -56,8 +56,8 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
// ::new (pv) T(std::forward(args)...)
// shall be well-formed, and private constructor would prevent that.
// There might be a way with a user-defined allocator, but we'll see that later...
Media(MediaLibraryPtr ml , sqlite::Row& row );
Media( const std::string &title, Type type);
Media( MediaLibraryPtr ml , sqlite::Row& row );
Media( MediaLibraryPtr ml, const std::string &title, Type type);
static std::shared_ptr<Media> create( MediaLibraryPtr ml, Type type, const fs::IFile& file );
static bool createTable( DBConnection connection );
......
......@@ -40,8 +40,9 @@ Movie::Movie(MediaLibraryPtr ml, sqlite::Row& row )
>> m_imdbId;
}
Movie::Movie( unsigned int mediaId, const std::string& title )
: m_id( 0 )
Movie::Movie( MediaLibraryPtr ml, unsigned int mediaId, const std::string& title )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
, m_title( title )
, m_releaseDate( 0 )
......@@ -144,12 +145,11 @@ bool Movie::createTable( DBConnection dbConnection )
std::shared_ptr<Movie> Movie::create( MediaLibraryPtr ml, unsigned int mediaId, const std::string& title )
{
auto movie = std::make_shared<Movie>( mediaId, title );
auto movie = std::make_shared<Movie>( ml, mediaId, title );
static const std::string req = "INSERT INTO " + policy::MovieTable::Name
+ "(media_id, title) VALUES(?, ?)";
if ( insert( ml, movie, req, mediaId, title ) == false )
return nullptr;
movie->m_ml = ml;
return movie;
}
......
......@@ -43,7 +43,7 @@ class Movie : public IMovie, public DatabaseHelpers<Movie, policy::MovieTable>
{
public:
Movie( MediaLibraryPtr ml, sqlite::Row& row );
Movie( unsigned int mediaId, const std::string& title );
Movie( MediaLibraryPtr ml, unsigned int mediaId, const std::string& title );
virtual unsigned int id() const override;
virtual const std::string& title() const override;
......
......@@ -31,26 +31,26 @@ const std::string PlaylistTable::PrimaryKeyColumn = "id_playlist";
unsigned int Playlist::* const PlaylistTable::PrimaryKey = &Playlist::m_id;
}
Playlist::Playlist(MediaLibraryPtr ml, sqlite::Row& row )
Playlist::Playlist( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
{
row >> m_id
>> m_name;
>> m_name;
}
Playlist::Playlist( const std::string& name )
: m_id( 0 )
Playlist::Playlist( MediaLibraryPtr ml, const std::string& name )
: m_ml( ml )
, m_id( 0 )
, m_name( name )
{
}
std::shared_ptr<Playlist> Playlist::create( MediaLibraryPtr ml, const std::string& name )
{
auto self = std::make_shared<Playlist>( name );
auto self = std::make_shared<Playlist>( ml, name );
static const std::string req = "INSERT INTO " + policy::PlaylistTable::Name + "(name) VALUES(?)";
if ( insert( ml, self, req, name ) == false )
return nullptr;
self->m_ml = ml;
return self;
}
......
......@@ -44,7 +44,7 @@ class Playlist : public IPlaylist, public DatabaseHelpers<Playlist, policy::Play
{
public:
Playlist( MediaLibraryPtr ml, sqlite::Row& row );
Playlist( const std::string& name );
Playlist( MediaLibraryPtr ml, const std::string& name );
static std::shared_ptr<Playlist> create( MediaLibraryPtr ml, const std::string& name );
......
......@@ -43,8 +43,9 @@ Show::Show( MediaLibraryPtr ml, sqlite::Row& row )
>> m_tvdbId;
}
Show::Show( const std::string& name )
: m_id( 0 )
Show::Show( MediaLibraryPtr ml, const std::string& name )
: m_ml( ml )
, m_id( 0 )
, m_name( name )
, m_releaseDate( 0 )
{
......@@ -150,11 +151,10 @@ bool Show::createTable( DBConnection dbConnection )
std::shared_ptr<Show> Show::create( MediaLibraryPtr ml, const std::string& name )
{
auto show = std::make_shared<Show>( name );
auto show = std::make_shared<Show>( ml, name );
static const std::string req = "INSERT INTO " + policy::ShowTable::Name
+ "(name) VALUES(?)";
if ( insert( ml, show, req, name ) == false )
return nullptr;
show->m_ml = ml;
return show;
}
......@@ -47,7 +47,7 @@ class Show : public IShow, public DatabaseHelpers<Show, policy::ShowTable>
{
public:
Show( MediaLibraryPtr ml, sqlite::Row& row );
Show( const std::string& name );
Show( MediaLibraryPtr ml, const std::string& name );
virtual unsigned int id() const override;
virtual const std::string& name() const override;
......
......@@ -43,8 +43,9 @@ ShowEpisode::ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row )
>> m_showId;
}
ShowEpisode::ShowEpisode( unsigned int mediaId, const std::string& name, unsigned int episodeNumber, unsigned int showId )
: m_id( 0 )
ShowEpisode::ShowEpisode( MediaLibraryPtr ml, unsigned int mediaId, const std::string& name, unsigned int episodeNumber, unsigned int showId )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
, m_episodeNumber( episodeNumber )
, m_name( name )
......@@ -166,12 +167,11 @@ bool ShowEpisode::createTable( DBConnection dbConnection )
std::shared_ptr<ShowEpisode> ShowEpisode::create( MediaLibraryPtr ml, unsigned int mediaId, const std::string& title, unsigned int episodeNumber, unsigned int showId )
{
auto episode = std::make_shared<ShowEpisode>( mediaId, title, episodeNumber, showId );
auto episode = std::make_shared<ShowEpisode>( ml, mediaId, title, episodeNumber, showId );
static const std::string req = "INSERT INTO " + policy::ShowEpisodeTable::Name
+ "(media_id, episode_number, title, show_id) VALUES(?, ? , ?, ?)";
if ( insert( ml, episode, req, mediaId, episodeNumber, title, showId ) == false )
return nullptr;
episode->m_ml = ml;
return episode;
}
......
......@@ -47,7 +47,7 @@ class ShowEpisode : public IShowEpisode, public DatabaseHelpers<ShowEpisode, pol
{
public:
ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row );
ShowEpisode( unsigned int mediaId, const std::string& name, unsigned int episodeNumber, unsigned int showId );
ShowEpisode( MediaLibraryPtr ml, unsigned int mediaId, const std::string& name, unsigned int episodeNumber, unsigned int showId );
virtual unsigned int id() const override;
virtual const std::string& artworkMrl() const override;
......
......@@ -38,8 +38,9 @@ VideoTrack::VideoTrack( MediaLibraryPtr ml, sqlite::Row& row )
>> m_mediaId;
}
VideoTrack::VideoTrack( const std::string& codec, unsigned int width, unsigned int height, float fps, unsigned int mediaId )
: m_id( 0 )
VideoTrack::VideoTrack( MediaLibraryPtr ml, const std::string& codec, unsigned int width, unsigned int height, float fps, unsigned int mediaId )
: m_ml( ml )
, m_id( 0 )
, m_codec( codec )
, m_width( width )
, m_height( height )
......@@ -78,10 +79,9 @@ std::shared_ptr<VideoTrack> VideoTrack::create( MediaLibraryPtr ml, const std::s
{
static const std::string req = "INSERT INTO " + policy::VideoTrackTable::Name
+ "(codec, width, height, fps, media_id) VALUES(?, ?, ?, ?, ?)";
auto track = std::make_shared<VideoTrack>( codec, width, height, fps, mediaId );
auto track = std::make_shared<VideoTrack>( ml, codec, width, height, fps, mediaId );
if ( insert( ml, track, req, codec, width, height, fps, mediaId ) == false )
return nullptr;
track->m_ml = ml;
return track;
}
......
......@@ -44,7 +44,8 @@ class VideoTrack : public IVideoTrack, public DatabaseHelpers<VideoTrack, policy
{
public:
VideoTrack( MediaLibraryPtr ml, sqlite::Row& row );
VideoTrack( const std::string& codec, unsigned int width, unsigned int height, float fps, unsigned int mediaId );
VideoTrack( MediaLibraryPtr ml, const std::string& codec,
unsigned int width, unsigned int height, float fps, unsigned int mediaId );
virtual unsigned int id() const override;
virtual const std::string& codec() const override;
......
......@@ -82,7 +82,7 @@ void Tests::InstantiateMediaLibrary()
MediaLibraryTester::MediaLibraryTester()
: dummyDirectory( new mock::NoopDirectory )
, dummyFolder( "./", 0, 0, false )
, dummyFolder( nullptr, "./", 0, 0, false )
{
}
......
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