X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketHandle.ih;fp=Socket%2FSocketHandle.ih;h=43edd145712a11eb948dd57cf9cccbbafd4662c8;hb=6f50bf49e282c0528f51faa0a245bbfa2b867399;hp=996ead40f227d82a56942cb0fff1f3a4a9bda6f8;hpb=66293acca094b2f29e26e70208691db4af274efb;p=senf.git diff --git a/Socket/SocketHandle.ih b/Socket/SocketHandle.ih index 996ead4..43edd14 100644 --- a/Socket/SocketHandle.ih +++ b/Socket/SocketHandle.ih @@ -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,18 @@ namespace senf { ///@} /////////////////////////////////////////////////////////////////////////// - SocketProtocol const & protocol() const; - ///< Access the protocol instance + SocketProtocol & protocol(); ///< Access the protocol instance + SocketProtocol const & protocol() const; ///< Access the protocol instance (const) + 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 +151,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////////////////////////////////////////