diff options
Diffstat (limited to 'src/image.hh')
| -rw-r--r-- | src/image.hh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/image.hh b/src/image.hh new file mode 100644 index 0000000..b9644b7 --- /dev/null +++ b/src/image.hh @@ -0,0 +1,67 @@ +#ifndef IMAGE_HH +#define IMAGE_HH + +#include "date.hh" +#include "location.hh" +#include "rotation.hh" + +#include <filesystem> +#include <memory> + +class RoBuffer; + +class Image { +public: + virtual ~Image() = default; + + class Thumbnail { + public: + virtual ~Thumbnail() = default; + + virtual std::string_view mime_type() const = 0; + virtual uint64_t size() const = 0; + + protected: + Thumbnail() = default; + }; + + static std::unique_ptr<Image> load(std::filesystem::path const& path); + + virtual uint64_t width() const = 0; + virtual uint64_t height() const = 0; + virtual Location location() const = 0; + virtual Rotation rotation() const = 0; + virtual Date date() const = 0; + + virtual Thumbnail* thumbnail() const = 0; + +protected: + Image() = default; + Image(Image const&) = delete; + Image& operator=(Image const&) = delete; +}; + +class ThumbnailReader { +public: + virtual ~ThumbnailReader() = default; + + static std::unique_ptr<ThumbnailReader> create(); + + enum class Return { + NEED_MORE, // Call drain() again if you want data. + DONE, // Data is available, no need to call drain() again. + ERR, // Error, no data will ever be available. + }; + + virtual Return drain(RoBuffer* in, size_t* bytes = nullptr) = 0; + + // Returns empty until drain() returns Return::DONE. + virtual std::string_view data() const = 0; + +protected: + ThumbnailReader() = default; + ThumbnailReader(ThumbnailReader const&) = delete; + ThumbnailReader& operator=(ThumbnailReader const&) = delete; +}; + +#endif // IMAGE_HH |
