基类成员函数是否可以直接访问子类成员函数?
我从 Androind 找到了代码,BufferQueue继承了BnSurfaceTexture,并且有一个成员函数“requestBuffer”。
在基类BnSurfaceTexture中,我发现它只是直接调用 requestBuffer 。
基类BnSurfaceTexture如何知道函数“requestBuffer”?
谢谢
基类成员函数:
status_t BnSurfaceTexture::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
case REQUEST_BUFFER: {
CHECK_INTERFACE(ISurfaceTexture, data, reply);
int bufferIdx = data.readInt32();
sp<GraphicBuffer> buffer;
/* it call requestBuffer directly */ <--------
int result = requestBuffer(bufferIdx, &buffer);
reply->writeInt32(buffer != 0);
子类声明和实现:
class BufferQueue : public BnSurfaceTexture {
private:
virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
ATRACE_CALL();
ST_LOGV("requestBuffer: slot=%d", slot);
Mutex::Autolock lock(mMutex);
...
return NO_ERROR;
}