X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fimageloader.h;h=53c9e7b7c88ffe04c5fc5ad098cc14ac7acafaf2;hb=72ed51af9656b47a331cf29565a0bdfd35f19847;hp=cb3f54ac204f303afe23e5bfc30b111ece28f33a;hpb=2ebdf45974a0a7649b3488f9da4b8cf90a1db584;p=libs%2Fgui.git diff --git a/source/graphics/imageloader.h b/source/graphics/imageloader.h index cb3f54a..53c9e7b 100644 --- a/source/graphics/imageloader.h +++ b/source/graphics/imageloader.h @@ -10,14 +10,12 @@ class unsupported_image_format: public std::runtime_error { public: unsupported_image_format(const std::string &w): std::runtime_error(w) { } - virtual ~unsupported_image_format() throw() { } }; class bad_image_data: public std::runtime_error { public: bad_image_data(const std::string &w): std::runtime_error(w) { } - virtual ~bad_image_data() throw() { } }; @@ -27,6 +25,7 @@ public: enum State { INITIAL, + HEADERS_LOADED, FINISHED }; @@ -47,35 +46,37 @@ protected: class RegisteredLoader: public RegisterBase { public: - virtual unsigned get_signature_size() const { return T::get_signature_size(); } - virtual bool detect(const std::string &s) const { return T::detect(s); } - virtual ImageLoader *create(IO::Seekable &io) const { return new T(io); } + unsigned get_signature_size() const override { return T::get_signature_size(); } + bool detect(const std::string &s) const override { return T::detect(s); } + ImageLoader *create(IO::Seekable &io) const override { return new T(io); } }; struct Registry { - std::list loaders; - bool changed; + std::vector loaders; + bool changed = false; - Registry(); ~Registry(); }; private: - IO::Base *source; - State state; + IO::Base *source = nullptr; + State state = INITIAL; protected: - ImageLoader(); + ImageLoader() = default; public: virtual ~ImageLoader(); + static bool detect_signature(const std::string &); static ImageLoader *open_file(const std::string &); static ImageLoader *open_io(IO::Seekable &); virtual void load(Image::Data &); + virtual void load_headers(Image::Data &); protected: - virtual void load_(Image::Data &) = 0; + virtual void load_headers_(Image::Data &) = 0; + virtual void load_pixels_(Image::Data &) = 0; public: State get_state() const { return state; }