0026843: New warning during compilation OCCT on MacOS
[occt.git] / src / OSD / OSD.hxx
1 // Copyright (c) 1992-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _OSD_HeaderFile
16 #define _OSD_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <Standard_Boolean.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_PCharacter.hxx>
26 #include <Standard_CString.hxx>
27 class OSD_Error;
28 class OSD_Protection;
29 class OSD_Path;
30 class OSD_FileNode;
31 class OSD_Disk;
32 class OSD_File;
33 class OSD_FileIterator;
34 class OSD_Directory;
35 class OSD_DirectoryIterator;
36 class OSD_Chronometer;
37 class OSD_Timer;
38 class OSD_Printer;
39 class OSD_Host;
40 class OSD_Environment;
41 class OSD_EnvironmentIterator;
42 class OSD_Process;
43 class OSD_SharedLibrary;
44 class OSD_Thread;
45
46
47 //! Set of Operating Sytem Dependent Tools
48 //! (O)perating (S)ystem (D)ependent
49 class OSD 
50 {
51 public:
52
53   DEFINE_STANDARD_ALLOC
54
55   
56   //! A tool to manage threads
57   //!
58   //! Sets signal and exception handlers.
59   //! <b>Windows-specific notes<\b>
60   //! Compiled with MS VC++ sets 3 main handlers:
61   //! @li Signal handlers (via ::signal() functions) that translate system signals
62   //! (SIGSEGV, SIGFPE, SIGILL) into C++ exceptions (classes inheriting
63   //! Standard_Failure). They only be called if user calls ::raise() function
64   //! with one of supported signal type set.
65   //! @li Exception handler OSD::WntHandler() (via ::SetUnhandledExceptionFilter())
66   //! that will be used when user's code is compiled with /EHs option.
67   //! @li Structured exception (SE) translator (via _set_se_translator()) that
68   //! translates SE exceptions (aka asynchronous exceptions) into the
69   //! C++ exceptions inheriting Standard_Failure. This translator will be
70   //! used when user's code is compiled with /EHa option.
71   //!
72   //! This approach ensures that regardless of the option the user chooses to
73   //! compile his code with (/EHs or /EHa), signals (or SE exceptions) will be
74   //! translated into Open CASCADE C++ exceptions.
75   //!
76   //! If @a theFloatingSignal is TRUE then floating point exceptions will be
77   //! generated in accordance with the mask
78   //! <tt>_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW<\tt> that is
79   //! used to call ::_controlfp() system function. If @a theFloatingSignal is FALSE
80   //! corresponding operations (e.g. division by zero) will gracefully complete
81   //! without an exception.
82   //!
83   //! <b>Unix-specific notes<\b>
84   //! OSD::SetSignal() sets handlers (via ::sigaction()) for multiple signals
85   //! (SIGFPE, SIGSEGV, etc). Currently the number of handled signals is much
86   //! greater than for Windows, in the future this may change to provide better
87   //! consistency with Windows.
88   //!
89   //! @a theFloatingSignal is recognized on Sun Solaris, Linux, and SGI Irix to
90   //! generate floating-point exception according to the mask
91   //! <tt>FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW</tt> (in Linux conventions).<br>
92   //! When compiled with OBJS macro defined, already set signal handlers (e.g.
93   //! by Data Base Managers) are not redefined.
94   //!
95   //! <b>Common notes<\b>
96   //! If OSD::SetSignal() method is used in at least one thread, it must also be
97   //! called in any other thread where Open CASCADE will be used, to ensure
98   //! consistency of behavior. Its @a aFloatingSignal argument must be consistent
99   //! across threads.
100   //!
101   //! Keep in mind that whether the C++ exception will really be thrown (i.e.
102   //! ::throw() will be called) is regulated by the NO_CXX_EXCEPTIONS and
103   //! OCC_CONVERT_SIGNALS macros used during compilation of Open CASCADE and
104   //! user's code. Refer to Foundation Classes User's Guide for further details.
105   Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True);
106   
107   //! Commands the process to sleep for a number of seconds.
108   Standard_EXPORT static void SecSleep (const Standard_Integer aDelay);
109   
110   //! Commands the process to sleep for a number of milliseconds
111   Standard_EXPORT static void MilliSecSleep (const Standard_Integer aDelay);
112   
113   //! Converts aReal into aCstring in exponential format with a period as
114   //! decimal point, no thousand separator and no grouping of digits.
115   //! The conversion is independant from the current locale
116   Standard_EXPORT static Standard_Boolean RealToCString (const Standard_Real aReal, Standard_PCharacter& aString);
117
118   //! Converts aCstring representing a real with a period as
119   //! decimal point, no thousand separator and no grouping of digits
120   //! into aReal .
121   //! The conversion is independant from the current locale.
122   Standard_EXPORT static Standard_Boolean CStringToReal (const Standard_CString aString, Standard_Real& aReal);
123   
124   //! since Windows NT does not support 'SIGINT' signal like UNIX,
125   //! then this method checks whether Ctrl-Break keystroke was or
126   //! not. If yes then raises Exception_CTRL_BREAK.
127   Standard_EXPORT static void ControlBreak();
128
129 };
130
131 #endif // _OSD_HeaderFile