ASSA::ServiceHandler< PEER_STREAM > Class Template Reference

#include <ServiceHandler.h>

Inheritance diagram for ASSA::ServiceHandler< PEER_STREAM >:

Inheritance graph
[legend]
Collaboration diagram for ASSA::ServiceHandler< PEER_STREAM >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ServiceHandler ()
 Default constructor.
 ServiceHandler (PEER_STREAM *ps_)
 Constructor that takes PEER_STREAM as a parameter.
virtual ~ServiceHandler ()
 Destructor closes and deletes PEER_STREAM.
virtual int open (void)=0
 Pure virtual method defined by subclass.
virtual void close (void)
 Pure virtual method defined by subclass.
 operator PEER_STREAM & ()
 Conversion operator to type PEER_STREAM &.
PEER_STREAM & get_stream ()
 Return referenct to underlying PEER_STREAM.

Protected Attributes

PEER_STREAM * m_peerStream
 Concrete Socket instance.

Detailed Description

template<class PEER_STREAM>
class ASSA::ServiceHandler< PEER_STREAM >

Definition at line 31 of file ServiceHandler.h.


Constructor & Destructor Documentation

template<class PEER_STREAM>
ASSA::ServiceHandler< PEER_STREAM >::ServiceHandler  )  [inline]
 

Default constructor.

In case of server-side, ServiceHandler is created by Acceptor, when new connection is detected.

Definition at line 38 of file ServiceHandler.h.

00039         : m_peerStream (new PEER_STREAM)
00040         {
00041             trace("ServiceHandler::ServiceHandler");
00042         }

template<class PEER_STREAM>
ASSA::ServiceHandler< PEER_STREAM >::ServiceHandler PEER_STREAM *  ps_  )  [inline]
 

Constructor that takes PEER_STREAM as a parameter.

In case of server-side, ServiceHandler is created by Acceptor, when new connection is detected. Note that PEER_STREAM is created by PEER_STREAM::accept () method.

Definition at line 49 of file ServiceHandler.h.

00050         : m_peerStream (ps_) 
00051         {
00052             trace("ServiceHandler::ServiceHandler");
00053         }

template<class PEER_STREAM>
virtual ASSA::ServiceHandler< PEER_STREAM >::~ServiceHandler  )  [inline, virtual]
 

Destructor closes and deletes PEER_STREAM.

Definition at line 56 of file ServiceHandler.h.

00056                                {
00057         trace("ServiceHandler::~ServiceHandler");
00058 
00059         if ( m_peerStream ) {
00060             delete m_peerStream;
00061             m_peerStream = (PEER_STREAM*) NULL;
00062         }
00063     }


Member Function Documentation

template<class PEER_STREAM>
virtual void ASSA::ServiceHandler< PEER_STREAM >::close void   )  [inline, virtual]
 

Pure virtual method defined by subclass.

The close() hook closes PEER_STREAM by default The behavior of this method can be changed by a subclass, which typically performs any service-specific cleanup. EventHandler::handle_close() method of base class EventHandler is called when client closes connection. ServiceHandler object can destroy itself from there.

Definition at line 81 of file ServiceHandler.h.

00082         {
00083             trace("ServiceHandler::close");
00084             if ( m_peerStream ) m_peerStream->close ();
00085         }

template<class PEER_STREAM>
PEER_STREAM& ASSA::ServiceHandler< PEER_STREAM >::get_stream  )  [inline]
 

Return referenct to underlying PEER_STREAM.

Definition at line 100 of file ServiceHandler.h.

00100 { return *m_peerStream; }

template<class PEER_STREAM>
virtual int ASSA::ServiceHandler< PEER_STREAM >::open void   )  [pure virtual]
 

Pure virtual method defined by subclass.

The open() hook is called by the Acceptor or Connector once a connection is established. The behavior of this method must be defined by a subclass, which typically performs any service-specific initialization.

Implemented in ASSA::RemoteLogger.

template<class PEER_STREAM>
ASSA::ServiceHandler< PEER_STREAM >::operator PEER_STREAM &  )  [inline]
 

Conversion operator to type PEER_STREAM &.

Comes handy when you want to call underlying PEER_STREAM member functions directly.

Returns:
reference to underlying stream mechanism

Definition at line 93 of file ServiceHandler.h.

References ASSA::ServiceHandler< PEER_STREAM >::m_peerStream.

00094         { 
00095             // trace("ServiceHandler::opt PEER_STREAM& ()");
00096             return *m_peerStream;
00097         }


Member Data Documentation

template<class PEER_STREAM>
PEER_STREAM* ASSA::ServiceHandler< PEER_STREAM >::m_peerStream [protected]
 

Concrete Socket instance.

ServiceHandler owns this object which is delete()-ed in destructor.

Definition at line 106 of file ServiceHandler.h.

Referenced by ASSA::ServiceHandler< ASSA::IPv4Socket >::close(), ASSA::ServiceHandler< ASSA::IPv4Socket >::get_stream(), ASSA::ServiceHandler< PEER_STREAM >::operator PEER_STREAM &(), and ASSA::ServiceHandler< ASSA::IPv4Socket >::~ServiceHandler().


The documentation for this class was generated from the following file:
Generated on Sun Aug 13 15:08:21 2006 for libassa by  doxygen 1.4.6