ProcessPolicy.h
资源名称:cppapp.zip [点击查看]
上传用户:smh666999
上传日期:2007-01-14
资源大小:553k
文件大小:2k
源码类别:
BREW编程
开发平台:
Visual C++
- #ifndef _PROC_PLCY_h_
- #define _PROC_PLCY_h_
- struct ConnectionPolicy
- {
- static bool isReusable()
- {
- return true;
- }
- };
- template <class Y, class F>
- struct pkCBK0
- {
- void setCallback(Y* y, F fx)
- {
- y_ = y;
- f_ = fx;
- }
- static void callbackHandler(void* v)
- {
- typedef pkCBK0<Y,F> pk;
- pk* z = static_cast<pk*>(v);
- F fx = z->f_;
- Y* y = z->y_;
- (*y.*fx)();
- }
- Y* y_;
- F f_;
- };
- template <class Y, class F>
- struct pkCBK1
- {
- void setCallback(Y* y, F fx)
- {
- y_ = y;
- f_ = fx;
- }
- template <class Z>
- static void callbackHandler(void* v, Z me)
- {
- typedef pkCBK1<Y,F> pk;
- pk* z = static_cast<pk*>(v);
- F fx = z->f_;
- Y* y = z->y_;
- (*y.*fx)(me);
- }
- Y* y_;
- F f_;
- };
- template <class Y>
- struct pkAEECBK
- {
- typedef void (Y::*FNX)( );
- void setCallback(Y* y, FNX fx, IShell* shell)
- {
- y_ = y;
- f_ = fx;
- shell_ = shell;
- }
- static void callbackHandler(void* v)
- {
- typedef pkAEECBK<Y> pk;
- pk* z = static_cast<pk*>(v);
- typedef void (Y::*FNX)();
- FNX fx = z->f_;
- Y* y = z->y_;
- (*y.*fx)();
- }
- void operator()()
- {
- cb_.pfnNotify = (PFNNOTIFY)callbackHandler;
- cb_.pNotifyData = this;
- cb_.pfnCancel = NULL;
- ISHELL_Resume(shell_,&cb_);
- }
- template <class U, class R>
- static U& initCbk(R* rr, Y* me, FNX onEndCbk, IShell* shell, Type2Type<U> )
- {
- U* prp = static_cast<U*>(rr->getRegistered(U::getID()));
- if (!prp)
- prp = new U;
- U& pr = *prp;
- pr.setCallback(me, onEndCbk, shell);
- rr->registerResource(prp);
- return pr;
- }
- AEECallback cb_;
- Y* y_;
- FNX f_;
- IShell* shell_;
- };
- #endif