VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GNet::ClientPtr< TClient > 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 (TClient *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 (TClient *p=nullptr)
 Resets the pointer.
 
TClient * get ()
 Returns the pointer, or nullptr if deleted.
 
TClient * operator-> ()
 Returns the pointer. Throws if deleted.
 
const TClient * 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::Signal0connectedSignal ()
 Returns a signal which indicates that the connection has been established successfully. More...
 
void releaseForExit ()
 Can be called on program termination when there may be no TimerList or EventLoop instances. More...
 
void cleanupForExit ()
 Can be called on program termination when there may be no TimerList or EventLoop instances. More...
 

Detailed Description

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

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 HeapClient's slots-and-signals are managed automatically so that client code does not have to disconnect and reconnect them.

Definition at line 44 of file gclientptr.h.

Member Function Documentation

template<typename TClient >
void GNet::ClientPtr< TClient >::cleanupForExit ( )

Can be called on program termination when there may be no TimerList or EventLoop instances.

The client is destructed so all relevant destructors should avoid doing anything with timers or the network (possibly even just closing sockets).

Definition at line 147 of file gclientptr.h.

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

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

Definition at line 197 of file gclientptr.h.

template<typename TClient >
G::Slot::Signal1< std::string > & GNet::ClientPtr< TClient >::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 185 of file gclientptr.h.

template<typename TClient >
void GNet::ClientPtr< TClient >::releaseForExit ( )

Can be called on program termination when there may be no TimerList or EventLoop instances.

The client object leaks.

Definition at line 137 of file gclientptr.h.


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