00001 #include <cstdio>
00002
00022
00023
00024
00025
00026 #ifndef __SYNFIG_IMPORTER_H
00027 #define __SYNFIG_IMPORTER_H
00028
00029
00030
00031 #include <map>
00032
00033 #include <ETL/handle>
00034 #include "string.h"
00035
00036
00037
00038 #include "time.h"
00039 #include "gamma.h"
00040
00041
00042
00044 #define SYNFIG_IMPORTER_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Importer *create(const char *filename);
00045
00047 #define SYNFIG_IMPORTER_SET_NAME(class,x) const char class::name__[]=x
00048
00050 #define SYNFIG_IMPORTER_SET_EXT(class,x) const char class::ext__[]=x
00051
00053 #define SYNFIG_IMPORTER_SET_VERSION(class,x) const char class::version__[]=x
00054
00056 #define SYNFIG_IMPORTER_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
00057
00059 #define SYNFIG_IMPORTER_INIT(class) synfig::Importer* class::create(const char *filename) { return new class(filename); }
00060
00061
00062
00063
00064
00065 namespace synfig {
00066
00067 class Surface;
00068 class ProgressCallback;
00069
00074 class Importer : public etl::shared_object
00075 {
00076 public:
00077 typedef Importer* (*Factory)(const char *filename);
00078 typedef std::map<String,Factory> Book;
00079 static Book* book_;
00080
00081 static Book& book();
00082
00083 static bool subsys_init();
00084 static bool subsys_stop();
00085
00086 typedef etl::handle<Importer> Handle;
00087 typedef etl::loose_handle<Importer> LooseHandle;
00088 typedef etl::handle<const Importer> ConstHandle;
00089
00090 private:
00091 Gamma gamma_;
00092
00093 protected:
00094 Importer();
00095
00096 public:
00097
00098 Gamma& gamma() { return gamma_; }
00099 const Gamma& gamma()const { return gamma_; }
00100
00101 virtual ~Importer();
00102
00104
00111 virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL)=0;
00112 virtual bool get_frame(Surface &surface,Time time,
00113 bool &trimmed __attribute__ ((unused)),
00114 unsigned int &width __attribute__ ((unused)), unsigned int &height __attribute__ ((unused)),
00115 unsigned int &top __attribute__ ((unused)), unsigned int &left __attribute__ ((unused)),
00116 ProgressCallback *callback=NULL) {
00117 return get_frame(surface,time,callback);
00118 }
00119
00121 virtual bool is_animated() { return false; }
00122
00124 static Handle open(const String &filename);
00125 };
00126
00127 };
00128
00129
00130
00131 #endif