0026937: Eliminate NO_CXX_EXCEPTION macro support
[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_Timer;
37 class OSD_Host;
38 class OSD_Environment;
39 class OSD_EnvironmentIterator;
40 class OSD_Process;
41 class OSD_SharedLibrary;
42 class OSD_Thread;
43
44
45 //! Set of Operating Sytem Dependent Tools
46 //! (O)perating (S)ystem (D)ependent
47 class OSD 
48 {
49 public:
50
51   DEFINE_STANDARD_ALLOC
52
53   
54   //! Sets signal and exception handlers.
55   //!
56   //! ### Windows-specific notes
57   //!
58   //! Compiled with MS VC++ sets 3 main handlers:
59   //! @li Signal handlers (via ::signal() functions) that translate system signals
60   //! (SIGSEGV, SIGFPE, SIGILL) into C++ exceptions (classes inheriting
61   //! Standard_Failure). They only be called if user calls ::raise() function
62   //! with one of supported signal type set.
63   //! @li Exception handler OSD::WntHandler() (via ::SetUnhandledExceptionFilter())
64   //! that will be used when user's code is compiled with /EHs option.
65   //! @li Structured exception (SE) translator (via _set_se_translator()) that
66   //! translates SE exceptions (aka asynchronous exceptions) into the
67   //! C++ exceptions inheriting Standard_Failure. This translator will be
68   //! used when user's code is compiled with /EHa option.
69   //!
70   //! This approach ensures that regardless of the option the user chooses to
71   //! compile his code with (/EHs or /EHa), signals (or SE exceptions) will be
72   //! translated into Open CASCADE C++ exceptions.
73   //!
74   //! If @a theFloatingSignal is TRUE then floating point exceptions will be
75   //! generated in accordance with the mask
76   //! <tt>_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW</tt> that is
77   //! used to call ::_controlfp() system function. If @a theFloatingSignal is FALSE
78   //! corresponding operations (e.g. division by zero) will gracefully complete
79   //! without an exception.
80   //!
81   //! ### Unix-specific notes
82   //!
83   //! OSD::SetSignal() sets handlers (via ::sigaction()) for multiple signals
84   //! (SIGFPE, SIGSEGV, etc). Currently the number of handled signals is much
85   //! greater than for Windows, in the future this may change to provide better
86   //! consistency with Windows.
87   //!
88   //! @a theFloatingSignal is recognized on Sun Solaris, Linux, and SGI Irix to
89   //! generate floating-point exception according to the mask
90   //! <tt>FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW</tt> (in Linux conventions).<br>
91   //! When compiled with OBJS macro defined, already set signal handlers (e.g.
92   //! by Data Base Managers) are not redefined.
93   //!
94   //! ### Common notes
95   //!
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
103   //! OCC_CONVERT_SIGNALS macro used during compilation of Open CASCADE and
104   //! user's code. Refer to Foundation Classes User's Guide for further details.
105   //!
106   Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True);
107   
108   //! Commands the process to sleep for a number of seconds.
109   Standard_EXPORT static void SecSleep (const Standard_Integer aDelay);
110   
111   //! Commands the process to sleep for a number of milliseconds
112   Standard_EXPORT static void MilliSecSleep (const Standard_Integer aDelay);
113   
114   //! Converts aReal into aCstring in exponential format with a period as
115   //! decimal point, no thousand separator and no grouping of digits.
116   //! The conversion is independant from the current locale
117   Standard_EXPORT static Standard_Boolean RealToCString (const Standard_Real aReal, Standard_PCharacter& aString);
118
119   //! Converts aCstring representing a real with a period as
120   //! decimal point, no thousand separator and no grouping of digits
121   //! into aReal .
122   //! The conversion is independant from the current locale.
123   Standard_EXPORT static Standard_Boolean CStringToReal (const Standard_CString aString, Standard_Real& aReal);
124   
125   //! since Windows NT does not support 'SIGINT' signal like UNIX,
126   //! then this method checks whether Ctrl-Break keystroke was or
127   //! not. If yes then raises Exception_CTRL_BREAK.
128   Standard_EXPORT static void ControlBreak();
129
130 };
131
132 #endif // _OSD_HeaderFile