📄 base_property.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.
*/#include "base_Property.h"#include "base_Property_Impl.h"using namespace Intel::Mobile::BaseAPI;////////////////////////////////////////////////////////////////////////////////// Base Class for all properties//==============================================================================// C_Tor()//==============================================================================Property::Property( void *pImpl, const IntelMobileChar* pszType ) : EventClient ( pImpl ){ (*reinterpret_cast<ObjectImplPtr*>(m_pImpl))->SetOwner( this ); if ( pszType ) {#ifdef _UNICODE m_sType = ::strcpy( new IntelMobileChar[::strlen(pszType)+1], pszType ); #else m_sType = strcpy( new IntelMobileChar[strlen(pszType)+1], pszType ); #endif }} // C_Tor()//==============================================================================// D_Tor()//==============================================================================Property::~Property(){ if ( m_pImpl ) // If we have a valid impl * delete the SMART POINTER object { PropertyBaseImplPtr* pPropertyImpl = reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl); (*pPropertyImpl)->SetOwner( NULL ); // Remove this as owner of the impl. delete pPropertyImpl; } if ( m_sType ) delete[] m_sType;}//==============================================================================// GetParent()//==============================================================================const InstanceObject* Property::GetParent() const{ InstanceObject* pParent = NULL; if ( m_pImpl ) { const InstanceObjectImplPtr pParemtImpl = (*reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl))->GetInstance(); pParent = reinterpret_cast<InstanceObject*>(pParemtImpl->GetOwner()); } return pParent;} // GetParent()//==============================================================================// Base class accessorsIntelMobileChar* Property::GetName () const { return (*reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl))->GetName (); }IntelMobileChar* Property::GetType () const {#ifdef _UNICODE return ::strcpy( new IntelMobileChar[ ::strlen( m_sType ) + 1 ], m_sType );#else return strcpy( new IntelMobileChar[ strlen( m_sType ) + 1 ], m_sType );#endif}IntelMobileChar* Property::GetNameType () const{ CheckValid(); return ::strcpy( new IntelMobileChar[ ::strlen( m_sNameType ) + 1 ], m_sNameType );}void Property::SetNameType ( IntelMobileChar* sNameType ){ m_sNameType = sNameType;}bool Property::IsNull () const { return (*reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl))->IsNull (); }bool Property::IsSettable () const { return (*reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl))->IsSettable(); }bool Property::IsStatic () const { return (*reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl))->IsStatic (); }bool Property::IsAvailable () const { if ( m_pImpl ) return true; return false;}//==============================================================================// CheckValid()//==============================================================================void Property::CheckValid() const{ if ( !IsAvailable() ) { IntelMobileException ex( IntelMobileText("Property : NotSupportProperty Exception"), IntelMobileText("CheckValid"), IntelMobileText("CheckValid") ); throw( ex ); } //InstanceObject* pParent = const_cast<InstanceObject*>(GetParent());
//if ( !pParent->IsValid() )
//{
// IntelMobileException ex( IntelMobileText("InValidInstance"), IntelMobileText("CheckValid"), IntelMobileText("CheckValid"), 0x80047000 );
// throw( ex );
//}} // CheckValid()// SCR#125, add for process-associated propertybool Property::IsProcessProperty () const { CheckValid(); return true;//(*reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl))->IsProcessProperty(); }//==============================================================================// AddObserver() //==============================================================================bool Property::AddObserver( Event::EventType eType, Observer& observer ){ if ( m_pImpl ) { PropertyBaseImplPtr spImpl = *reinterpret_cast<PropertyBaseImplPtr*>(m_pImpl); return spImpl->AddObserver( eType, *reinterpret_cast<ObserverImpl*>(observer.GetImpl()) );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -