E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gexceptionhandler.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file gexceptionhandler.h
19 ///
20
21 #ifndef G_NET_EXCEPTION_HANDLER__H
22 #define G_NET_EXCEPTION_HANDLER__H
23
24 #include "gdef.h"
25 #include <exception>
26
27 namespace GNet
28 {
29 class ExceptionHandler ;
30 }
31
32 /// \class GNet::ExceptionHandler
33 /// An abstract interface for handling exceptions thrown out of event-loop
34 /// callbacks (socket events, future events and timer events). If the handler
35 /// just rethrows then the event loop will terminate.
36 ///
37 /// Many GNet classes require a ExceptionHandler reference to be passed
38 /// around, but only classes that manage their own lifetimes on the heap will
39 /// use this as a base; these classes override onException() to absorb the
40 /// exception and schedule their own deletion.
41 ///
42 /// The event loop itself derives from this interface as a convenience.
43 ///
44 class GNet::ExceptionHandler
45 {
46 public:
47 virtual void onException( std::exception & ) = 0 ;
48 ///< Called by the event loop when an exception is thrown out
49 ///< of an event loop callback.
50 ///<
51 ///< The implementation may just do a "throw" to rethrow the
52 ///< current exception out of the event loop, or schedule
53 ///< a "delete this" for objects that manage themselves
54 ///< on the heap.
55
56 protected:
57 virtual ~ExceptionHandler() ;
58 ///< Destructor.
59
60 private:
61 void operator=( const ExceptionHandler & ) ;
62 } ;
63
64 #endif
GNet
Network classes.
Definition: gaddress.h:29
GNet::ExceptionHandler
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
Definition: gexceptionhandler.h:44
GNet::ExceptionHandler::~ExceptionHandler
virtual ~ExceptionHandler()
Destructor.
Definition: gexceptionhandler.cpp:26
GNet::ExceptionHandler::onException
virtual void onException(std::exception &)=0
Called by the event loop when an exception is thrown out of an event loop callback.