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