📄 base_instanceobject_impl.h
字号:
/*
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.
*///==============================================================================// base_InstanceObject_Impl.h//// Contents: Definition of base class InstanceObjectImpl //==============================================================================#ifndef _CLIENT_BASE_INSTANCEOBJECT_IMPL_H#define _CLIENT_BASE_INSTANCEOBJECT_IMPL_H#include "base_EventClient_Impl.h"#include "base_Object_Impl.h"#include "base_Exception.h"#include <string>//#include "inc/framework/base_InstanceObject.h"using namespace std;using namespace Intel::Mobile::BaseAPI;/*//==============================================================================#define GETFROMSERVERSTR(ServerFunc) \{ IntelMobileChar* pszRtn = NULL;\ IntelMobileChar* pszTmp = NULL;\ try { pszTmp = (IntelMobileChar *)m_pSvrInstObj->ServerFunc().c_str();\ pszRtn = ::strcpy( new IntelMobileChar[::strlen( pszTmp ) + 1], pszTmp );\ } catch ( ... ) \ { IntelMobileException ex(IntelMobileText("TBD"), IntelMobileText("InstanceObject"), \ IntelMobileText( #ServerFunc ) ); throw( ex ); } \ return pszRtn; }//==============================================================================#define GETFROMSERVER(Type,ServerFunc) \{ Type retValue; \ try { if ( FAILED ( m_pSvrInstObj->ServerFunc( &retValue ) ) ) \ { IntelMobileException ex( IntelMobileText("Failure getting value from server") \ IntelMobileText("InstanceObject"),IntelMobileText(#ServerFunc) ); \ throw ex; } \ } catch (...) \ { IntelMobileException ex(IntelMobileText("TBD"), IntelMobileText("InstanceObject"), \ IntelMobileText( #ServerFunc ) ); throw( ex ); } \ return retValue; }//==============================================================================#define CALLSERVERMETHOD(ServerFunc) \{ try { if ( FAILED ( m_pSvrInstObj->ServerFunc() ) ) \ { IntelMobileException ex( IntelMobileText("Failure calling server method") \ IntelMobileText("InstanceObject"),IntelMobileText(#ServerFunc) ); \ throw ex; } \ } catch (...) \ { IntelMobileException ex(IntelMobileText("TBD"), IntelMobileText("InstanceObject"), \ IntelMobileText( #ServerFunc ) ); throw( ex ); } } *///class Observer;//==============================================================================//class InstanceObjectImpl;class PropertyBaseImpl;typedef map<IntelMobileString, PropertyBaseImpl*> PROPERTYIMPLMAP;class InstanceObjectImpl : public EventClientImpl{protected: //ServerInstanceObject * m_pSvrInstObj; void* m_pSvrInstObj; HRESULT DoSubscribe ( Intel::Mobile::BaseAPI::Event::EventType eType, void* pClientEventSubject); HRESULT UnDoSubscribe ( Intel::Mobile::BaseAPI::Event::EventType eType, void* pClientEventSubject);public: //ServerObject * GetSvrObj(); void* GetSvrObj(); Intel::Mobile::BaseAPI::Event::Event *CreateClassEvent(Intel::Mobile::BaseAPI::Event::EventType eType); //InstanceObjectImpl( ServerInstanceObject * pSvrInstObj, Object *pOwner = NULL); InstanceObjectImpl( void* pSvrInstObj, Intel::Mobile::BaseAPI::Object *pOwner = NULL); virtual ~InstanceObjectImpl(); virtual bool operator==( const ObjectImpl& rhs ) const; //virtual ServerPropertyBase* GetProperty ( const IntelMobileString& sName ); virtual void* GetProperty ( const IntelMobileString& sName ); IntelMobileChar* InvokeMethod( IntelMobileChar* methodName, IntelMobileChar* param ); PropertyBaseImpl* GetPropertyImplByName( IntelMobileChar* name, IntelMobileChar* type ); bool IsAvailable( IntelMobileChar* methodName ); virtual bool IsEventAvailable( Intel::Mobile::BaseAPI::Event::EventType eType ); virtual bool AddObserver ( Intel::Mobile::BaseAPI::Event::EventType eType, ObserverImpl& observer ); virtual bool RemoveObserver( Intel::Mobile::BaseAPI::Event::EventType eType, ObserverImpl& observer ); virtual bool EventFired( LONG lType, time_t lTimeStamp ); //virtual IntelMobileChar* GetType () const { GETFROMSERVERSTR(GetType) } virtual IntelMobileChar* GetType (); IntelMobileChar* GetKey (); // IntelMobileChar* GetKey () const { GETFROMSERVERSTR(GetKey ) }private: PROPERTYIMPLMAP m_Properties;};typedef SmartPtr<InstanceObjectImpl> InstanceObjectImplPtr;//==============================================================================#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -