Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

general/SUtil.h

Go to the documentation of this file.
00001 /* #start# ***********************************************************
00002 
00003            Scheduling Simulator
00004         Lehrstuhl f"ur Effiziente Algorithmen
00005            Technische Universit"at M"unchen
00006 
00007  File    : $Id: SUtil.h,v 1.5 2003/03/13 19:23:58 taeubig Exp $
00008 
00009  Purpose : several small useful functions ... e.g. for debugging
00010 
00011  RCS-Log:
00012  $Log: SUtil.h,v $
00013  Revision 1.5  2003/03/13 19:23:58  taeubig
00014  prob.dists in new dir, other changes, removed log messages
00015 
00016  Revision 1.4  2003/01/08 18:57:12  meierb
00017  added randomized release times
00018 
00019  Revision 1.1.1.1  2002/12/02 22:26:19  meierb
00020  my_schedule
00021 
00022  Revision 1.2  2002/11/09 02:51:03  taeubig
00023  Replaced <iostream.h> header inclusion by <iostream>, cerr by std::cerr...
00024 
00025  Revision 1.1  2002/08/29 12:59:58  taeubig
00026  Added the sources
00027 
00028  Revision 1.6  2000/05/24 12:28:52  taeubig
00029  New compiler (gcc-2.95) and new Qt (2.1)
00030  Replaced "list" by "leda_list" etc.
00031 
00032  Revision 1.5  1999/12/02 13:11:11  zoidl
00033  visual errorMsg()
00034 
00035  Revision 1.4  1999/11/03 08:12:00  schickin
00036  Use of macros NOCOPY and DUMMYIO clarified
00037 
00038  Revision 1.3  1999/10/06 13:37:07  zoidl
00039  added errorMsg
00040 
00041  Revision 1.2  1999/04/27 13:38:53  schickin
00042  well folks, that's the first demo version that really runs 8-)
00043 
00044  Revision 1.1  1999/02/10 15:53:32  hall
00045  TypeInfo, Observer works
00046 
00047 
00048  * #end# ************************************************************* */
00049  
00050 #ifndef SUTIL_H
00051 #define SUTIL_H 
00052 
00053 // system header files
00054 #include <iostream>
00055 #include <cmath>
00056 
00057 #include <LEDA/string.h>
00058 
00059 extern int myInfoFlag;
00060 
00061 #define SPEEDUP false
00062 
00063 #define NODBG false
00064 #define NOINFO false
00065 
00066 #define dbgOn true
00067 
00068 #define DBG \
00069         if( (!NODBG) && dbgOn ) \
00070           std::cerr << "Debug: line " << __LINE__ << " of " << __FILE__ << ": "
00071 
00072 #define DBGX \
00073         if( (!NODBG) && dbgOn ) \
00074           std::cerr
00075 
00076 #define dbgVar(name, val) \
00077         if( (!NODBG) && dbgOn ) \
00078         { \
00079     std::cerr << "Debug: line " << __LINE__ << " of " << __FILE__ << ": " \
00080          << name << " = " << val << std::endl; \
00081   }
00082 
00083 
00084 
00085 
00086 #define infoVar(m, name, val) \
00087         if( (!NOINFO) && (myInfoFlag >= m) ) \
00088         { \
00089       std::cout << name << " = " << val << std::endl; \
00090   }
00091 
00092 inline void die(const leda_string& s)
00093 {
00094   std::cerr << s << std::endl;
00095   exit(1);
00096 }
00097 
00098 // default: error messages are copied to stderr
00099 /* inline void errorMsgSTDERR(const leda_string& caption, const leda_string& message)
00100 {
00101   std::cerr << caption << ": " << message << std::endl;
00102 }
00103 */
00104 
00105 // function pointer can be redirected to any function, that matches this 
00106 // prototype
00107 // the default is set in SUtil.cpp
00108 // extern void (*errorMsg)(const leda_string&, const leda_string&);
00109 
00110 template <class T>
00111 inline T sgn(T x)
00112 {
00113   return (x < 0) ? -1 : ((x == 0) ? 0 : 1);
00114 }
00115 
00116 // a new mins, which allow constant arguments
00117 inline int min(int a, int b)
00118 {
00119   return (a < b) ? a : b;
00120 }
00121 
00122 inline double min(double a, double b)
00123 {
00124   return (a < b) ? a : b;
00125 }
00126 
00127 #define NOCOPY(classname) \
00128   classname(classname&)
00129 
00130 #define DUMMYIO(classname) \
00131 class foo { \
00132   friend std::ostream& operator<<(std::ostream& os, const foo&) \
00133     { assert( 0 && "Not implemented." ); return os; }; \
00134   friend std::istream& operator>>(std::istream& is, foo&) \
00135     { assert( 0 && "Not implemented." ); return is; }; \
00136 }
00137 
00138 #endif

Generated on Thu May 22 16:48:08 2003 for Sketch-it! by doxygen1.2.18