mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
More SectorInterface refactoring.
This commit is contained in:
@@ -67,6 +67,7 @@ LIBFLUXENGINE_SRCS = \
|
||||
lib/vfs/brother120fs.cc \
|
||||
lib/vfs/acorndfs.cc \
|
||||
lib/vfs/vfs.cc \
|
||||
lib/vfs/imagesectorinterface.cc \
|
||||
|
||||
LIBFLUXENGINE_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(LIBFLUXENGINE_SRCS))
|
||||
OBJS += $(LIBFLUXENGINE_OBJS)
|
||||
|
||||
31
lib/vfs/imagesectorinterface.cc
Normal file
31
lib/vfs/imagesectorinterface.cc
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "lib/globals.h"
|
||||
#include "lib/vfs/sectorinterface.h"
|
||||
#include "lib/image.h"
|
||||
|
||||
class ImageSectorInterface : public SectorInterface
|
||||
{
|
||||
public:
|
||||
ImageSectorInterface(std::shared_ptr<Image> image):
|
||||
_image(image)
|
||||
{}
|
||||
|
||||
public:
|
||||
std::shared_ptr<const Sector> get(unsigned track, unsigned side, unsigned sectorId)
|
||||
{
|
||||
return _image->get(track, side, sectorId);
|
||||
}
|
||||
|
||||
std::shared_ptr<Sector> put(unsigned track, unsigned side, unsigned sectorId)
|
||||
{
|
||||
return _image->put(track, side, sectorId);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Image> _image;
|
||||
};
|
||||
|
||||
std::unique_ptr<SectorInterface> SectorInterface::createImageSectorInterface(std::shared_ptr<Image> image)
|
||||
{
|
||||
return std::make_unique<ImageSectorInterface>(image);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SECTORINTERFACE_H
|
||||
|
||||
class Image;
|
||||
class Sector;
|
||||
|
||||
class SectorInterface
|
||||
{
|
||||
@@ -10,28 +11,9 @@ public:
|
||||
virtual std::shared_ptr<Sector> put(unsigned track, unsigned side, unsigned sectorId) = 0;
|
||||
|
||||
virtual void flush() {}
|
||||
};
|
||||
|
||||
class ImageSectorInterface : public SectorInterface
|
||||
{
|
||||
public:
|
||||
ImageSectorInterface(std::shared_ptr<Image> image):
|
||||
_image(image)
|
||||
{}
|
||||
|
||||
public:
|
||||
std::shared_ptr<const Sector> get(unsigned track, unsigned side, unsigned sectorId)
|
||||
{
|
||||
return _image->get(track, side, sectorId);
|
||||
}
|
||||
|
||||
std::shared_ptr<Sector> put(unsigned track, unsigned side, unsigned sectorId)
|
||||
{
|
||||
return _image->put(track, side, sectorId);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Image> _image;
|
||||
static std::unique_ptr<SectorInterface> createImageSectorInterface(std::shared_ptr<Image> image);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ int mainGetFileInfo(int argc, const char* argv[])
|
||||
|
||||
auto reader = ImageReader::create(config.image_reader());
|
||||
std::shared_ptr<Image> image(std::move(reader->readImage()));
|
||||
sectorInterface = std::make_shared<ImageSectorInterface>(image);
|
||||
sectorInterface = SectorInterface::createImageSectorInterface(image);
|
||||
auto filesystem =
|
||||
Filesystem::createFilesystem(config.filesystem(), sectorInterface);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ int mainLs(int argc, const char* argv[])
|
||||
|
||||
auto reader = ImageReader::create(config.image_reader());
|
||||
std::shared_ptr<Image> image(std::move(reader->readImage()));
|
||||
sectorInterface = std::make_shared<ImageSectorInterface>(image);
|
||||
sectorInterface = SectorInterface::createImageSectorInterface(image);
|
||||
auto filesystem =
|
||||
Filesystem::createFilesystem(config.filesystem(), sectorInterface);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user