Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSysEvtHandler.h
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Fons Rademakers 16/09/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TSysEvtHandler
13#define ROOT_TSysEvtHandler
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TSysEvtHandler //
19// //
20// Abstract base class for handling system events. //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TObject.h"
25#include "TQObject.h"
26
27
28class TSysEvtHandler : public TObject, public TQObject {
29
30private:
31 Bool_t fIsActive; // kTRUE if handler is active, kFALSE if not active
32
33 void *GetSender() override { return this; } //used to set gTQSender
34
35public:
37 virtual ~TSysEvtHandler() { }
38
39 void Activate();
40 void DeActivate();
41 Bool_t IsActive() const { return fIsActive; }
42
43 virtual void Add() = 0;
44 virtual void Remove() = 0;
45 virtual Bool_t Notify() override = 0;
46
47 virtual void Activated() { Emit("Activated()"); } //*SIGNAL*
48 virtual void DeActivated() { Emit("DeActivated()"); } //*SIGNAL*
49 virtual void Notified() { Emit("Notified()"); } //*SIGNAL*
50 virtual void Added() { Emit("Added()"); } //*SIGNAL*
51 virtual void Removed() { Emit("Removed()"); } //*SIGNAL*
52
53 ClassDefOverride(TSysEvtHandler,0) //ABC for handling system events
54};
55
56
57//////////////////////////////////////////////////////////////////////////
58// //
59// TFileHandler //
60// //
61// Handles events on file descriptors. //
62// //
63//////////////////////////////////////////////////////////////////////////
64
66
67protected:
68 int fFileNum; //File descriptor
69 int fMask; //Event interest mask, either bit 1 (read), 2 (write) or both can be set
70 int fReadyMask; //Readiness mask, either bit 1 (read), 2 (write) or both can be set
71
73
74public:
75 enum { kRead = 1, kWrite = 2 };
76
77 TFileHandler(int fd, int mask);
78 virtual ~TFileHandler() { Remove(); }
79 int GetFd() const { return fFileNum; }
80 void SetFd(int fd) { fFileNum = fd; }
81 Bool_t Notify() override;
82 virtual Bool_t ReadNotify();
83 virtual Bool_t WriteNotify();
84 virtual Bool_t HasReadInterest();
85 virtual Bool_t HasWriteInterest();
86 virtual void SetInterest(Int_t mask);
87 virtual void ResetReadyMask() { fReadyMask = 0; }
88 virtual void SetReadReady() { fReadyMask |= 0x1; }
89 virtual void SetWriteReady() { fReadyMask |= 0x2; }
90 virtual Bool_t IsReadReady() const { return (fReadyMask & 0x1) == 0x1; }
91 virtual Bool_t IsWriteReady() const { return (fReadyMask & 0x2) == 0x2; }
92 void Add() override;
93 void Remove() override;
94
95 ClassDefOverride(TFileHandler,0) //Handles events on file descriptors
96};
97
98
99//////////////////////////////////////////////////////////////////////////
100// //
101// TSignalHandler //
102// //
103// Handles signals. //
104// //
105//////////////////////////////////////////////////////////////////////////
106
125
126
128
129protected:
130 ESignals fSignal; //Signal to be handled
131 Bool_t fSync; //Synchronous or a-synchronous signal
132 Int_t fDelay; //Delay handling of signal (use fDelay in Notify())
133
135
136public:
137 TSignalHandler(ESignals sig, Bool_t sync = kTRUE);
138 virtual ~TSignalHandler() { Remove(); }
139 void Delay() { fDelay = 1; }
140 void HandleDelayedSignal();
141 ESignals GetSignal() const { return fSignal; }
142 void SetSignal(ESignals sig) { fSignal = sig; }
143 Bool_t IsSync() const { return fSync; }
144 Bool_t IsAsync() const { return !fSync; }
145 Bool_t Notify() override;
146 void Add() override;
147 void Remove() override;
148
149 ClassDefOverride(TSignalHandler,0) //Signal event handler
150};
151
153{
154 if (fDelay > 1) {
155 fDelay = 0;
156 Notify();
157 } else
158 fDelay = 0;
159}
160
161
162//////////////////////////////////////////////////////////////////////////
163// //
164// TStdExceptionHandler //
165// //
166// Handles standard C++ exceptions. //
167// //
168//////////////////////////////////////////////////////////////////////////
169
170namespace std { class exception; }
171
173
174public:
176
179
180 void Add() override;
181 void Remove() override;
182 Bool_t Notify() override;
183
184 virtual EStatus Handle(std::exception& exc) = 0;
185
186 ClassDefOverride(TStdExceptionHandler,0) //C++ exception handler
187};
188
189#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
ESignals
@ kSigTermination
@ kSigIllegalInstruction
@ kSigPipe
@ kSigBus
@ kSigAbort
@ kSigWindowChanged
@ kSigUrgent
@ kSigInterrupt
@ kSigUser2
@ kSigFloatingException
@ kSigUser1
@ kSigChild
@ kSigAlarm
@ kSigSegmentationViolation
@ kSigSystem
@ kSigQuit
virtual void SetInterest(Int_t mask)
Set interest mask to 'mask'.
virtual void SetWriteReady()
virtual ~TFileHandler()
void SetFd(int fd)
virtual void SetReadReady()
virtual Bool_t HasReadInterest()
True if handler is interested in read events.
void Remove() override
Remove file event handler from system file handler list.
virtual Bool_t WriteNotify()
Notify when something can be written to the descriptor associated with this handler.
virtual Bool_t HasWriteInterest()
True if handler is interested in write events.
int GetFd() const
void Add() override
Add file event handler to system file handler list.
virtual void ResetReadyMask()
virtual Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
virtual Bool_t IsWriteReady() const
virtual Bool_t IsReadReady() const
Bool_t Notify() override
Notify when event occurred on descriptor associated with this handler.
Mother of all ROOT objects.
Definition TObject.h:41
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition TQObject.h:48
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
void Add() override
Add signal handler to system signal handler list.
Bool_t Notify() override
Notify when signal occurs.
virtual ~TSignalHandler()
void Remove() override
Remove signal handler from system signal handler list.
Bool_t IsSync() const
Bool_t IsAsync() const
void SetSignal(ESignals sig)
ESignals GetSignal() const
void HandleDelayedSignal()
TStdExceptionHandler()
Handle standard C++ exceptions intercepted by the TSystem::Run().
void Add() override
Add std::exception handler to system handler list.
Bool_t Notify() override
Notify when signal occurs.
virtual ~TStdExceptionHandler()
virtual EStatus Handle(std::exception &exc)=0
void Remove() override
Remove std::exception handler from system handler list.
Abstract base class for handling system events.
void DeActivate()
De-activate a system event handler.
virtual void Add()=0
virtual void Added()
virtual void Notified()
virtual ~TSysEvtHandler()
virtual void Removed()
Bool_t IsActive() const
void Activate()
Activate a system event handler.
virtual void DeActivated()
virtual void Remove()=0
void * GetSender() override
virtual void Activated()
virtual Bool_t Notify() override=0
This method must be overridden to handle object notification (the base implementation is no-op).