E-MailRelay
Public Member Functions | List of all members
GNet::ClientPtr< T > Class Template Reference

A smart pointer class for GNet::HeapClient that keeps track of when the contained instance deletes itself. More...

#include <gclientptr.h>

Public Member Functions

 ClientPtr (T *p=nullptr)
 Constructor. Takes ownership of the new-ed client.
 
 ~ClientPtr ()
 Destructor.
 
bool busy () const
 Returns true if the pointer is not nullptr.
 
void reset (T *p=nullptr)
 Resets the pointer. More...
 
void resetForExit ()
 Resets the pointer. More...
 
T * release ()
 Releases the pointer so ownership is transfered to the caller. More...
 
T * get ()
 Returns the pointer, or nullptr if deleted.
 
T * operator-> ()
 Returns the pointer. Throws if deleted.
 
const T * operator-> () const
 Returns the pointer. Throws if deleted.
 
G::Slot::Signal1< std::string > & doneSignal ()
 Returns a signal which indicates that client processing is complete and the client instance has deleted itself. More...
 
G::Slot::Signal2< std::string, std::string > & eventSignal ()
 Returns a signal which indicates something interesting.
 
G::Slot::Signal0 & connectedSignal ()
 Returns a signal which indicates that the connection has been established successfully. More...
 

Detailed Description

template<typename T>
class GNet::ClientPtr< T >

A smart pointer class for GNet::HeapClient that keeps track of when the contained instance deletes itself.

When the smart pointer goes out of scope the HeapClient object is told to delete itself asynchronously using its doDelete() mechanism. The GNet::Client's slots-and-signals are managed automatically so that ClientPtr users do not have to disconnect and reconnect them.

Definition at line 33 of file gclientptr.h.

Member Function Documentation

template<typename T >
G::Slot::Signal0 & GNet::ClientPtr< T >::connectedSignal ( )

Returns a signal which indicates that the connection has been established successfully.

Definition at line 199 of file gclientptr.h.

template<typename T >
G::Slot::Signal1< std::string > & GNet::ClientPtr< T >::doneSignal ( )

Returns a signal which indicates that client processing is complete and the client instance has deleted itself.

The signal parameter is the failure reason.

Definition at line 187 of file gclientptr.h.

template<typename T >
T * GNet::ClientPtr< T >::release ( )

Releases the pointer so ownership is transfered to the caller.

The released object's signals are disconnected.

Definition at line 139 of file gclientptr.h.

template<typename T>
void GNet::ClientPtr< T >::reset ( T *  p = nullptr)

Resets the pointer.

The old client object, if any, is told to delete itself asynchronously and it will be released from this smart pointer while it does so, with its signals going nowhere.

Definition at line 163 of file gclientptr.h.

template<typename T >
void GNet::ClientPtr< T >::resetForExit ( )

Resets the pointer.

The old client object, if any, is deleted synchronously. This should only be used from outside of EventLoop::run(), just as the TimerList is going away.

Definition at line 176 of file gclientptr.h.


The documentation for this class was generated from the following file: