]> Creatis software - bbtk.git/blob - kernel/src/bbtkSystem.h
Feature #1774
[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   // IF NOT DEF THEN INTERNAL COMPILER ERROR WITH BOOST 1.37 ON VISUAL C++ 
113   #define BOOST_SP_NO_SP_CONVERTIBLE
114 #endif
115
116 #if defined(_WIN32) 
117 //&& defined(BUILD_SHARED_LIBS)
118 //#include "WWW.h"
119   #ifdef BBTK_EXPORT_SYMBOLS
120     #define BBTK_EXPORT __declspec( dllexport )
121 #else
122     #define BBTK_EXPORT __declspec( dllimport )
123   #endif
124   #define BBTK_CDECL __cdecl
125 #else
126   #define BBTK_EXPORT
127   #define BBTK_CDECL
128 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
129
130
131
132 #ifdef __BORLANDC__
133 #include <mem.h>
134 #endif //__BORLANDC__
135
136
137
138
139
140 //-----------------------------------------------------------------------------
141 // Version
142 #include <string.h>
143
144 namespace bbtk
145 {
146 #define BBTK_STRINGIFY(A) #A
147 #define BBTK_STRINGIFY_SYMBOL(A) BBTK_STRINGIFY(A)
148
149   extern "C" 
150   {
151     BBTK_EXPORT inline const std::string& BBTK_CDECL GetVersion() 
152     {
153       static const std::string v(BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
154       return v;
155     }
156   }
157
158 }
159 //-----------------------------------------------------------------------------
160
161
162
163
164 //-----------------------------------------------------------------------------
165 /*
166 #ifdef _WIN32
167 typedef  signed char         int8_t;
168 typedef  signed short        int16_t;
169 typedef  signed int          int32_t;
170 typedef  unsigned char       uint8_t;
171 typedef  unsigned short      uint16_t;
172 typedef  unsigned int        uint32_t;
173 #else 
174 #include <stdint.h>
175 #include <inttypes.h> 
176 #endif
177 */
178
179 #ifdef CMAKE_HAVE_STDINT_H
180    #include <stdint.h>
181 #else
182 #ifdef CMAKE_HAVE_INTTYPES_H
183    // Old system only have this
184    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
185 #else
186    //#include "XXX.h"
187 // Broken plateforms do not respect C99 and do not provide those typedef
188 // Special case for recent Borland compiler, comes with stdint.h
189 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  \
190                       || defined(__MINGW32__)
191 typedef  signed char         int8_t;
192 typedef  signed short        int16_t;
193 typedef  signed int          int32_t;
194 typedef  unsigned char       uint8_t;
195 typedef  unsigned short      uint16_t;
196 typedef  unsigned int        uint32_t;
197
198 /// \todo Find a clever way to deal with int64_t, uint64_t
199
200 #else
201 #error "Sorry your plateform is not supported"
202 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  || defined(__MINGW32__)
203 #endif // CMAKE_HAVE_INTTYPES_H
204 #endif // CMAKE_HAVE_STDINT_H
205
206 // Basically for VS6 and bcc 5.5.1:
207 #ifndef UINT32_MAX
208 #define UINT32_MAX    (4294967295U)
209 #endif
210
211
212
213 //-----------------------------------------------------------------------------
214
215
216 //-----------------------------------------------------------------------------
217 namespace bbtk
218 {
219  
220   /// System related stuff
221   struct System
222   {
223     /// returns true iff the program has a tty
224     static int HasTTY(); 
225   };
226
227 } // namespace bbtk
228 //-----------------------------------------------------------------------------
229
230     // file separator
231 #if defined(_WIN32)
232 #define VALID_FILE_SEPARATOR "\\"
233 #define INVALID_FILE_SEPARATOR "/"
234 #define VALID_FILE_SEPARATOR_CHAR '\\'
235 #define INVALID_FILE_SEPARATOR_CHAR '/'
236 #else
237 #define INVALID_FILE_SEPARATOR "\\"
238 #define VALID_FILE_SEPARATOR "/"
239 #define INVALID_FILE_SEPARATOR_CHAR '\\'
240 #define VALID_FILE_SEPARATOR_CHAR '/'
241 #endif
242
243 #endif
244
245
246 //----------------------------
247 #ifndef _WIN32
248 #include <unistd.h> //for access, unlink
249 #else
250 #include <io.h> //for _access on Win32
251 #endif
252
253 #ifdef _MSC_VER
254 # define access _access
255 #endif
256
257
258
259
260 //===========================================================
261 // Define the groups (modules) for doxygen documentation
262 /**
263  * \defgroup box Black boxes related classes
264  * \defgroup interface Graphical User Interface components
265  * \defgroup data Data
266 */