]> Creatis software - crea.git/blob - src/creaSystem.h
#3180 crea Feature New Normal Future - Set wx-config for wxWidgets 2.8
[crea.git] / src / creaSystem.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                                                                                 
30   Program:   crea
31   Module:    $RCSfile: creaSystem.h,v $
32   Language:  C++
33   Date:      $Date: 2012/11/15 10:43:26 $
34   Version:   $Revision: 1.16 $
35 =========================================================================*/
36
37 /**
38  *\file
39  *\brief contains all the OS depending stuff
40  */
41 #ifndef __creaSystem_h__
42 #define __creaSystem_h__
43
44 #include "creaConfigure.h"
45
46 // We try for Visual 6..????
47 //#pragma warning( disable : 4786)
48
49 //-----------------------------------------------------------------------------
50 //This is needed when compiling in debug mode
51 #ifdef _MSC_VER
52 // 'identifier' : class 'type' needs to have dll-interface to be used by
53 // clients of class 'type2'
54 #pragma warning ( disable : 4251 )
55 // non dll-interface class 'type' used as base for dll-interface class 'type2'
56 #pragma warning ( disable : 4275 )
57 // 'identifier' : identifier was truncated to 'number' characters in the
58 // debug information
59 #pragma warning ( disable : 4786 )
60 //'identifier' : decorated name length exceeded, name was truncated
61 #pragma warning ( disable : 4503 )
62 // C++ exception specification ignored except to indicate a 
63 // function is not __declspec(nothrow)
64 #pragma warning ( disable : 4290 )
65 // signed/unsigned mismatch
66 #pragma warning ( disable : 4018 )
67 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
68 // produce errors if applied using infix notation
69 #pragma warning ( disable : 4284 )
70 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
71 // //#pragma warning ( disable : 4800 )
72 #endif //_MSC_VER
73
74
75 #include <stdio.h>  // for printf, ...
76 #include <iostream> // for cout, endl, ...
77
78 #ifdef _MSC_VER
79 // Micro$oft related stuff
80 #pragma once
81 #include <conio.h>
82 #include <tchar.h>
83 #else
84 //#include  <curses.h> // for getch
85 #endif //_MSC_VER
86
87 //-----------------------------------------------------------------------------
88 // Micro$oft shared library related stuff
89 //
90 // all the classes that must be visible outside the crea library 
91 // should be defined as :
92 // class CREA_EXPORT ClassName 
93 // instead of :
94 // class ClassName
95
96
97 /*
98 // Useless ?
99 #if defined(_WIN32) 
100 //&& defined(BUILD_SHARED_LIBS)
101   #ifdef CREA_EXPORTS2
102     #define CREA_EXPORT2 export
103   #else
104     #define CREA_EXPORT2 
105   #endif
106 #else
107   #define CREA_EXPORT2
108 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
109 */
110 //#define TEST toto
111
112
113 #if defined(_WIN32) && defined(CREA_BUILD_SHARED)
114   #ifdef CREA_EXPORT_SYMBOLS
115     #define CREA_EXPORT __declspec( dllexport ) 
116   #else
117         #define CREA_EXPORT __declspec( dllimport )
118   #endif
119   #define CREA_CDECL __cdecl
120 #else
121   #define CREA_EXPORT
122   #define CREA_CDECL
123 #endif // defined(_WIN32) && defined(CREA_BUILD_SHARED)
124
125
126 #ifdef __BORLANDC__
127 #include <mem.h>
128 #endif //__BORLANDC__
129
130
131
132 // ----------------------------------------------------------------------------
133 // wx headers
134 // ----------------------------------------------------------------------------
135 //#include "creaWx.h"
136
137 /*
138 #ifdef _USE_WXWIDGETS_
139 #include "wx/wxprec.h"
140 #include <wx/datetime.h>
141 #ifndef WX_PRECOMP
142 #   include <wx/wx.h>
143 #endif //WX_PRECOMP
144
145 #include <wx/log.h>
146
147 #ifdef __WXGTK__
148 # include <locale.h>
149 #endif //__WXGTK__
150
151 #endif //_USE_WXWIDGETS_
152 */
153 //-----------------------------------------------------------------------------
154
155 //-----------------------------------------------------------------------------
156 // Version
157 #include <string.h>
158
159 namespace crea
160 {
161 #define CREA_STRINGIFY(A) #A
162 #define CREA_STRINGIFY_SYMBOL(A) CREA_STRINGIFY(A)
163
164   extern "C" 
165   {
166     CREA_EXPORT inline const std::string& CREA_CDECL GetVersion() 
167     {
168       static const std::string v(CREA_STRINGIFY_SYMBOL(CREA_VERSION));
169       return v;
170     }
171   }
172
173 }
174 //-----------------------------------------------------------------------------
175
176 //-----------------------------------------------------------------------------
177 /*
178 #ifdef _WIN32
179 typedef  signed char         int8_t;
180 typedef  signed short        int16_t;
181 typedef  signed int          int32_t;
182 typedef  unsigned char       uint8_t;
183 typedef  unsigned short      uint16_t;
184 typedef  unsigned int        uint32_t;
185 #else 
186 #include <stdint.h>
187 #include <inttypes.h> 
188 #endif
189 */
190
191 #ifdef CMAKE_HAVE_STDINT_H
192    #include <stdint.h>
193 #else
194 #ifdef CMAKE_HAVE_INTTYPES_H
195    // Old system only have this
196    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
197 #else
198    //#include "XXX.h"
199 // Broken plateforms do not respect C99 and do not provide those typedef
200 // Special case for recent Borland compiler, comes with stdint.h
201 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  \
202                       || defined(__MINGW32__)
203 typedef  signed char         int8_t;
204 typedef  signed short        int16_t;
205 typedef  signed int          int32_t;
206 typedef  unsigned char       uint8_t;
207 typedef  unsigned short      uint16_t;
208 typedef  unsigned int        uint32_t;
209
210 /// \todo Find a clever way to deal with int64_t, uint64_t
211
212 #else
213 #error "Sorry your plateform is not supported"
214 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560)  || defined(__MINGW32__)
215 #endif // CMAKE_HAVE_INTTYPES_H
216 #endif // CMAKE_HAVE_STDINT_H
217
218 // Basically for VS6 and bcc 5.5.1:
219 #ifndef UINT32_MAX
220 #define UINT32_MAX    (4294967295U)
221 #endif
222
223 //-----------------------------------------------------------------------------
224
225
226 //-----------------------------------------------------------------------------
227 namespace crea
228 {
229  
230   /// System related stuff
231   struct System
232   {
233     /// returns true iff the program has a tty
234     static int HasTTY(); 
235     CREA_EXPORT static int GetAppPath(char *pname, size_t pathsize);
236     CREA_EXPORT static std::string GetDllAppPath(std::string &nomdll);
237     CREA_EXPORT static std::string GetDllAppPath(const char *nomdll);   
238     CREA_EXPORT static std::string GetExecutablePath();
239     CREA_EXPORT static void createDirectory(const char* directorypath);
240   };
241
242 } // namespace crea
243 //-----------------------------------------------------------------------------
244
245     // file separator
246 #if defined(_WIN32)
247 #define VALID_FILE_SEPARATOR "\\"
248 #define INVALID_FILE_SEPARATOR "/"
249 #else
250 #define INVALID_FILE_SEPARATOR "\\"
251 #define VALID_FILE_SEPARATOR "/"
252 #endif
253
254 #endif