1 #ifndef MSP_GRAPHICS_IMAGELOADER_H_
2 #define MSP_GRAPHICS_IMAGELOADER_H_
9 class unsupported_image_format: public std::runtime_error
12 unsupported_image_format(const std::string &w): std::runtime_error(w) { }
13 virtual ~unsupported_image_format() throw() { }
16 class bad_image_data: public std::runtime_error
19 bad_image_data(const std::string &w): std::runtime_error(w) { }
20 virtual ~bad_image_data() throw() { }
32 virtual ~RegisterBase() { }
34 virtual unsigned get_signature_size() const = 0;
35 virtual bool detect(const std::string &) const = 0;
36 virtual ImageLoader *create(IO::Seekable &) const = 0;
42 static std::list<RegisterBase *> &get_registered_loaders();
43 static bool registered_loaders_changed;
44 static bool signature_size_compare(RegisterBase *, RegisterBase *);
49 virtual ~ImageLoader();
51 static ImageLoader *open_file(const std::string &);
52 static ImageLoader *open_io(IO::Seekable &);
54 virtual void load(Image::Data &) = 0;
59 class RegisteredImageLoader: public ImageLoader
61 friend class ImageLoader;
64 class Register: public RegisterBase
67 virtual unsigned get_signature_size() const { return T::get_signature_size(); }
68 virtual bool detect(const std::string &s) const { return T::detect(s); }
69 virtual ImageLoader *create(IO::Seekable &io) const { return new T(io); }
75 RegisteredImageLoader() { (void)reg; }
79 typename RegisteredImageLoader<T>::Register RegisteredImageLoader<T>::reg;
81 } // namespace Graphics