Commit d662c1b7 authored by Kyle Nekritz's avatar Kyle Nekritz Committed by facebook-github-bot-4

Make getWrappedTransport/getUnderlyingTransport const.

Reviewed By: mzlee

Differential Revision: D2709222

fb-gh-sync-id: 67a00a49bbcef5572b6092d7bfba1842d985e643
parent 37b28711
...@@ -543,7 +543,7 @@ class AsyncTransportWrapper : virtual public AsyncTransport, ...@@ -543,7 +543,7 @@ class AsyncTransportWrapper : virtual public AsyncTransport,
* transport that is wrapped. It returns nullptr if there is no wrapped * transport that is wrapped. It returns nullptr if there is no wrapped
* transport. * transport.
*/ */
virtual AsyncTransportWrapper* getWrappedTransport() { virtual const AsyncTransportWrapper* getWrappedTransport() const {
return nullptr; return nullptr;
} }
...@@ -553,10 +553,10 @@ class AsyncTransportWrapper : virtual public AsyncTransport, ...@@ -553,10 +553,10 @@ class AsyncTransportWrapper : virtual public AsyncTransport,
* the derived classes of the underlying transport. * the derived classes of the underlying transport.
*/ */
template <class T> template <class T>
T* getUnderlyingTransport() { const T* getUnderlyingTransport() const {
AsyncTransportWrapper* current = this; const AsyncTransportWrapper* current = this;
while (current) { while (current) {
auto sock = dynamic_cast<T*>(current); auto sock = dynamic_cast<const T*>(current);
if (sock) { if (sock) {
return sock; return sock;
} }
...@@ -565,6 +565,12 @@ class AsyncTransportWrapper : virtual public AsyncTransport, ...@@ -565,6 +565,12 @@ class AsyncTransportWrapper : virtual public AsyncTransport,
return nullptr; 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 * Return the application protocol being used by the underlying transport
* protocol. This is useful for transports which are used to tunnel other * protocol. This is useful for transports which are used to tunnel other
......
...@@ -77,7 +77,7 @@ class MockAsyncTransport: public AsyncTransportWrapper { ...@@ -77,7 +77,7 @@ class MockAsyncTransport: public AsyncTransportWrapper {
MOCK_CONST_METHOD0(getRawBytesReceived, size_t()); MOCK_CONST_METHOD0(getRawBytesReceived, size_t());
MOCK_CONST_METHOD0(isEorTrackingEnabled, bool()); MOCK_CONST_METHOD0(isEorTrackingEnabled, bool());
MOCK_METHOD1(setEorTracking, void(bool)); MOCK_METHOD1(setEorTracking, void(bool));
MOCK_METHOD0(getWrappedTransport, AsyncTransportWrapper*()); MOCK_CONST_METHOD0(getWrappedTransport, AsyncTransportWrapper*());
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment