Commit 7c56df4c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Remove setters & modification methods from public interfaces

parent 4d8a8fcd
......@@ -34,16 +34,10 @@ class IAlbum
virtual unsigned int id() const = 0;
virtual const std::string& title() const = 0;
virtual time_t releaseDate() const = 0;
virtual bool setReleaseDate( time_t date ) = 0;
virtual const std::string& shortSummary() const = 0;
virtual bool setShortSummary( const std::string& summary ) = 0;
virtual const std::string& artworkUrl() const = 0;
virtual bool setArtworkUrl( const std::string& artworkUrl ) = 0;
virtual std::vector<std::shared_ptr<IAlbumTrack>> tracks() const = 0;
virtual AlbumTrackPtr addTrack( const std::string& title, unsigned int trackId ) = 0;
virtual std::vector<ArtistPtr> artists() const = 0;
virtual bool addArtist( ArtistPtr artist ) = 0;
virtual bool destroy() = 0;
};
#endif // IALBUM_H
......@@ -34,17 +34,12 @@ class IAlbumTrack
virtual unsigned int id() const = 0;
virtual const std::string& genre() = 0;
virtual bool setGenre( const std::string& genre ) = 0;
virtual const std::string& title() = 0;
virtual unsigned int trackNumber() = 0;
virtual std::shared_ptr<IAlbum> album() = 0;
virtual bool addArtist( ArtistPtr artist ) = 0;
virtual std::vector<ArtistPtr> artists() const = 0;
virtual std::vector<FilePtr> files() = 0;
/**
* @brief destroy Deletes the album track and the file(s) associated
*/
virtual bool destroy() = 0;
};
#endif // IALBUMTRACK_H
......@@ -34,7 +34,6 @@ public:
virtual unsigned int id() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& shortBio() const = 0;
virtual bool setShortBio( const std::string& shortBio ) = 0;
virtual std::vector<AlbumPtr> albums() const = 0;
virtual std::vector<AlbumTrackPtr> tracks() const = 0;
};
......@@ -45,45 +45,24 @@ class IFile
virtual unsigned int id() const = 0;
virtual Type type() = 0;
virtual bool setType( Type type ) = 0;
virtual const std::string& name() = 0;
virtual bool setName( const std::string& name ) = 0;
virtual AlbumTrackPtr albumTrack() = 0;
virtual bool setAlbumTrack(AlbumTrackPtr albumTrack ) = 0;
/**
* @brief duration Returns the file duration in ms
*/
virtual int64_t duration() const = 0;
virtual bool setDuration( int64_t duration ) = 0;
virtual std::shared_ptr<IShowEpisode> showEpisode() = 0;
virtual bool setShowEpisode( ShowEpisodePtr showEpisode ) = 0;
virtual int playCount() const = 0;
virtual const std::string& mrl() const = 0;
virtual bool addLabel( LabelPtr label ) = 0;
virtual bool removeLabel( LabelPtr label ) = 0;
virtual MoviePtr movie() = 0;
virtual bool setMovie( MoviePtr movie ) = 0;
virtual std::vector<std::shared_ptr<ILabel> > labels() = 0;
virtual bool addVideoTrack( const std::string& codec, unsigned int width,
unsigned int height, float fps ) = 0;
virtual std::vector<VideoTrackPtr> videoTracks() = 0;
virtual bool addAudioTrack( const std::string& codec, unsigned int bitrate,
unsigned int sampleRate, unsigned int nbChannels ) = 0;
virtual std::vector<AudioTrackPtr> audioTracks() = 0;
// Returns the location of this file snapshot.
// This is likely to be used for album arts as well.
virtual const std::string& snapshot() = 0;
virtual bool setSnapshot( const std::string& snapshot ) = 0;
/// Returns wether the file has been added as a stand alone file (true), or as
/// part of a folder (false)
virtual bool isStandAlone() = 0;
/// Explicitely mark a file as fully parsed, meaning no metadata service needs to run anymore.
//FIXME: This lacks granularity as we don't have a straight forward way to know which service
//needs to run or not.
virtual bool markParsed() = 0;
virtual bool isParsed() const = 0;
virtual unsigned int lastModificationDate() = 0;
};
#endif // IFILE_H
......@@ -36,7 +36,6 @@ public:
virtual std::vector<FilePtr> files() = 0;
virtual std::vector<FolderPtr> folders() = 0;
virtual unsigned int lastModificationDate() = 0;
virtual bool setLastModificationDate( unsigned int lastModificationDate ) = 0;
virtual bool isRemovable() = 0;
virtual FolderPtr parent() = 0;
};
......@@ -79,7 +79,6 @@ class IMediaLibrary
/// a stand alone file.
/// \return The newly created file, or nullptr in case of error
///
virtual FilePtr addFile( const std::string& path, FolderPtr parentFolder ) = 0;
virtual FilePtr file( const std::string& path ) = 0;
virtual bool deleteFile( const std::string& mrl ) = 0;
virtual bool deleteFile( FilePtr file ) = 0;
......@@ -95,19 +94,15 @@ class IMediaLibrary
virtual std::vector<FilePtr> audioFiles() = 0;
virtual std::vector<FilePtr> videoFiles() = 0;
virtual AlbumPtr album( const std::string& title ) = 0;
virtual AlbumPtr createAlbum( const std::string& title ) = 0;
virtual std::vector<AlbumPtr> albums() = 0;
virtual ShowPtr show( const std::string& name ) = 0;
virtual ShowPtr createShow( const std::string& name ) = 0;
virtual MoviePtr movie( const std::string& title ) = 0;
virtual MoviePtr createMovie( const std::string& title ) = 0;
virtual ArtistPtr artist( const std::string& name ) = 0;
/**
* @brief unknownArtist returns a representation of a virtual "unknown" artist.
* If all tracks have an associated artist, this returns nullptr.
*/
virtual ArtistPtr unknownArtist() = 0;
virtual ArtistPtr createArtist( const std::string& name ) = 0;
virtual std::vector<ArtistPtr> artists() const = 0;
/**
......
......@@ -24,21 +24,24 @@
#define IMETADATASERVICE_H
#include "IMediaLibrary.h"
#include "File.h"
class MediaLibrary;
class IMetadataServiceCb
{
public:
virtual ~IMetadataServiceCb(){}
virtual void done( FilePtr file, ServiceStatus status, void* data ) = 0;
virtual void done( std::shared_ptr<File> file, ServiceStatus status, void* data ) = 0;
};
class IMetadataService
{
public:
virtual ~IMetadataService() = default;
virtual bool initialize( IMetadataServiceCb* callback, IMediaLibrary* ml ) = 0;
virtual bool initialize( IMetadataServiceCb* callback, MediaLibrary* ml ) = 0;
virtual unsigned int priority() const = 0;
virtual bool run( FilePtr file, void* data ) = 0;
virtual bool run( std::shared_ptr<File> file, void* data ) = 0;
};
#endif // IMETADATASERVICE_H
......@@ -32,14 +32,9 @@ class IMovie
virtual unsigned int id() const = 0;
virtual const std::string& title() const = 0;
virtual time_t releaseDate() const = 0;
virtual bool setReleaseDate( time_t date ) = 0;
virtual const std::string& shortSummary() const = 0;
virtual bool setShortSummary( const std::string& summary ) = 0;
virtual const std::string& artworkUrl() const = 0;
virtual bool setArtworkUrl( const std::string& artworkUrl ) = 0;
virtual const std::string& imdbId() const = 0;
virtual bool setImdbId( const std::string& id ) = 0;
virtual bool destroy() = 0;
virtual std::vector<FilePtr> files() = 0;
};
......
......@@ -32,16 +32,10 @@ class IShow
virtual unsigned int id() const = 0;
virtual const std::string& name() const = 0;
virtual time_t releaseDate() const = 0;
virtual bool setReleaseDate( time_t date ) = 0;
virtual const std::string& shortSummary() const = 0;
virtual bool setShortSummary( const std::string& summary ) = 0;
virtual const std::string& artworkUrl() const = 0;
virtual bool setArtworkUrl( const std::string& artworkUrl ) = 0;
virtual const std::string& tvdbId() = 0;
virtual bool setTvdbId( const std::string& id ) = 0;
virtual ShowEpisodePtr addEpisode( const std::string& title, unsigned int episodeNumber ) = 0;
virtual std::vector<ShowEpisodePtr> episodes() = 0;
virtual bool destroy() = 0;
};
#endif // ISHOW_H
......@@ -34,22 +34,14 @@ class IShowEpisode
virtual unsigned int id() const = 0;
virtual const std::string& artworkUrl() const = 0;
virtual bool setArtworkUrl( const std::string& artworkUrl ) = 0;
virtual unsigned int episodeNumber() const = 0;
virtual time_t lastSyncDate() const = 0;
virtual const std::string& name() const = 0;
virtual unsigned int seasonNumber() const = 0;
virtual bool setSeasonNumber(unsigned int seasonNumber) = 0;
virtual const std::string& shortSummary() const = 0;
virtual bool setShortSummary( const std::string& summary ) = 0;
virtual const std::string& tvdbId() const = 0;
virtual bool setTvdbId( const std::string& tvdbId ) = 0;
virtual std::shared_ptr<IShow> show() = 0;
virtual std::vector<FilePtr> files() = 0;
/**
* @brief destroy Deletes the album track and the file(s) associated
*/
virtual bool destroy() = 0;
};
#endif // ISHOWEPISODE_H
......@@ -116,7 +116,7 @@ std::vector<std::shared_ptr<IAlbumTrack>> Album::tracks() const
return AlbumTrack::fetchAll( m_dbConnection, req, m_id );
}
AlbumTrackPtr Album::addTrack( const std::string& title, unsigned int trackNb )
std::shared_ptr<AlbumTrack> Album::addTrack( const std::string& title, unsigned int trackNb )
{
return AlbumTrack::create( m_dbConnection, m_id, title, trackNb );
}
......@@ -129,7 +129,7 @@ std::vector<ArtistPtr> Album::artists() const
return Artist::fetchAll( m_dbConnection, req, m_id );
}
bool Album::addArtist( ArtistPtr artist )
bool Album::addArtist( std::shared_ptr<Artist> artist )
{
static const std::string req = "INSERT INTO AlbumArtistRelation VALUES(?, ?)";
if ( m_id == 0 || artist->id() == 0 )
......@@ -144,8 +144,9 @@ bool Album::destroy()
{
auto ts = tracks();
//FIXME: Have a single request to fetch all files at once, instead of having one per track
for ( auto& t : ts )
for ( auto& it : ts )
{
auto t = std::static_pointer_cast<AlbumTrack>( it );
t->destroy();
}
return _Cache::destroy( m_dbConnection, this );
......@@ -176,7 +177,7 @@ bool Album::createTable(DBConnection dbConnection )
sqlite::Tools::executeRequest( dbConnection, reqRel );
}
AlbumPtr Album::create(DBConnection dbConnection, const std::string& title )
std::shared_ptr<Album> Album::create(DBConnection dbConnection, const std::string& title )
{
auto album = std::make_shared<Album>( title );
static const std::string req = "INSERT INTO " + policy::AlbumTable::Name +
......
......@@ -32,6 +32,8 @@
#include "IAlbum.h"
class Album;
class AlbumTrack;
class Artist;
namespace policy
{
......@@ -61,15 +63,15 @@ class Album : public IAlbum, public Cache<Album, IAlbum, policy::AlbumTable>
virtual bool setArtworkUrl( const std::string& artworkUrl );
virtual time_t lastSyncDate() const;
virtual std::vector<std::shared_ptr<IAlbumTrack> > tracks() const;
virtual AlbumTrackPtr addTrack( const std::string& title, unsigned int trackNb );
std::shared_ptr<AlbumTrack> addTrack( const std::string& title, unsigned int trackNb );
virtual std::vector<ArtistPtr> artists() const override;
virtual bool addArtist( ArtistPtr artist ) override;
virtual bool addArtist( std::shared_ptr<Artist> artist );
virtual bool destroy();
static bool createTable( DBConnection dbConnection );
static AlbumPtr create(DBConnection dbConnection, const std::string& title );
static std::shared_ptr<Album> create(DBConnection dbConnection, const std::string& title );
protected:
DBConnection m_dbConnection;
......
......@@ -79,7 +79,7 @@ bool AlbumTrack::createTable( DBConnection dbConnection )
sqlite::Tools::executeRequest( dbConnection, reqRel );
}
AlbumTrackPtr AlbumTrack::create(DBConnection dbConnection, unsigned int albumId, const std::string& name, unsigned int trackNb)
std::shared_ptr<AlbumTrack> AlbumTrack::create(DBConnection dbConnection, unsigned int albumId, const std::string& name, unsigned int trackNb)
{
auto self = std::make_shared<AlbumTrack>( name, trackNb, albumId );
static const std::string req = "INSERT INTO " + policy::AlbumTrackTable::Name
......
......@@ -63,7 +63,7 @@ class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, pol
virtual std::vector<FilePtr> files();
static bool createTable( DBConnection dbConnection );
static AlbumTrackPtr create( DBConnection dbConnection, unsigned int albumId,
static std::shared_ptr<AlbumTrack> create( DBConnection dbConnection, unsigned int albumId,
const std::string& name, unsigned int trackNb );
private:
......
......@@ -118,7 +118,7 @@ bool Artist::createTable( DBConnection dbConnection )
return sqlite::Tools::executeRequest( dbConnection, req );
}
ArtistPtr Artist::create( DBConnection dbConnection, const std::string &name )
std::shared_ptr<Artist> Artist::create( DBConnection dbConnection, const std::string &name )
{
auto artist = std::make_shared<Artist>( name );
static const std::string req = "INSERT INTO " + policy::ArtistTable::Name +
......
......@@ -55,12 +55,12 @@ public:
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 bool setShortBio( const std::string& shortBio );
virtual std::vector<AlbumPtr> albums() const override;
virtual std::vector<AlbumTrackPtr> tracks() const override;
static bool createTable( DBConnection dbConnection );
static ArtistPtr create( DBConnection dbConnection, const std::string& name );
static std::shared_ptr<Artist> create( DBConnection dbConnection, const std::string& name );
private:
DBConnection m_dbConnection;
......
......@@ -84,7 +84,7 @@ bool AudioTrack::createTable( DBConnection dbConnection )
return sqlite::Tools::executeRequest( dbConnection, req );
}
AudioTrackPtr AudioTrack::fetch(DBConnection dbConnection, const std::string& codec,
std::shared_ptr<AudioTrack> AudioTrack::fetch(DBConnection dbConnection, const std::string& codec,
unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels )
{
static const std::string req = "SELECT * FROM " + policy::AudioTrackTable::Name
......@@ -92,7 +92,7 @@ AudioTrackPtr AudioTrack::fetch(DBConnection dbConnection, const std::string& co
return AudioTrack::fetchOne( dbConnection, req, codec, bitrate, sampleRate, nbChannels );
}
AudioTrackPtr AudioTrack::create( DBConnection dbConnection, const std::string& codec,
std::shared_ptr<AudioTrack> AudioTrack::create( DBConnection dbConnection, const std::string& codec,
unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels )
{
static const std::string req = "INSERT INTO " + policy::AudioTrackTable::Name
......
......@@ -52,9 +52,9 @@ class AudioTrack : public IAudioTrack, public Cache<AudioTrack, IAudioTrack, pol
virtual unsigned int nbChannels() const;
static bool createTable( DBConnection dbConnection );
static AudioTrackPtr fetch( DBConnection dbConnection, const std::string& codec,
static std::shared_ptr<AudioTrack> fetch( DBConnection dbConnection, const std::string& codec,
unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels );
static AudioTrackPtr create(DBConnection dbConnection, const std::string& codec, unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels);
static std::shared_ptr<AudioTrack> create(DBConnection dbConnection, const std::string& codec, unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels);
private:
DBConnection m_dbConnection;
......
......@@ -76,7 +76,7 @@ File::File( const fs::IFile* file, unsigned int folderId, const std::string& nam
{
}
FilePtr File::create( DBConnection dbConnection, Type type, const fs::IFile* file, unsigned int folderId )
std::shared_ptr<File> File::create( DBConnection dbConnection, Type type, const fs::IFile* file, unsigned int folderId )
{
auto self = std::make_shared<File>( file, folderId, file->name(), type );
static const std::string req = "INSERT INTO " + policy::FileTable::Name +
......
......@@ -64,18 +64,18 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
File(DBConnection dbConnection , sqlite3_stmt* stmt);
File(const fs::IFile* file, unsigned int folderId, const std::string &name, Type type);
static FilePtr create(DBConnection dbConnection, Type type, const fs::IFile* file , unsigned int folderId);
static std::shared_ptr<File> create(DBConnection dbConnection, Type type, const fs::IFile* file , unsigned int folderId);
static bool createTable( DBConnection connection );
virtual unsigned int id() const;
virtual Type type() override;
virtual bool setType( Type type ) override;
virtual bool setType( Type type );
virtual const std::string& name() override;
virtual bool setName( const std::string& name ) override;
virtual bool setName( const std::string& name );
virtual AlbumTrackPtr albumTrack();
virtual bool setAlbumTrack( AlbumTrackPtr albumTrack );
virtual int64_t duration() const;
virtual bool setDuration( int64_t duration) override;
virtual bool setDuration( int64_t duration);
virtual std::shared_ptr<IShowEpisode> showEpisode();
virtual bool setShowEpisode( ShowEpisodePtr showEpisode );
virtual bool addLabel( LabelPtr label );
......@@ -91,13 +91,16 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
virtual bool addAudioTrack(const std::string& codec, unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels);
virtual std::vector<AudioTrackPtr> audioTracks();
virtual const std::string& snapshot() override;
virtual bool setSnapshot( const std::string& snapshot ) override;
virtual bool setSnapshot( const std::string& snapshot );
virtual bool isStandAlone() override;
virtual unsigned int lastModificationDate() override;
virtual bool isStandAlone();
virtual unsigned int lastModificationDate();
virtual bool markParsed() override;
virtual bool isParsed() const override;
/// Explicitely mark a file as fully parsed, meaning no metadata service needs to run anymore.
//FIXME: This lacks granularity as we don't have a straight forward way to know which service
//needs to run or not.
virtual bool markParsed();
virtual bool isParsed() const;
private:
DBConnection m_dbConnection;
......
......@@ -78,7 +78,7 @@ bool Folder::createTable(DBConnection connection)
return sqlite::Tools::executeRequest( connection, req );
}
FolderPtr Folder::create( DBConnection connection, const std::string& path, time_t lastModificationDate, bool isRemovable, unsigned int parentId )
std::shared_ptr<Folder> Folder::create( DBConnection connection, const std::string& path, time_t lastModificationDate, bool isRemovable, unsigned int parentId )
{
auto self = std::make_shared<Folder>( path, lastModificationDate, isRemovable, parentId );
static const std::string req = "INSERT INTO " + policy::FolderTable::Name +
......
......@@ -61,7 +61,7 @@ public:
Folder( const std::string& path, time_t lastModificationDate, bool isRemovable, unsigned int parent );
static bool createTable( DBConnection connection );
static FolderPtr create( DBConnection connection, const std::string& path, time_t lastModificationDate, bool isRemovable, unsigned int parentId );
static std::shared_ptr<Folder> create( DBConnection connection, const std::string& path, time_t lastModificationDate, bool isRemovable, unsigned int parentId );
virtual unsigned int id() const override;
virtual const std::string& path() override;
......@@ -69,7 +69,7 @@ public:
virtual std::vector<FolderPtr> folders() override;
virtual FolderPtr parent() override;
virtual unsigned int lastModificationDate() override;
virtual bool setLastModificationDate(unsigned int lastModificationDate) override;
virtual bool setLastModificationDate(unsigned int lastModificationDate);
virtual bool isRemovable() override;
private:
......
......@@ -183,7 +183,7 @@ FilePtr MediaLibrary::file( const std::string& path )
return File::fetch( m_dbConnection.get(), path );
}
FilePtr MediaLibrary::addFile( const std::string& path, FolderPtr parentFolder )
std::shared_ptr<File> MediaLibrary::addFile( const std::string& path, FolderPtr parentFolder )
{
std::unique_ptr<fs::IFile> file;
try
......@@ -269,7 +269,7 @@ AlbumPtr MediaLibrary::album(const std::string& title )
return Album::fetchOne( m_dbConnection.get(), req, title );
}
AlbumPtr MediaLibrary::createAlbum(const std::string& title )
std::shared_ptr<Album> MediaLibrary::createAlbum(const std::string& title )
{
return Album::create( m_dbConnection.get(), title );
}
......@@ -286,7 +286,7 @@ ShowPtr MediaLibrary::show(const std::string& name)
return Show::fetchOne( m_dbConnection.get(), req, name );
}
ShowPtr MediaLibrary::createShow(const std::string& name)
std::shared_ptr<Show> MediaLibrary::createShow(const std::string& name)
{
return Show::create( m_dbConnection.get(), name );
}
......@@ -298,7 +298,7 @@ MoviePtr MediaLibrary::movie( const std::string& title )
return Movie::fetchOne( m_dbConnection.get(), req, title );
}
MoviePtr MediaLibrary::createMovie( const std::string& title )
std::shared_ptr<Movie> MediaLibrary::createMovie( const std::string& title )
{
return Movie::create( m_dbConnection.get(), title );
}
......@@ -323,7 +323,7 @@ ArtistPtr MediaLibrary::unknownArtist()
return m_unknownArtist;
}
ArtistPtr MediaLibrary::createArtist( const std::string& name )
std::shared_ptr<Artist> MediaLibrary::createArtist( const std::string& name )
{
return Artist::create( m_dbConnection.get(), name );
}
......
......@@ -27,13 +27,17 @@ class Parser;
class DiscovererWorker;
class SqliteConnection;
#include <sqlite3.h>
#include "IMediaLibrary.h"
#include "IDiscoverer.h"
#include "logging/Logger.h"
#include "vlcpp/vlc.hpp"
class Album;
class Artist;
class File;
class Movie;
class Show;
class MediaLibrary : public IMediaLibrary
{
public:
......@@ -46,7 +50,7 @@ class MediaLibrary : public IMediaLibrary
virtual std::vector<FilePtr> audioFiles() override;
virtual std::vector<FilePtr> videoFiles() override;
virtual FilePtr file( const std::string& path ) override;
virtual FilePtr addFile(const std::string& path , FolderPtr parentFolder) override;
std::shared_ptr<File> addFile(const std::string& path , FolderPtr parentFolder);
virtual bool deleteFile( const std::string& mrl ) override;
virtual bool deleteFile( FilePtr file ) override;
......@@ -58,18 +62,18 @@ class MediaLibrary : public IMediaLibrary
virtual bool deleteLabel( LabelPtr label ) override;
virtual AlbumPtr album( const std::string& title ) override;
virtual AlbumPtr createAlbum( const std::string& title ) override;
virtual std::shared_ptr<Album> createAlbum( const std::string& title );
virtual std::vector<AlbumPtr> albums() override;
virtual ShowPtr show( const std::string& name ) override;
virtual ShowPtr createShow( const std::string& name ) override;
virtual std::shared_ptr<Show> createShow( const std::string& name );
virtual MoviePtr movie( const std::string& title ) override;
virtual MoviePtr createMovie( const std::string& title ) override;
virtual std::shared_ptr<Movie> createMovie( const std::string& title );
virtual ArtistPtr artist( const std::string& name ) override;
virtual ArtistPtr unknownArtist() override;
virtual ArtistPtr createArtist( const std::string& name ) override;
std::shared_ptr<Artist> createArtist( const std::string& name );
virtual std::vector<ArtistPtr> artists() const override;
virtual void discover( const std::string& entryPoint ) override;
......
......@@ -148,7 +148,7 @@ bool Movie::createTable( DBConnection dbConnection )
return sqlite::Tools::executeRequest( dbConnection, req );
}
MoviePtr Movie::create(DBConnection dbConnection, const std::string& title )
std::shared_ptr<Movie> Movie::create(DBConnection dbConnection, const std::string& title )
{
auto movie = std::make_shared<Movie>( title );
static const std::string req = "INSERT INTO " + policy::MovieTable::Name
......
......@@ -59,7 +59,7 @@ class Movie : public IMovie, public Cache<Movie, IMovie, policy::MovieTable>
virtual std::vector<FilePtr> files();
static bool createTable( DBConnection dbConnection );
static MoviePtr create( DBConnection dbConnection, const std::string& title );
static std::shared_ptr<Movie> create( DBConnection dbConnection, const std::string& title );
private:
DBConnection m_dbConnection;
......
......@@ -55,7 +55,7 @@ void Parser::addService(std::unique_ptr<IMetadataService> service)
});
}
void Parser::parse(FilePtr file, IMediaLibraryCb* cb)
void Parser::parse(std::shared_ptr<File> file, IMediaLibraryCb* cb)
{
std::lock_guard<std::mutex> lock( m_lock );
......@@ -91,7 +91,7 @@ void Parser::run()
}
Parser::Task::Task( FilePtr file, Parser::ServiceList& serviceList, IMediaLibraryCb* metadataCb )
Parser::Task::Task(std::shared_ptr<File> file, Parser::ServiceList& serviceList, IMediaLibraryCb* metadataCb )
: file(file)
, it( serviceList.begin() )
, end( serviceList.end() )
......@@ -100,7 +100,7 @@ Parser::Task::Task( FilePtr file, Parser::ServiceList& serviceList, IMediaLibrar
}
void Parser::done( FilePtr file, ServiceStatus status, void* data )
void Parser::done(std::shared_ptr<File> file, ServiceStatus status, void* data )
{
Task *t = reinterpret_cast<Task*>( data );
if ( status == StatusTemporaryUnavailable || status == StatusFatal )
......
......@@ -41,10 +41,10 @@ class Parser : public IMetadataServiceCb
Parser();
~Parser();
void addService(std::unique_ptr<IMetadataService> service );
void parse( FilePtr file, IMediaLibraryCb* cb );
void parse( std::shared_ptr<File> file, IMediaLibraryCb* cb );
private:
virtual void done( FilePtr file, ServiceStatus status, void* data );
virtual void done( std::shared_ptr<File> file, ServiceStatus status, void* data );
void run();
private:
......@@ -52,11 +52,11 @@ class Parser : public IMetadataServiceCb
typedef std::vector<ServicePtr> ServiceList;
struct Task
{
Task(FilePtr file, ServiceList& serviceList , IMediaLibraryCb* metadataCb);
FilePtr file;
Task(std::shared_ptr<File> file, ServiceList& serviceList , IMediaLibraryCb* metadataCb);
std::shared_ptr<File> file;
ServiceList::iterator it;
ServiceList::iterator end;
IMediaLibraryCb* cb;
IMediaLibraryCb* cb;
};
private:
......
......@@ -123,7 +123,7 @@ bool Show::setTvdbId( const std::string& tvdbId )
return true;
}
ShowEpisodePtr Show::addEpisode(const std::string& title, unsigned int episodeNumber)
std::shared_ptr<ShowEpisode> Show::addEpisode(const std::string& title, unsigned int episodeNumber)
{
return ShowEpisode::create( m_dbConnection, title, episodeNumber, m_id );
}
......@@ -139,9 +139,10 @@ bool Show::destroy()
{
auto eps = episodes();
//FIXME: This is suboptimal. Each episode::destroy() will fire a SQL request of its own
for ( auto& t : eps )
for ( auto& it : eps )
{
t->destroy();
auto e = std::static_pointer_cast<ShowEpisode>( it );
e->destroy();
}
return _Cache::destroy( m_dbConnection, this );
}
......@@ -160,7 +161,7 @@ bool Show::createTable(DBConnection dbConnection)
return sqlite::Tools::executeRequest( dbConnection, req );
}
ShowPtr Show::create(DBConnection dbConnection, const std::string& name )
std::shared_ptr<Show> Show::create(DBConnection dbConnection, const std::string& name )
{
auto show = std::make_shared<Show>( name );
static const std::string req = "INSERT INTO " + policy::ShowTable::Name
......
......@@ -30,6 +30,7 @@
#include "IShow.h"
class Show;
class ShowEpisode;
namespace policy
{
......@@ -58,12 +59,12 @@ class Show : public IShow, public Cache<Show, IShow, policy::ShowTable>
virtual time_t lastSyncDate() const;
virtual const std::string& tvdbId();
virtual bool setTvdbId( const std::string& summary );
virtual ShowEpisodePtr addEpisode( const std::string& title, unsigned int episodeNumber );
virtual std::shared_ptr<ShowEpisode> addEpisode( const std::string& title, unsigned int episodeNumber );
virtual std::vector<ShowEpisodePtr> episodes();
virtual bool destroy();
static bool createTable( DBConnection dbConnection );
static ShowPtr create( DBConnection dbConnection, const std::string& name );
static std::shared_ptr<Show> create( DBConnection dbConnection, const std::string& name );
protected:
DBConnection m_dbConnection;
......
......@@ -174,7 +174,7 @@ bool ShowEpisode::createTable( DBConnection dbConnection )
return sqlite::Tools::executeRequest( dbConnection, req );
}
ShowEpisodePtr ShowEpisode::create( DBConnection dbConnection, const std::string& title, unsigned int episodeNumber, unsigned int showId )
std::shared_ptr<ShowEpisode> ShowEpisode::create( DBConnection dbConnection, const std::string& title, unsigned int episodeNumber, unsigned int showId )
{
auto episode = std::make_shared<ShowEpisode>( title, episodeNumber, showId );
static const std::string req = "INSERT INTO " + policy::ShowEpisodeTable::Name
......
......@@ -51,22 +51,22 @@ class ShowEpisode : public IShowEpisode, public Cache<ShowEpisode, IShowEpisode,
virtual unsigned int id() const;
virtual const std::string& artworkUrl() const;
virtual bool setArtworkUrl( const std::string& artworkUrl );
bool setArtworkUrl( const std::string& artworkUrl );
virtual unsigned int episodeNumber() const;
virtual time_t lastSyncDate() const;
virtual const std::string& name() const;
virtual unsigned int seasonNumber() const;
virtual bool setSeasonNumber(unsigned int seasonNumber);
unsigned int seasonNumber() const;
bool setSeasonNumber(unsigned int seasonNumber);