1 /* === S Y N F I G ========================================================= */
3 ** \brief General macros, classes, and prodecure declarations
5 ** $Id: general.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_GENERAL_H
26 #define __SYNFIG_GENERAL_H
28 /* === H E A D E R S ======================================================= */
30 #include <ETL/stringf>
34 /* === M A C R O S ========================================================= */
36 // Quick hack to keep stuff working until gettext support is added
40 //#define gettext(x) (x)
43 #define SYNFIG_COPYRIGHT "Copyright (c) 2001-2004 Voria Software, LLC"
48 #define DEBUGPOINT() synfig::warning(etl::strprintf(__FILE__":"__FUNC__":%d DEBUGPOINT",__LINE__))
49 #define DEBUGINFO(x) synfig::warning(etl::strprintf(__FILE__":"__FUNC__":%d:DEBUGINFO:",__LINE__)+x)
51 #define DEBUGPOINT() synfig::warning(etl::strprintf(__FILE__":%d DEBUGPOINT",__LINE__))
52 #define DEBUGINFO(x) synfig::warning(etl::strprintf(__FILE__":%d:DEBUGINFO:",__LINE__)+x)
60 /* === C L A S S E S & S T R U C T S ======================================= */
64 /*! \class ProgressCallback
67 class ProgressCallback
71 virtual ~ProgressCallback() { }
72 virtual bool task(const String &task) { return true; }
73 virtual bool error(const String &task) { return true; }
74 virtual bool warning(const String &task) { return true; }
75 virtual bool amount_complete(int current, int total) { return true; }
77 virtual bool valid() const { return true; }
80 typedef ProgressCallback ProgressManager;
82 /*! \class SuperCallback
85 class SuperCallback : public ProgressCallback
92 SuperCallback() { cb=NULL; }
93 SuperCallback(ProgressCallback *cb,int start, int end, int total):cb(cb),start(start),end(end),tot(total)
95 //make sure we don't "inherit" if our subcallback is invalid
96 if(!cb || !cb->valid())
100 virtual bool task(const String &task) { if(cb)return cb->task(task); return true; }
101 virtual bool error(const String &task) { if(cb)return cb->error(task); return true; }
102 virtual bool warning(const String &task) { if(cb)return cb->warning(task); return true; }
103 virtual bool amount_complete(int cur, int total) { if(cb)return cb->amount_complete(start+cur*w/total,tot); return true; }
105 virtual bool valid() const { return cb != 0; }
108 /*! \class SoftwareExpired
109 ** \brief This class is thrown when the software timeout has been reached.
111 class SoftwareExpired
113 }; // END of class SoftwareExpired
117 inline void CHECK_EXPIRE_TIME() { if(time(0)>DEATH_TIME) throw SoftwareExpired(); }
119 #define CHECK_EXPIRE_TIME() while(0){ }
123 extern bool add_to_module_search_path(const std:string &path);
124 extern bool add_to_config_search_path(const std:string &path);
127 //! Shutdown the synfig environment
128 extern void shutdown();
131 /*! Call this when an error occurs, describing what happened */
132 extern void error(const char *format,...);
133 extern void error(const String &str);
135 //! Reports a warning
136 /*! Call this when something questionable occurs, describing what happened */
137 extern void warning(const char *format,...);
138 extern void warning(const String &str);
140 //! Reports some information
141 /*! Call this to report various information. Please be sparse... */
142 extern void info(const char *format,...);
143 extern void info(const String &str);
145 }; // END of namespace synfig
147 /* === E N D =============================================================== */