⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hxpropwclnt.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    ,m_pPropWatch(pClientPropWatch)
    ,m_bIsCallbackPending (FALSE)
{
}

HXClientPropWatch::PropWatchCallback::~PropWatchCallback()
{
}

/*
 * IUnknown methods
 */

/////////////////////////////////////////////////////////////////////////
//      Method:
//              IUnknown::QueryInterface
//      Purpose:
//              Implement this to export the interfaces supported by your
//              object.
//
STDMETHODIMP HXClientPropWatch::PropWatchCallback::QueryInterface(REFIID riid, void** ppvObj)
{
    QInterfaceList qiList[] =
        {
            { GET_IIDHANDLE(IID_IHXCallback), (IHXCallback*)this },
            { GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXCallback*)this },
        };
    
    return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
}

/////////////////////////////////////////////////////////////////////////
//      Method:
//              IUnknown::AddRef
//      Purpose:
//              Everyone usually implements this the same... feel free to use
//              this implementation.
//
STDMETHODIMP_(ULONG32) HXClientPropWatch::PropWatchCallback::AddRef()
{
    return InterlockedIncrement(&m_lRefCount);
}

/////////////////////////////////////////////////////////////////////////
//      Method:
//              IUnknown::Release
//      Purpose:
//              Everyone usually implements this the same... feel free to use
//              this implementation.
//
STDMETHODIMP_(ULONG32) HXClientPropWatch::PropWatchCallback::Release()
{
    if (InterlockedDecrement(&m_lRefCount) > 0)
    {
	return m_lRefCount;
    }

    delete this;
    return 0;
}


/*
 *      IHXCallback methods
 */
STDMETHODIMP HXClientPropWatch::PropWatchCallback::Func(void)
{
    m_PendingHandle         = 0;
    m_bIsCallbackPending    = FALSE;

    if (m_pPropWatch && m_pPropWatch->m_pInternalResponse)
    {
	m_pPropWatch->m_pInternalResponse->ProcessPendingResponses();
    }

    return HXR_OK;
}


// PropWatchResponse

HXClientPropWatch::PropWatchResponse::PropWatchResponse(HXClientPropWatch* pClientPropWatch) :
     m_lRefCount (0)
    ,m_pPropWatch(pClientPropWatch)
    ,m_pPendingResponseList (NULL)
{
}

HXClientPropWatch::PropWatchResponse::~PropWatchResponse()
{
    while (m_pPendingResponseList && m_pPendingResponseList->GetCount() > 0)
    {
	PropResponseValues* pValues = (PropResponseValues*) 
					m_pPendingResponseList->RemoveHead();
	delete pValues;
    }

    HX_DELETE(m_pPendingResponseList);
}

/*
 * IUnknown methods
 */

/////////////////////////////////////////////////////////////////////////
//      Method:
//              IUnknown::QueryInterface
//      Purpose:
//              Implement this to export the interfaces supported by your
//              object.
//
STDMETHODIMP HXClientPropWatch::PropWatchResponse::QueryInterface(REFIID riid, void** ppvObj)
{
    QInterfaceList qiList[] =
        {
            { GET_IIDHANDLE(IID_IHXPropWatchResponse), (IHXPropWatchResponse*)this },
            { GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXPropWatchResponse*)this },
        };
    
    return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
}

/////////////////////////////////////////////////////////////////////////
//      Method:
//              IUnknown::AddRef
//      Purpose:
//              Everyone usually implements this the same... feel free to use
//              this implementation.
//
STDMETHODIMP_(ULONG32) HXClientPropWatch::PropWatchResponse::AddRef()
{
    return InterlockedIncrement(&m_lRefCount);
}

/////////////////////////////////////////////////////////////////////////
//      Method:
//              IUnknown::Release
//      Purpose:
//              Everyone usually implements this the same... feel free to use
//              this implementation.
//
STDMETHODIMP_(ULONG32) HXClientPropWatch::PropWatchResponse::Release()
{
    if (InterlockedDecrement(&m_lRefCount) > 0)
    {
	return m_lRefCount;
    }

    delete this;
    return 0;
}


/*
 *	IHXPropWatchResponse methods
 */
STDMETHODIMP
HXClientPropWatch::PropWatchResponse::AddedProp(const UINT32		id,
			     const HXPropType   	propType,
			     const UINT32		ulParentID)
{
    /* If we are at interrupt time, make sure that the 
     * response is interrupt safe
     */
    if (m_pPropWatch->m_pInterruptState &&
	m_pPropWatch->m_pInterruptState->AtInterruptTime() &&
	(!m_pPropWatch->m_pInterruptSafeResponse ||
	!m_pPropWatch->m_pInterruptSafeResponse->IsInterruptSafe()))
    {
	ScheduleCallback(ADDEDPROP, id, propType, ulParentID);
    }
    else
    {
	ProcessPendingResponses();
	m_pPropWatch->m_pResponse->AddedProp(id, propType, ulParentID);
    }

    return HXR_OK;
}

STDMETHODIMP
HXClientPropWatch::PropWatchResponse::ModifiedProp(const UINT32		id,
			     const HXPropType   	propType,
			     const UINT32		ulParentID)
{
    /* If we are at interrupt time, make sure that the 
     * response is interrupt safe
     */
    if (m_pPropWatch->m_pInterruptState &&
	m_pPropWatch->m_pInterruptState->AtInterruptTime() &&
	(!m_pPropWatch->m_pInterruptSafeResponse ||
	!m_pPropWatch->m_pInterruptSafeResponse->IsInterruptSafe()))
    {
	ScheduleCallback(MODIFIEDPROP, id, propType, ulParentID);
    }
    else
    {
	ProcessPendingResponses();
	m_pPropWatch->m_pResponse->ModifiedProp(id, propType, ulParentID);
    }

    return HXR_OK;
}

STDMETHODIMP
HXClientPropWatch::PropWatchResponse::DeletedProp(const UINT32		id,
			     const UINT32		ulParentID)
{
    /* If we are at interrupt time, make sure that the 
     * response is interrupt safe
     */
    if (m_pPropWatch->m_pInterruptState &&
	m_pPropWatch->m_pInterruptState->AtInterruptTime() &&
	(!m_pPropWatch->m_pInterruptSafeResponse ||
	!m_pPropWatch->m_pInterruptSafeResponse->IsInterruptSafe()))
    {
	ScheduleCallback(DELETEDPROP, id, (HXPropType) 0, ulParentID);
    }
    else
    {
	ProcessPendingResponses();
	m_pPropWatch->m_pResponse->DeletedProp(id, ulParentID);
    }

    return HXR_OK;
}

void
HXClientPropWatch::PropWatchResponse::ScheduleCallback(ResponseType	uResponseType,
				    const UINT32		id,
				    const HXPropType   	propType,
				    const UINT32		ulParentID)
{
    if (!m_pPendingResponseList)
    {
	m_pPendingResponseList = new CHXSimpleList;
    }

    PropResponseValues* pValues = new PropResponseValues(uResponseType, id, 
						    propType, ulParentID);

    m_pPendingResponseList->AddTail((void*) pValues);

    if (!m_pPropWatch->m_pCallback)
    {
	m_pPropWatch->m_pCallback = new PropWatchCallback(m_pPropWatch);
	m_pPropWatch->m_pCallback->AddRef();
    }

    if (!m_pPropWatch->m_pCallback->m_bIsCallbackPending &&
	m_pPropWatch->m_pScheduler)
    {
	m_pPropWatch->m_pCallback->m_bIsCallbackPending = TRUE;
	m_pPropWatch->m_pCallback->m_PendingHandle = 
	    m_pPropWatch->m_pScheduler->RelativeEnter(
				    m_pPropWatch->m_pCallback, 0);
    }
}

void
HXClientPropWatch::PropWatchResponse::ProcessPendingResponses()
{
    /* remove any pending callback */
    if (m_pPropWatch->m_pCallback &&
	m_pPropWatch->m_pCallback->m_bIsCallbackPending &&
	m_pPropWatch->m_pScheduler)
    {
	m_pPropWatch->m_pCallback->m_bIsCallbackPending = FALSE;
	m_pPropWatch->m_pScheduler->Remove(
			m_pPropWatch->m_pCallback->m_PendingHandle);
    }

    while (m_pPendingResponseList && m_pPendingResponseList->GetCount() > 0)
    {
	PropResponseValues* pValues = (PropResponseValues*) 
					m_pPendingResponseList->RemoveHead();

	switch (pValues->m_uResponseType)
	{
	    case ADDEDPROP:
		m_pPropWatch->m_pResponse->AddedProp(pValues->m_ulId, 
						     pValues->m_propType,
						     pValues->m_ulParentID);
    		break;
	    case MODIFIEDPROP:
		m_pPropWatch->m_pResponse->ModifiedProp(pValues->m_ulId, 
						      pValues->m_propType,
						      pValues->m_ulParentID);
		break;
	    case DELETEDPROP:
		m_pPropWatch->m_pResponse->DeletedProp(pValues->m_ulId, 
						       pValues->m_ulParentID);
		break;
	    default:
		HX_ASSERT(0);
		break;
	}

	delete pValues;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -