+ class RegisterBase
+ {
+ protected:
+ RegisterBase() = default;
+ public:
+ virtual ~RegisterBase() = default;
+
+ virtual unsigned get_signature_size() const = 0;
+ virtual bool detect(const std::string &) const = 0;
+ virtual ImageLoader *create(IO::Seekable &) const = 0;
+ };
+
+ template<typename T>
+ class RegisteredLoader: public RegisterBase
+ {
+ public:
+ 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::vector<RegisterBase *> loaders;
+ bool changed = false;
+
+ ~Registry();
+ };
+
+private:
+ IO::Base *source = nullptr;
+ State state = INITIAL;