Loading...
Searching...
No Matches
ServiceHandler.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// ServiceHandler.h
//------------------------------------------------------------------------------
// Copyright (c) 1999 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
//------------------------------------------------------------------------------
// Created: 06/07/99
//------------------------------------------------------------------------------
#ifndef SERVICE_HANDLER_H
#define SERVICE_HANDLER_H
#include "assa/Assure.h"
#include "assa/EventHandler.h"
namespace ASSA {
template <class PEER_STREAM>
class ServiceHandler : public EventHandler
{
public:
ServiceHandler ()
: m_peerStream (new PEER_STREAM)
{
trace("ServiceHandler::ServiceHandler");
}
ServiceHandler (PEER_STREAM* ps_)
: m_peerStream (ps_)
{
trace("ServiceHandler::ServiceHandler");
}
virtual ~ServiceHandler () {
trace("ServiceHandler::~ServiceHandler");
if ( m_peerStream ) {
delete m_peerStream;
m_peerStream = (PEER_STREAM*) NULL;
}
}
virtual int open (void) = 0;
virtual void close (void)
{
trace("ServiceHandler::close");
if ( m_peerStream ) m_peerStream->close ();
}
operator PEER_STREAM& ()
{
// trace("ServiceHandler::opt PEER_STREAM& ()");
return *m_peerStream;
}
PEER_STREAM& get_stream () { return *m_peerStream; }
protected:
PEER_STREAM* m_peerStream;
};
} // end namespace ASSA
#endif /* SERVICE_HANDLER_H */
Assure.h
A collection of assert function wrappers.
EventHandler.h
An abstract interface for handling I/O events, timers, and such.
trace
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition Logger.h:429
ASSA::EventHandler::EventHandler
EventHandler()
Constructor.
Definition EventHandler.h:165
ASSA::ServiceHandler::m_peerStream
PEER_STREAM * m_peerStream
Concrete Socket instance.
Definition ServiceHandler.h:106
ASSA::ServiceHandler::get_stream
PEER_STREAM & get_stream()
Return referenct to underlying PEER_STREAM.
Definition ServiceHandler.h:100
ASSA::ServiceHandler::close
virtual void close(void)
Pure virtual method defined by subclass.
Definition ServiceHandler.h:81
ASSA::ServiceHandler::ServiceHandler
ServiceHandler(PEER_STREAM *ps_)
Constructor that takes PEER_STREAM as a parameter.
Definition ServiceHandler.h:49
ASSA::ServiceHandler::ServiceHandler
ServiceHandler()
Default constructor.
Definition ServiceHandler.h:38
ASSA::ServiceHandler::~ServiceHandler
virtual ~ServiceHandler()
Destructor closes and deletes PEER_STREAM.
Definition ServiceHandler.h:56
ASSA::ServiceHandler::open
virtual int open(void)=0
Pure virtual method defined by subclass.
ASSA
Definition Acceptor.h:40