1 /*=========================================================================
3 Module: $RCSfile: bbtkSystem.h,v $
5 Date: $Date: 2009/06/08 14:50:04 $
6 Version: $Revision: 1.14 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
34 *\brief contains all the OS depending stuff
36 #ifndef __bbtkSystem_h__
37 #define __bbtkSystem_h__
39 #include "bbtkConfigure.h"
41 // We try for Visual 6..????
42 //#pragma warning( disable : 4786)
46 //-----------------------------------------------------------------------------
47 //This is needed when compiling in debug mode
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
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 // Has revealed a real error !
69 // bbSignalOutputModification(bool) called rather than
70 // bbSignalOutputModification(const std::string&, bool = true)
71 // when invoking bbSignalOutputModification("Out")
73 // //#pragma warning ( disable : 4800 )
75 // 'PACKAGE_NAMEGetPackage' has C-linkage specified, but returns UDT 'boost::shared_ptr<T>' which is incompatible with C
76 #pragma warning ( disable : 4190 )
82 #include <stdio.h> // for printf, ...
83 #include <iostream> // for cout, endl, ...
86 // Micro$oft related stuff
91 //#include <curses.h> // for getch
94 //-----------------------------------------------------------------------------
95 // Micro$oft shared library related stuff
97 // all the classes that must be visible outside the bbtk library
98 // should be defined as :
99 // class BBTK_EXPORT ClassName
105 // IF NOT DEF THEN INTERNAL COMPILER ERROR WITH BOOST 1.37 ON VISUAL C++
106 #define BOOST_SP_NO_SP_CONVERTIBLE
110 //&& defined(BUILD_SHARED_LIBS)
112 #ifdef BBTK_EXPORT_SYMBOLS
113 #define BBTK_EXPORT __declspec( dllexport )
115 #define BBTK_EXPORT __declspec( dllimport )
117 #define BBTK_CDECL __cdecl
121 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
127 #endif //__BORLANDC__
133 //-----------------------------------------------------------------------------
139 #define BBTK_STRINGIFY(A) #A
140 #define BBTK_STRINGIFY_SYMBOL(A) BBTK_STRINGIFY(A)
144 BBTK_EXPORT inline const std::string& BBTK_CDECL GetVersion()
146 static const std::string v(BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
152 //-----------------------------------------------------------------------------
157 //-----------------------------------------------------------------------------
160 typedef signed char int8_t;
161 typedef signed short int16_t;
162 typedef signed int int32_t;
163 typedef unsigned char uint8_t;
164 typedef unsigned short uint16_t;
165 typedef unsigned int uint32_t;
168 #include <inttypes.h>
172 #ifdef CMAKE_HAVE_STDINT_H
175 #ifdef CMAKE_HAVE_INTTYPES_H
176 // Old system only have this
177 #include <inttypes.h> // For uint8_t uint16_t and uint32_t
180 // Broken plateforms do not respect C99 and do not provide those typedef
181 // Special case for recent Borland compiler, comes with stdint.h
182 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) \
183 || defined(__MINGW32__)
184 typedef signed char int8_t;
185 typedef signed short int16_t;
186 typedef signed int int32_t;
187 typedef unsigned char uint8_t;
188 typedef unsigned short uint16_t;
189 typedef unsigned int uint32_t;
191 /// \todo Find a clever way to deal with int64_t, uint64_t
194 #error "Sorry your plateform is not supported"
195 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) || defined(__MINGW32__)
196 #endif // CMAKE_HAVE_INTTYPES_H
197 #endif // CMAKE_HAVE_STDINT_H
199 // Basically for VS6 and bcc 5.5.1:
201 #define UINT32_MAX (4294967295U)
206 //-----------------------------------------------------------------------------
209 //-----------------------------------------------------------------------------
213 /// System related stuff
216 /// returns true iff the program has a tty
221 //-----------------------------------------------------------------------------
225 #define VALID_FILE_SEPARATOR "\\"
226 #define INVALID_FILE_SEPARATOR "/"
227 #define VALID_FILE_SEPARATOR_CHAR '\\'
228 #define INVALID_FILE_SEPARATOR_CHAR '/'
230 #define INVALID_FILE_SEPARATOR "\\"
231 #define VALID_FILE_SEPARATOR "/"
232 #define INVALID_FILE_SEPARATOR_CHAR '\\'
233 #define VALID_FILE_SEPARATOR_CHAR '/'
239 //----------------------------
241 #include <unistd.h> //for access, unlink
243 #include <io.h> //for _access on Win32
247 # define access _access
253 //===========================================================
254 // Define the groups (modules) for doxygen documentation
256 * \defgroup box Black boxes related classes
257 * \defgroup interface Graphical User Interface components
258 * \defgroup data Data