Skip to content
Snippets Groups Projects
Commit 556a682d authored by g0dil's avatar g0dil
Browse files

Socket: Make protocl() member return non-const SocketProtocol reference

parent 597fc510
No related branches found
No related tags found
No related merge requests found
......@@ -58,13 +58,13 @@ ProtocolClientSocketHandle(FileHandle other, bool isChecked)
{}
template <class SocketProtocol>
prefix_ SocketProtocol const &
prefix_ SocketProtocol &
senf::ProtocolClientSocketHandle<SocketProtocol>::protocol()
{
SENF_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
SENF_ASSERT( dynamic_cast<SocketProtocol *>(&this->body().protocol()) );
// Need dynamic_cast here, since senf::SocketProtocol is a
// virtual base
return dynamic_cast<SocketProtocol const &>(this->body().protocol());
return dynamic_cast<SocketProtocol &>(this->body().protocol());
}
template <class SocketProtocol>
......
......@@ -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.
......
......@@ -50,13 +50,13 @@ prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::ProtocolServerSocketHa
#include BOOST_PP_ITERATE()
template <class SocketProtocol>
prefix_ SocketProtocol const &
prefix_ SocketProtocol &
senf::ProtocolServerSocketHandle<SocketProtocol>::protocol()
{
SENF_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
// Need dynamic_cast here, since senf::SocketProtocol is a
// virtual base
return dynamic_cast<SocketProtocol const &>(this->body().protocol());
return dynamic_cast<SocketProtocol &>(this->body().protocol());
}
template <class SocketProtocol>
......
......@@ -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.
......
......@@ -43,14 +43,9 @@ prefix_ senf::SocketBody::SocketBody(bool isServer, int fd)
{}
prefix_ senf::SocketProtocol & senf::SocketBody::protocol()
{
return const_cast<SocketProtocol &>(v_protocol());
}
prefix_ senf::SocketProtocol const & senf::SocketBody::protocol()
const
{
return v_protocol();
return const_cast<SocketProtocol &>(v_protocol());
}
prefix_ bool senf::SocketBody::isServer()
......
......@@ -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();
......@@ -189,11 +189,11 @@ prefix_ std::string senf::SocketHandle<SPolicy>::dumpState(unsigned lod)
template <class SPolicy>
template <class Facet>
prefix_ Facet const & senf::SocketHandle<SPolicy>::facet()
prefix_ Facet & senf::SocketHandle<SPolicy>::facet()
{
try {
return dynamic_cast<Facet const &>(protocol());
return dynamic_cast<Facet &>(protocol());
}
SENF_WRAP_EXC(std::bad_cast)
}
......
......@@ -148,7 +148,7 @@ namespace senf {
documentation. */
template <class Facet>
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 */
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment