]> 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/10 12:25:10 $
7   Version:   $Revision: 1.8 $
8                                                                                
9  Copyright (c) CREATIS-LRMN 
10    Centre de Recherche Et d'Application en Traitement de l'Image et du Signal
11  Authors : Laurent Guigues, Eduardo Davila, Jean-Pierre Roux
12  e-mail  : creatools@creatis.insa-lyon.fr
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 /**
34  *\file
35  *\brief contains all the OS depending stuff
36  */
37 #ifndef __bbtkSystem_h__
38 #define __bbtkSystem_h__
39
40 #include "bbtkConfigure.h"
41
42 // We try for Visual 6..????
43 //#pragma warning( disable : 4786)
44
45
46
47 //-----------------------------------------------------------------------------
48 //This is needed when compiling in debug mode
49 #ifdef _MSC_VER
50 // 'identifier' : class 'type' needs to have dll-interface to be used by
51 // clients of class 'type2'
52 #pragma warning ( disable : 4251 )
53 // non dll-interface class 'type' used as base for dll-interface class 'type2'
54 #pragma warning ( disable : 4275 )
55 // 'identifier' : identifier was truncated to 'number' characters in the
56 // debug information
57 #pragma warning ( disable : 4786 )
58 //'identifier' : decorated name length exceeded, name was truncated
59 #pragma warning ( disable : 4503 )
60 // C++ exception specification ignored except to indicate a 
61 // function is not __declspec(nothrow)
62 #pragma warning ( disable : 4290 )
63 // signed/unsigned mismatch
64 #pragma warning ( disable : 4018 )
65 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
66 // produce errors if applied using infix notation
67 #pragma warning ( disable : 4284 )
68 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
69 // //#pragma warning ( disable : 4800 )
70 #endif //_MSC_VER
71
72
73 #include <stdio.h>  // for printf, ...
74 #include <iostream> // for cout, endl, ...
75
76 #ifdef _MSC_VER
77 // Micro$oft related stuff
78 #pragma once
79 #include <conio.h>
80 #include <tchar.h>
81 #else
82 //#include  <curses.h> // for getch
83 #endif //_MSC_VER
84
85 //-----------------------------------------------------------------------------
86 // Micro$oft shared library related stuff
87 //
88 // all the classes that must be visible outside the bbtk library 
89 // should be defined as :
90 // class BBTK_EXPORT ClassName 
91 // instead of :
92 // class ClassName
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
121 //-----------------------------------------------------------------------------
122 // Version
123 #include <string.h>
124
125 namespace bbtk
126 {
127 #define BBTK_STRINGIFY(A) #A
128 #define BBTK_STRINGIFY_SYMBOL(A) BBTK_STRINGIFY(A)
129
130   extern "C" 
131   {
132     BBTK_EXPORT inline const std::string& BBTK_CDECL GetVersion() 
133     {
134       static const std::string v(BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
135       return v;
136     }
137   }
138
139 }
140 //-----------------------------------------------------------------------------
141
142
143
144
145 //-----------------------------------------------------------------------------
146 /*
147 #ifdef _WIN32
148 typedef  signed char         int8_t;
149 typedef  signed short        int16_t;
150 typedef  signed int          int32_t;
151 typedef  unsigned char       uint8_t;
152 typedef  unsigned short      uint16_t;
153 typedef  unsigned int        uint32_t;
154 #else 
155 #include <stdint.h>
156 #include <inttypes.h> 
157 #endif
158 */
159
160 #ifdef CMAKE_HAVE_STDINT_H
161    #include <stdint.h>
162 #else
163 #ifdef CMAKE_HAVE_INTTYPES_H
164    // Old system only have this
165    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
166 #else
167    //#include "XXX.h"
168 // Broken plateforms do not respect C99 and do not provide those typedef
169 // Special case for recent Borland compiler, comes with stdint.h
170 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  \
171                       || defined(__MINGW32__)
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
179 /// \todo Find a clever way to deal with int64_t, uint64_t
180
181 #else
182 #error "Sorry your plateform is not supported"
183 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  || defined(__MINGW32__)
184 #endif // CMAKE_HAVE_INTTYPES_H
185 #endif // CMAKE_HAVE_STDINT_H
186
187 // Basically for VS6 and bcc 5.5.1:
188 #ifndef UINT32_MAX
189 #define UINT32_MAX    (4294967295U)
190 #endif
191
192
193
194 //-----------------------------------------------------------------------------
195
196
197 //-----------------------------------------------------------------------------
198 namespace bbtk
199 {
200  
201   /// System related stuff
202   struct System
203   {
204     /// returns true iff the program has a tty
205     static int HasTTY(); 
206   };
207
208 } // namespace bbtk
209 //-----------------------------------------------------------------------------
210
211     // file separator
212 #if defined(_WIN32)
213 #define VALID_FILE_SEPARATOR "\\"
214 #define INVALID_FILE_SEPARATOR "/"
215 #else
216 #define INVALID_FILE_SEPARATOR "\\"
217 #define VALID_FILE_SEPARATOR "/"
218 #endif
219
220 #endif