Socket: Make protocl() member return non-const SocketProtocol reference
[senf.git] / Socket / SocketHandle.cti
index 39b3273..23997a8 100644 (file)
@@ -88,7 +88,7 @@ prefix_ senf::SocketBody const & senf::SocketHandle<SPolicy>::body()
 }
 
 template <class SPolicy>
-prefix_ senf::SocketProtocol const & senf::SocketHandle<SPolicy>::protocol()
+prefix_ senf::SocketProtocol & senf::SocketHandle<SPolicy>::protocol()
     const
 {
     return body().protocol();
@@ -133,11 +133,11 @@ prefix_ Target senf::static_socket_cast(Source handle)
 template <class Target, class Source>
 prefix_ Target senf::dynamic_socket_cast(Source handle)
 {
-    BOOST_STATIC_ASSERT((
-        boost::is_convertible<Source*,FileHandle*>::value &&
-        boost::is_convertible<Target*,FileHandle*>::value &&
-        ( boost::is_convertible<Source,Target>::value ||
-          boost::is_convertible<Target,Source>::value ) ));
+//     BOOST_STATIC_ASSERT((
+//         boost::is_convertible<Source*,FileHandle*>::value &&
+//         boost::is_convertible<Target*,FileHandle*>::value &&
+//         ( boost::is_convertible<Source,Target>::value ||
+//           boost::is_convertible<Target,Source>::value ) ));
     try {
         return Target::cast_dynamic(handle);
     }
@@ -147,11 +147,11 @@ prefix_ Target senf::dynamic_socket_cast(Source handle)
 template <class Target, class Source>
 prefix_ bool senf::check_socket_cast(Source handle)
 {
-    BOOST_STATIC_ASSERT((
-        boost::is_convertible<Source*,FileHandle*>::value &&
-        boost::is_convertible<Target*,FileHandle*>::value &&
-        ( boost::is_convertible<Source,Target>::value ||
-          boost::is_convertible<Target,Source>::value ) ));
+//     BOOST_STATIC_ASSERT((
+//         boost::is_convertible<Source*,FileHandle*>::value &&
+//         boost::is_convertible<Target*,FileHandle*>::value &&
+//         ( boost::is_convertible<Source,Target>::value ||
+//           boost::is_convertible<Target,Source>::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
@@ -187,6 +187,17 @@ prefix_ std::string senf::SocketHandle<SPolicy>::dumpState(unsigned lod)
     return detail::dumpState(map);
 }
 
+template <class SPolicy>
+template <class Facet>
+prefix_ Facet & senf::SocketHandle<SPolicy>::facet()
+
+{
+    try {
+        return dynamic_cast<Facet &>(protocol());
+    }
+    SENF_WRAP_EXC(std::bad_cast)
+}
+
 ///////////////////////////////////////////////////////////////////////////
 // senf::ProtocolSocketBody<SProtocol>