namespace Msp {
namespace Graphics {
-ImageLoader::Register<DevilLoader> DevilLoader::reg;
-
DevilLoader::DevilLoader(IO::Seekable &i):
io(i)
{
namespace Msp {
namespace Graphics {
-class DevilLoader: public ImageLoader
+class DevilLoader: public RegisteredImageLoader<DevilLoader>
{
private:
IO::Base &io;
unsigned id;
- static Register<DevilLoader> reg;
-
public:
DevilLoader(IO::Seekable &);
virtual ~DevilLoader();
class ImageLoader
{
-private:
+protected:
class RegisterBase
{
protected:
virtual ImageLoader *create(IO::Seekable &) const = 0;
};
-protected:
- template<typename T>
- class Register: 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 T *create(IO::Seekable &io) const { return new T(io); }
- };
-
private:
IO::Base *source;
virtual void load(Image::Data &) = 0;
};
+
+template<typename T>
+class RegisteredImageLoader: public ImageLoader
+{
+private:
+ class Register: 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); }
+ };
+
+ static Register reg;
+
+protected:
+ RegisteredImageLoader() { (void)reg; }
+};
+
+template<typename T>
+typename RegisteredImageLoader<T>::Register RegisteredImageLoader<T>::reg;
+
} // namespace Graphics
} // namespace Msp
};
-ImageLoader::Register<JpegLoader> JpegLoader::reg;
-
JpegLoader::JpegLoader(IO::Seekable &io):
priv(new Private)
{
namespace Msp {
namespace Graphics {
-class JpegLoader: public ImageLoader
+class JpegLoader: public RegisteredImageLoader<JpegLoader>
{
private:
struct Private;
Private *priv;
- static Register<JpegLoader> reg;
-
public:
JpegLoader(IO::Seekable &);
virtual ~JpegLoader();
png_info *info;
};
-ImageLoader::Register<PngLoader> PngLoader::reg;
PngLoader::PngLoader(IO::Base &io, unsigned sig_bytes):
priv(new Private)
namespace Msp {
namespace Graphics {
-class PngLoader: public ImageLoader
+class PngLoader: public RegisteredImageLoader<PngLoader>
{
private:
struct Private;
Private *priv;
- static Register<PngLoader> reg;
-
public:
PngLoader(IO::Base &, unsigned = 0);
virtual ~PngLoader();
};
-ImageLoader::Register<QuartzLoader> QuartzLoader::reg;
-
QuartzLoader::QuartzLoader(IO::Seekable &io):
priv(new Private)
{
namespace Msp {
namespace Graphics {
-class QuartzLoader: public ImageLoader
+class QuartzLoader: public RegisteredImageLoader<QuartzLoader>
{
private:
struct Private;
Private *priv;
- static Register<QuartzLoader> reg;
-
public:
QuartzLoader(IO::Seekable &);
virtual ~QuartzLoader();