more updates
[synfig.git] / synfig-core / trunk / src / synfig / importer.h
1 /* === S I N F 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 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SINFG_IMPORTER_H
25 #define __SINFG_IMPORTER_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <map>
30 //#include <cmath>
31 #include <ETL/handle>
32 #include "string.h"
33 //#include "surface.h"
34 //#include "general.h"
35 //#include "vector.h"
36 #include "time.h"
37 #include "gamma.h"
38
39 /* === M A C R O S ========================================================= */
40
41 //! \writeme
42 #define SINFG_IMPORTER_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Importer *create(const char *filename);
43
44 //! Sets the name of the importer
45 #define SINFG_IMPORTER_SET_NAME(class,x) const char class::name__[]=x
46
47 //! \writeme
48 #define SINFG_IMPORTER_SET_EXT(class,x) const char class::ext__[]=x
49
50 //! Sets the version of the importer
51 #define SINFG_IMPORTER_SET_VERSION(class,x) const char class::version__[]=x
52
53 //! Sets the CVS ID of the importer
54 #define SINFG_IMPORTER_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
55
56 //! \writeme
57 #define SINFG_IMPORTER_INIT(class) sinfg::Importer* class::create(const char *filename) { return new class(filename); }
58
59 /* === T Y P E D E F S ===================================================== */
60
61 /* === C L A S S E S & S T R U C T S ======================================= */
62
63 namespace sinfg {
64
65 class Surface;
66 class ProgressCallback;
67
68 /*!     \class Importer
69 **      \brief Used for importing bitmaps of various formats, including animations
70 **      \todo Write more detailed description
71 */
72 class Importer : public etl::shared_object
73 {
74 public:
75         typedef Importer* (*Factory)(const char *filename);
76         typedef std::map<String,Factory> Book;
77         static Book* book_;
78         
79         static Book& book();
80         
81         static bool subsys_init();
82         static bool subsys_stop();
83
84         typedef etl::handle<Importer> Handle;
85         typedef etl::loose_handle<Importer> LooseHandle;
86         typedef etl::handle<const Importer> ConstHandle;
87
88 private:
89         Gamma gamma_;
90
91 protected:
92         Importer();
93
94 public:
95
96         Gamma& gamma() { return gamma_; }
97         const Gamma& gamma()const { return gamma_; }
98         
99         virtual ~Importer();
100
101         //! Gets a frame and puts it into \a surface
102         /*!     \param  surface Reference to surface to put frame into
103         **      \param  time    For animated importers, determines which frame to get.
104         **              For static importers, this parameter is unused.
105         **      \param  callback Pointer to callback class for progress, errors, etc.
106         **      \return \c true on success, \c false on error
107         **      \see ProgressCallback, Surface
108         */
109         virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL)=0;
110
111         //! Returns \c true if the importer pays attention to the \a time parameter of get_frame()
112         virtual bool is_animated() { return false; }
113
114         //! Attempts to open \a filename, and returns a handle to the associated Importer
115         static Handle open(const String &filename);
116 };
117
118 }; // END of namespace sinfg
119
120 /* === E N D =============================================================== */
121
122 #endif