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

📄 valuethreshold_impl.cpp

📁 270的linux说明
💻 CPP
字号:
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*///==============================================================================// ValueThreshold_Impl.cpp //       Implementation of base class ValueThresholdImpl//==============================================================================#include "./ValueThreshold_Impl.h"  #include "../Base/base_Exception.h"//#include "IntelMobile_Server/IntelMobile_Server.h"#include "../Ipc_Support.h"//==============================================================================// C-Tor() : Constructor//==============================================================================ValueThresholdImpl::ValueThresholdImpl( Object*   pOwner,                                        IntelMobileChar*  sType )                  : ThresholdImpl( pOwner, sType ){}//==============================================================================// D-Tor() : //==============================================================================ValueThresholdImpl::~ValueThresholdImpl(){}//==============================================================================// GetNotifyMatch() : //==============================================================================bool ValueThresholdImpl::GetNotifyMatch()          { 	//return reinterpret_cast<ServerValueThreshold*> (GetInterface())->GetNotifyMatch();	//IPC support	EnterCriticalSection(&m_csIpc);	bool retValue;	vector<string> vectParam, vectRtn;	vectParam.push_back(IntelMobileText("GetNotifyMatch"));		HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, (GetInterface()), vectParam, vectRtn);	if ( FAILED( hr ) )	{		 IntelMobileException ex( IntelMobileText("Error retrieving NotifyMatch value"),                                 m_sThresholdType.c_str(), IntelMobileText("GetNotifyMatch"), hr );	 	LeaveCriticalSection(&m_csIpc);            throw( ex ); 	}	else	{		CStringHelper::Str2Param(vectRtn[0], retValue);	 	LeaveCriticalSection(&m_csIpc);		return retValue;	}} // GetNotifyMatch()//==============================================================================// GetNotifyDiffer() : //==============================================================================bool ValueThresholdImpl::GetNotifyDiffer()          {     //return reinterpret_cast<ServerValueThreshold*> (GetInterface())->GetNotifyDiffer();	//IPC support	EnterCriticalSection(&m_csIpc);	bool retValue;	vector<string> vectParam, vectRtn;	vectParam.push_back(IntelMobileText("GetNotifyDiffer"));		HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, (GetInterface()), vectParam, vectRtn);	if ( FAILED( hr ) )	{		IntelMobileException ex( IntelMobileText("Error retrieving NotifyDiffer value"),                                 m_sThresholdType.c_str(), IntelMobileText("GetNotifyDiffer"), hr);	 	LeaveCriticalSection(&m_csIpc);            throw( ex ); 	}	else	{		CStringHelper::Str2Param(vectRtn[0], retValue);	 	LeaveCriticalSection(&m_csIpc);		return retValue;	}} // GetNotifyDiffer()//==============================================================================// SetNotifyMatch() : //==============================================================================bool ValueThresholdImpl::SetNotifyMatch( bool bNotify )          {  	//reinterpret_cast<ServerValueThreshold*> (GetInterface())->SetNotifyMatch( bNotify );	//bool retValue;	//IPC support	EnterCriticalSection(&m_csIpc);	vector<string> vectParam, vectRtn;	vectParam.push_back(IntelMobileText("SetNotifyMatch"));	vectParam.push_back(CStringHelper::Param2Str(bNotify));		HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, (GetInterface()), vectParam, vectRtn);		if ( FAILED( hr ) )    {        IntelMobileException ex( IntelMobileText("Error setting NotifyMatch value"),                             m_sThresholdType.c_str(), IntelMobileText("SetNotifyMatch"), hr );	 	LeaveCriticalSection(&m_csIpc);        throw( ex );     }	LeaveCriticalSection(&m_csIpc);	return true;} // SetNotifyMatch()//==============================================================================// SetNotifyDiffer() : //==============================================================================bool ValueThresholdImpl::SetNotifyDiffer( bool bNotify )          {	//reinterpret_cast<ServerValueThreshold*> (GetInterface())->SetNotifyDiffer( bNotify );	//IPC support	EnterCriticalSection(&m_csIpc);	vector<string> vectParam, vectRtn;	vectParam.push_back(IntelMobileText("SetNotifyDiffer"));	vectParam.push_back(CStringHelper::Param2Str(bNotify));		HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, (GetInterface()), vectParam, vectRtn);	if ( FAILED( hr ) )    {        IntelMobileException ex( IntelMobileText("Error setting NotifyMatch value"),                             m_sThresholdType.c_str(), IntelMobileText("SetNotifyDiffer"), hr);	 	LeaveCriticalSection(&m_csIpc);        throw( ex );     }			LeaveCriticalSection(&m_csIpc);	return true;	} // SetNotifyDiffer()/*//==============================================================================// AddObserver() : //==============================================================================bool ValueThresholdImpl::AddObserver( ObserverImpl& observer  ) {     EventClientImpl::AddObserver( Event::eThresholdEqual, observer );	return EventClientImpl::AddObserver( Event::eThresholdDiffer, observer );} // AddObserver()//==============================================================================// RemoveObserver() : //==============================================================================bool ValueThresholdImpl::RemoveObserver( ObserverImpl& observer ) {     EventClientImpl::RemoveObserver( Event::eThresholdEqual, observer );	return EventClientImpl::RemoveObserver(  Event::eThresholdDiffer, observer );} // RemoveObserver()//==============================================================================// RemoveObservers() : //==============================================================================bool ValueThresholdImpl::RemoveObservers( ) { 	bool bRemoved = false;	CClientImplEventManager &eventMgr = CClientImplEventManager::GetClientImplEventManagerInst();    //CEventBind  *pEb = eventMgr.GetEventBind( this, Event::eThresholdEqual );	//if (NULL != pEb)	{		//bRemoved = eventMgr.RemoveObservers(pEb->GetHandle());		bRemoved = eventMgr.RemoveObservers(Event::eThresholdEqual, this);	}		//pEb = eventMgr.GetEventBind( this, Event::eThresholdDiffer );	//if (NULL != pEb)	{		//return bRemoved & eventMgr.RemoveObservers(pEb->GetHandle());		return bRemoved & eventMgr.RemoveObservers(Event::eThresholdDiffer, this);	}    return false; } // RemoveObservers()//==============================================================================// SetObserverEvent() : //==============================================================================bool ValueThresholdImpl::SetObserverEvent( ) { 	bool bRet = false;	Event * event = ThresholdImpl::CreateClassEvent( Event::eThresholdEqual );	bRet = EventClientImpl::UpdateEvent( Event::eThresholdEqual, *event);	delete event;	event = ThresholdImpl::CreateClassEvent( Event::eThresholdDiffer );	bRet &= EventClientImpl::UpdateEvent( Event::eThresholdDiffer, *event);	delete event;	return bRet;} // SetObserverEvent()*///==============================================================================// GetDistinctEvent() : //==============================================================================Event::EventType ValueThresholdImpl::GetDistinctEvent( ) {     return Event::eThresholdEqual;} // GetDistinctEvent()// END CLASS DEFINITION ValueThreshold//------------------------------------------------------------------------// // Class: StringValueThreshold////------------------------------------------------------------------------//==============================================================================// C-Tor() : Constructor//==============================================================================StringValueThresholdImpl::StringValueThresholdImpl( Object*  pOwner,                                                    IntelMobileChar* pszValue )                  : ValueThresholdImpl( pOwner, IntelMobileText("StringValueThreshold") ){    SetValue( pszValue );}//==============================================================================// SetValue() : //==============================================================================bool StringValueThresholdImpl::SetValue( const IntelMobileChar* pszValue )          {	//reinterpret_cast<ServerStringValueThreshold*> (GetInterface())->SetValue( pszValue );		//IPC support	EnterCriticalSection(&m_csIpc);	vector<string> vectParam, vectRtn;	vectParam.push_back(IntelMobileText("SetValue"));	vectParam.push_back(CStringHelper::Param2Str(pszValue));		HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, (GetInterface()), vectParam, vectRtn);	if ( FAILED( hr ) )    {        IntelMobileException ex( IntelMobileText("Error setting value"),                             m_sThresholdType.c_str(), IntelMobileText("SetValue"), hr );	 	LeaveCriticalSection(&m_csIpc);        throw( ex );     }	LeaveCriticalSection(&m_csIpc);	return true;} // SetValue()//==============================================================================// GetValue() : //==============================================================================const IntelMobileChar* StringValueThresholdImpl::GetValue()           {     //pszValue = ::wcscpy( new IntelMobileChar[::wcslen(bsValue)+1], bsValue );	//const IntelMobileChar * pszValue = reinterpret_cast<ServerStringValueThreshold*> (GetInterface())->GetValue();	//IPC support	EnterCriticalSection(&m_csIpc);	IntelMobileChar* pszValue;	vector<string> vectParam, vectRtn;	vectParam.push_back(IntelMobileText("GetValue"));		HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, (GetInterface()), vectParam, vectRtn);	if ( FAILED( hr ) )    {			IntelMobileException ex( IntelMobileText("Error getting value"),                             m_sThresholdType.c_str(), IntelMobileText("GetValue"), hr );	 	LeaveCriticalSection(&m_csIpc);        throw( ex ); 	}	else	{		CStringHelper::Str2Param(vectRtn[0], pszValue);	#ifdef _UNICODE		return wcscpy( new IntelMobileChar[::wcslen(pszValue)+1], pszValue );#else		return strcpy( new IntelMobileChar[::strlen(pszValue)+1], pszValue );#endif	}    	LeaveCriticalSection(&m_csIpc);	return NULL;} // SetValue()//==============================================================================// GetInterface() : Returns the interface pointer, having instantiated it if needed.//==============================================================================void* StringValueThresholdImpl::GetInterface(){	EnterCriticalSection(&m_csIpc);    if (m_pSvrThresholdObject == NULL)	{		//m_pSvrThresholdObject = GetNewServerThreshold(IntelMobileText("StringValueThreshold"));		//IPC support		m_sName = "StringValueThreshold";		m_nDataType = ID_TYPE_THRESHOLD;		vector<string> vectParam, vectRtn;			vectParam.push_back(CStringHelper::Param2Str(m_sName));		//printf("want to send %s\n",vectParam[0].c_str());				HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, /*GetSvrObj()*/NULL, vectParam, vectRtn); //now GetSvrObj() should be null		if ( FAILED( hr ) )        {            IntelMobileException ex( IntelMobileText("Error setting GetInterface value"),                                 m_sThresholdType.c_str(), IntelMobileText("GetInterface"), hr );	 		LeaveCriticalSection(&m_csIpc);            throw( ex );         }					else            CStringHelper::Str2Param(vectRtn[0], (int &)m_pSvrThresholdObject);		//printf("getted  %s\n",vectRtn[0].c_str());	}		LeaveCriticalSection(&m_csIpc);	return (m_pSvrThresholdObject);} // GetInterface()//end class StringValueThreshold //==============================================================================

⌨️ 快捷键说明

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