Socket: Move protocol into the socket body (as private base class) and allow non...
[senf.git] / Socket / SocketHandle.cti
index 08a3e4d..983c5a5 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
-// Copyright (C) 2006 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Copyright (C) 2006
+// 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
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief senf::SocketHandle inline template implementation
+    \brief SocketHandle inline template implementation
  */
 
 #include "SocketHandle.ih"
 
 // Custom includes
+#include "../Utils/senfassert.hh"
 #include <typeinfo>
 #include <boost/lexical_cast.hpp>
-#include "Utils/TypeInfo.hh"
+#include "../Utils/TypeInfo.hh"
 
 #define prefix_ inline
 ///////////////////////////////cti.p///////////////////////////////////////
 
+///////////////////////////////////////////////////////////////////////////
+// senf::SocketHandle<SocketPolicy>
+
+template <class SocketPolicy>
+prefix_ senf::SocketHandle<SocketPolicy>::SocketHandle()
+{}
+
 template <class SocketPolicy>
 template <class OtherPolicy>
 prefix_ senf::SocketHandle<SocketPolicy>::SocketHandle(SocketHandle<OtherPolicy> other,
@@ -51,24 +59,23 @@ senf::SocketHandle<SocketPolicy>::operator=(SocketHandle<OtherPolicy> other)
 }
 
 template <class SocketPolicy>
-prefix_ 
-senf::SocketHandle<SocketPolicy>::SocketHandle(std::auto_ptr<SocketProtocol> protocol,
-                                                      bool isServer)
-    : FileHandle(std::auto_ptr<FileBody>(new SocketBody(protocol,isServer)))
+prefix_
+senf::SocketHandle<SocketPolicy>::SocketHandle(std::auto_ptr<SocketBody> body)
+    : FileHandle(std::auto_ptr<FileBody>(body.release()))
 {}
 
 template <class SocketPolicy>
 prefix_ senf::SocketHandle<SocketPolicy>::SocketHandle(FileHandle other, bool isChecked)
     : FileHandle(other)
 {
-    BOOST_ASSERT( isChecked );
-    BOOST_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
+    SENF_ASSERT( isChecked );
+    SENF_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
 }
 
 template <class SocketPolicy>
 prefix_ senf::SocketBody & senf::SocketHandle<SocketPolicy>::body()
 {
-    BOOST_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
+    SENF_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
     return static_cast<SocketBody &>(FileHandle::body());
 }
 
@@ -76,7 +83,7 @@ template <class SocketPolicy>
 prefix_ senf::SocketBody const & senf::SocketHandle<SocketPolicy>::body()
     const
 {
-    BOOST_ASSERT( dynamic_cast<SocketBody const *>(&FileHandle::body()) );
+    SENF_ASSERT( dynamic_cast<SocketBody const *>(&FileHandle::body()) );
     return static_cast<SocketBody const &>(FileHandle::body());
 }
 
@@ -119,7 +126,7 @@ prefix_ Target senf::static_socket_cast(Source handle)
         boost::is_convertible<Target*,FileHandle*>::value &&
         ( boost::is_convertible<Source,Target>::value ||
           boost::is_convertible<Target,Source>::value ) ));
-    BOOST_ASSERT( check_socket_cast<Target>(handle) );
+    SENF_ASSERT( check_socket_cast<Target>(handle) );
     return Target::cast_static(handle);
 }
 
@@ -165,7 +172,7 @@ prefix_ void senf::SocketHandle<SocketPolicy>::state(SocketStateMap & map, unsig
     // automatically include the SocketPolicy template parameter in
     // the type name and therefore show the \e static policy of the
     // socket handle.
-    map["handle"] = prettyName(typeid(*this));
+    map["handle"] << prettyName(typeid(*this));
     body().state(map,lod);
 }
 
@@ -178,11 +185,16 @@ prefix_ std::string senf::SocketHandle<SocketPolicy>::dumpState(unsigned lod)
 }
 
 ///////////////////////////////////////////////////////////////////////////
-// senf::detail::ConvertibleString
+// senf::ProtocolSocketBody<SProtocol>
+
+template <class SProtocol>
+prefix_ senf::ProtocolSocketBody<SProtocol>::ProtocolSocketBody(bool isServer)
+    : SocketBody(isServer)
+{}
 
-template <class T>
-prefix_ senf::detail::ConvertibleString::ConvertibleString(T const & other)
-    : std::string(boost::lexical_cast<std::string>(other))
+template <class SProtocol>
+prefix_ senf::ProtocolSocketBody<SProtocol>::ProtocolSocketBody(bool isServer, int fd)
+    : SocketBody(isServer, fd)
 {}
 
 ///////////////////////////////cti.e///////////////////////////////////////
@@ -191,5 +203,10 @@ prefix_ senf::detail::ConvertibleString::ConvertibleString(T const & other)
 \f
 // Local Variables:
 // mode: c++
+// fill-column: 100
 // c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
 // End: