X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketHandle.ih;h=de34df0ac42f4af9d9e0600c721df02a129f9190;hb=99822a43b5a79b68563b8ae09e1f36791ede66b1;hp=996ead40f227d82a56942cb0fff1f3a4a9bda6f8;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Socket/SocketHandle.ih b/Socket/SocketHandle.ih index 996ead4..de34df0 100644 --- a/Socket/SocketHandle.ih +++ b/Socket/SocketHandle.ih @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// 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 @@ -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////////////////////////////////////////