xref: /AOO41X/main/vos/inc/vos/signal.hxx (revision 1be3ed10e7d2672e4fa7df184b766627fd8bc1dd)
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 
32 namespace vos
33 {
34 
35 extern "C"
36 typedef oslSignalAction SignalHandlerFunction_impl(void *, oslSignalInfo *);
37 SignalHandlerFunction_impl signalHandlerFunction_impl;
38 
39 /** OSignalHandler is an objectoriented interface for signal handlers.
40 
41     @author  Ralf Hofmann
42     @version 1.0
43 */
44 
45 class OSignalHandler : public vos::OObject
46 {
47     VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSignalHandler, vos));
48 
49 public:
50 
51     enum TSignal
52     {
53         TSignal_System              = osl_Signal_System,
54         TSignal_Terminate           = osl_Signal_Terminate,
55         TSignal_AccessViolation     = osl_Signal_AccessViolation,
56         TSignal_IntegerDivideByZero = osl_Signal_IntegerDivideByZero,
57         TSignal_FloatDivideByZero   = osl_Signal_FloatDivideByZero,
58         TSignal_DebugBreak          = osl_Signal_DebugBreak,
59         TSignal_SignalUser          = osl_Signal_User
60     };
61 
62     enum TSignalAction
63     {
64         TAction_CallNextHandler  = osl_Signal_ActCallNextHdl,
65         TAction_Ignore           = osl_Signal_ActIgnore,
66         TAction_AbortApplication = osl_Signal_ActAbortApp,
67         TAction_KillApplication  = osl_Signal_ActKillApp
68     };
69 
70     typedef oslSignalInfo TSignalInfo;
71 
72     /// Constructor
73     OSignalHandler();
74 
75     /// Destructor kills thread if neccessary
76     virtual ~OSignalHandler();
77 
78     static TSignalAction SAL_CALL raise(sal_Int32 Signal, void *pData = 0);
79 
80 protected:
81 
82     /// Working method which should be overridden.
83     virtual TSignalAction SAL_CALL signal(TSignalInfo *pInfo) = 0;
84 
85 protected:
86     oslSignalHandler m_hHandler;
87 
88     friend oslSignalAction signalHandlerFunction_impl(void *, oslSignalInfo *);
89 };
90 
91 }
92 
93 #endif // _VOS_SIGNAL_HXX_
94 
95