X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketHandle.cti;h=acdf0dc76d0d13b95142e1d7d758b55fe1e90fc9;hb=532240d72e09e19e57fac9bb55c2560b9c9e5b97;hp=f059c56680449368e9eb6c31822ca058421eec11;hpb=c778649a04a9835ecaad9108b9613832d76c2d15;p=senf.git diff --git a/Socket/SocketHandle.cti b/Socket/SocketHandle.cti index f059c56..acdf0dc 100644 --- a/Socket/SocketHandle.cti +++ b/Socket/SocketHandle.cti @@ -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 @@ -27,9 +27,8 @@ #include "SocketHandle.ih" // Custom includes -#include "../Utils/senfassert.hh" #include -#include +#include "../Utils/senfassert.hh" #include "../Utils/TypeInfo.hh" #define prefix_ inline @@ -88,7 +87,7 @@ prefix_ senf::SocketBody const & senf::SocketHandle::body() } template -prefix_ senf::SocketProtocol const & senf::SocketHandle::protocol() +prefix_ senf::SocketProtocol & senf::SocketHandle::protocol() const { return body().protocol(); @@ -113,7 +112,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 policy is not compatible + // throws bad_cast if the policy is not compatible (already wrapped ...) SPolicy::checkBaseOf(body.protocol().policy()); return cast_static(handle); } @@ -133,22 +132,25 @@ prefix_ Target senf::static_socket_cast(Source handle) template prefix_ Target senf::dynamic_socket_cast(Source handle) { - BOOST_STATIC_ASSERT(( - boost::is_convertible::value && - boost::is_convertible::value && - ( boost::is_convertible::value || - boost::is_convertible::value ) )); - return Target::cast_dynamic(handle); +// BOOST_STATIC_ASSERT(( +// boost::is_convertible::value && +// boost::is_convertible::value && +// ( boost::is_convertible::value || +// boost::is_convertible::value ) )); + try { + return Target::cast_dynamic(handle); + } + SENF_WRAP_EXC(std::bad_cast) } template prefix_ bool senf::check_socket_cast(Source handle) { - BOOST_STATIC_ASSERT(( - boost::is_convertible::value && - boost::is_convertible::value && - ( boost::is_convertible::value || - boost::is_convertible::value ) )); +// BOOST_STATIC_ASSERT(( +// boost::is_convertible::value && +// boost::is_convertible::value && +// ( boost::is_convertible::value || +// boost::is_convertible::value ) )); // we don't have a non-throwing variant of cast_dynamic // for two reasons: // a) since the handle is passed back by value, we cannot return @@ -184,6 +186,17 @@ prefix_ std::string senf::SocketHandle::dumpState(unsigned lod) return detail::dumpState(map); } +template +template +prefix_ Facet & senf::SocketHandle::facet() + +{ + try { + return dynamic_cast(protocol()); + } + SENF_WRAP_EXC(std::bad_cast) +} + /////////////////////////////////////////////////////////////////////////// // senf::ProtocolSocketBody