Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_05 / synfig-core / src / synfig / importer.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file importer.h
3 **      \brief writeme
4 **
5 **      $Id: importer.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
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 <map>
31 //#include <cmath>
32 #include <ETL/handle>
33 #include "string.h"
34 //#include "surface.h"
35 //#include "general.h"
36 //#include "vector.h"
37 #include "time.h"
38 #include "gamma.h"
39
40 /* === M A C R O S ========================================================= */
41
42 //! \writeme
43 #define SYNFIG_IMPORTER_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Importer *create(const char *filename);
44
45 //! Sets the name of the importer
46 #define SYNFIG_IMPORTER_SET_NAME(class,x) const char class::name__[]=x
47
48 //! \writeme
49 #define SYNFIG_IMPORTER_SET_EXT(class,x) const char class::ext__[]=x
50
51 //! Sets the version of the importer
52 #define SYNFIG_IMPORTER_SET_VERSION(class,x) const char class::version__[]=x
53
54 //! Sets the CVS ID of the importer
55 #define SYNFIG_IMPORTER_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
56
57 //! \writeme
58 #define SYNFIG_IMPORTER_INIT(class) synfig::Importer* class::create(const char *filename) { return new class(filename); }
59
60 /* === T Y P E D E F S ===================================================== */
61
62 /* === C L A S S E S & S T R U C T S ======================================= */
63
64 namespace synfig {
65
66 class Surface;
67 class ProgressCallback;
68
69 /*!     \class Importer
70 **      \brief Used for importing bitmaps of various formats, including animations
71 **      \todo Write more detailed description
72 */
73 class Importer : public etl::shared_object
74 {
75 public:
76         typedef Importer* (*Factory)(const char *filename);
77         typedef std::map<String,Factory> Book;
78         static Book* book_;
79         
80         static Book& book();
81         
82         static bool subsys_init();
83         static bool subsys_stop();
84
85         typedef etl::handle<Importer> Handle;
86         typedef etl::loose_handle<Importer> LooseHandle;
87         typedef etl::handle<const Importer> ConstHandle;
88
89 private:
90         Gamma gamma_;
91
92 protected:
93         Importer();
94
95 public:
96
97         Gamma& gamma() { return gamma_; }
98         const Gamma& gamma()const { return gamma_; }
99         
100         virtual ~Importer();
101
102         //! Gets a frame and puts it into \a surface
103         /*!     \param  surface Reference to surface to put frame into
104         **      \param  time    For animated importers, determines which frame to get.
105         **              For static importers, this parameter is unused.
106         **      \param  callback Pointer to callback class for progress, errors, etc.
107         **      \return \c true on success, \c false on error
108         **      \see ProgressCallback, Surface
109         */
110         virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL)=0;
111
112         //! Returns \c true if the importer pays attention to the \a time parameter of get_frame()
113         virtual bool is_animated() { return false; }
114
115         //! Attempts to open \a filename, and returns a handle to the associated Importer
116         static Handle open(const String &filename);
117 };
118
119 }; // END of namespace synfig
120
121 /* === E N D =============================================================== */
122
123 #endif