libDwm-0.9.45
DwmSignal.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2000-2007, 2016
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
32// PURPOSE, OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _DWMSIGNAL_HH_
42#define _DWMSIGNAL_HH_
43
44extern "C" {
45 #include <signal.h>
46}
47
48#include <string>
49#include <deque>
50#include <map>
51
52namespace Dwm {
53
54 //--------------------------------------------------------------------------
56 //--------------------------------------------------------------------------
57 class Signal
58 {
59 public:
60 //------------------------------------------------------------------------
62 //------------------------------------------------------------------------
63 Signal(int sigNum);
64
65 //------------------------------------------------------------------------
67 //------------------------------------------------------------------------
68 Signal(const Signal & signal);
69
70 //------------------------------------------------------------------------
72 //------------------------------------------------------------------------
73 bool Block();
74
75 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
78 bool Unblock();
79
80 //------------------------------------------------------------------------
82 //------------------------------------------------------------------------
83 bool IsBlocked();
84
85 //------------------------------------------------------------------------
87 //------------------------------------------------------------------------
88 bool IsPending();
89
90 //------------------------------------------------------------------------
93 //------------------------------------------------------------------------
94 void Wait();
95
96 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
101 int PushHandler(void (*handler)(int));
102
103 //------------------------------------------------------------------------
105 //------------------------------------------------------------------------
107
108 //------------------------------------------------------------------------
110 //------------------------------------------------------------------------
111 const std::string & Name() const;
112
113 protected:
114 int _sigNum;
115 std::deque<void (*)(int)> _handlers;
116
117 Signal();
118
119 static const std::map<int,std::string,std::less<int> > _names;
120 };
121
122} // namespace Dwm
123
124#endif // _DWMSIGNAL_HH_
125
126//---------------------------- emacs settings -----------------------------
127// Local Variables:
128// mode: C++
129// tab-width: 2
130// indent-tabs-mode: nil
131// c-basic-offset: 2
132// End:
133//-------------------------------------------------------------------------
This class encapsulates a signal.
Definition DwmSignal.hh:58
const std::string & Name() const
Returns a string representation of the signal ("e.g. "SIGHUP").
Signal(int sigNum)
Construct from a signal number (e.g. SIGHUP).
bool Unblock()
Unblock the signal.
bool IsPending()
Returns true if the signal is currently pending.
int PushHandler(void(*handler)(int))
Pushes a signal onto the top of a stack of signal handlers for the signal.
int PopHandler()
Pops the top signal handler off of the stack of signal handlers.
bool IsBlocked()
Returns true if the signal is currently blocked.
Signal(const Signal &signal)
Copy constructor.
bool Block()
Block the signal.
void Wait()
Waits for the delivery of the signal to the calling thread.