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

MediaLibrary: Do not take FileSystem factory ownership

This is mostly aiming at allowing us to fiddle with the mock FS during
tests.
parent ddc5602e
......@@ -39,7 +39,7 @@ class IMediaLibrary
/// In case this is a nullptr, a default factory will be used
/// \return true in case of success, false otherwise
///
virtual bool initialize( const std::string& dbPath, std::unique_ptr<factory::IFileSystem> fsFactory = nullptr ) = 0;
virtual bool initialize( const std::string& dbPath, std::shared_ptr<factory::IFileSystem> fsFactory = nullptr ) = 0;
/// Adds a stand alone file
virtual FilePtr addFile( const std::string& path ) = 0;
virtual FilePtr file( const std::string& path ) = 0;
......
......@@ -59,10 +59,10 @@ MediaLibrary::~MediaLibrary()
AudioTrack::clear();
}
bool MediaLibrary::initialize( const std::string& dbPath, std::unique_ptr<factory::IFileSystem> fsFactory )
bool MediaLibrary::initialize( const std::string& dbPath, std::shared_ptr<factory::IFileSystem> fsFactory )
{
if ( fsFactory != nullptr )
m_fsFactory = std::move( fsFactory );
m_fsFactory = fsFactory;
else
m_fsFactory.reset( new factory::FileSystemDefaultFactory );
......
......@@ -12,7 +12,7 @@ class MediaLibrary : public IMediaLibrary
public:
MediaLibrary();
~MediaLibrary();
virtual bool initialize( const std::string& dbPath, std::unique_ptr<factory::IFileSystem> fsFactory );
virtual bool initialize( const std::string& dbPath, std::shared_ptr<factory::IFileSystem> fsFactory );
virtual std::vector<FilePtr> files();
virtual FilePtr file( const std::string& path );
......@@ -46,6 +46,6 @@ class MediaLibrary : public IMediaLibrary
private:
std::shared_ptr<sqlite3> m_dbConnection;
std::unique_ptr<Parser> m_parser;
std::unique_ptr<factory::IFileSystem> m_fsFactory;
std::shared_ptr<factory::IFileSystem> m_fsFactory;
};
#endif // MEDIALIBRARY_H
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