专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Brew

VTBL(IWindow) vtbl;解决方案

发布时间:2010-05-30 20:18:51 文章来源:www.iduyao.cn 采编人员:星星草
VTBL(IWindow) vtbl;
摘一段sample的代码:
/***********************************************************************************/
static IWindow * CFileListWin_New(CMediaPlayer * pOwner)
{
  CFileListWin * pme;
  VTBL(IWindow) vtbl;
   
  MP_IWINDOW_SETVTBL(&vtbl, CFileListWin_Enable, CFileListWin_Redraw, CFileListWin_HandleEvent, CFileListWin_Delete);
...
/***********************************************************************************/

麻烦解释一下这段code的意思.VTBL(IWindow) vtbl;
还有我一直不太清楚VTBL 到底是什么, 这里的
#define VTBL(iname) iname##Vtbl

Brew/C 里面的继承有哪几种途径..

谢谢.

------解决方案--------------------
#define VTBL(iname) iname##Vtbl
VTBL就是一个宏定义而已,用来定义接口的。
面向对象设计中,接口定义很重要,接口就是定义了一系列的操作,在c为基础的brew中,就是表现为一个函数指针的结构体。下面的struct IWindowVtbl 就是例子,只有函数指针,没有其它数据了,因为 IWindow就是:
struct _IWindow {
struct IWindowVtbl *pvt; 
 };
就是函数指针堆在一起而已!!



VTBL(IWindow) vtbl;
展开后就是
IWindowVtbl vtbl


#define QINTERFACE(iname) struct _##iname {\
struct VTBL(iname) *pvt; \
};\
typedef struct VTBL(iname) VTBL(iname); \
struct VTBL(iname)
IWindow的定义如下:
typedef struct _IWindow IWindow;

struct _IWindow {
struct IWindowVtbl *pvt; 
 };
typedef struct IWindowVtbl IWindowVtbl ; 
struct IWindowVtbl 
{
/*
* Enables/Disables the window. Window controls will not process
* events if the window is disabled.
*/
void (*Enable)(IWindow *po, boolean bEnable);

/*
* Redraws the window if enabled
*/
void (*Redraw)(IWindow *po);

/*
* Handles the events routed to the window
*/
boolean (*HandleEvent)(IWindow *po, AEEEvent eCode, uint16 wParam,
uint32 dwParam);

/*
* Releases the window resources
*/
void (*Delete)(IWindow *po);
};

------解决方案--------------------
这里的这个
C/C++ code

VTBL(IWindow) vtbl;
#define VTBL(iname) iname##Vtbl

------解决方案--------------------
就是函数指针表.
你把宏展开,就非常明白了.
其实上层,还可以对这个表做扩展,非常灵活
------解决方案--------------------
看一下AEE.h和AEEInterface.h这两个文件,把宏定义都展开一下就明白了。
别人说多少遍也不如自己展开看一遍的效果好。
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: