From: g0dil Date: Mon, 2 Mar 2009 09:41:59 +0000 (+0000) Subject: Socket: Make protocl() member return non-const SocketProtocol reference X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=99822a43b5a79b68563b8ae09e1f36791ede66b1;p=senf.git Socket: Make protocl() member return non-const SocketProtocol reference git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1137 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/ProtocolClientSocketHandle.cti b/Socket/ProtocolClientSocketHandle.cti index 9f54fe9..efdb934 100644 --- a/Socket/ProtocolClientSocketHandle.cti +++ b/Socket/ProtocolClientSocketHandle.cti @@ -58,13 +58,13 @@ ProtocolClientSocketHandle(FileHandle other, bool isChecked) {} template -prefix_ SocketProtocol const & +prefix_ SocketProtocol & senf::ProtocolClientSocketHandle::protocol() { - SENF_ASSERT( dynamic_cast(&this->body().protocol()) ); + SENF_ASSERT( dynamic_cast(&this->body().protocol()) ); // Need dynamic_cast here, since senf::SocketProtocol is a // virtual base - return dynamic_cast(this->body().protocol()); + return dynamic_cast(this->body().protocol()); } template diff --git a/Socket/ProtocolClientSocketHandle.hh b/Socket/ProtocolClientSocketHandle.hh index 835733e..a633951 100644 --- a/Socket/ProtocolClientSocketHandle.hh +++ b/Socket/ProtocolClientSocketHandle.hh @@ -100,7 +100,7 @@ namespace senf { ///@} /////////////////////////////////////////////////////////////////////////// - Protocol const & protocol(); ///< Access the protocol interface + Protocol & protocol(); ///< Access the protocol interface /**< The returned protocol class reference gives access to the complete protocol interface as defined by that class. See the respective protocol class documentation. diff --git a/Socket/ProtocolServerSocketHandle.cti b/Socket/ProtocolServerSocketHandle.cti index e2c750f..2cd7753 100644 --- a/Socket/ProtocolServerSocketHandle.cti +++ b/Socket/ProtocolServerSocketHandle.cti @@ -50,13 +50,13 @@ prefix_ senf::ProtocolServerSocketHandle::ProtocolServerSocketHa #include BOOST_PP_ITERATE() template -prefix_ SocketProtocol const & +prefix_ SocketProtocol & senf::ProtocolServerSocketHandle::protocol() { SENF_ASSERT( dynamic_cast(&this->body().protocol()) ); // Need dynamic_cast here, since senf::SocketProtocol is a // virtual base - return dynamic_cast(this->body().protocol()); + return dynamic_cast(this->body().protocol()); } template diff --git a/Socket/ProtocolServerSocketHandle.hh b/Socket/ProtocolServerSocketHandle.hh index a39c760..57d980e 100644 --- a/Socket/ProtocolServerSocketHandle.hh +++ b/Socket/ProtocolServerSocketHandle.hh @@ -104,7 +104,7 @@ namespace senf { ///@} /////////////////////////////////////////////////////////////////////////// - Protocol const & protocol(); ///< Access the protocol interface + Protocol & protocol(); ///< Access the protocol interface /**< The returned protocol class reference gives access to the complete protocol interface as defined by that class. See the respective protocol class documentation. diff --git a/Socket/SocketHandle.cci b/Socket/SocketHandle.cci index 38bd8fc..ec22ca3 100644 --- a/Socket/SocketHandle.cci +++ b/Socket/SocketHandle.cci @@ -43,14 +43,9 @@ prefix_ senf::SocketBody::SocketBody(bool isServer, int fd) {} prefix_ senf::SocketProtocol & senf::SocketBody::protocol() -{ - return const_cast(v_protocol()); -} - -prefix_ senf::SocketProtocol const & senf::SocketBody::protocol() const { - return v_protocol(); + return const_cast(v_protocol()); } prefix_ bool senf::SocketBody::isServer() diff --git a/Socket/SocketHandle.cti b/Socket/SocketHandle.cti index b04f1f8..23997a8 100644 --- a/Socket/SocketHandle.cti +++ b/Socket/SocketHandle.cti @@ -88,7 +88,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(); @@ -189,11 +189,11 @@ prefix_ std::string senf::SocketHandle::dumpState(unsigned lod) template template -prefix_ Facet const & senf::SocketHandle::facet() +prefix_ Facet & senf::SocketHandle::facet() { try { - return dynamic_cast(protocol()); + return dynamic_cast(protocol()); } SENF_WRAP_EXC(std::bad_cast) } diff --git a/Socket/SocketHandle.hh b/Socket/SocketHandle.hh index 9f41494..a119d2b 100644 --- a/Socket/SocketHandle.hh +++ b/Socket/SocketHandle.hh @@ -148,7 +148,7 @@ namespace senf { documentation. */ template - Facet const & facet(); ///< Access a protocol facet + Facet & facet(); ///< Access a protocol facet /**< This member will try to access the given protocol facet of the socket. If \a Facet is a valid facet of the protocol, it is returned, otherwise \c std::bad_cast @@ -190,7 +190,7 @@ namespace senf { /**< This member replaces the corresponding FileHandle member and returns an appropriately cast body reference */ - SocketProtocol const & protocol() const; + SocketProtocol & protocol() const; ///< Access protocol class void assign(FileHandle other); /**< \internal */ diff --git a/Socket/SocketHandle.ih b/Socket/SocketHandle.ih index bc974b8..de34df0 100644 --- a/Socket/SocketHandle.ih +++ b/Socket/SocketHandle.ih @@ -122,8 +122,7 @@ namespace senf { ///@} /////////////////////////////////////////////////////////////////////////// - SocketProtocol & protocol(); ///< Access the protocol instance - SocketProtocol const & protocol() const; ///< Access the protocol instance (const) + SocketProtocol & protocol() const; ///< Access the protocol instance bool isServer(); ///< Check socket type /**< \return \c true, if this is a server socket, \c false