X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketHandle.cti;h=983c5a5c9bac83600c6e5bbfe7b9bf184ce392b2;hb=6f50bf49e282c0528f51faa0a245bbfa2b867399;hp=e93ec630b939fec3d6dd2b5fb08d93fcc5754a2d;hpb=70256cc93f59f5d2c9b3428775a181e5e225bfc5;p=senf.git diff --git a/Socket/SocketHandle.cti b/Socket/SocketHandle.cti index e93ec63..983c5a5 100644 --- a/Socket/SocketHandle.cti +++ b/Socket/SocketHandle.cti @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2006 +// 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 @@ -21,19 +21,27 @@ // 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 #include -#include "Utils/TypeInfo.hh" +#include "../Utils/TypeInfo.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +// senf::SocketHandle + +template +prefix_ senf::SocketHandle::SocketHandle() +{} + template template prefix_ senf::SocketHandle::SocketHandle(SocketHandle other, @@ -51,24 +59,23 @@ senf::SocketHandle::operator=(SocketHandle other) } template -prefix_ -senf::SocketHandle::SocketHandle(std::auto_ptr protocol, - bool isServer) - : FileHandle(std::auto_ptr(new SocketBody(protocol,isServer))) +prefix_ +senf::SocketHandle::SocketHandle(std::auto_ptr body) + : FileHandle(std::auto_ptr(body.release())) {} template prefix_ senf::SocketHandle::SocketHandle(FileHandle other, bool isChecked) : FileHandle(other) { - BOOST_ASSERT( isChecked ); - BOOST_ASSERT( dynamic_cast(&FileHandle::body()) ); + SENF_ASSERT( isChecked ); + SENF_ASSERT( dynamic_cast(&FileHandle::body()) ); } template prefix_ senf::SocketBody & senf::SocketHandle::body() { - BOOST_ASSERT( dynamic_cast(&FileHandle::body()) ); + SENF_ASSERT( dynamic_cast(&FileHandle::body()) ); return static_cast(FileHandle::body()); } @@ -76,7 +83,7 @@ template prefix_ senf::SocketBody const & senf::SocketHandle::body() const { - BOOST_ASSERT( dynamic_cast(&FileHandle::body()) ); + SENF_ASSERT( dynamic_cast(&FileHandle::body()) ); return static_cast(FileHandle::body()); } @@ -106,7 +113,7 @@ senf::SocketHandle::cast_dynamic(FileHandle handle) { // throws bad_cast if the body is not a SocketBody SocketBody & body (dynamic_cast(FileHandle::body(handle))); - // throws bad_cast if the poplicy is not compatible + // throws bad_cast if the policy is not compatible SocketPolicy::checkBaseOf(body.protocol().policy()); return cast_static(handle); } @@ -119,7 +126,7 @@ prefix_ Target senf::static_socket_cast(Source handle) boost::is_convertible::value && ( boost::is_convertible::value || boost::is_convertible::value ) )); - BOOST_ASSERT( check_socket_cast(handle) ); + SENF_ASSERT( check_socket_cast(handle) ); return Target::cast_static(handle); } @@ -160,7 +167,12 @@ prefix_ bool senf::check_socket_cast(Source handle) template prefix_ void senf::SocketHandle::state(SocketStateMap & map, unsigned lod) { - map["handle"] = prettyName(typeid(*this)); + // We use typeid here even though the type of *this is static + // (SocketHandle is not polymorphic and has no vtable). This will + // 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)); body().state(map,lod); } @@ -173,11 +185,16 @@ prefix_ std::string senf::SocketHandle::dumpState(unsigned lod) } /////////////////////////////////////////////////////////////////////////// -// senf::detail::ConvertibleString +// senf::ProtocolSocketBody + +template +prefix_ senf::ProtocolSocketBody::ProtocolSocketBody(bool isServer) + : SocketBody(isServer) +{} -template -prefix_ senf::detail::ConvertibleString::ConvertibleString(T const & other) - : std::string(boost::lexical_cast(other)) +template +prefix_ senf::ProtocolSocketBody::ProtocolSocketBody(bool isServer, int fd) + : SocketBody(isServer, fd) {} ///////////////////////////////cti.e/////////////////////////////////////// @@ -186,5 +203,10 @@ prefix_ senf::detail::ConvertibleString::ConvertibleString(T const & other) // 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: