/home/vlg/develop/libASSA/libassa/assa/ServiceHandler.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 //                             ServiceHandler.h
00004 //------------------------------------------------------------------------------
00005 //  Copyright (c) 1999 by Vladislav Grinchenko
00006 //
00007 //  This library is free software; you can redistribute it and/or
00008 //  modify it under the terms of the GNU Library General Public
00009 //  License as published by the Free Software Foundation; either
00010 //  version 2 of the License, or (at your option) any later version.
00011 //
00012 //------------------------------------------------------------------------------
00013 //  Created: 06/07/99
00014 //------------------------------------------------------------------------------
00015 #ifndef SERVICE_HANDLER_H
00016 #define SERVICE_HANDLER_H
00017 
00018 #include "assa/Assure.h"
00019 #include "assa/EventHandler.h"
00020 
00021 namespace ASSA {
00022 
00030 template <class PEER_STREAM>
00031 class ServiceHandler : public EventHandler
00032 {
00033 public:
00038     ServiceHandler () 
00039         : m_peerStream (new PEER_STREAM)
00040         {
00041             trace("ServiceHandler::ServiceHandler");
00042         }
00043         
00049     ServiceHandler (PEER_STREAM* ps_)
00050         : m_peerStream (ps_) 
00051         {
00052             trace("ServiceHandler::ServiceHandler");
00053         }
00054 
00056     virtual ~ServiceHandler () {
00057         trace("ServiceHandler::~ServiceHandler");
00058 
00059         if ( m_peerStream ) {
00060             delete m_peerStream;
00061             m_peerStream = (PEER_STREAM*) NULL;
00062         }
00063     }
00064     
00071     virtual int open (void) = 0;
00072 
00081     virtual void close (void) 
00082         {
00083             trace("ServiceHandler::close");
00084             if ( m_peerStream ) m_peerStream->close ();
00085         }
00086 
00093     operator PEER_STREAM& () 
00094         { 
00095             // trace("ServiceHandler::opt PEER_STREAM& ()");
00096             return *m_peerStream;
00097         }
00098 
00100     PEER_STREAM& get_stream () { return *m_peerStream; }
00101 
00102 protected:
00106     PEER_STREAM* m_peerStream;
00107 };
00108 
00109 } // end namespace ASSA
00110 
00111 #endif /* SERVICE_HANDLER_H */

Generated on Sun Aug 13 15:08:00 2006 for libassa by  doxygen 1.4.6