Warning, file /include/root/TSysEvtHandler.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TSysEvtHandler
0013 #define ROOT_TSysEvtHandler
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "TObject.h"
0025 #include "TQObject.h"
0026
0027
0028 class TSysEvtHandler : public TObject, public TQObject {
0029
0030 private:
0031 Bool_t fIsActive;
0032
0033 void *GetSender() override { return this; }
0034
0035 public:
0036 TSysEvtHandler() : fIsActive(kTRUE) { }
0037 virtual ~TSysEvtHandler() { }
0038
0039 void Activate();
0040 void DeActivate();
0041 Bool_t IsActive() const { return fIsActive; }
0042
0043 virtual void Add() = 0;
0044 virtual void Remove() = 0;
0045 virtual Bool_t Notify() override = 0;
0046
0047 virtual void Activated() { Emit("Activated()"); }
0048 virtual void DeActivated() { Emit("DeActivated()"); }
0049 virtual void Notified() { Emit("Notified()"); }
0050 virtual void Added() { Emit("Added()"); }
0051 virtual void Removed() { Emit("Removed()"); }
0052
0053 ClassDefOverride(TSysEvtHandler,0)
0054 };
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 class TFileHandler : public TSysEvtHandler {
0066
0067 protected:
0068 int fFileNum;
0069 int fMask;
0070 int fReadyMask;
0071
0072 TFileHandler(): fFileNum(-1), fMask(0), fReadyMask(0) { }
0073
0074 public:
0075 enum { kRead = 1, kWrite = 2 };
0076
0077 TFileHandler(int fd, int mask);
0078 virtual ~TFileHandler() { Remove(); }
0079 int GetFd() const { return fFileNum; }
0080 void SetFd(int fd) { fFileNum = fd; }
0081 Bool_t Notify() override;
0082 virtual Bool_t ReadNotify();
0083 virtual Bool_t WriteNotify();
0084 virtual Bool_t HasReadInterest();
0085 virtual Bool_t HasWriteInterest();
0086 virtual void SetInterest(Int_t mask);
0087 virtual void ResetReadyMask() { fReadyMask = 0; }
0088 virtual void SetReadReady() { fReadyMask |= 0x1; }
0089 virtual void SetWriteReady() { fReadyMask |= 0x2; }
0090 virtual Bool_t IsReadReady() const { return (fReadyMask & 0x1) == 0x1; }
0091 virtual Bool_t IsWriteReady() const { return (fReadyMask & 0x2) == 0x2; }
0092 void Add() override;
0093 void Remove() override;
0094
0095 ClassDefOverride(TFileHandler,0)
0096 };
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 enum ESignals {
0108 kSigBus,
0109 kSigSegmentationViolation,
0110 kSigSystem,
0111 kSigPipe,
0112 kSigIllegalInstruction,
0113 kSigAbort,
0114 kSigQuit,
0115 kSigInterrupt,
0116 kSigWindowChanged,
0117 kSigAlarm,
0118 kSigChild,
0119 kSigUrgent,
0120 kSigFloatingException,
0121 kSigTermination,
0122 kSigUser1,
0123 kSigUser2
0124 };
0125
0126
0127 class TSignalHandler : public TSysEvtHandler {
0128
0129 protected:
0130 ESignals fSignal;
0131 Bool_t fSync;
0132 Int_t fDelay;
0133
0134 TSignalHandler(): fSignal((ESignals)-1), fSync(kTRUE), fDelay(0) { }
0135
0136 public:
0137 TSignalHandler(ESignals sig, Bool_t sync = kTRUE);
0138 virtual ~TSignalHandler() { Remove(); }
0139 void Delay() { fDelay = 1; }
0140 void HandleDelayedSignal();
0141 ESignals GetSignal() const { return fSignal; }
0142 void SetSignal(ESignals sig) { fSignal = sig; }
0143 Bool_t IsSync() const { return fSync; }
0144 Bool_t IsAsync() const { return !fSync; }
0145 Bool_t Notify() override;
0146 void Add() override;
0147 void Remove() override;
0148
0149 ClassDefOverride(TSignalHandler,0)
0150 };
0151
0152 inline void TSignalHandler::HandleDelayedSignal()
0153 {
0154 if (fDelay > 1) {
0155 fDelay = 0;
0156 Notify();
0157 } else
0158 fDelay = 0;
0159 }
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170 namespace std { class exception; }
0171
0172 class TStdExceptionHandler : public TSysEvtHandler {
0173
0174 public:
0175 enum EStatus { kSEProceed, kSEHandled, kSEAbort };
0176
0177 TStdExceptionHandler();
0178 virtual ~TStdExceptionHandler() { }
0179
0180 void Add() override;
0181 void Remove() override;
0182 Bool_t Notify() override;
0183
0184 virtual EStatus Handle(std::exception& exc) = 0;
0185
0186 ClassDefOverride(TStdExceptionHandler,0)
0187 };
0188
0189 #endif