1 /*=========================================================================
4 Module: $RCSfile: creaSystem.h,v $
6 Date: $Date: 2010/06/11 05:06:46 $
7 Version: $Revision: 1.12 $
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.
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.
17 =========================================================================*/
21 *\brief contains all the OS depending stuff
23 #ifndef __creaSystem_h__
24 #define __creaSystem_h__
26 #include "creaConfigure.h"
28 // We try for Visual 6..????
29 //#pragma warning( disable : 4786)
31 //-----------------------------------------------------------------------------
32 //This is needed when compiling in debug mode
34 // 'identifier' : class 'type' needs to have dll-interface to be used by
35 // clients of class 'type2'
36 #pragma warning ( disable : 4251 )
37 // non dll-interface class 'type' used as base for dll-interface class 'type2'
38 #pragma warning ( disable : 4275 )
39 // 'identifier' : identifier was truncated to 'number' characters in the
41 #pragma warning ( disable : 4786 )
42 //'identifier' : decorated name length exceeded, name was truncated
43 #pragma warning ( disable : 4503 )
44 // C++ exception specification ignored except to indicate a
45 // function is not __declspec(nothrow)
46 #pragma warning ( disable : 4290 )
47 // signed/unsigned mismatch
48 #pragma warning ( disable : 4018 )
49 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
50 // produce errors if applied using infix notation
51 #pragma warning ( disable : 4284 )
52 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
53 // //#pragma warning ( disable : 4800 )
57 #include <stdio.h> // for printf, ...
58 #include <iostream> // for cout, endl, ...
61 // Micro$oft related stuff
66 //#include <curses.h> // for getch
69 //-----------------------------------------------------------------------------
70 // Micro$oft shared library related stuff
72 // all the classes that must be visible outside the crea library
73 // should be defined as :
74 // class CREA_EXPORT ClassName
82 //&& defined(BUILD_SHARED_LIBS)
84 #define CREA_EXPORT2 export
90 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
95 #if defined(_WIN32) && defined(CREA_BUILD_SHARED)
96 #ifdef CREA_EXPORT_SYMBOLS
97 #define CREA_EXPORT __declspec( dllexport )
99 #define CREA_EXPORT __declspec( dllimport )
101 #define CREA_CDECL __cdecl
105 #endif // defined(_WIN32) && defined(CREA_BUILD_SHARED)
110 #endif //__BORLANDC__
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
117 //#include "creaWx.h"
120 #ifdef _USE_WXWIDGETS_
121 #include "wx/wxprec.h"
122 #include <wx/datetime.h>
133 #endif //_USE_WXWIDGETS_
135 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------
143 #define CREA_STRINGIFY(A) #A
144 #define CREA_STRINGIFY_SYMBOL(A) CREA_STRINGIFY(A)
148 CREA_EXPORT inline const std::string& CREA_CDECL GetVersion()
150 static const std::string v(CREA_STRINGIFY_SYMBOL(CREA_VERSION));
156 //-----------------------------------------------------------------------------
158 //-----------------------------------------------------------------------------
161 typedef signed char int8_t;
162 typedef signed short int16_t;
163 typedef signed int int32_t;
164 typedef unsigned char uint8_t;
165 typedef unsigned short uint16_t;
166 typedef unsigned int uint32_t;
169 #include <inttypes.h>
173 #ifdef CMAKE_HAVE_STDINT_H
176 #ifdef CMAKE_HAVE_INTTYPES_H
177 // Old system only have this
178 #include <inttypes.h> // For uint8_t uint16_t and uint32_t
181 // Broken plateforms do not respect C99 and do not provide those typedef
182 // Special case for recent Borland compiler, comes with stdint.h
183 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) \
184 || defined(__MINGW32__)
185 typedef signed char int8_t;
186 typedef signed short int16_t;
187 typedef signed int int32_t;
188 typedef unsigned char uint8_t;
189 typedef unsigned short uint16_t;
190 typedef unsigned int uint32_t;
192 /// \todo Find a clever way to deal with int64_t, uint64_t
195 #error "Sorry your plateform is not supported"
196 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) || defined(__MINGW32__)
197 #endif // CMAKE_HAVE_INTTYPES_H
198 #endif // CMAKE_HAVE_STDINT_H
200 // Basically for VS6 and bcc 5.5.1:
202 #define UINT32_MAX (4294967295U)
205 //-----------------------------------------------------------------------------
208 //-----------------------------------------------------------------------------
212 /// System related stuff
215 /// returns true iff the program has a tty
217 CREA_EXPORT static int GetAppPath(char *pname, size_t pathsize);
218 CREA_EXPORT static std::string GetDllAppPath(std::string &nomdll);
219 CREA_EXPORT static std::string GetDllAppPath(const char *nomdll);
220 CREA_EXPORT static std::string GetExecutablePath();
221 CREA_EXPORT static void createDirectory(const char* directorypath);
225 //-----------------------------------------------------------------------------
229 #define VALID_FILE_SEPARATOR "\\"
230 #define INVALID_FILE_SEPARATOR "/"
232 #define INVALID_FILE_SEPARATOR "\\"
233 #define VALID_FILE_SEPARATOR "/"