Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GTL.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GTL.h
1 /* This software is distributed under the GNU Lesser General Public License */
2 //==========================================================================
3 //
4 // GTL.h - Internal header: DO NO USE IT DIRECTLY !!!
5 //
6 //==========================================================================
7 // $Id: GTL.h,v 1.29 2008/02/03 18:17:08 chris Exp $
8 
9 #ifndef GTL_GTL_H
10 #define GTL_GTL_H
11 
12 #include <GTL/version.h>
13 
14 //--------------------------------------------------------------------------
15 // Generic iteration over container elements
16 //--------------------------------------------------------------------------
17 //
18 // elem: loop variable
19 // cont: container to iterate over
20 // iter_t: iterator type
21 // iter: prefix for begin() and end()
22 //
23 // contains a hack for Microsoft Visual C++ 5.0, because code like
24 //
25 // for(int i=0; i<10; ++i) { ... do something ... }
26 // for(int i=0; i<10; ++i) { ... do something again ... }
27 //
28 // is illegal with Microsoft Extensions enabled, but without Microsoft
29 // Extensions, the Microsoft STL does not work :-(.
30 // So we code the line number (__LINE__) into our loop variables.
31 
32 #define GTL_CONCAT(x, y) x##y
33 #define GTL_FORALL_VAR(y) GTL_CONCAT(GTL_FORALL_VAR, y)
34 
35 #define GTL_FORALL(elem, cont, iter_t, iter) \
36 if ((cont).iter##begin() != (cont).iter##end()) \
37  (elem) = *((cont).iter##begin()); \
38 for (iter_t GTL_FORALL_VAR(__LINE__) = (cont).iter##begin(); \
39  GTL_FORALL_VAR(__LINE__) != (cont).iter##end(); \
40  (elem) = (++GTL_FORALL_VAR(__LINE__)) == \
41  (cont).iter##end() ? (elem) : *GTL_FORALL_VAR(__LINE__))
42 
43 //--------------------------------------------------------------------------
44 // Configuration for GCC >= 2.8.0
45 //--------------------------------------------------------------------------
46 
47 //
48 // Using namespaces is the default; may be unset by one of the
49 // following configurations.
50 //
51 
52 #define __GTL_USE_NAMESPACES
53 
54 #ifdef __GNUC__
55 
56 # define __GTL_GCC
57 
58 # if __GNUC__ == 2 && __GNUC_MINOR__ >= 8
59 
60 # undef __GTL_USE_NAMESPACES
61 
62 # elif __GNUC__ < 3
63 
64 # error "Need at least version 2.8.0 of GCC to compile GTL."
65 
66 # endif
67 
68 //
69 // 2/3/2008 chris:
70 //
71 // Enable comparison of iterators in debug mode
72 //
73 
74 # if __GNUC__ >= 4
75 # undef _GLIBCXX_DEBUG
76 # endif
77 #endif
78 
79 //--------------------------------------------------------------------------
80 // Configuration for Microsoft Visual C++ 5.0
81 //--------------------------------------------------------------------------
82 
83 #ifdef _MSC_VER
84 
85 # if _MSC_VER >= 1400 // Visual Studio 2005
86 
87 # define _HAS_ITERATOR_DEBUGGING 0
88 # define _CRT_SECURE_NO_DEPRECATE 1
89 # define _SECURE_SCL 0
90 
91 # endif
92 
93 # if _MSC_VER >= 1100
94 
95 # define __GTL_USE_NAMESPACES
96 # define __GTL_MSVCC
97 
98 # pragma warning( disable : 4786 )
99 # pragma warning( disable : 4251 )
100 
101 # if defined(GTL_STATIC)
102 # define GTL_EXTERN
103 # elif defined(GTL_EXPORTS)
104 # define GTL_EXTERN __declspec(dllexport)
105 # else
106 # define GTL_EXTERN __declspec(dllimport)
107 # endif
108 
109 # else
110 
111 # error "Need at least version 5.0 of MS Visual C++ to compile GTL."
112 
113 # endif
114 #else
115 
116 # define GTL_EXTERN
117 
118 #endif
119 
120 //--------------------------------------------------------------------------
121 // Namespaces
122 //--------------------------------------------------------------------------
123 
124 #ifdef __GTL_USE_NAMESPACES
125 
126 # define __GTL_BEGIN_NAMESPACE namespace GTL {
127 # define __GTL_END_NAMESPACE }
128 
129 #else
130 
131 # define __GTL_BEGIN_NAMESPACE
132 # define __GTL_END_NAMESPACE
133 
134 #endif
135 
136 //--------------------------------------------------------------------------
137 // Temporary hack until Graphlet (i.e. gcc) supports Namespaces
138 //--------------------------------------------------------------------------
139 
140 #ifdef __GTL_USE_NAMESPACES
141 
142 namespace GTL {};
143 using namespace GTL;
144 
145 // namespace std {};
146 //using namespace std;
147 #include<list>
148 #include<map>
149 #include<set>
150 #include<queue>
151 #include<deque>
152 #include<stack>
153 #include<vector>
154 #include<iostream>
155 #include<string>
156 using std::vector;
157 using std::list;
158 using std::queue;
159 using std::priority_queue;
160 using std::deque;
161 using std::pair;
162 using std::stack;
163 using std::map;
164 using std::set;
165 using std::allocator;
166 using std::binary_function;
167 using std::ostream;
168 using std::ofstream;
169 using std::cout;
170 using std::cerr;
171 using std::endl;
172 using std::string;
173 
174 
175 
176 #endif // __GTL_USE_NAMESPACES
177 
178 //--------------------------------------------------------------------------
179 // Bugfix for EGCS & GCC < 2.95
180 //--------------------------------------------------------------------------
181 
182 #if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 95
183 
184 #include <map>
185 #include <memory>
186 
190 template <class T>
191 class allocator : public alloc
192 {
193 };
194 
195 #endif
196 
197 //--------------------------------------------------------------------------
198 // MSVC 6 does not define min and max in <algorithm>
199 //--------------------------------------------------------------------------
200 
201 #if defined(__GTL_MSVCC) && _MSC_VER < 1300
202 
203 #ifndef min
204 template<class T>
205 const T& min(const T& x, const T& y)
206 {
207  return ( x < y ? x : y);
208 }
209 #endif
210 
211 #ifndef max
212 template<class T>
213 const T& max(const T& x, const T& y)
214 {
215  return ( x > y ? x : y);
216 }
217 #endif
218 
219 #endif
220 
221 //--------------------------------------------------------------------------
222 // enable debugging of memory leaks in debug mode of MSVC
223 //--------------------------------------------------------------------------
224 
225 #ifdef __GTL_MSVCC
226 # ifdef _DEBUG
227 # define WINVER 0x0400 // compatibility with at least WinNT4
228  // usually the followin two lines are defined in Microsoft's
229  // generated stdafx.h
230 # define VC_EXTRALEAN // do not include rarely used parts
231 # include <afxwin.h> // MFC core und standard components
232  // extra definition for check whether all needed headers are included
233 # undef SEARCH_MEMORY_LEAKS_ENABLED
234 # define SEARCH_MEMORY_LEAKS_ENABLED
235 # endif // _DEBUG
236 #endif // __GTL_MSVCC
237 
238 #endif // GTL_GTL_H
239 
240 //--------------------------------------------------------------------------
241 // end of file
242 //--------------------------------------------------------------------------