Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TException.h
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Fons Rademakers 21/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_TException
13#define ROOT_TException
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// Exception Handling //
19// //
20// Provide some macro's to simulate the coming C++ try, catch and throw //
21// exception handling functionality. //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include <setjmp.h>
26
27#include <ROOT/RConfig.hxx>
28#include "DllImport.h"
29
31#ifdef NEED_SIGJMP
32 sigjmp_buf fBuf;
33#else
34 jmp_buf fBuf;
35#endif
36};
37
38#ifdef NEED_SIGJMP
39# define SETJMP(buf) sigsetjmp(buf,1)
40#else
41#define SETJMP(buf) setjmp(buf)
42#endif
43
44#define RETRY \
45 { \
46 static ExceptionContext_t R__curr, *R__old = gException; \
47 int R__code; \
48 gException = &R__curr; \
49 R__code = SETJMP(gException->fBuf); if (R__code) { }; {
50
51#define TRY \
52 { \
53 static ExceptionContext_t R__curr, *R__old = gException; \
54 int R__code; \
55 gException = &R__curr; \
56 if ((R__code = SETJMP(gException->fBuf)) == 0) {
57
58#define CATCH(n) \
59 gException = R__old; \
60 } else { \
61 int n = R__code; \
62 gException = R__old;
63
64#define ENDTRY \
65 } \
66 gException = R__old; \
67 }
68
70
71R__EXTERN void Throw(int code);
72
74public:
75 virtual ~TExceptionHandler() {}
76 virtual void HandleException(int sig) = 0;
77};
78
80
81#endif
#define R__EXTERN
Definition DllImport.h:26
R__EXTERN TExceptionHandler * gExceptionHandler
Definition TException.h:79
R__EXTERN ExceptionContext_t * gException
Definition TException.h:69
R__EXTERN void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
virtual void HandleException(int sig)=0
virtual ~TExceptionHandler()
Definition TException.h:75