general.h

Go to the documentation of this file.
00001 /* === S Y N F I G ========================================================= */
00021 /* ========================================================================= */
00022 
00023 /* === S T A R T =========================================================== */
00024 
00025 #ifndef __SYNFIG_GENERAL_H
00026 #define __SYNFIG_GENERAL_H
00027 
00028 /* === H E A D E R S ======================================================= */
00029 
00030 #include <ETL/stringf>
00031 #include "string.h"
00032 #include "version.h"
00033 #include <locale.h>
00034 
00035 /* === M A C R O S ========================================================= */
00036 
00037 // Quick hack to keep stuff working until gettext support is added
00038 #ifndef _
00039 #define _(x)        (x)
00040 #define N_(x)       (x)
00041 //#define gettext(x)    (x)
00042 #endif
00043 
00044 #define SYNFIG_COPYRIGHT "Copyright (c) 2001-2005 Robert B. Quattlebaum Jr., Adrian Bentley"
00045 
00046 
00047 #ifdef _DEBUG
00048 #ifdef __FUNC__
00049 #define DEBUGPOINT()    synfig::warning(etl::strprintf(__FILE__":"__FUNC__":%d DEBUGPOINT",__LINE__))
00050 #define DEBUGINFO(x)    synfig::warning(etl::strprintf(__FILE__":"__FUNC__":%d:DEBUGINFO:",__LINE__)+x)
00051 #else
00052 #define DEBUGPOINT()    synfig::warning(etl::strprintf(__FILE__":%d DEBUGPOINT",__LINE__))
00053 #define DEBUGINFO(x)    synfig::warning(etl::strprintf(__FILE__":%d:DEBUGINFO:",__LINE__)+x)
00054 #endif
00055 
00056 #else
00057 #define DEBUGPOINT()
00058 #define DEBUGINFO(x)
00059 #endif
00060 
00061 /* === C L A S S E S & S T R U C T S ======================================= */
00062 
00063 namespace synfig {
00064 
00065 class ChangeLocale {
00066     const char *previous;
00067     int category;
00068 public:
00069     ChangeLocale(int category, const char *locale):
00070         previous(setlocale(category,NULL)),category(category)
00071     {
00072             setlocale(category,locale);
00073     }
00074     ~ChangeLocale() {
00075         setlocale(category,previous);
00076     }
00077 };
00078 
00082 class ProgressCallback
00083 {
00084 public:
00085 
00086     virtual ~ProgressCallback() { }
00087     virtual bool task(const String &task) { return true; }
00088     virtual bool error(const String &task) { return true; }
00089     virtual bool warning(const String &task) { return true; }
00090     virtual bool amount_complete(int current, int total) { return true; }
00091     
00092     virtual bool valid() const { return true; }
00093 };
00094 
00095 typedef ProgressCallback ProgressManager;
00096 
00100 class SuperCallback : public ProgressCallback
00101 {
00102     ProgressCallback *cb;
00103     int start,end,tot;
00104     int w;
00105 public:
00106 
00107     SuperCallback() { cb=NULL; }
00108     SuperCallback(ProgressCallback *cb,int start, int end, int total):cb(cb),start(start),end(end),tot(total)
00109     {
00110         //make sure we don't "inherit" if our subcallback is invalid
00111         if(!cb || !cb->valid())
00112             cb = NULL;
00113         w=end-start;
00114     }
00115     virtual bool task(const String &task) { if(cb)return cb->task(task); return true; }
00116     virtual bool error(const String &task) { if(cb)return cb->error(task); return true; }
00117     virtual bool warning(const String &task) { if(cb)return cb->warning(task); return true; }
00118     virtual bool amount_complete(int cur, int total) { if(cb)return cb->amount_complete(start+cur*w/total,tot); return true; }
00119     
00120     virtual bool valid() const { return cb != 0; }
00121 };
00122 
00126 class SoftwareExpired
00127 {
00128 }; // END of class SoftwareExpired
00129 
00130 
00131 #ifdef DEATH_TIME
00132 inline void CHECK_EXPIRE_TIME() { if(time(0)>DEATH_TIME) throw SoftwareExpired(); }
00133 #else
00134 #define CHECK_EXPIRE_TIME() while(0){ }
00135 #endif
00136 
00137 /*
00138 extern bool add_to_module_search_path(const std:string &path);
00139 extern bool add_to_config_search_path(const std:string &path);
00140 */
00141 
00143 extern void shutdown();
00144 
00146 
00147 extern void error(const char *format,...);
00148 extern void error(const String &str);
00149 
00151 
00152 extern void warning(const char *format,...);
00153 extern void warning(const String &str);
00154 
00156 
00157 extern void info(const char *format,...);
00158 extern void info(const String &str);
00159 
00160 }; // END of namespace synfig
00161 
00162 /* === E N D =============================================================== */
00163 
00164 #endif

Generated on Fri Jun 23 15:20:49 2006 for synfig by  doxygen 1.4.6