E-MailRelay
|
A smart pointer class for GNet::Client. More...
#include <gclientptr.h>
Public Member Functions | |
ClientPtr (T *p=nullptr) | |
Constructor. Takes ownership of the new-ed client. More... | |
~ClientPtr () override | |
Destructor. More... | |
bool | busy () const |
Returns true if the pointer is not nullptr. More... | |
void | reset (T *p) noexcept |
Resets the pointer. More... | |
void | reset (std::unique_ptr< T > p) noexcept |
Resets the pointer. More... | |
void | reset () noexcept |
Resets the pointer. More... | |
T * | get () noexcept |
Returns the pointer, or nullptr if deleted. More... | |
T * | operator-> () |
Returns the pointer. Throws if deleted. More... | |
const T * | operator-> () const |
Returns the pointer. Throws if deleted. More... | |
bool | hasConnected () const noexcept |
Returns true if any Client owned by this smart pointer has ever successfully connected. More... | |
ClientPtr (const ClientPtr &)=delete | |
ClientPtr (ClientPtr &&)=delete | |
void | operator= (const ClientPtr &)=delete |
void | operator= (ClientPtr &&)=delete |
![]() | |
G::Slot::Signal< const std::string &, const std::string &, const std::string & > & | eventSignal () |
See GNet::Client::eventSignal(). More... | |
G::Slot::Signal< const std::string & > & | deleteSignal () |
A signal that is triggered as the client is deleted following an exception handled by this class. More... | |
G::Slot::Signal< const std::string & > & | deletedSignal () |
A signal that is triggered after deleteSignal() once the client has been deleted and the ClientPtr is empty. More... | |
ClientPtrBase (const ClientPtrBase &)=delete | |
ClientPtrBase (ClientPtrBase &&)=delete | |
void | operator= (const ClientPtrBase &)=delete |
void | operator= (ClientPtrBase &&)=delete |
![]() | |
virtual | ~ExceptionHandler () |
Destructor. More... | |
virtual void | onException (ExceptionSource *source, std::exception &e, bool done)=0 |
Called by the event loop when an exception is thrown out of an event loop callback. More... | |
ExceptionHandler (const ExceptionHandler &)=delete | |
ExceptionHandler (ExceptionHandler &&)=delete | |
void | operator= (const ExceptionHandler &)=delete |
void | operator= (ExceptionHandler &&)=delete |
![]() | |
virtual std::string | exceptionSourceId () const |
Returns an identifying string for logging purposes, or the empty string. More... | |
virtual | ~ExceptionSource () |
Destructor. More... | |
ExceptionSource (const ExceptionSource &)=delete | |
ExceptionSource (ExceptionSource &&)=delete | |
void | operator= (const ExceptionSource &)=delete |
void | operator= (ExceptionSource &&)=delete |
Additional Inherited Members | |
![]() | |
ClientPtrBase () | |
Default constructor. | |
void | connectSignals (Client &) |
Connects the given client's signals to this object's slots. More... | |
void | disconnectSignals (Client &) noexcept |
Disconnects the given client's signals from this object's slots. More... | |
A smart pointer class for GNet::Client.
The ClientPtr is-a ExceptionHandler, so it should normally be used as the Client's ExceptionSink:
If that is done then the contained Client object will get deleted as the result of an exception thrown out of a network event handler (including GNet::Done) with internal notification to the Client's onDelete() method and external notification via the smart pointer's deleteSignal(). If the Client is deleted from the smart pointer's destructor then there are no notifications.
If the Client is given some higher-level object as its ExceptionSink then the ClientPtr will not do any notification and the higher-level object must ensure that the Client object is deleted or disconnected when an exception is thrown:
Failure to delete the client from within the higher-level object's exception handler will result in bad event handling, with the event loop raising events that are never cleared.
Note that the ClientPtr exception handler ignores the ExceptionSource pointer, so it can be set to be the same as the higher-level object, for better event logging (as shown above).
Definition at line 134 of file gclientptr.h.
|
explicit |
Constructor. Takes ownership of the new-ed client.
Definition at line 194 of file gclientptr.h.
|
override |
Destructor.
Definition at line 202 of file gclientptr.h.
bool GNet::ClientPtr< T >::busy |
Returns true if the pointer is not nullptr.
Definition at line 288 of file gclientptr.h.
|
noexcept |
Returns the pointer, or nullptr if deleted.
Definition at line 282 of file gclientptr.h.
|
noexcept |
Returns true if any Client owned by this smart pointer has ever successfully connected.
Definition at line 294 of file gclientptr.h.
T * GNet::ClientPtr< T >::operator-> |
Returns the pointer. Throws if deleted.
Definition at line 300 of file gclientptr.h.
const T * GNet::ClientPtr< T >::operator-> |
Returns the pointer. Throws if deleted.
Definition at line 308 of file gclientptr.h.
|
noexcept |
Resets the pointer.
There is no call to onDelete() and no emitted signals.
Definition at line 276 of file gclientptr.h.
|
noexcept |
Resets the pointer.
There is no call to onDelete() and no emitted signals.
Definition at line 270 of file gclientptr.h.
|
noexcept |
Resets the pointer.
There is no call to onDelete() and no emitted signals.
Definition at line 264 of file gclientptr.h.