X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketHandle.ih;h=de34df0ac42f4af9d9e0600c721df02a129f9190;hb=b8ca4a544cce3e6023bb56b712a03d6362f2bb79;hp=3e3663a3226145be17df2811069da5d91636a68c;hpb=1ad3873b372da6187b1fbc645bf276287d2efb54;p=senf.git diff --git a/Socket/SocketHandle.ih b/Socket/SocketHandle.ih index 3e3663a..de34df0 100644 --- a/Socket/SocketHandle.ih +++ b/Socket/SocketHandle.ih @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ \brief SocketHandle internal header */ -#ifndef IH_SocketHandle_ -#define IH_SocketHandle_ 1 +#ifndef IH_SENF_Socket_SocketHandle_ +#define IH_SENF_Socket_SocketHandle_ 1 // Custom includes #include @@ -85,6 +85,8 @@ namespace senf { std::string dumpState(SocketStateMap const & map); } + template class ConcreteSocketProtocol; + /** \brief SocketHandle referenced body \internal @@ -95,13 +97,9 @@ namespace senf { properly. If this invariant is violated, your Program will probably crash. */ class SocketBody - : public FileBody, - public senf::pool_alloc_mixin + : public FileBody { public: - using senf::pool_alloc_mixin::operator new; - using senf::pool_alloc_mixin::operator delete; - /////////////////////////////////////////////////////////////////////////// // Types @@ -111,19 +109,12 @@ namespace senf { ///\name Structors and default members ///@{ - SocketBody(std::auto_ptr protocol, bool isServer); - /**< - \param protocol Protocol class implementing the desired - protocol - \param isServer \c true, if this socket is a server - socket, false otherwise */ - SocketBody(std::auto_ptr protocol, bool isServer, int fd); - /**< - \param protocol Protocol class implementing the desired - protocol - \param isServer \c true, if this socket is a server - socket, false otherwise - \param fd socket file descriptor */ + SocketBody(bool isServer); /**< \param isServer \c true, if this socket is a server + socket, false otherwise */ + SocketBody(bool isServer, int fd); + /**< \param isServer \c true, if this socket is a server + socket, false otherwise + \param fd socket file descriptor */ // no copy // no conversion constructors @@ -131,14 +122,17 @@ namespace senf { ///@} /////////////////////////////////////////////////////////////////////////// - SocketProtocol const & protocol() const; - ///< Access the protocol instance + SocketProtocol & protocol() const; ///< Access the protocol instance + bool isServer(); ///< Check socket type /**< \return \c true, if this is a server socket, \c false otherwise */ void state(SocketStateMap & map, unsigned lod); + std::auto_ptr clone(bool isServer) const; + std::auto_ptr clone(int fd, bool isServer) const; + private: virtual void v_close(); ///< Close socket /**< This override will automatically \c shutdown() the @@ -156,10 +150,38 @@ namespace senf { dependent, this member will forward the call to senf::SocketPolicy::eof() */ - boost::scoped_ptr protocol_; + virtual SocketProtocol const & v_protocol() const = 0; + virtual std::string v_protocolName() const = 0; + bool isServer_; }; + template + class ProtocolSocketBody + : public SocketBody, + private SProtocol, + public senf::pool_alloc_mixin< ProtocolSocketBody > + { + public: + typedef SProtocol Protocol; + + using senf::pool_alloc_mixin< ProtocolSocketBody >::operator new; + using senf::pool_alloc_mixin< ProtocolSocketBody >::operator delete; + + ProtocolSocketBody(bool isServer); /**< \param isServer \c true, if this socket is a server + socket, false otherwise */ + ProtocolSocketBody(bool isServer, int fd); + /**< \param isServer \c true, if this socket is a server + socket, false otherwise + \param fd socket file descriptor */ + + private: + virtual SocketProtocol const & v_protocol() const; + virtual std::string v_protocolName() const; + + friend class ConcreteSocketProtocol; + }; + } ///////////////////////////////ih.e////////////////////////////////////////