// $Id$
//
// Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
//
// 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
\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 <map>
std::string dumpState(SocketStateMap const & map);
}
+ template <class Policy, class Self> class ConcreteSocketProtocol;
+
/** \brief SocketHandle referenced body
\internal
properly. If this invariant is violated, your Program will probably crash.
*/
class SocketBody
- : public FileBody,
- public senf::pool_alloc_mixin<SocketBody>
+ : public FileBody
{
public:
- using senf::pool_alloc_mixin<SocketBody>::operator new;
- using senf::pool_alloc_mixin<SocketBody>::operator delete;
-
///////////////////////////////////////////////////////////////////////////
// Types
///\name Structors and default members
///@{
- SocketBody(std::auto_ptr<SocketProtocol> 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<SocketProtocol> 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
///@}
///////////////////////////////////////////////////////////////////////////
- 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<SocketBody> clone(bool isServer) const;
+ std::auto_ptr<SocketBody> clone(int fd, bool isServer) const;
+
private:
virtual void v_close(); ///< Close socket
/**< This override will automatically \c shutdown() the
dependent, this member will forward the call to
senf::SocketPolicy::eof() */
- boost::scoped_ptr<SocketProtocol> protocol_;
+ virtual SocketProtocol const & v_protocol() const = 0;
+ virtual std::string v_protocolName() const = 0;
+
bool isServer_;
};
+ template <class SProtocol>
+ class ProtocolSocketBody
+ : public SocketBody,
+ private SProtocol,
+ public senf::pool_alloc_mixin< ProtocolSocketBody<SProtocol> >
+ {
+ public:
+ typedef SProtocol Protocol;
+
+ using senf::pool_alloc_mixin< ProtocolSocketBody<SProtocol> >::operator new;
+ using senf::pool_alloc_mixin< ProtocolSocketBody<SProtocol> >::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<typename SProtocol::Policy, SProtocol>;
+ };
+
}
///////////////////////////////ih.e////////////////////////////////////////