]> Creatis software - bbtk.git/blob - kernel/src/bbtkSystem.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkSystem.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkSystem.h,v $
5   Language:  C++
6   Date:      $Date: 2008/07/24 14:37:05 $
7   Version:   $Revision: 1.5 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 /**
20  *\file
21  *\brief contains all the OS depending stuff
22  */
23 #ifndef __bbtkSystem_h__
24 #define __bbtkSystem_h__
25
26 #include "bbtkConfigure.h"
27
28 // We try for Visual 6..????
29 //#pragma warning( disable : 4786)
30
31
32
33 //-----------------------------------------------------------------------------
34 //This is needed when compiling in debug mode
35 #ifdef _MSC_VER
36 // 'identifier' : class 'type' needs to have dll-interface to be used by
37 // clients of class 'type2'
38 #pragma warning ( disable : 4251 )
39 // non dll-interface class 'type' used as base for dll-interface class 'type2'
40 #pragma warning ( disable : 4275 )
41 // 'identifier' : identifier was truncated to 'number' characters in the
42 // debug information
43 #pragma warning ( disable : 4786 )
44 //'identifier' : decorated name length exceeded, name was truncated
45 #pragma warning ( disable : 4503 )
46 // C++ exception specification ignored except to indicate a 
47 // function is not __declspec(nothrow)
48 #pragma warning ( disable : 4290 )
49 // signed/unsigned mismatch
50 #pragma warning ( disable : 4018 )
51 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
52 // produce errors if applied using infix notation
53 #pragma warning ( disable : 4284 )
54 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
55 // //#pragma warning ( disable : 4800 )
56 #endif //_MSC_VER
57
58
59 #include <stdio.h>  // for printf, ...
60 #include <iostream> // for cout, endl, ...
61
62 #ifdef _MSC_VER
63 // Micro$oft related stuff
64 #pragma once
65 #include <conio.h>
66 #include <tchar.h>
67 #else
68 //#include  <curses.h> // for getch
69 #endif //_MSC_VER
70
71 //-----------------------------------------------------------------------------
72 // Micro$oft shared library related stuff
73 //
74 // all the classes that must be visible outside the bbtk library 
75 // should be defined as :
76 // class BBTK_EXPORT ClassName 
77 // instead of :
78 // class ClassName
79
80
81 /*
82 // Useless ?
83 #if defined(_WIN32) 
84 //&& defined(BUILD_SHARED_LIBS)
85   #ifdef BBTK_EXPORTS2
86     #define BBTK_EXPORT2 export
87   #else
88     #define BBTK_EXPORT2 
89   #endif
90 #else
91   #define BBTK_EXPORT2
92 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
93 */
94
95
96
97 #if defined(_WIN32) 
98 //&& defined(BUILD_SHARED_LIBS)
99 //#include "WWW.h"
100   #ifdef BBTK_EXPORT_SYMBOLS
101     #define BBTK_EXPORT __declspec( dllexport )
102 #else
103     #define BBTK_EXPORT __declspec( dllimport )
104   #endif
105   #define BBTK_CDECL __cdecl
106 #else
107   #define BBTK_EXPORT
108   #define BBTK_CDECL
109 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
110
111
112
113 #ifdef __BORLANDC__
114 #include <mem.h>
115 #endif //__BORLANDC__
116
117
118
119 // ----------------------------------------------------------------------------
120 // wx headers
121 // ----------------------------------------------------------------------------
122 //#include "bbtkWx.h"
123
124 /*
125 #ifdef _USE_WXWIDGETS_
126 #include "wx/wxprec.h"
127 #include <wx/datetime.h>
128 #ifndef WX_PRECOMP
129 #   include <wx/wx.h>
130 #endif //WX_PRECOMP
131
132 #include <wx/log.h>
133
134 #ifdef __WXGTK__
135 # include <locale.h>
136 #endif //__WXGTK__
137
138 #endif //_USE_WXWIDGETS_
139 */
140 //-----------------------------------------------------------------------------
141
142
143
144
145 //-----------------------------------------------------------------------------
146 // Version
147 #include <string.h>
148
149 namespace bbtk
150 {
151 #define BBTK_STRINGIFY(A) #A
152 #define BBTK_STRINGIFY_SYMBOL(A) BBTK_STRINGIFY(A)
153
154   extern "C" 
155   {
156     BBTK_EXPORT inline const std::string& BBTK_CDECL GetVersion() 
157     {
158       static const std::string v(BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
159       return v;
160     }
161   }
162
163 }
164 //-----------------------------------------------------------------------------
165
166
167
168
169 //-----------------------------------------------------------------------------
170 /*
171 #ifdef _WIN32
172 typedef  signed char         int8_t;
173 typedef  signed short        int16_t;
174 typedef  signed int          int32_t;
175 typedef  unsigned char       uint8_t;
176 typedef  unsigned short      uint16_t;
177 typedef  unsigned int        uint32_t;
178 #else 
179 #include <stdint.h>
180 #include <inttypes.h> 
181 #endif
182 */
183
184 #ifdef CMAKE_HAVE_STDINT_H
185    #include <stdint.h>
186 #else
187 #ifdef CMAKE_HAVE_INTTYPES_H
188    // Old system only have this
189    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
190 #else
191    //#include "XXX.h"
192 // Broken plateforms do not respect C99 and do not provide those typedef
193 // Special case for recent Borland compiler, comes with stdint.h
194 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  \
195                       || defined(__MINGW32__)
196 typedef  signed char         int8_t;
197 typedef  signed short        int16_t;
198 typedef  signed int          int32_t;
199 typedef  unsigned char       uint8_t;
200 typedef  unsigned short      uint16_t;
201 typedef  unsigned int        uint32_t;
202
203 /// \todo Find a clever way to deal with int64_t, uint64_t
204
205 #else
206 #error "Sorry your plateform is not supported"
207 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  || defined(__MINGW32__)
208 #endif // CMAKE_HAVE_INTTYPES_H
209 #endif // CMAKE_HAVE_STDINT_H
210
211 // Basically for VS6 and bcc 5.5.1:
212 #ifndef UINT32_MAX
213 #define UINT32_MAX    (4294967295U)
214 #endif
215
216
217
218 //-----------------------------------------------------------------------------
219
220
221 //-----------------------------------------------------------------------------
222 namespace bbtk
223 {
224  
225   /// System related stuff
226   struct System
227   {
228     /// returns true iff the program has a tty
229     static int HasTTY(); 
230   };
231
232 } // namespace bbtk
233 //-----------------------------------------------------------------------------
234
235 #endif