Skip to content

Commit

Permalink
removed inheritence from File
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfrojdh committed Mar 27, 2024
1 parent d07f867 commit 130f674
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
29 changes: 15 additions & 14 deletions file_io/include/aare/File.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "aare/FileInterface.hpp"
class File : public FileInterface {
class File {
private:
FileInterface *file_impl;

Expand All @@ -10,19 +10,20 @@ class File : public FileInterface {
// - a appending (appends to existing file)
// TODO! do we need to support w+, r+ and a+?
File(std::filesystem::path fname, std::string mode);
Frame read() override;
std::vector<Frame> read(size_t n_frames) override;
void read_into(std::byte *image_buf) override;
void read_into(std::byte *image_buf, size_t n_frames) override;
size_t frame_number(size_t frame_index) override;
size_t bytes_per_frame() override;
size_t pixels() override;
void seek(size_t frame_number) override;
size_t tell() override;
size_t total_frames() const override ;
ssize_t rows() const override ;
ssize_t cols() const override ;
ssize_t bitdepth() const override ;
Frame read();
Frame iread(size_t frame_number);
std::vector<Frame> read(size_t n_frames);
void read_into(std::byte *image_buf);
void read_into(std::byte *image_buf, size_t n_frames);
size_t frame_number(size_t frame_index);
size_t bytes_per_frame();
size_t pixels();
void seek(size_t frame_number);
size_t tell() const;
size_t total_frames() const;
ssize_t rows() const;
ssize_t cols() const;
ssize_t bitdepth() const;
File(File &&other);


Expand Down
6 changes: 5 additions & 1 deletion file_io/src/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ size_t File::frame_number(size_t frame_index) { return file_impl->frame_number(f
size_t File::bytes_per_frame() { return file_impl->bytes_per_frame(); }
size_t File::pixels() { return file_impl->pixels(); }
void File::seek(size_t frame_number) { file_impl->seek(frame_number); }
size_t File::tell() { return file_impl->tell(); }
size_t File::tell() const{ return file_impl->tell(); }
ssize_t File::rows() const { return file_impl->rows(); }
ssize_t File::cols() const { return file_impl->cols(); }
ssize_t File::bitdepth() const { return file_impl->bitdepth(); }
File::~File() {
delete file_impl;
}

Frame File::iread(size_t frame_number) {
return file_impl->iread(frame_number);
}

File::File(File &&other) {
file_impl = other.file_impl;
other.file_impl = nullptr;
Expand Down

0 comments on commit 130f674

Please sign in to comment.