Version: 0.6.0
base.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: base header.
4  * Author: Bishop (aka Barishnikov Dmitriy), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009-2012 Bishop
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 
22 #pragma once
23 
24 #include <wx/wxprec.h>
25 
26 #ifdef __BORLANDC__
27  #pragma hdrstop
28 #endif
29 
30 #ifndef WX_PRECOMP
31  #include <wx/wx.h>
32 #endif
33 
34 #ifdef __WXMAC__
35  #include <wx/osx/private.h>
36 #endif
37 
38 #if defined(HAVE_VISIBILITY)
39 # define WXEXPORT __attribute__ ((visibility("default")))
40 # define WXIMPORT __attribute__ ((visibility("default")))
41 #elif defined(__WINDOWS__)
42  /*
43  __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
44  as VC++.
45  */
46 # if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
47 # define WXEXPORT __declspec(dllexport)
48 # define WXIMPORT __declspec(dllimport)
49  /*
50  While gcc also supports __declspec(dllexport), it creates unusably huge
51  DLL files since gcc 4.5 (while taking horribly long amounts of time),
52  see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601. Because of this
53  we rely on binutils auto export/import support which seems to work
54  quite well for 4.5+.
55  */
56 # elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5)
57  /*
58  __declspec could be used here too but let's use the native
59  __attribute__ instead for clarity.
60  */
61 # define WXEXPORT __attribute__((dllexport))
62 # define WXIMPORT __attribute__((dllimport))
63 # endif
64 #elif defined(__WXPM__)
65 # if defined (__WATCOMC__)
66 # define WXEXPORT __declspec(dllexport)
67  /*
68  __declspec(dllimport) prepends __imp to imported symbols. We do NOT
69  want that!
70  */
71 # define WXIMPORT
72 # elif defined(__EMX__)
73 # define WXEXPORT
74 # define WXIMPORT
75 # elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
76 # define WXEXPORT _Export
77 # define WXIMPORT _Export
78 # endif
79 #elif defined(__WXMAC__) || defined(__WXCOCOA__)
80 # ifdef __MWERKS__
81 # define WXEXPORT __declspec(export)
82 # define WXIMPORT __declspec(import)
83 # endif
84 #elif defined(__CYGWIN__)
85 # define WXEXPORT __declspec(dllexport)
86 # define WXIMPORT __declspec(dllimport)
87 #endif
88 
89 /* for other platforms/compilers we don't anything */
90 #ifndef WXEXPORT
91 # define WXEXPORT
92 # define WXIMPORT
93 #endif
94 
95 #ifdef WXMAKINGDLL_GIS_CORE
96 # define WXDLLIMPEXP_GIS_CORE WXEXPORT
97 # define WXDLLIMPEXP_DATA_GIS_CORE(type) WXEXPORT type
98 #elif defined(WXUSINGDLL)
99 # define WXDLLIMPEXP_GIS_CORE WXIMPORT
100 # define WXDLLIMPEXP_DATA_GIS_CORE(type) WXIMPORT type
101 #else /* not making nor using DLL */
102 # define WXDLLIMPEXP_GIS_CORE
103 # define WXDLLIMPEXP_DATA_GIS_CORE(type) type
104 #endif
105 
106 #ifdef WXMAKINGDLL_GIS_FRW
107 # define WXDLLIMPEXP_GIS_FRW WXEXPORT
108 # define WXDLLIMPEXP_DATA_GIS_FRW(type) WXEXPORT type
109 #elif defined(WXUSINGDLL)
110 # define WXDLLIMPEXP_GIS_FRW WXIMPORT
111 # define WXDLLIMPEXP_DATA_GIS_FRW(type) WXIMPORT type
112 #else /* not making nor using DLL */
113 # define WXDLLIMPEXP_GIS_FRW
114 # define WXDLLIMPEXP_DATA_GIS_FRW(type) type
115 #endif
116 
117 #ifdef WXMAKINGDLL_GIS_DSP
118 # define WXDLLIMPEXP_GIS_DSP WXEXPORT
119 # define WXDLLIMPEXP_DATA_GIS_DSP(type) WXEXPORT type
120 #elif defined(WXUSINGDLL)
121 # define WXDLLIMPEXP_GIS_DSP WXIMPORT
122 # define WXDLLIMPEXP_DATA_GIS_DSP(type) WXIMPORT type
123 #else /* not making nor using DLL */
124 # define WXDLLIMPEXP_GIS_DSP
125 # define WXDLLIMPEXP_DATA_GIS_DSP(type) type
126 #endif
127 
128 #ifdef WXMAKINGDLL_GIS_CRT
129 # define WXDLLIMPEXP_GIS_CRT WXEXPORT
130 # define WXDLLIMPEXP_DATA_GIS_CRT(type) WXEXPORT type
131 #elif defined(WXUSINGDLL)
132 # define WXDLLIMPEXP_GIS_CRT WXIMPORT
133 # define WXDLLIMPEXP_DATA_GIS_CRT(type) WXIMPORT type
134 #else /* not making nor using DLL */
135 # define WXDLLIMPEXP_GIS_CRT
136 # define WXDLLIMPEXP_DATA_GIS_CRT(type) type
137 #endif
138 
139 #ifdef WXMAKINGDLL_GIS_CTU
140 # define WXDLLIMPEXP_GIS_CTU WXEXPORT
141 # define WXDLLIMPEXP_DATA_GIS_CTU(type) WXEXPORT type
142 #elif defined(WXUSINGDLL)
143 # define WXDLLIMPEXP_GIS_CTU WXIMPORT
144 # define WXDLLIMPEXP_DATA_GIS_CTU(type) WXIMPORT type
145 #else /* not making nor using DLL */
146 # define WXDLLIMPEXP_GIS_CTU
147 # define WXDLLIMPEXP_DATA_GIS_CTU(type) type
148 #endif
149 
150 #ifdef WXMAKINGDLL_GIS_CLT
151 # define WXDLLIMPEXP_GIS_CLT WXEXPORT
152 # define WXDLLIMPEXP_DATA_GIS_CLT(type) WXEXPORT type
153 #elif defined(WXUSINGDLL)
154 # define WXDLLIMPEXP_GIS_CLT WXIMPORT
155 # define WXDLLIMPEXP_DATA_GIS_CLT(type) WXIMPORT type
156 #else /* not making nor using DLL */
157 # define WXDLLIMPEXP_GIS_CLT
158 # define WXDLLIMPEXP_DATA_GIS_CLT(type) type
159 #endif
160 
161 #ifdef WXMAKINGDLL_GIS_CLU
162 # define WXDLLIMPEXP_GIS_CLU WXEXPORT
163 # define WXDLLIMPEXP_DATA_GIS_CLU(type) WXEXPORT type
164 #elif defined(WXUSINGDLL)
165 # define WXDLLIMPEXP_GIS_CLU WXIMPORT
166 # define WXDLLIMPEXP_DATA_GIS_CLU(type) WXIMPORT type
167 #else /* not making nor using DLL */
168 # define WXDLLIMPEXP_GIS_CLU
169 # define WXDLLIMPEXP_DATA_GIS_CLU(type) type
170 #endif
171 
172 //#ifdef WXMAKINGDLL_GIS_GEOM
173 //# define WXDLLIMPEXP_GIS_GEOM WXEXPORT
174 //# define WXDLLIMPEXP_DATA_GIS_GEOM(type) WXEXPORT type
175 //#elif defined(WXUSINGDLL)
176 //# define WXDLLIMPEXP_GIS_GEOM WXIMPORT
177 //# define WXDLLIMPEXP_DATA_GIS_GEOM(type) WXIMPORT type
178 //#else /* not making nor using DLL */
179 //# define WXDLLIMPEXP_GIS_GEOM
180 //# define WXDLLIMPEXP_DATA_GIS_GEOM(type) type
181 //#endif
182 
183 #ifdef WXMAKINGDLL_GIS_DS
184 # define WXDLLIMPEXP_GIS_DS WXEXPORT
185 # define WXDLLIMPEXP_DATA_GIS_DS(type) WXEXPORT type
186 #elif defined(WXUSINGDLL)
187 # define WXDLLIMPEXP_GIS_DS WXIMPORT
188 # define WXDLLIMPEXP_DATA_GIS_DS(type) WXIMPORT type
189 #else /* not making nor using DLL */
190 # define WXDLLIMPEXP_GIS_DS
191 # define WXDLLIMPEXP_DATA_GIS_DS(type) type
192 #endif
193 
194 #ifdef WXMAKINGDLL_GIS_GP
195 # define WXDLLIMPEXP_GIS_GP WXEXPORT
196 # define WXDLLIMPEXP_DATA_GIS_GP(type) WXEXPORT type
197 #elif defined(WXUSINGDLL)
198 # define WXDLLIMPEXP_GIS_GP WXIMPORT
199 # define WXDLLIMPEXP_DATA_GIS_GP(type) WXIMPORT type
200 #else /* not making nor using DLL */
201 # define WXDLLIMPEXP_GIS_GP
202 # define WXDLLIMPEXP_DATA_GIS_GP(type) type
203 #endif
204 
205 #ifdef WXMAKINGDLL_GIS_GPU
206 # define WXDLLIMPEXP_GIS_GPU WXEXPORT
207 # define WXDLLIMPEXP_DATA_GIS_GPU(type) WXEXPORT type
208 #elif defined(WXUSINGDLL)
209 # define WXDLLIMPEXP_GIS_GPU WXIMPORT
210 # define WXDLLIMPEXP_DATA_GIS_GPU(type) WXIMPORT type
211 #else /* not making nor using DLL */
212 # define WXDLLIMPEXP_GIS_GPU
213 # define WXDLLIMPEXP_DATA_GIS_GPU(type) type
214 #endif
215 
216 #ifdef WXMAKINGDLL_GIS_RS
217 # define WXDLLIMPEXP_GIS_RS WXEXPORT
218 # define WXDLLIMPEXP_DATA_GIS_RS(type) WXEXPORT type
219 #elif defined(WXUSINGDLL)
220 # define WXDLLIMPEXP_GIS_RS WXIMPORT
221 # define WXDLLIMPEXP_DATA_GIS_RS(type) WXIMPORT type
222 #else /* not making nor using DLL */
223 # define WXDLLIMPEXP_GIS_RS
224 # define WXDLLIMPEXP_DATA_GIS_RS(type) type
225 #endif
226 
227 #ifdef WXMAKINGDLL_GIS_RSU
228 # define WXDLLIMPEXP_GIS_RSU WXEXPORT
229 # define WXDLLIMPEXP_DATA_GIS_RSU(type) WXEXPORT type
230 #elif defined(WXUSINGDLL)
231 # define WXDLLIMPEXP_GIS_RSU WXIMPORT
232 # define WXDLLIMPEXP_DATA_GIS_RSU(type) WXIMPORT type
233 #else /* not making nor using DLL */
234 # define WXDLLIMPEXP_GIS_RSU
235 # define WXDLLIMPEXP_DATA_GIS_RSU(type) type
236 #endif
237 
238 #ifdef WXMAKINGDLL_GIS_NET
239 # define WXDLLIMPEXP_GIS_NET WXEXPORT
240 # define WXDLLIMPEXP_DATA_GIS_NET(type) WXEXPORT type
241 #elif defined(WXUSINGDLL)
242 # define WXDLLIMPEXP_GIS_NET WXIMPORT
243 # define WXDLLIMPEXP_DATA_GIS_NET(type) WXIMPORT type
244 #else /* not making nor using DLL */
245 # define WXDLLIMPEXP_GIS_NET
246 # define WXDLLIMPEXP_DATA_GIS_NET(type) type
247 #endif
248 
249 #ifdef WXMAKINGDLL_GIS_MAPU
250 # define WXDLLIMPEXP_GIS_MAPU WXEXPORT
251 # define WXDLLIMPEXP_DATA_GIS_MAPU(type) WXEXPORT type
252 #elif defined(WXUSINGDLL)
253 # define WXDLLIMPEXP_GIS_MAPU WXIMPORT
254 # define WXDLLIMPEXP_DATA_GIS_MAPU(type) WXIMPORT type
255 #else /* not making nor using DLL */
256 # define WXDLLIMPEXP_GIS_MAPU
257 # define WXDLLIMPEXP_DATA_GIS_MAPU(type) type
258 #endif
259 
260 #ifdef WXMAKINGDLL_GIS_MAP
261 # define WXDLLIMPEXP_GIS_MAP WXEXPORT
262 # define WXDLLIMPEXP_DATA_GIS_MAP(type) WXEXPORT type
263 #elif defined(WXUSINGDLL)
264 # define WXDLLIMPEXP_GIS_MAP WXIMPORT
265 # define WXDLLIMPEXP_DATA_GIS_MAP(type) WXIMPORT type
266 #else /* not making nor using DLL */
267 # define WXDLLIMPEXP_GIS_MAP
268 # define WXDLLIMPEXP_DATA_GIS_MAP(type) type
269 #endif
270 
271 #ifdef WXMAKINGDLL_GIS_SRVNET
272 # define WXDLLIMPEXP_GIS_SRVNET WXEXPORT
273 # define WXDLLIMPEXP_DATA_GIS_SRVNET(type) WXEXPORT type
274 #elif defined(WXUSINGDLL)
275 # define WXDLLIMPEXP_GIS_SRVNET WXIMPORT
276 # define WXDLLIMPEXP_DATA_GIS_SRVNET(type) WXIMPORT type
277 #else /* not making nor using DLL */
278 # define WXDLLIMPEXP_GIS_SRVNET
279 # define WXDLLIMPEXP_DATA_GIS_SRVNET(type) type
280 #endif
281 
282 #if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__))
283  #define WXDLLIMPEXP_FWD_GIS_CORE
284  #define WXDLLIMPEXP_FWD_GIS_FRW
285  #define WXDLLIMPEXP_FWD_GIS_DSP
286  #define WXDLLIMPEXP_FWD_GIS_CRT
287  #define WXDLLIMPEXP_FWD_GIS_CTU
288  #define WXDLLIMPEXP_FWD_GIS_CLT
289  #define WXDLLIMPEXP_FWD_GIS_CLU
290  //#define WXDLLIMPEXP_FWD_GIS_GEOM
291  #define WXDLLIMPEXP_FWD_GIS_DS
292  #define WXDLLIMPEXP_FWD_GIS_GP
293  #define WXDLLIMPEXP_FWD_GIS_GPU
294  #define WXDLLIMPEXP_FWD_GIS_RS
295  #define WXDLLIMPEXP_FWD_GIS_RSU
296  #define WXDLLIMPEXP_FWD_GIS_NET
297  #define WXDLLIMPEXP_FWD_GIS_MAPU
298  #define WXDLLIMPEXP_FWD_GIS_MAP
299  #define WXDLLIMPEXP_FWD_GIS_SRVNET
300 #else
301  #define WXDLLIMPEXP_FWD_GIS_CORE WXDLLIMPEXP_GIS_CORE
302  #define WXDLLIMPEXP_FWD_GIS_FRW WXDLLIMPEXP_GIS_FRW
303  #define WXDLLIMPEXP_FWD_GIS_DSP WXDLLIMPEXP_GIS_DSP
304  #define WXDLLIMPEXP_FWD_GIS_CRT WXDLLIMPEXP_GIS_CRT
305  #define WXDLLIMPEXP_FWD_GIS_CTU WXDLLIMPEXP_GIS_CTU
306  #define WXDLLIMPEXP_FWD_GIS_CLT WXDLLIMPEXP_GIS_CLT
307  #define WXDLLIMPEXP_FWD_GIS_CLU WXDLLIMPEXP_GIS_CLU
308  //#define WXDLLIMPEXP_FWD_GIS_GEOM WXDLLIMPEXP_GIS_GEOM
309  #define WXDLLIMPEXP_FWD_GIS_DS WXDLLIMPEXP_GIS_DS
310  #define WXDLLIMPEXP_FWD_GIS_GP WXDLLIMPEXP_GIS_GP
311  #define WXDLLIMPEXP_FWD_GIS_GPU WXDLLIMPEXP_GIS_GPU
312  #define WXDLLIMPEXP_FWD_GIS_RS WXDLLIMPEXP_GIS_RS
313  #define WXDLLIMPEXP_FWD_GIS_RSU WXDLLIMPEXP_GIS_RSU
314  #define WXDLLIMPEXP_FWD_GIS_NET WXDLLIMPEXP_GIS_NET
315  #define WXDLLIMPEXP_FWD_GIS_MAPU WXDLLIMPEXP_GIS_MAPU
316  #define WXDLLIMPEXP_FWD_GIS_MAP WXDLLIMPEXP_GIS_MAP
317  #define WXDLLIMPEXP_FWD_GIS_SRVNET WXDLLIMPEXP_GIS_SRVNET
318 #endif
319 
320 #include <algorithm>
321 #include <map>
322 #include <vector>
323 #include <queue>
324 
325 #define DEF wxT("~def~")
326 #define NON wxT("~non~")
327 #define ERR wxT("~err~")
328 #define NONAME _("no name")
329 #define CACHE_SIZE 3000
330 #define EPSILON std::numeric_limits<double>::epsilon() * 16
331 #define DELTA (EPSILON * 16)
332 //M_PI
333 #define PI 3.1415926535897932384626433832795
334 #define DOUBLEPI 6.283185307179586476925286766558
335 #define PIDEG 0.017453292519943295769236907684886
336 #define DEGPI 57.295779513082320876798155633941
337 
338 /*
339  MSVC up to 6.0 needs to be explicitly told to export template instantiations
340  used by the DLL clients, use this macro to do it like this:
341 
342  template <typename T> class Foo { ... };
343  WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> )
344 
345  (notice that currently we only need this for wxBase and wxCore libraries)
346  */
347 #if defined(__VISUALC__) && (__VISUALC__ <= 1200)
348  #ifdef WXMAKINGDLL_BASE
349  #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
350  template class WXDLLIMPEXP_BASE decl;
351  #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
352  template class WXDLLIMPEXP_CORE decl;
353  #else
354  /*
355  We need to disable this warning when using this macro, as
356  recommended by Microsoft itself:
357 
358  http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958
359  */
360  #pragma warning(disable:4231)
361 
362  #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
363  extern template class WXDLLIMPEXP_BASE decl;
364  #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
365  extern template class WXDLLIMPEXP_CORE decl;
366  #endif
367 #else /* not VC <= 6 */
368  #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
369  #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl)
370 #endif /* VC6/others */
371 
372 #include "wxgisdefs.h"