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