1 /* === S Y N F I G ========================================================= */
3 ** \brief General macros, classes, and procedure declarations
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>
35 /* === M A C R O S ========================================================= */
37 // Quick hack to keep stuff working until gettext support is added
41 //#define gettext(x) (x)
44 #define SYNFIG_COPYRIGHT "Copyright (c) 2001-2005 Robert B. Quattlebaum Jr., Adrian Bentley"
49 #define DEBUGPOINT() synfig::warning(etl::strprintf(__FILE__":"__FUNC__":%d DEBUGPOINT",__LINE__))
50 #define DEBUGINFO(x) synfig::warning(etl::strprintf(__FILE__":"__FUNC__":%d:DEBUGINFO:",__LINE__)+x)
52 #define DEBUGPOINT() synfig::warning(etl::strprintf(__FILE__":%d DEBUGPOINT",__LINE__))
53 #define DEBUGINFO(x) synfig::warning(etl::strprintf(__FILE__":%d:DEBUGINFO:",__LINE__)+x)
61 /* === C L A S S E S & S T R U C T S ======================================= */
66 const String previous;
69 ChangeLocale(int category, const char *locale):
70 previous(setlocale(category,locale)),category(category)
74 setlocale(category,previous.c_str());
78 /*! \class ProgressCallback
81 class ProgressCallback
85 virtual ~ProgressCallback() { }
86 virtual bool task(const String &/*task*/) { return true; }
87 virtual bool error(const String &/*task*/) { return true; }
88 virtual bool warning(const String &/*task*/) { return true; }
89 virtual bool amount_complete(int /*current*/, int /*total*/) { return true; }
91 virtual bool valid() const { return true; }
94 typedef ProgressCallback ProgressManager;
96 /*! \class SuperCallback
99 class SuperCallback : public ProgressCallback
101 ProgressCallback *cb;
106 SuperCallback() { cb=NULL; }
107 SuperCallback(ProgressCallback *cb,int start, int end, int total):cb(cb),start(start),end(end),tot(total)
109 //make sure we don't "inherit" if our subcallback is invalid
110 if(!cb || !cb->valid())
114 virtual bool task(const String &task) { if(cb)return cb->task(task); return true; }
115 virtual bool error(const String &task) { if(cb)return cb->error(task); return true; }
116 virtual bool warning(const String &task) { if(cb)return cb->warning(task); return true; }
117 virtual bool amount_complete(int cur, int total) { if(cb)return cb->amount_complete(start+cur*w/total,tot); return true; }
119 virtual bool valid() const { return cb != 0; }
122 /*! \class SoftwareExpired
123 ** \brief This class is thrown when the software timeout has been reached.
125 class SoftwareExpired
127 }; // END of class SoftwareExpired
131 inline void CHECK_EXPIRE_TIME() { if(time(0)>DEATH_TIME) throw SoftwareExpired(); }
133 #define CHECK_EXPIRE_TIME() while(0){ }
137 extern bool add_to_module_search_path(const std:string &path);
138 extern bool add_to_config_search_path(const std:string &path);
141 //! Shutdown the synfig environment
142 extern void shutdown();
145 /*! Call this when an error occurs, describing what happened */
146 extern void error(const char *format,...);
147 extern void error(const String &str);
149 //! Reports a warning
150 /*! Call this when something questionable occurs, describing what happened */
151 extern void warning(const char *format,...);
152 extern void warning(const String &str);
154 //! Reports some information
155 /*! Call this to report various information. Please be sparse... */
156 extern void info(const char *format,...);
157 extern void info(const String &str);
159 }; // END of namespace synfig
161 /* === E N D =============================================================== */