libassa 3.5.1
Loading...
Searching...
No Matches
ServiceHandler.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// ServiceHandler.h
4//------------------------------------------------------------------------------
5// Copyright (c) 1999 by Vladislav Grinchenko
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//
12//------------------------------------------------------------------------------
13// Created: 06/07/99
14//------------------------------------------------------------------------------
15#ifndef SERVICE_HANDLER_H
16#define SERVICE_HANDLER_H
17
18#include "assa/Assure.h"
19#include "assa/EventHandler.h"
20
21namespace ASSA {
22
30template <class PEER_STREAM>
32{
33public:
40 {
41 trace("ServiceHandler::ServiceHandler");
42 }
43
50 : m_peerStream (ps_)
51 {
52 trace("ServiceHandler::ServiceHandler");
53 }
54
56 virtual ~ServiceHandler () {
57 trace("ServiceHandler::~ServiceHandler");
58
59 if ( m_peerStream ) {
60 delete m_peerStream;
62 }
63 }
64
71 virtual int open (void) = 0;
72
81 virtual void close (void)
82 {
83 trace("ServiceHandler::close");
84 if ( m_peerStream ) m_peerStream->close ();
85 }
86
93 operator PEER_STREAM& ()
94 {
95 // trace("ServiceHandler::opt PEER_STREAM& ()");
96 return *m_peerStream;
97 }
98
101
102protected:
107};
108
109} // end namespace ASSA
110
111#endif /* SERVICE_HANDLER_H */
A collection of assert function wrappers.
An abstract interface for handling I/O events, timers, and such.
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition Logger.h:429
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
EventHandler class.
PEER_STREAM * m_peerStream
Concrete Socket instance.
PEER_STREAM & get_stream()
Return referenct to underlying PEER_STREAM.
virtual void close(void)
Pure virtual method defined by subclass.
ServiceHandler(PEER_STREAM *ps_)
Constructor that takes PEER_STREAM as a parameter.
ServiceHandler()
Default constructor.
virtual ~ServiceHandler()
Destructor closes and deletes PEER_STREAM.
virtual int open(void)=0
Pure virtual method defined by subclass.