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

factory::IFileSystem -> fs::IFileSystemFactory

parent 6372a1da
...@@ -33,14 +33,11 @@ namespace fs ...@@ -33,14 +33,11 @@ namespace fs
class IDirectory; class IDirectory;
class IFile; class IFile;
class IDevice; class IDevice;
}
namespace factory class IFileSystemFactory
{
class IFileSystem
{ {
public: public:
virtual ~IFileSystem() = default; virtual ~IFileSystemFactory() = default;
/// ///
/// \brief createDirectory creates a representation of a directory /// \brief createDirectory creates a representation of a directory
/// \note This method can fail by throwing an exception if the /// \note This method can fail by throwing an exception if the
......
...@@ -1200,7 +1200,7 @@ IDeviceListerCb* MediaLibrary::setDeviceLister( DeviceListerPtr lister ) ...@@ -1200,7 +1200,7 @@ IDeviceListerCb* MediaLibrary::setDeviceLister( DeviceListerPtr lister )
return static_cast<IDeviceListerCb*>( this ); return static_cast<IDeviceListerCb*>( this );
} }
std::shared_ptr<factory::IFileSystem> MediaLibrary::fsFactoryForMrl( const std::string& mrl ) const std::shared_ptr<fs::IFileSystemFactory> MediaLibrary::fsFactoryForMrl( const std::string& mrl ) const
{ {
for ( const auto& f : m_fsFactories ) for ( const auto& f : m_fsFactories )
{ {
...@@ -1221,7 +1221,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled ) ...@@ -1221,7 +1221,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
#ifdef HAVE_LIBVLC #ifdef HAVE_LIBVLC
if ( enabled ) if ( enabled )
{ {
auto it = std::find_if( begin( m_fsFactories ), end( m_fsFactories ), []( const std::shared_ptr<factory::IFileSystem> fs ) { auto it = std::find_if( begin( m_fsFactories ), end( m_fsFactories ), []( const std::shared_ptr<fs::IFileSystemFactory> fs ) {
return fs->isNetworkFileSystem(); return fs->isNetworkFileSystem();
}); });
if ( it == end( m_fsFactories ) ) if ( it == end( m_fsFactories ) )
...@@ -1229,7 +1229,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled ) ...@@ -1229,7 +1229,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
} }
else else
{ {
m_fsFactories.erase( std::remove_if( begin( m_fsFactories ), end( m_fsFactories ), []( const std::shared_ptr<factory::IFileSystem> fs ) { m_fsFactories.erase( std::remove_if( begin( m_fsFactories ), end( m_fsFactories ), []( const std::shared_ptr<fs::IFileSystemFactory> fs ) {
return fs->isNetworkFileSystem(); return fs->isNetworkFileSystem();
}), end( m_fsFactories ) ); }), end( m_fsFactories ) );
} }
...@@ -1279,7 +1279,7 @@ void MediaLibrary::setLogger( ILogger* logger ) ...@@ -1279,7 +1279,7 @@ void MediaLibrary::setLogger( ILogger* logger )
Log::SetLogger( logger ); Log::SetLogger( logger );
} }
void MediaLibrary::refreshDevices( factory::IFileSystem& fsFactory ) void MediaLibrary::refreshDevices( fs::IFileSystemFactory& fsFactory )
{ {
// Don't refuse to process devices when none seem to be present, it might be a valid case // Don't refuse to process devices when none seem to be present, it might be a valid case
// if the user only discovered removable storages, and we would still need to mark those // if the user only discovered removable storages, and we would still need to mark those
......
...@@ -46,15 +46,11 @@ class Folder; ...@@ -46,15 +46,11 @@ class Folder;
class Genre; class Genre;
class Playlist; class Playlist;
namespace factory
{
class IFileSystem;
}
namespace fs namespace fs
{ {
class IFile; class IFile;
class IDirectory; class IDirectory;
class IFileSystemFactory;
} }
namespace parser namespace parser
...@@ -160,9 +156,9 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb ...@@ -160,9 +156,9 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
std::shared_ptr<ModificationNotifier> getNotifier() const; std::shared_ptr<ModificationNotifier> getNotifier() const;
virtual IDeviceListerCb* setDeviceLister( DeviceListerPtr lister ) override; virtual IDeviceListerCb* setDeviceLister( DeviceListerPtr lister ) override;
std::shared_ptr<factory::IFileSystem> fsFactoryForMrl( const std::string& path ) const; std::shared_ptr<fs::IFileSystemFactory> fsFactoryForMrl( const std::string& path ) const;
void refreshDevices(factory::IFileSystem& fsFactory); void refreshDevices(fs::IFileSystemFactory& fsFactory);
virtual void forceRescan() override; virtual void forceRescan() override;
...@@ -200,7 +196,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb ...@@ -200,7 +196,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
void registerEntityHooks(); void registerEntityHooks();
static bool validateSearchPattern( const std::string& pattern ); static bool validateSearchPattern( const std::string& pattern );
// Returns true if the device actually changed // Returns true if the device actually changed
bool onDeviceChanged( factory::IFileSystem& fsFactory, Device& device ); bool onDeviceChanged( fs::IFileSystemFactory& fsFactory, Device& device );
protected: protected:
virtual void addLocalFsFactory(); virtual void addLocalFsFactory();
...@@ -214,7 +210,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb ...@@ -214,7 +210,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
protected: protected:
std::shared_ptr<sqlite::Connection> m_dbConnection; std::shared_ptr<sqlite::Connection> m_dbConnection;
std::vector<std::shared_ptr<factory::IFileSystem>> m_fsFactories; std::vector<std::shared_ptr<fs::IFileSystemFactory>> m_fsFactories;
std::string m_thumbnailPath; std::string m_thumbnailPath;
IMediaLibraryCb* m_callback; IMediaLibraryCb* m_callback;
DeviceListerPtr m_deviceLister; DeviceListerPtr m_deviceLister;
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
namespace medialibrary namespace medialibrary
{ {
FsDiscoverer::FsDiscoverer( std::shared_ptr<factory::IFileSystem> fsFactory, MediaLibrary* ml, IMediaLibraryCb* cb, std::unique_ptr<prober::IProbe> probe ) FsDiscoverer::FsDiscoverer( std::shared_ptr<fs::IFileSystemFactory> fsFactory, MediaLibrary* ml, IMediaLibraryCb* cb, std::unique_ptr<prober::IProbe> probe )
: m_ml( ml ) : m_ml( ml )
, m_fsFactory( std::move( fsFactory )) , m_fsFactory( std::move( fsFactory ))
, m_cb( cb ) , m_cb( cb )
......
...@@ -41,7 +41,7 @@ class IProbe; ...@@ -41,7 +41,7 @@ class IProbe;
class FsDiscoverer : public IDiscoverer class FsDiscoverer : public IDiscoverer
{ {
public: public:
FsDiscoverer( std::shared_ptr<factory::IFileSystem> fsFactory, MediaLibrary* ml , IMediaLibraryCb* cb, std::unique_ptr<prober::IProbe> probe ); FsDiscoverer( std::shared_ptr<fs::IFileSystemFactory> fsFactory, MediaLibrary* ml , IMediaLibraryCb* cb, std::unique_ptr<prober::IProbe> probe );
virtual bool discover(const std::string& entryPoint ) override; virtual bool discover(const std::string& entryPoint ) override;
virtual bool reload() override; virtual bool reload() override;
virtual bool reload( const std::string& entryPoint ) override; virtual bool reload( const std::string& entryPoint ) override;
...@@ -61,7 +61,7 @@ private: ...@@ -61,7 +61,7 @@ private:
private: private:
MediaLibrary* m_ml; MediaLibrary* m_ml;
std::shared_ptr<factory::IFileSystem> m_fsFactory; std::shared_ptr<fs::IFileSystemFactory> m_fsFactory;
IMediaLibraryCb* m_cb; IMediaLibraryCb* m_cb;
std::unique_ptr<prober::IProbe> m_probe; std::unique_ptr<prober::IProbe> m_probe;
}; };
......
...@@ -35,7 +35,7 @@ namespace medialibrary ...@@ -35,7 +35,7 @@ namespace medialibrary
namespace factory namespace factory
{ {
class FileSystemFactory : public IFileSystem class FileSystemFactory : public fs::IFileSystemFactory
{ {
// UUID -> Device instance map // UUID -> Device instance map
using DeviceCacheMap = std::unordered_map<std::string, std::shared_ptr<fs::IDevice>>; using DeviceCacheMap = std::unordered_map<std::string, std::shared_ptr<fs::IDevice>>;
......
...@@ -35,7 +35,7 @@ class IMediaLibraryCb; ...@@ -35,7 +35,7 @@ class IMediaLibraryCb;
namespace factory namespace factory
{ {
class NetworkFileSystemFactory : public factory::IFileSystem class NetworkFileSystemFactory : public fs::IFileSystemFactory
{ {
public: public:
/** /**
......
...@@ -36,7 +36,7 @@ namespace medialibrary ...@@ -36,7 +36,7 @@ namespace medialibrary
namespace fs namespace fs
{ {
medialibrary::fs::CommonDirectory::CommonDirectory( factory::IFileSystem& fsFactory ) medialibrary::fs::CommonDirectory::CommonDirectory( fs::IFileSystemFactory& fsFactory )
: m_fsFactory( fsFactory ) : m_fsFactory( fsFactory )
{ {
} }
......
...@@ -28,15 +28,15 @@ ...@@ -28,15 +28,15 @@
namespace medialibrary namespace medialibrary
{ {
namespace factory { class IFileSystem; }
namespace fs namespace fs
{ {
class IFileSystemFactory;
class CommonDirectory : public IDirectory class CommonDirectory : public IDirectory
{ {
public: public:
explicit CommonDirectory( factory::IFileSystem& fsFactory ); explicit CommonDirectory( fs::IFileSystemFactory& fsFactory );
virtual const std::vector<std::shared_ptr<IFile>>& files() const override; virtual const std::vector<std::shared_ptr<IFile>>& files() const override;
virtual const std::vector<std::shared_ptr<IDirectory>>& dirs() const override; virtual const std::vector<std::shared_ptr<IDirectory>>& dirs() const override;
virtual std::shared_ptr<IDevice> device() const override; virtual std::shared_ptr<IDevice> device() const override;
...@@ -48,7 +48,7 @@ protected: ...@@ -48,7 +48,7 @@ protected:
mutable std::vector<std::shared_ptr<IFile>> m_files; mutable std::vector<std::shared_ptr<IFile>> m_files;
mutable std::vector<std::shared_ptr<IDirectory>> m_dirs; mutable std::vector<std::shared_ptr<IDirectory>> m_dirs;
mutable Cache<std::shared_ptr<IDevice>> m_device; mutable Cache<std::shared_ptr<IDevice>> m_device;
factory::IFileSystem& m_fsFactory; fs::IFileSystemFactory& m_fsFactory;
}; };
} }
......
...@@ -43,7 +43,7 @@ namespace medialibrary ...@@ -43,7 +43,7 @@ namespace medialibrary
namespace fs namespace fs
{ {
NetworkDirectory::NetworkDirectory( const std::string& mrl, factory::IFileSystem& fsFactory ) NetworkDirectory::NetworkDirectory( const std::string& mrl, fs::IFileSystemFactory& fsFactory )
: CommonDirectory( fsFactory ) : CommonDirectory( fsFactory )
, m_mrl( utils::file::toFolderPath( mrl ) ) , m_mrl( utils::file::toFolderPath( mrl ) )
{ {
......
...@@ -29,7 +29,7 @@ namespace fs ...@@ -29,7 +29,7 @@ namespace fs
class NetworkDirectory : public CommonDirectory class NetworkDirectory : public CommonDirectory
{ {
public: public:
NetworkDirectory(const std::string& mrl, factory::IFileSystem& fsFactory ); NetworkDirectory(const std::string& mrl, fs::IFileSystemFactory& fsFactory );
virtual const std::string& mrl() const override; virtual const std::string& mrl() const override;
private: private:
......
...@@ -46,7 +46,7 @@ namespace medialibrary ...@@ -46,7 +46,7 @@ namespace medialibrary
namespace fs namespace fs
{ {
Directory::Directory( const std::string& mrl, factory::IFileSystem& fsFactory ) Directory::Directory( const std::string& mrl, fs::IFileSystemFactory& fsFactory )
: CommonDirectory( fsFactory ) : CommonDirectory( fsFactory )
{ {
m_path = utils::file::toFolderPath( toAbsolute( utils::file::toLocalPath( mrl ) ) ); m_path = utils::file::toFolderPath( toAbsolute( utils::file::toLocalPath( mrl ) ) );
......
...@@ -35,7 +35,7 @@ namespace fs ...@@ -35,7 +35,7 @@ namespace fs
class Directory : public CommonDirectory class Directory : public CommonDirectory
{ {
public: public:
Directory( const std::string& mrl, factory::IFileSystem& fsFactory ); Directory( const std::string& mrl, fs::IFileSystemFactory& fsFactory );
const std::string& mrl() const override; const std::string& mrl() const override;
private: private:
......
...@@ -43,7 +43,7 @@ namespace medialibrary ...@@ -43,7 +43,7 @@ namespace medialibrary
namespace fs namespace fs
{ {
Directory::Directory( const std::string& mrl , factory::IFileSystem& fsFactory ) Directory::Directory( const std::string& mrl , fs::IFileSystemFactory& fsFactory )
: CommonDirectory( fsFactory ) : CommonDirectory( fsFactory )
{ {
m_path = utils::file::toFolderPath( toAbsolute( utils::file::toLocalPath( mrl ) ) ); m_path = utils::file::toFolderPath( toAbsolute( utils::file::toLocalPath( mrl ) ) );
......
...@@ -33,7 +33,7 @@ namespace fs ...@@ -33,7 +33,7 @@ namespace fs
class Directory : public CommonDirectory class Directory : public CommonDirectory
{ {
public: public:
Directory( const std::string& mrl, factory::IFileSystem& fsFactory ); Directory( const std::string& mrl, fs::IFileSystemFactory& fsFactory );
const std::string& mrl() const override; const std::string& mrl() const override;
private: private:
......
...@@ -143,7 +143,7 @@ std::shared_ptr<Device> MediaLibraryTester::addDevice( const std::string& uuid, ...@@ -143,7 +143,7 @@ std::shared_ptr<Device> MediaLibraryTester::addDevice( const std::string& uuid,
return Device::create( this, uuid, "file://", isRemovable ); return Device::create( this, uuid, "file://", isRemovable );
} }
void MediaLibraryTester::setFsFactory( std::shared_ptr<factory::IFileSystem> fsf ) void MediaLibraryTester::setFsFactory( std::shared_ptr<fs::IFileSystemFactory> fsf )
{ {
fsFactory = fsf; fsFactory = fsf;
} }
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
void deleteGenre( int64_t genreId ); void deleteGenre( int64_t genreId );
void deleteArtist( int64_t artistId ); void deleteArtist( int64_t artistId );
std::shared_ptr<Device> addDevice( const std::string& uuid, bool isRemovable ); std::shared_ptr<Device> addDevice( const std::string& uuid, bool isRemovable );
void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory ); void setFsFactory( std::shared_ptr<fs::IFileSystemFactory> fsFactory );
void deleteTrack( int64_t trackId ); void deleteTrack( int64_t trackId );
std::shared_ptr<AlbumTrack> albumTrack( int64_t id ); std::shared_ptr<AlbumTrack> albumTrack( int64_t id );
// Use to run tests that fiddles with file properties (modification dates, size...) // Use to run tests that fiddles with file properties (modification dates, size...)
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
private: private:
std::shared_ptr<fs::IDirectory> dummyDirectory; std::shared_ptr<fs::IDirectory> dummyDirectory;
std::shared_ptr<factory::IFileSystem> fsFactory; std::shared_ptr<fs::IFileSystemFactory> fsFactory;
std::shared_ptr<Folder> dummyFolder; std::shared_ptr<Folder> dummyFolder;
}; };
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
namespace mock namespace mock
{ {
struct FileSystemFactory : public factory::IFileSystem struct FileSystemFactory : public fs::IFileSystemFactory
{ {
static const std::string Root; static const std::string Root;
static const std::string SubFolder; static const std::string SubFolder;
...@@ -344,7 +344,7 @@ class NoopDirectory : public fs::IDirectory ...@@ -344,7 +344,7 @@ class NoopDirectory : public fs::IDirectory
} }
}; };
class NoopFsFactory : public factory::IFileSystem class NoopFsFactory : public fs::IFileSystemFactory
{ {
public: public:
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& ) override virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& ) override
......
...@@ -43,12 +43,12 @@ void Tests::TearDown() ...@@ -43,12 +43,12 @@ void Tests::TearDown()
ml.reset(); ml.reset();
} }
void Tests::Reload( std::shared_ptr<factory::IFileSystem> fs /*= nullptr*/, IMediaLibraryCb* metadataCb /*= nullptr*/ ) void Tests::Reload( std::shared_ptr<fs::IFileSystemFactory> fs /*= nullptr*/, IMediaLibraryCb* metadataCb /*= nullptr*/ )
{ {
InstantiateMediaLibrary(); InstantiateMediaLibrary();
if ( fs == nullptr ) if ( fs == nullptr )
{ {
fs = std::shared_ptr<factory::IFileSystem>( new mock::NoopFsFactory ); fs = std::shared_ptr<fs::IFileSystemFactory>( new mock::NoopFsFactory );
} }
if ( metadataCb == nullptr ) if ( metadataCb == nullptr )
{ {
......
...@@ -33,11 +33,11 @@ class Tests : public testing::Test ...@@ -33,11 +33,11 @@ class Tests : public testing::Test
protected: protected:
std::unique_ptr<MediaLibraryTester> ml; std::unique_ptr<MediaLibraryTester> ml;
std::unique_ptr<mock::NoopCallback> cbMock; std::unique_ptr<mock::NoopCallback> cbMock;
std::shared_ptr<factory::IFileSystem> fsFactory; std::shared_ptr<fs::IFileSystemFactory> fsFactory;
std::shared_ptr<mock::MockDeviceLister> mockDeviceLister; std::shared_ptr<mock::MockDeviceLister> mockDeviceLister;
virtual void SetUp() override; virtual void SetUp() override;
virtual void InstantiateMediaLibrary(); virtual void InstantiateMediaLibrary();
void Reload( std::shared_ptr<factory::IFileSystem> fs = nullptr, IMediaLibraryCb* metadataCb = nullptr ); void Reload( std::shared_ptr<fs::IFileSystemFactory> fs = nullptr, IMediaLibraryCb* metadataCb = nullptr );
virtual void TearDown() override; virtual void TearDown() override;
}; };
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