* transport that is wrapped. It returns nullptr if there is no wrapped
* transport.
*/
- virtual AsyncTransportWrapper* getWrappedTransport() {
+ virtual const AsyncTransportWrapper* getWrappedTransport() const {
return nullptr;
}
* the derived classes of the underlying transport.
*/
template <class T>
- T* getUnderlyingTransport() {
- AsyncTransportWrapper* current = this;
+ const T* getUnderlyingTransport() const {
+ const AsyncTransportWrapper* current = this;
while (current) {
- auto sock = dynamic_cast<T*>(current);
+ auto sock = dynamic_cast<const T*>(current);
if (sock) {
return sock;
}
return nullptr;
}
+ template <class T>
+ T* getUnderlyingTransport() {
+ return const_cast<T*>(static_cast<const AsyncTransportWrapper*>(this)
+ ->getUnderlyingTransport<T>());
+ }
+
/**
* Return the application protocol being used by the underlying transport
* protocol. This is useful for transports which are used to tunnel other
MOCK_CONST_METHOD0(getRawBytesReceived, size_t());
MOCK_CONST_METHOD0(isEorTrackingEnabled, bool());
MOCK_METHOD1(setEorTracking, void(bool));
- MOCK_METHOD0(getWrappedTransport, AsyncTransportWrapper*());
+ MOCK_CONST_METHOD0(getWrappedTransport, AsyncTransportWrapper*());
};