My Project
 All Classes Files Functions Variables Enumerations Pages
common.h
1 /**************************************************************************/
2 /* Copyright 2009 Tim Day */
3 /* */
4 /* This file is part of Fracplanet */
5 /* */
6 /* Fracplanet is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* Fracplanet is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
18 /**************************************************************************/
19 
20 #ifndef _common_h_
21 #define _common_h_
22 
23 extern "C"
24 {
25 #include <stdlib.h>
26 #include <time.h>
27 }
28 
29 #include <cassert>
30 #include <cmath>
31 #include <deque>
32 #include <fstream>
33 #include <iomanip>
34 #include <iostream>
35 #include <map>
36 #include <memory>
37 #include <numeric>
38 #include <set>
39 #include <sstream>
40 #include <string>
41 #include <vector>
42 
43 #include <boost/array.hpp>
44 #include <boost/bind.hpp>
45 #include <boost/function.hpp>
46 #include <boost/noncopyable.hpp>
47 #include <boost/optional.hpp>
48 #include <boost/program_options/errors.hpp>
49 #include <boost/program_options/options_description.hpp>
50 #include <boost/program_options/parsers.hpp>
51 #include <boost/program_options/variables_map.hpp>
52 #include <boost/random.hpp>
53 #include <boost/range.hpp>
54 #include <boost/scoped_array.hpp>
55 #include <boost/scoped_ptr.hpp>
56 
57 #include <QApplication>
58 #include <QButtonGroup>
59 #include <QCheckBox>
60 #include <QComboBox>
61 #include <QColorDialog>
62 #include <QCursor>
63 #include <QDateTime>
64 #include <QDialog>
65 #include <QFileDialog>
66 #include <QFont>
67 #include <QGridLayout>
68 #include <QGroupBox>
69 #include <QKeyEvent>
70 #include <QIcon>
71 #include <QLabel>
72 #include <QLineEdit>
73 #include <QMessageBox>
74 #include <QObject>
75 #include <QProgressDialog>
76 #include <QPushButton>
77 #include <QRadioButton>
78 #include <QSlider>
79 #include <QSpinBox>
80 #include <QStatusBar>
81 #include <QTabWidget>
82 #include <QTextBrowser>
83 #include <QTextEdit>
84 #include <QTime>
85 #include <QTimer>
86 #include <QToolTip>
87 #include <QVBoxLayout>
88 #include <QWidget>
89 
90 #define GL_GLEXT_PROTOTYPES
91 #include <GL/gl.h>
92 #include <GL/glext.h>
93 
94 #include <QtOpenGL/qgl.h>
95 
96 #define stringify(S) __STRING(S)
97 
98 typedef unsigned int uint;
99 typedef unsigned short ushort;
100 typedef unsigned char uchar;
101 
102 template <class T> inline const T maximum(T a,T b) {return (a>b ? a : b);}
103 template <class T> inline const T minimum(T a,T b) {return (a<b ? a : b);}
104 
105 template <class T> inline const T maximum(T a,T b,T c) {return maximum(a,maximum(b,c));}
106 template <class T> inline const T minimum(T a,T b,T c) {return minimum(a,minimum(b,c));}
107 
108 template <class T> inline const T maximum(T a,T b,T c,T d) {return maximum(maximum(a,b),maximum(c,d));}
109 template <class T> inline const T minimum(T a,T b,T c,T d) {return minimum(minimum(a,b),minimum(c,d));}
110 
111 template <class T> inline const T sqr(T a) {return a*a;}
112 
113 template <class T> inline const T clamped(T v,T lo,T hi) {return (v<lo ? lo : (v>hi ? hi : v));}
114 
115 template <class T> inline void clamp(T& v,T lo,T hi) {v=(v<lo ? lo : (v>hi ? hi : v));}
116 
117 template <class T> inline void exchange(T& a,T& b) {const T x(a);a=b;b=x;}
118 
119 extern void fatal_error(const char*);
120 
121 inline void fatal_error(const std::string& s)
122 {
123  fatal_error(s.c_str());
124 }
125 
126 extern void fatal_internal_error(const char* src_file,uint src_line);
127 
128 extern void constraint_violation(const char* test,const char* src_file,uint src_line);
129 #define constraint(TEST) {if (!TEST) {constraint_violation(#TEST,__FILE__,__LINE__);}}
130 
131 #endif