📄 base_property_impl.h
字号:
EnterCriticalSection(&m_csIpc);\ vector<string> vectParam, vectRtn; \ vectParam.push_back(CStringHelper::Param2Str(IntelMobileText( #method ))); \ vectParam.push_back( CStringHelper::Param2Str(Value) ); \ HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, GetSvrProperty(), vectParam, vectRtn); \ if (FAILED(hr) ) \ {\ IntelMobileException ex( IntelMobileText("Failure Setting Array Value"), IntelMobileText("Property"), IntelMobileText("SetValue"), hr); \ LeaveCriticalSection(&m_csIpc);\ throw( ex ); \ }\ else\ {\ CStringHelper::Str2Param(vectRtn[0], retValue);\ }\ LeaveCriticalSection(&m_csIpc);\ return retValue; \#define SAFECLEARARRAYVALUE( method, Value ) \ bool retValue = false; \ EnterCriticalSection(&m_csIpc);\ vector<string> vectParam, vectRtn; \ vectParam.push_back(CStringHelper::Param2Str(IntelMobileText( #method ))); \ vectParam.push_back( CStringHelper::Param2Str(Value) ); \ HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, GetSvrProperty(), vectParam, vectRtn); \ if (FAILED(hr) ) \ {\ IntelMobileException ex( IntelMobileText("Failure Setting Array Value"), IntelMobileText("Property"), IntelMobileText("SetValue"), hr); \ LeaveCriticalSection(&m_csIpc);\ throw( ex ); \ }\ else\ {\ CStringHelper::Str2Param(vectRtn[0], retValue);\ }\ LeaveCriticalSection(&m_csIpc);\ return retValue; \////////////////////////////////////////////////////////////////////////////////// Base Class for all propertiesclass PropertyBaseImpl : public EventClientImpl{protected: IntelMobileString m_sName; InstanceObjectImpl* m_pParentObject; // Pointer to encapsulating instance void* m_pSvrPropBase; // Not loaded until used. // IPropertyEventSubjectPtr m_spIEventSubject; HRESULT DoSubscribe (Intel::Mobile::BaseAPI::Event::EventType eType, void* ); HRESULT UnDoSubscribe (Intel::Mobile::BaseAPI::Event::EventType eType, void* );public: void* GetSvrObj(); void* GetSvrProperty(); Intel::Mobile::BaseAPI::Event *CreateClassEvent(Intel::Mobile::BaseAPI::Event::EventType eType); PropertyBaseImpl( IntelMobileChar* szName, InstanceObjectImpl* pParent ); virtual ~PropertyBaseImpl() { EnterCriticalSection(&m_csIpc); RELEASE(m_pSvrPropBase); LeaveCriticalSection(&m_csIpc); } virtual bool operator==( const ObjectImpl& rhs ) const; virtual size_t GetSize () = 0; InstanceObjectImplPtr GetInstance () { return m_pParentObject; } virtual bool AddObserver ( Intel::Mobile::BaseAPI::Event::EventType eType, ObserverImpl& observer ); virtual bool RemoveObserver( Intel::Mobile::BaseAPI::Event::EventType eType, ObserverImpl& observer ); bool EventFired( LONG lType, time_t lTimeStamp); //======================================================== bool IsNull(); bool IsSettable(); bool IsStatic(); IntelMobileChar* GetName(); };typedef SmartPtr<PropertyBaseImpl> PropertyBaseImplPtr;////////////////////////////////////////////////////////////////////////////////// template Class for all propertiestemplate<class T>class PropertyImpl : public PropertyBaseImpl{public: PropertyImpl( IntelMobileChar* szName, InstanceObjectImpl* pParent) : PropertyBaseImpl( szName, pParent ) { } virtual ~PropertyImpl() { /*RELEASE(m_pSvrPropBase);*/} virtual size_t GetSize() { return 1; } T GetValue() { /*return (reinterpret_cast<ServerProperty<T>*>( GetSvrProperty() ))->GetValue();*/ T retValue = (T)NULL; /* try {*/ GetValueImpl( retValue ); /* vector<string> vectParam, vectRtn; vectParam.push_back(IntelMobileText("GetValue")); GetIpcClient()->IpcCall(m_nDataType, GetSvrProperty() , vectParam, vectRtn); CStringHelper::Str2Param(vectRtn[0], retValue);*//* } catch (...) { IntelMobileException ex( IntelMobileText("Operation Error"), IntelMobileText("PropertyImpl"), IntelMobileText("GetValue") ); throw( ex ); }*/ return retValue; } bool SetValue( T Value ) { /* try {*/ //(reinterpret_cast<ServerProperty<T>*>( GetSvrProperty() ))->SetValue( Value );/* vector<string> vectParam, vectRtn; vectParam.push_back(IntelMobileText("SetValue")); vectParam.push_back( CStringHelper::Param2Str(Value) ); GetIpcClient()->IpcCall(m_nDataType, GetSvrProperty(), vectParam, vectRtn); bool retValue; CStringHelper::Str2Param(vectRtn[0], retValue); return retValue;*/ SetValueImpl( Value );/* } catch (...) { return FALSE; }*/ // // TODO, return value? return TRUE; } protected: void GetValueImpl( int& retValue ) { SAFEGETVALUE ( GetIntValue, retValue ); } void GetValueImpl( unsigned char& retValue ) { SAFEGETVALUE( GetByteValue, retValue ); } void GetValueImpl( unsigned int& retValue ) { SAFEGETVALUE( GetUintValue, retValue ); } void GetValueImpl( __int64& retValue ) { SAFEGETVALUE( GetInt64Value, retValue ); } void GetValueImpl( unsigned __int64& retValue ) { SAFEGETVALUE( GetUInt64Value, retValue ); } void GetValueImpl( float& retValue ) { SAFEGETVALUE( GetFloatValue, retValue ); } void GetValueImpl( DATE& retValue ) { SAFEGETVALUE( GetDatetimeValue, retValue ); } void GetValueImpl( bool& retValue ) { SAFEGETVALUE( GetBoolValue, retValue ); } void GetValueImpl( IntelMobileChar*& retValue ) { // void* ssp = GetSvrProperty();// IntelMobileString szValue = ssp->GetValue(); IntelMobileString szValue ; SAFEGETVALUE( GetStringValue, szValue );#ifdef _UNICODE retValue = ::wcscpy( new IntelMobileChar[::wcslen(szValue.c_str())+1], szValue.c_str()) ;#else retValue = ::strcpy( new IntelMobileChar[::strlen(szValue.c_str())+1], szValue.c_str()) ;#endif } void SetValueImpl( int Value ) { SAFESETVALUE( SetIntValue, Value ) ; } void SetValueImpl( unsigned char Value ) { SAFESETVALUE( SetByteValue, Value ) ; } void SetValueImpl( unsigned int Value ) { SAFESETVALUE( SetUintValue, Value ) ; } void SetValueImpl( __int64 Value ) { SAFESETVALUE( SetInt64Value, Value ) ; } void SetValueImpl( unsigned __int64 Value ) { SAFESETVALUE( SetUInt64Value, Value ) ; } void SetValueImpl( float Value ) { SAFESETVALUE( SetFloatValue, Value ) ; } void SetValueImpl( DATE Value ) { SAFESETVALUE( SetDatetimeValue, Value ) ; } void SetValueImpl( bool Value ) { SAFESETVALUE( SetBoolValue, Value ) ; } void SetValueImpl( IntelMobileChar* Value ) { /*void* ssp = GetSvrProperty(); IntelMobileString szValue = Value; ssp->SetValue( Value);*/ SAFESETVALUE( SetStringValue, Value ) ; }}; // template class Property ////////////////////////////////////////////////////////////////////////////////Object// template class ArrayPropertytemplate<class T>class ArrayPropertyImpl : public PropertyImpl<T>{public: int m_nDataType;// why not inherit from father class? CRITICAL_SECTION m_csIpc; ArrayPropertyImpl( IntelMobileChar* szName, InstanceObjectImpl* pParent ): PropertyImpl<T>( szName, pParent ) { InitializeCriticalSection(&m_csIpc); } virtual ~ArrayPropertyImpl() { /*void *obj=GetSvrProperty(); RELEASE(obj );printf("There is a bug when release srvobj in ArrayPropertyImpl, please notify to fix it\n");*/ DeleteCriticalSection(&m_csIpc); } virtual size_t GetSize() { //return (reinterpret_cast<ServerArrayProperty<T>*>( GetSvrProperty() ))->GetSize(); size_t retValue =0; int bfsh; /* try {*/ EnterCriticalSection(&m_csIpc); vector<string> vectParam, vectRtn; vectParam.push_back(IntelMobileText("GetSize")); HRESULT hr = GetIpcClient()->IpcCall(m_nDataType, GetSvrProperty(), vectParam, vectRtn); if (FAILED(hr) ) { IntelMobileException ex( IntelMobileText("Failure Getting Value"), IntelMobileText("Property"), IntelMobileText("GetSize"), hr); LeaveCriticalSection(&m_csIpc); throw( ex ); } else { CStringHelper::Str2Param(vectRtn[0], retValue); //CStringHelper::Str2Param(vectRtn[0], bfsh);/* } catch (...) { return 0;//FALSE; }*/ } LeaveCriticalSection(&m_csIpc); return retValue; } T GetValue( const size_t Offset ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -