xref: /AOO42X/main/vos/inc/vos/signal.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef _VOS_SIGNAL_HXX_
26 #define _VOS_SIGNAL_HXX_
27 
28 #   include <vos/types.hxx>
29 #   include <vos/object.hxx>
30 #   include <osl/signal.h>
31 #   include <vos/vosdllapi.h>
32 
33 namespace vos
34 {
35 
36 extern "C"
37 typedef oslSignalAction SignalHandlerFunction_impl(void *, oslSignalInfo *);
38 SignalHandlerFunction_impl signalHandlerFunction_impl;
39 
40 /** OSignalHandler is an objectoriented interface for signal handlers.
41 
42     @author  Ralf Hofmann
43     @version 1.0
44 */
45 
46 class VOS_DLLPUBLIC OSignalHandler : public vos::OObject
47 {
48     VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSignalHandler, vos));
49 
50 public:
51 
52     enum TSignal
53     {
54         TSignal_System              = osl_Signal_System,
55         TSignal_Terminate           = osl_Signal_Terminate,
56         TSignal_AccessViolation     = osl_Signal_AccessViolation,
57         TSignal_IntegerDivideByZero = osl_Signal_IntegerDivideByZero,
58         TSignal_FloatDivideByZero   = osl_Signal_FloatDivideByZero,
59         TSignal_DebugBreak          = osl_Signal_DebugBreak,
60         TSignal_SignalUser          = osl_Signal_User
61     };
62 
63     enum TSignalAction
64     {
65         TAction_CallNextHandler  = osl_Signal_ActCallNextHdl,
66         TAction_Ignore           = osl_Signal_ActIgnore,
67         TAction_AbortApplication = osl_Signal_ActAbortApp,
68         TAction_KillApplication  = osl_Signal_ActKillApp
69     };
70 
71     typedef oslSignalInfo TSignalInfo;
72 
73     /// Constructor
74     OSignalHandler();
75 
76     /// Destructor kills thread if necessary
77     virtual ~OSignalHandler();
78 
79     static TSignalAction SAL_CALL raise(sal_Int32 Signal, void *pData = 0);
80 
81 protected:
82 
83     /// Working method which should be overridden.
84     virtual TSignalAction SAL_CALL signal(TSignalInfo *pInfo) = 0;
85 
86 protected:
87     oslSignalHandler m_hHandler;
88 
89     friend oslSignalAction signalHandlerFunction_impl(void *, oslSignalInfo *);
90 };
91 
92 }
93 
94 #endif // _VOS_SIGNAL_HXX_
95