GNet::ClientPtr< TClient > Class Template Reference

A smart pointer class for GNet::HeapClient. More...

#include <gclientptr.h>

List of all members.

Public Member Functions

 ClientPtr (TClient *p=NULL, bool preserve_resolver_info=false)
 Constructor.
 ~ClientPtr ()
 Destructor.
bool busy () const
 Returns true if the pointer is not NULL.
void reset (TClient *p=NULL)
 Resets the pointer.
TClient * get ()
 Returns the pointer, or NULL if deleted.
TClient * operator-> ()
 Returns the pointer. Throws if deleted.
const TClient * operator-> () const
 Returns the pointer. Throws if deleted.
G::Signal2< std::string, bool > & doneSignal ()
 Returns a signal which indicates that client processing is complete and the client instance has deleted itself.
G::Signal2< std::string,
std::string > & 
eventSignal ()
 Returns a signal which indicates something interesting.
G::Signal0connectedSignal ()
 Returns a signal which indicates that the connection has been established successfully.
ResolverInfo resolverInfo () const
 Returns the current or last client's ResolverInfo.


Detailed Description

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

A smart pointer class for GNet::HeapClient.

Keeps track of when the contained instance deletes itself and also does some signal forwarding so that the user of the smart pointer can work with the smart pointers signals and not worry about the client objects' signals.

When the smart pointer goes out of scope while it is managing a client object then the client object is told to delete itself asynchronously using the HeapClient class's doDelete() mechanism.

The smart pointer also optionally maintains an internal ResolverInfo object so that name resolution results can be retained from one contained client object to the next. If the smart pointer is loaded with a new client that has the same host and service name in its ResolverInfo as the previous client then the resolved address is propagated into the new client so that name lookup is short-circuited within the SimpleClient code. The danger with this is that the name lookup becomes stale, so it is probably only a good idea for local addresses and/or short-lived objects.

Definition at line 60 of file gclientptr.h.


Constructor & Destructor Documentation

template<typename TClient>
GNet::ClientPtr< TClient >::ClientPtr ( TClient *  p = NULL,
bool  preserve_resolver_info = false 
) [inline, explicit]

Constructor.

< should p->doDelete() here

Definition at line 121 of file gclientptr.h.

template<typename TClient>
GNet::ClientPtr< TClient >::~ClientPtr (  )  [inline]

Destructor.

Definition at line 142 of file gclientptr.h.


Member Function Documentation

template<typename TClient>
bool GNet::ClientPtr< TClient >::busy (  )  const [inline]

Returns true if the pointer is not NULL.

Definition at line 241 of file gclientptr.h.

template<typename TClient>
void GNet::ClientPtr< TClient >::reset ( TClient *  p = NULL  )  [inline]

Resets the pointer.

Definition at line 163 of file gclientptr.h.

Referenced by GSmtp::ProtocolMessageForward::reset(), and Main::Run::~Run().

template<typename TClient>
TClient * GNet::ClientPtr< TClient >::get (  )  [inline]

Returns the pointer, or NULL if deleted.

Definition at line 235 of file gclientptr.h.

Referenced by GSmtp::ProtocolMessageForward::~ProtocolMessageForward().

template<typename TClient>
TClient * GNet::ClientPtr< TClient >::operator-> (  )  [inline]

Returns the pointer. Throws if deleted.

Definition at line 247 of file gclientptr.h.

template<typename TClient>
const TClient * GNet::ClientPtr< TClient >::operator-> (  )  const [inline]

Returns the pointer. Throws if deleted.

Definition at line 255 of file gclientptr.h.

template<typename TClient>
G::Signal2< std::string, bool > & GNet::ClientPtr< TClient >::doneSignal (  )  [inline]

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

The first signal parameter is the failure reason and the second is a 'can-retry' flag.

Definition at line 183 of file gclientptr.h.

Referenced by GSmtp::AdminServerPeer::AdminServerPeer(), GSmtp::ProtocolMessageForward::ProtocolMessageForward(), Main::Run::Run(), GSmtp::AdminServerPeer::~AdminServerPeer(), GSmtp::ProtocolMessageForward::~ProtocolMessageForward(), and Main::Run::~Run().

template<typename TClient>
G::Signal2< std::string, std::string > & GNet::ClientPtr< TClient >::eventSignal (  )  [inline]

Returns a signal which indicates something interesting.

Definition at line 189 of file gclientptr.h.

Referenced by Main::Run::Run(), and Main::Run::~Run().

template<typename TClient>
G::Signal0 & GNet::ClientPtr< TClient >::connectedSignal (  )  [inline]

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

Definition at line 195 of file gclientptr.h.

template<typename TClient>
ResolverInfo GNet::ClientPtr< TClient >::resolverInfo (  )  const [inline]

Returns the current or last client's ResolverInfo.

Definition at line 263 of file gclientptr.h.


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5