]> 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/10/02 12:29:26 $
7   Version:   $Revision: 1.7 $
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
83 #if defined(_WIN32) 
84 //&& defined(BUILD_SHARED_LIBS)
85 //#include "WWW.h"
86   #ifdef BBTK_EXPORT_SYMBOLS
87     #define BBTK_EXPORT __declspec( dllexport )
88 #else
89     #define BBTK_EXPORT __declspec( dllimport )
90   #endif
91   #define BBTK_CDECL __cdecl
92 #else
93   #define BBTK_EXPORT
94   #define BBTK_CDECL
95 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
96
97
98
99 #ifdef __BORLANDC__
100 #include <mem.h>
101 #endif //__BORLANDC__
102
103
104
105
106
107 //-----------------------------------------------------------------------------
108 // Version
109 #include <string.h>
110
111 namespace bbtk
112 {
113 #define BBTK_STRINGIFY(A) #A
114 #define BBTK_STRINGIFY_SYMBOL(A) BBTK_STRINGIFY(A)
115
116   extern "C" 
117   {
118     BBTK_EXPORT inline const std::string& BBTK_CDECL GetVersion() 
119     {
120       static const std::string v(BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
121       return v;
122     }
123   }
124
125 }
126 //-----------------------------------------------------------------------------
127
128
129
130
131 //-----------------------------------------------------------------------------
132 /*
133 #ifdef _WIN32
134 typedef  signed char         int8_t;
135 typedef  signed short        int16_t;
136 typedef  signed int          int32_t;
137 typedef  unsigned char       uint8_t;
138 typedef  unsigned short      uint16_t;
139 typedef  unsigned int        uint32_t;
140 #else 
141 #include <stdint.h>
142 #include <inttypes.h> 
143 #endif
144 */
145
146 #ifdef CMAKE_HAVE_STDINT_H
147    #include <stdint.h>
148 #else
149 #ifdef CMAKE_HAVE_INTTYPES_H
150    // Old system only have this
151    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
152 #else
153    //#include "XXX.h"
154 // Broken plateforms do not respect C99 and do not provide those typedef
155 // Special case for recent Borland compiler, comes with stdint.h
156 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  \
157                       || defined(__MINGW32__)
158 typedef  signed char         int8_t;
159 typedef  signed short        int16_t;
160 typedef  signed int          int32_t;
161 typedef  unsigned char       uint8_t;
162 typedef  unsigned short      uint16_t;
163 typedef  unsigned int        uint32_t;
164
165 /// \todo Find a clever way to deal with int64_t, uint64_t
166
167 #else
168 #error "Sorry your plateform is not supported"
169 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  || defined(__MINGW32__)
170 #endif // CMAKE_HAVE_INTTYPES_H
171 #endif // CMAKE_HAVE_STDINT_H
172
173 // Basically for VS6 and bcc 5.5.1:
174 #ifndef UINT32_MAX
175 #define UINT32_MAX    (4294967295U)
176 #endif
177
178
179
180 //-----------------------------------------------------------------------------
181
182
183 //-----------------------------------------------------------------------------
184 namespace bbtk
185 {
186  
187   /// System related stuff
188   struct System
189   {
190     /// returns true iff the program has a tty
191     static int HasTTY(); 
192   };
193
194 } // namespace bbtk
195 //-----------------------------------------------------------------------------
196
197     // file separator
198 #if defined(_WIN32)
199 #define VALID_FILE_SEPARATOR "\\"
200 #define INVALID_FILE_SEPARATOR "/"
201 #else
202 #define INVALID_FILE_SEPARATOR "\\"
203 #define VALID_FILE_SEPARATOR "/"
204 #endif
205
206 #endif