]> Creatis software - bbtk.git/blob - kernel/src/bbtkSystem.h
0b36ebf882d39dec8754de8bc63a89ed4ccd5864
[bbtk.git] / kernel / src / bbtkSystem.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkSystem.h,v $
4   Language:  C++
5   Date:      $Date: 2008/11/12 12:47:01 $
6   Version:   $Revision: 1.10 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  *\file
34  *\brief contains all the OS depending stuff
35  */
36 #ifndef __bbtkSystem_h__
37 #define __bbtkSystem_h__
38
39 #include "bbtkConfigure.h"
40
41 // We try for Visual 6..????
42 //#pragma warning( disable : 4786)
43
44
45
46 //-----------------------------------------------------------------------------
47 //This is needed when compiling in debug mode
48 #ifdef _MSC_VER
49 // 'identifier' : class 'type' needs to have dll-interface to be used by
50 // clients of class 'type2'
51 #pragma warning ( disable : 4251 )
52 // non dll-interface class 'type' used as base for dll-interface class 'type2'
53 #pragma warning ( disable : 4275 )
54 // 'identifier' : identifier was truncated to 'number' characters in the
55 // debug information
56 #pragma warning ( disable : 4786 )
57 //'identifier' : decorated name length exceeded, name was truncated
58 #pragma warning ( disable : 4503 )
59 // C++ exception specification ignored except to indicate a 
60 // function is not __declspec(nothrow)
61 #pragma warning ( disable : 4290 )
62 // signed/unsigned mismatch
63 #pragma warning ( disable : 4018 )
64 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
65 // produce errors if applied using infix notation
66 #pragma warning ( disable : 4284 )
67 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
68 // //#pragma warning ( disable : 4800 )
69 #endif //_MSC_VER
70
71
72 #include <stdio.h>  // for printf, ...
73 #include <iostream> // for cout, endl, ...
74
75 #ifdef _MSC_VER
76 // Micro$oft related stuff
77 #pragma once
78 #include <conio.h>
79 #include <tchar.h>
80 #else
81 //#include  <curses.h> // for getch
82 #endif //_MSC_VER
83
84 //-----------------------------------------------------------------------------
85 // Micro$oft shared library related stuff
86 //
87 // all the classes that must be visible outside the bbtk library 
88 // should be defined as :
89 // class BBTK_EXPORT ClassName 
90 // instead of :
91 // class ClassName
92
93
94
95
96 #if defined(_WIN32) 
97 //&& defined(BUILD_SHARED_LIBS)
98 //#include "WWW.h"
99   #ifdef BBTK_EXPORT_SYMBOLS
100     #define BBTK_EXPORT __declspec( dllexport )
101 #else
102     #define BBTK_EXPORT __declspec( dllimport )
103   #endif
104   #define BBTK_CDECL __cdecl
105 #else
106   #define BBTK_EXPORT
107   #define BBTK_CDECL
108 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
109
110
111
112 #ifdef __BORLANDC__
113 #include <mem.h>
114 #endif //__BORLANDC__
115
116
117
118
119
120 //-----------------------------------------------------------------------------
121 // Version
122 #include <string.h>
123
124 namespace bbtk
125 {
126 #define BBTK_STRINGIFY(A) #A
127 #define BBTK_STRINGIFY_SYMBOL(A) BBTK_STRINGIFY(A)
128
129   extern "C" 
130   {
131     BBTK_EXPORT inline const std::string& BBTK_CDECL GetVersion() 
132     {
133       static const std::string v(BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
134       return v;
135     }
136   }
137
138 }
139 //-----------------------------------------------------------------------------
140
141
142
143
144 //-----------------------------------------------------------------------------
145 /*
146 #ifdef _WIN32
147 typedef  signed char         int8_t;
148 typedef  signed short        int16_t;
149 typedef  signed int          int32_t;
150 typedef  unsigned char       uint8_t;
151 typedef  unsigned short      uint16_t;
152 typedef  unsigned int        uint32_t;
153 #else 
154 #include <stdint.h>
155 #include <inttypes.h> 
156 #endif
157 */
158
159 #ifdef CMAKE_HAVE_STDINT_H
160    #include <stdint.h>
161 #else
162 #ifdef CMAKE_HAVE_INTTYPES_H
163    // Old system only have this
164    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
165 #else
166    //#include "XXX.h"
167 // Broken plateforms do not respect C99 and do not provide those typedef
168 // Special case for recent Borland compiler, comes with stdint.h
169 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  \
170                       || defined(__MINGW32__)
171 typedef  signed char         int8_t;
172 typedef  signed short        int16_t;
173 typedef  signed int          int32_t;
174 typedef  unsigned char       uint8_t;
175 typedef  unsigned short      uint16_t;
176 typedef  unsigned int        uint32_t;
177
178 /// \todo Find a clever way to deal with int64_t, uint64_t
179
180 #else
181 #error "Sorry your plateform is not supported"
182 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  || defined(__MINGW32__)
183 #endif // CMAKE_HAVE_INTTYPES_H
184 #endif // CMAKE_HAVE_STDINT_H
185
186 // Basically for VS6 and bcc 5.5.1:
187 #ifndef UINT32_MAX
188 #define UINT32_MAX    (4294967295U)
189 #endif
190
191
192
193 //-----------------------------------------------------------------------------
194
195
196 //-----------------------------------------------------------------------------
197 namespace bbtk
198 {
199  
200   /// System related stuff
201   struct System
202   {
203     /// returns true iff the program has a tty
204     static int HasTTY(); 
205   };
206
207 } // namespace bbtk
208 //-----------------------------------------------------------------------------
209
210     // file separator
211 #if defined(_WIN32)
212 #define VALID_FILE_SEPARATOR "\\"
213 #define INVALID_FILE_SEPARATOR "/"
214 #define VALID_FILE_SEPARATOR_CHAR '\\'
215 #define INVALID_FILE_SEPARATOR_CHAR '/'
216 #else
217 #define INVALID_FILE_SEPARATOR "\\"
218 #define VALID_FILE_SEPARATOR "/"
219 #define INVALID_FILE_SEPARATOR_CHAR '\\'
220 #define VALID_FILE_SEPARATOR_CHAR '/'
221 #endif
222
223 #endif