synfig-core  1.0.3
importer.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
21 /* ========================================================================= */
22 
23 /* === S T A R T =========================================================== */
24 
25 #ifndef __SYNFIG_IMPORTER_H
26 #define __SYNFIG_IMPORTER_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include <cstdio>
31 #include <map>
32 #include <ETL/handle>
33 #include "string.h"
34 #include "time.h"
35 #include "gamma.h"
36 #include "renddesc.h"
37 #include "filesystem.h"
38 
39 /* === M A C R O S ========================================================= */
40 
43 #define SYNFIG_IMPORTER_MODULE_EXT \
44  public: static const char name__[], version__[], ext__[],cvs_id__[]; \
45  static const bool supports_file_system_wrapper__; \
46  static synfig::Importer *create(const synfig::FileSystem::Identifier &identifier);
47 
49 #define SYNFIG_IMPORTER_MODULE_CONSTRUCTOR_DERIVED(class, parent) \
50  public: class(const synfig::FileSystem::Identifier &identifier): parent(identifier) { }
51 
53 #define SYNFIG_IMPORTER_MODULE_CONSTRUCTOR(class) \
54  SYNFIG_IMPORTER_MODULE_CONSTRUCTOR_DERIVED(class, synfig::Importer)
55 
59 #define SYNFIG_IMPORTER_MODULE_DECLARATIONS_DERIVED(class, parent) \
60  SYNFIG_IMPORTER_MODULE_EXT \
61  SYNFIG_IMPORTER_MODULE_CONSTRUCTOR_DERIVED(class, parent)
62 
66 #define SYNFIG_IMPORTER_MODULE_DECLARATIONS(class) \
67  SYNFIG_IMPORTER_MODULE_EXT \
68  SYNFIG_IMPORTER_MODULE_CONSTRUCTOR(class)
69 
71 #define SYNFIG_IMPORTER_SET_NAME(class,x) const char class::name__[]=x
72 
74 #define SYNFIG_IMPORTER_SET_EXT(class,x) const char class::ext__[]=x
75 
77 #define SYNFIG_IMPORTER_SET_VERSION(class,x) const char class::version__[]=x
78 
80 #define SYNFIG_IMPORTER_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
81 
83 #define SYNFIG_IMPORTER_SET_SUPPORTS_FILE_SYSTEM_WRAPPER(class,x) const bool class::supports_file_system_wrapper__=x
84 
87 #define SYNFIG_IMPORTER_INIT(class) synfig::Importer* class::create(const synfig::FileSystem::Identifier &identifier) { return new class(identifier); }
88 
89 /* === T Y P E D E F S ===================================================== */
90 
91 /* === C L A S S E S & S T R U C T S ======================================= */
92 
93 namespace synfig {
94 
95 class Surface;
96 class ProgressCallback;
97 
110 class Importer : public etl::shared_object
111 {
112 public:
115  typedef Importer* (*Factory)(const FileSystem::Identifier &identifier);
116 
117  struct BookEntry
118  {
121 
124  factory(factory), supports_file_system_wrapper(supports_file_system_wrapper)
125  { }
126  };
127 
128  typedef std::map<std::string,BookEntry> Book;
129  static Book* book_;
130 
131  static Book& book();
132 
135  static bool subsys_init();
138  static bool subsys_stop();
139 
140  typedef etl::handle<Importer> Handle;
141  typedef etl::loose_handle<Importer> LooseHandle;
142  typedef etl::handle<const Importer> ConstHandle;
143 
144 private:
147  Gamma gamma_;
148 
149 protected:
150 
152 
153 public:
155 
156  Gamma& gamma() { return gamma_; }
157  const Gamma& gamma()const { return gamma_; }
158 
159  virtual ~Importer();
160 
162 
169  virtual bool get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *callback=NULL)=0;
170  virtual bool get_frame(Surface &surface, const RendDesc &renddesc,Time time,
171  bool &trimmed __attribute__ ((unused)),
172  unsigned int &width __attribute__ ((unused)),
173  unsigned int &height __attribute__ ((unused)),
174  unsigned int &top __attribute__ ((unused)),
175  unsigned int &left __attribute__ ((unused)),
176  ProgressCallback *callback=NULL)
177  {
178  return get_frame(surface,renddesc,time,callback);
179  }
180 
182  virtual bool is_animated() { return false; }
183 
186 };
187 
188 }; // END of namespace synfig
189 
190 /* === E N D =============================================================== */
191 
192 #endif