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