1 /* === S I N F G =========================================================== */
3 ** \brief Target Class Implementation
5 ** $Id: target.h,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
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.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_TARGET_H
25 #define __SINFG_TARGET_H
27 /* === H E A D E R S ======================================================= */
29 #include "string_decl.h"
35 //#include "general.h"
39 /* === M A C R O S ========================================================= */
42 #define SINFG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
44 //! Sets the name of the target
45 #define SINFG_TARGET_SET_NAME(class,x) const char class::name__[]=x
48 #define SINFG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
50 //! Sets the version of the target
51 #define SINFG_TARGET_SET_VERSION(class,x) const char class::version__[]=x
53 //! Sets the CVS ID of the target
54 #define SINFG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
57 #define SINFG_TARGET_INIT(class) sinfg::Target* class::create(const char *filename) { return new class(filename); }
59 /* === T Y P E D E F S ===================================================== */
61 /* === C L A S S E S & S T R U C T S ======================================= */
68 class ProgressCallback;
71 ** \brief Render-target
74 class Target : public etl::shared_object
77 typedef etl::handle<Target> Handle;
78 typedef etl::loose_handle<Target> LooseHandle;
79 typedef etl::handle<const Target> ConstHandle;
81 typedef Target* (*Factory)(const char *filename);
83 //! A type for a map of targets, indexed by the name of the Target
84 typedef std::map<String,std::pair<Factory,String> > Book;
86 typedef std::map<String,String> ExtBook;
88 //! Target Book, indexed by the target's name
91 //! Map of target names indexed by associated file extension
92 static ExtBook* ext_book_;
95 static ExtBook& ext_book();
97 static bool subsys_init();
98 static bool subsys_stop();
100 //! Adjusted Render description set by set_rend_desc()
103 etl::handle<Canvas> canvas;
110 bool avoid_time_sync_;
117 virtual ~Target() { }
119 int get_quality()const { return quality_; }
121 void set_quality(int q) { quality_=q; }
123 void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
125 bool get_avoid_time_sync()const { return avoid_time_sync_; }
127 bool get_remove_alpha()const { return remove_alpha; }
129 void set_remove_alpha(bool x=true) { remove_alpha=x; }
131 Gamma &gamma() { return gamma_; }
133 const Gamma &gamma()const { return gamma_; }
135 virtual void set_canvas(etl::handle<Canvas> c);
137 const etl::handle<Canvas> &get_canvas()const { return canvas; }
139 RendDesc &rend_desc() { return desc; }
140 const RendDesc &rend_desc()const { return desc; }
142 //! Renders the canvas to the target
143 virtual bool render(ProgressCallback *cb=NULL)=0;
145 //! Sets the RendDesc for the Target to \a desc.
146 /*! If there are any parts of \a desc that the render target
147 ** is not capable of doing, the render target will adjust
148 ** \a desc to fit it's needs.
150 virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
152 virtual bool init() { return true; }
154 //! Creates a new Target described by \a type, outputing to a file described by \a filename.
155 static Handle create(const String &type, const String &filename);
156 }; // END of class Target
158 }; // END of namespace sinfg
160 /* === E N D =============================================================== */