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
class IDirectory;
class IFile;
class IDevice;
}
namespace factory
{
class IFileSystem
class IFileSystemFactory
{
public:
virtual ~IFileSystem() = default;
virtual ~IFileSystemFactory() = default;
///
/// \brief createDirectory creates a representation of a directory
/// \note This method can fail by throwing an exception if the
......
......@@ -1200,7 +1200,7 @@ IDeviceListerCb* MediaLibrary::setDeviceLister( DeviceListerPtr lister )
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 )
{
......@@ -1221,7 +1221,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
#ifdef HAVE_LIBVLC
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();
});
if ( it == end( m_fsFactories ) )
......@@ -1229,7 +1229,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
}
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();
}), end( m_fsFactories ) );
}
......@@ -1279,7 +1279,7 @@ void MediaLibrary::setLogger( ILogger* 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
// if the user only discovered removable storages, and we would still need to mark those
......
......@@ -46,15 +46,11 @@ class Folder;
class Genre;
class Playlist;
namespace factory
{
class IFileSystem;
}
namespace fs
{
class IFile;
class IDirectory;
class IFileSystemFactory;
}
namespace parser
......@@ -160,9 +156,9 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
std::shared_ptr<ModificationNotifier> getNotifier() const;
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;
......@@ -200,7 +196,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
void registerEntityHooks();
static bool validateSearchPattern( const std::string& pattern );
// Returns true if the device actually changed
bool onDeviceChanged( factory::IFileSystem& fsFactory, Device& device );
bool onDeviceChanged( fs::IFileSystemFactory& fsFactory, Device& device );
protected:
virtual void addLocalFsFactory();
......@@ -214,7 +210,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
protected:
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;
IMediaLibraryCb* m_callback;
DeviceListerPtr m_deviceLister;
......
......@@ -58,7 +58,7 @@ public:
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_fsFactory( std::move( fsFactory ))
, m_cb( cb )
......
......@@ -41,7 +41,7 @@ class IProbe;
class FsDiscoverer : public IDiscoverer
{
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 reload() override;
virtual bool reload( const std::string& entryPoint ) override;
......@@ -61,7 +61,7 @@ private:
private:
MediaLibrary* m_ml;
std::shared_ptr<factory::IFileSystem> m_fsFactory;
std::shared_ptr<fs::IFileSystemFactory> m_fsFactory;
IMediaLibraryCb* m_cb;
std::unique_ptr<prober::IProbe> m_probe;
};
......
......@@ -35,7 +35,7 @@ namespace medialibrary
namespace factory
{
class FileSystemFactory : public IFileSystem
class FileSystemFactory : public fs::IFileSystemFactory
{
// UUID -> Device instance map
using DeviceCacheMap = std::unordered_map<std::string, std::shared_ptr<fs::IDevice>>;
......
......@@ -35,7 +35,7 @@ class IMediaLibraryCb;
namespace factory
{
class NetworkFileSystemFactory : public factory::IFileSystem
class NetworkFileSystemFactory : public fs::IFileSystemFactory
{
public:
/**
......
......@@ -36,7 +36,7 @@ namespace medialibrary
namespace fs
{
medialibrary::fs::CommonDirectory::CommonDirectory( factory::IFileSystem& fsFactory )
medialibrary::fs::CommonDirectory::CommonDirectory( fs::IFileSystemFactory& fsFactory )
: m_fsFactory( fsFactory )
{
}
......
......@@ -28,15 +28,15 @@
namespace medialibrary
{
namespace factory { class IFileSystem; }
namespace fs
{
class IFileSystemFactory;
class CommonDirectory : public IDirectory
{
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<IDirectory>>& dirs() const override;
virtual std::shared_ptr<IDevice> device() const override;
......@@ -48,7 +48,7 @@ protected:
mutable std::vector<std::shared_ptr<IFile>> m_files;
mutable std::vector<std::shared_ptr<IDirectory>> m_dirs;
mutable Cache<std::shared_ptr<IDevice>> m_device;
factory::IFileSystem& m_fsFactory;
fs::IFileSystemFactory& m_fsFactory;
};
}
......
......@@ -43,7 +43,7 @@ namespace medialibrary
namespace fs
{
NetworkDirectory::NetworkDirectory( const std::string& mrl, factory::IFileSystem& fsFactory )
NetworkDirectory::NetworkDirectory( const std::string& mrl, fs::IFileSystemFactory& fsFactory )
: CommonDirectory( fsFactory )
, m_mrl( utils::file::toFolderPath( mrl ) )
{
......
......@@ -29,7 +29,7 @@ namespace fs
class NetworkDirectory : public CommonDirectory
{
public:
NetworkDirectory(const std::string& mrl, factory::IFileSystem& fsFactory );
NetworkDirectory(const std::string& mrl, fs::IFileSystemFactory& fsFactory );
virtual const std::string& mrl() const override;
private:
......
......@@ -46,7 +46,7 @@ namespace medialibrary
namespace fs
{
Directory::Directory( const std::string& mrl, factory::IFileSystem& fsFactory )
Directory::Directory( const std::string& mrl, fs::IFileSystemFactory& fsFactory )
: CommonDirectory( fsFactory )
{
m_path = utils::file::toFolderPath( toAbsolute( utils::file::toLocalPath( mrl ) ) );
......
......@@ -35,7 +35,7 @@ namespace fs
class Directory : public CommonDirectory
{
public:
Directory( const std::string& mrl, factory::IFileSystem& fsFactory );
Directory( const std::string& mrl, fs::IFileSystemFactory& fsFactory );
const std::string& mrl() const override;
private:
......
......@@ -43,7 +43,7 @@ namespace medialibrary
namespace fs
{
Directory::Directory( const std::string& mrl , factory::IFileSystem& fsFactory )
Directory::Directory( const std::string& mrl , fs::IFileSystemFactory& fsFactory )
: CommonDirectory( fsFactory )
{
m_path = utils::file::toFolderPath( toAbsolute( utils::file::toLocalPath( mrl ) ) );
......
......@@ -33,7 +33,7 @@ namespace fs
class Directory : public CommonDirectory
{
public:
Directory( const std::string& mrl, factory::IFileSystem& fsFactory );
Directory( const std::string& mrl, fs::IFileSystemFactory& fsFactory );
const std::string& mrl() const override;
private:
......
......@@ -143,7 +143,7 @@ std::shared_ptr<Device> MediaLibraryTester::addDevice( const std::string& uuid,
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;
}
......
......@@ -54,7 +54,7 @@ public:
void deleteGenre( int64_t genreId );
void deleteArtist( int64_t artistId );
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 );
std::shared_ptr<AlbumTrack> albumTrack( int64_t id );
// Use to run tests that fiddles with file properties (modification dates, size...)
......@@ -76,7 +76,7 @@ public:
private:
std::shared_ptr<fs::IDirectory> dummyDirectory;
std::shared_ptr<factory::IFileSystem> fsFactory;
std::shared_ptr<fs::IFileSystemFactory> fsFactory;
std::shared_ptr<Folder> dummyFolder;
};
......
......@@ -43,7 +43,7 @@
namespace mock
{
struct FileSystemFactory : public factory::IFileSystem
struct FileSystemFactory : public fs::IFileSystemFactory
{
static const std::string Root;
static const std::string SubFolder;
......@@ -344,7 +344,7 @@ class NoopDirectory : public fs::IDirectory
}
};
class NoopFsFactory : public factory::IFileSystem
class NoopFsFactory : public fs::IFileSystemFactory
{
public:
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& ) override
......
......@@ -43,12 +43,12 @@ void Tests::TearDown()
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();
if ( fs == nullptr )
{
fs = std::shared_ptr<factory::IFileSystem>( new mock::NoopFsFactory );
fs = std::shared_ptr<fs::IFileSystemFactory>( new mock::NoopFsFactory );
}
if ( metadataCb == nullptr )
{
......
......@@ -33,11 +33,11 @@ class Tests : public testing::Test
protected:
std::unique_ptr<MediaLibraryTester> ml;
std::unique_ptr<mock::NoopCallback> cbMock;
std::shared_ptr<factory::IFileSystem> fsFactory;
std::shared_ptr<fs::IFileSystemFactory> fsFactory;
std::shared_ptr<mock::MockDeviceLister> mockDeviceLister;
virtual void SetUp() override;
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;
};
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