kimageiofactory.h

00001 /*
00002 * kimgio.h -- Declaration of interface to the KDE Image IO library.
00003 * Sirtaj Singh Kang <taj@kde.org>, 23 Sep 1998.
00004 *
00005 * This library is distributed under the conditions of the GNU LGPL.
00006 */
00007 
00008 #ifndef SSK_KIMGIOFACTORY_H
00009 #define SSK_KIMGIOFACTORY_H
00010 
00011 #include "ksycocafactory.h"
00012 #include "kimageio.h"
00013 
00014 class KImageIOFormat;
00015 class KImageIOFormatList;
00016 
00018 class KIO_EXPORT KImageIOFormat : public KSycocaEntry
00019 {
00020   K_SYCOCATYPE( KST_KImageIOFormat, KSycocaEntry )
00021 
00022 public:
00023   typedef KSharedPtr<KImageIOFormat> Ptr;
00024   typedef QValueList<Ptr> List;
00025 public: // KDoc seems to barf on those typedefs and generates no docs after them
00029   KImageIOFormat( const QString & path);
00030   
00034   KImageIOFormat( QDataStream& _str, int offset);
00035 
00036   virtual ~KImageIOFormat();
00037 
00038   virtual QString name() const { return mType; }
00039 
00040   virtual bool isValid() const { return true; } 
00041 
00046   virtual void load(QDataStream& ); 
00047 
00052   virtual void save(QDataStream& );
00053 
00058   void callLibFunc( bool read, QImageIO *);
00059 
00060 public:  
00061   QString mType;
00062   QString mHeader;
00063   QString mFlags;
00064   bool bRead;
00065   bool bWrite;
00066   QStringList mSuffices;
00067   QString mPattern;
00068   QString mMimetype;
00069   QString mLib;
00070   QStringList rPaths;
00071   bool bLibLoaded;
00072   void (*mReadFunc)(QImageIO *);
00073   void (*mWriteFunc)(QImageIO *);
00074 protected:
00075   virtual void virtual_hook( int id, void* data );
00076 };
00077 
00079 class KIO_EXPORT KImageIOFormatList : public KImageIOFormat::List
00080 {
00081 public:
00082    KImageIOFormatList() { }
00083 };
00084 
00085 
00087 class KIO_EXPORT KImageIOFactory : public KSycocaFactory
00088 {
00089   friend class KImageIO;
00090   K_SYCOCAFACTORY( KST_KImageIO )
00091 public:
00092   static KImageIOFactory *self() 
00093   { if (!_self) new KImageIOFactory(); return _self; }
00094   KImageIOFactory();
00095   virtual ~KImageIOFactory();
00096 
00097 protected: // Internal stuff
00103   void load();
00104 
00108   QString createPattern( KImageIO::Mode _mode);
00109 
00113   virtual KSycocaEntry *createEntry(const QString &, const char *)
00114     { return 0; }                                                    
00115 
00119   virtual KSycocaEntry *createEntry(int offset);
00120 
00124   static void readImage( QImageIO *iio);
00125 
00129   static void writeImage( QImageIO *iio);
00130   
00131 protected:
00132   static KImageIOFactory *_self;  
00133   static KImageIOFormatList *formatList;
00134   QString mReadPattern;
00135   QString mWritePattern;
00136   QStringList rPath;
00137 protected:
00138     virtual void virtual_hook( int id, void* data );
00139 };
00140 
00141 #endif
00142 
KDE Home | KDE Accessibility Home | Description of Access Keys