1 /* === S I N F 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 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_GENERAL_H
25 #define __SINFG_GENERAL_H
27 /* === H E A D E R S ======================================================= */
29 #include <ETL/stringf>
33 /* === M A C R O S ========================================================= */
35 // Quick hack to keep stuff working until gettext support is added
39 //#define gettext(x) (x)
42 #define SINFG_COPYRIGHT "Copyright (c) 2001-2004 Voria Software, LLC"
47 #define DEBUGPOINT() sinfg::warning(etl::strprintf(__FILE__":"__FUNC__":%d DEBUGPOINT",__LINE__))
48 #define DEBUGINFO(x) sinfg::warning(etl::strprintf(__FILE__":"__FUNC__":%d:DEBUGINFO:",__LINE__)+x)
50 #define DEBUGPOINT() sinfg::warning(etl::strprintf(__FILE__":%d DEBUGPOINT",__LINE__))
51 #define DEBUGINFO(x) sinfg::warning(etl::strprintf(__FILE__":%d:DEBUGINFO:",__LINE__)+x)
59 /* === C L A S S E S & S T R U C T S ======================================= */
63 /*! \class ProgressCallback
66 class ProgressCallback
70 virtual ~ProgressCallback() { }
71 virtual bool task(const String &task) { return true; }
72 virtual bool error(const String &task) { return true; }
73 virtual bool warning(const String &task) { return true; }
74 virtual bool amount_complete(int current, int total) { return true; }
76 virtual bool valid() const { return true; }
79 typedef ProgressCallback ProgressManager;
81 /*! \class SuperCallback
84 class SuperCallback : public ProgressCallback
91 SuperCallback() { cb=NULL; }
92 SuperCallback(ProgressCallback *cb,int start, int end, int total):cb(cb),start(start),end(end),tot(total)
94 //make sure we don't "inherit" if our subcallback is invalid
95 if(!cb || !cb->valid())
99 virtual bool task(const String &task) { if(cb)return cb->task(task); return true; }
100 virtual bool error(const String &task) { if(cb)return cb->error(task); return true; }
101 virtual bool warning(const String &task) { if(cb)return cb->warning(task); return true; }
102 virtual bool amount_complete(int cur, int total) { if(cb)return cb->amount_complete(start+cur*w/total,tot); return true; }
104 virtual bool valid() const { return cb != 0; }
107 /*! \class SoftwareExpired
108 ** \brief This class is thrown when the software timeout has been reached.
110 class SoftwareExpired
112 }; // END of class SoftwareExpired
116 inline void CHECK_EXPIRE_TIME() { if(time(0)>DEATH_TIME) throw SoftwareExpired(); }
118 #define CHECK_EXPIRE_TIME() while(0){ }
122 extern bool add_to_module_search_path(const std:string &path);
123 extern bool add_to_config_search_path(const std:string &path);
126 //! Shutdown the sinfg environment
127 extern void shutdown();
130 /*! Call this when an error occurs, describing what happened */
131 extern void error(const char *format,...);
132 extern void error(const String &str);
134 //! Reports a warning
135 /*! Call this when something questionable occurs, describing what happened */
136 extern void warning(const char *format,...);
137 extern void warning(const String &str);
139 //! Reports some information
140 /*! Call this to report various information. Please be sparse... */
141 extern void info(const char *format,...);
142 extern void info(const String &str);
144 }; // END of namespace sinfg
146 /* === E N D =============================================================== */