chxavactivecompletiondispatch.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:3k
源码类别:
Symbian
开发平台:
C/C++
- /************************************************************************
- * chxavactivecompletiondispatch.h
- * -------------------------------
- *
- * Synopsis:
- *
- * Dispatch for CAtive derived objects.
- *
- * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- ************************************************************************/
- #ifndef _chxavactivecompletiondispatch_h_
- #define _chxavactivecompletiondispatch_h_
- // Symbian includes...
- #include <e32base.h>
- #include <basched.h>
- // Helix includes...
- #include "unkimp.h"
- #include "ihxpckts.h"
- #include "hxstring.h"
- #include "hxurl.h"
- #include "hxwintyp.h"
- #include "hxcom.h"
- #include "hxcomm.h"
- #include "hxmon.h"
- #include "hxfiles.h"
- #include "hxcore.h"
- #include "hxwin.h"
- // Include from this project...
- #include "chxbody.h"
- #include "chxmakesmartptr.h"
- // CHXAvActiveCmpl:
- // Active Object completion dispatch.
- class CHXAvActiveCmpl :
- public CActive, public CHXBody
- {
- public:
- CHXAvActiveCmpl() : CActive(0) {}
- virtual ~CHXAvActiveCmpl() {}
- virtual TRequestStatus& Status() = 0;
- virtual void RunL() = 0;
- virtual void Activate() = 0;
- protected:
- virtual void DoCancel() = 0;
- };
- MakeSmartPtr(CHXAvActiveCmpl); // Create a smart pointer class CHXAvActiveCmplPtr
- template<class Recv>
- class CHXAvActiveDisp : public CHXAvActiveCmpl {
- public:
- typedef void (Recv::*FuncPtr)(int);
- CHXAvActiveDisp(Recv* pRecv, FuncPtr pCmpl, FuncPtr pCancel);
- virtual ~CHXAvActiveDisp();
- virtual TRequestStatus& Status();
- virtual void RunL();
- virtual void Activate();
- protected:
- virtual void DoCancel();
- private:
- Recv* m_pRecv; // Object receiving completion
- FuncPtr m_pCmpl; // Completion function
- FuncPtr m_pCancel; // Cancel function
- };
- template<class Recv>
- inline
- CHXAvActiveDisp<Recv>::CHXAvActiveDisp(Recv* pRecv, FuncPtr pCmpl, FuncPtr pCancel)
- : m_pRecv(pRecv),
- m_pCmpl(pCmpl),
- m_pCancel(pCancel)
- {}
- template<class Recv>
- inline
- CHXAvActiveDisp<Recv>::~CHXAvActiveDisp()
- {
- }
- template<class Recv>
- inline
- TRequestStatus& CHXAvActiveDisp<Recv>::Status()
- {
- return iStatus;
- }
- template<class Recv>
- inline
- void CHXAvActiveDisp<Recv>::RunL()
- {
- #if defined(DEBUG)
- // our active object should not be leaving (except new)
- TRAPD(err,
- (m_pRecv->*m_pCmpl)(iStatus.Int()) );
- HX_ASSERT(err == KErrNone);
- User::LeaveIfError(err); // possibly continue leaving
- #else
- (m_pRecv->*m_pCmpl)(iStatus.Int());
- #endif
- }
- template<class Recv>
- inline
- void CHXAvActiveDisp<Recv>::DoCancel()
- {
- (m_pRecv->*m_pCancel)(0);
- }
- template<class Recv>
- inline
- void CHXAvActiveDisp<Recv>::Activate()
- {
- if (!IsActive())
- SetActive();
- }
- #endif // _chxavactivecompletiondispatch_h_