E-MailRelay
|
A smart pointer class for GNet::Client or similar. 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) |
Resets the pointer. More... | |
void | reset (std::unique_ptr< T > p) |
Resets the pointer. More... | |
void | reset () noexcept |
Resets the pointer. More... | |
T * | get () noexcept |
Returns the pointer, or nullptr if deleted. More... | |
const T * | get () const 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 &&) noexcept | |
ClientPtr & | operator= (const ClientPtr &)=delete |
ClientPtr & | operator= (ClientPtr &&) noexcept |
![]() | |
G::Slot::Signal< const std::string &, const std::string &, const std::string & > & | eventSignal () noexcept |
A signal that is linked to the contained client's eventSignal(). More... | |
G::Slot::Signal< const std::string & > & | deleteSignal () noexcept |
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 () noexcept |
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 | |
ClientPtrBase & | operator= (const ClientPtrBase &)=delete |
ClientPtrBase & | 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 &&)=default | |
ExceptionHandler & | operator= (const ExceptionHandler &)=delete |
ExceptionHandler & | operator= (ExceptionHandler &&)=default |
![]() | |
virtual | ~ExceptionSource () |
Destructor. | |
ExceptionSource (const ExceptionSource &)=delete | |
ExceptionSource (ExceptionSource &&)=delete | |
ExceptionSource & | operator= (const ExceptionSource &)=delete |
ExceptionSource & | operator= (ExceptionSource &&)=delete |
Additional Inherited Members | |
![]() | |
ClientPtrBase () | |
Default constructor. | |
void | eventSlot (const std::string &, const std::string &, const std::string &) |
Emits an eventSignal(). More... | |
A smart pointer class for GNet::Client or similar.
The ClientPtr is-a ExceptionHandler, so it should be the ExceptionHandler part of the Client's EventState:
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 ExceptionHandler 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.
Definition at line 143 of file gclientptr.h.
|
explicit |
Constructor. Takes ownership of the new-ed client.
Definition at line 208 of file gclientptr.h.
|
override |
Destructor.
Definition at line 218 of file gclientptr.h.
bool GNet::ClientPtr< T >::busy |
Returns true if the pointer is not nullptr.
Definition at line 311 of file gclientptr.h.
|
noexcept |
Returns the pointer, or nullptr if deleted.
Definition at line 305 of file gclientptr.h.
|
noexcept |
Returns the pointer, or nullptr if deleted.
Definition at line 299 of file gclientptr.h.
|
noexcept |
Returns true if any Client owned by this smart pointer has ever successfully connected.
Returns false if T is-not-a Client.
Definition at line 317 of file gclientptr.h.
T * GNet::ClientPtr< T >::operator-> |
Returns the pointer. Throws if deleted.
Definition at line 323 of file gclientptr.h.
const T * GNet::ClientPtr< T >::operator-> |
Returns the pointer. Throws if deleted.
Definition at line 331 of file gclientptr.h.
|
noexcept |
Resets the pointer.
There is no call to onDelete() and no emitted signals.
Definition at line 293 of file gclientptr.h.
void GNet::ClientPtr< T >::reset | ( | std::unique_ptr< T > | p | ) |
Resets the pointer.
There is no call to onDelete() and no emitted signals.
Definition at line 287 of file gclientptr.h.
void GNet::ClientPtr< T >::reset | ( | T * | p | ) |
Resets the pointer.
There is no call to onDelete() and no emitted signals.
Definition at line 281 of file gclientptr.h.