📄 intelmobilenetworkinstanceprovider.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.
*///==============================================================================// IntelMobileNetworkInstanceProvider.cpp//// Declaration of the class for the network instance provider for IntelMobile. It // supports all types of devices according to specification.//// It's only job is to create InstanceObjects. Including the base header for// network instance providers and implementing the functions are all that's// necessary.//// The heart of creation is done in the following files:// instance_NetworkAdapterInstanctObject// instance_RadioAdapterInstanctObject// instance_WiredAdapterInstanctObject// instance_Protocol802_11InstanctObject// instance_Protocol802_3InstanctObject// instance_LinkProtocolInstanctObject//// //==============================================================================#include "IntelMobileNetworkInstanceProvider.h"NetworkAdapterInstanceProvider LocalNetworkAdapterInstanceProvider;WiredAdapterInstanceProvider LocalWiredAdapterInstanceProvider;RadioAdapterInstanceProvider LocalRadioAdapterInstanceProvider;LinkProtocolInstanceProvider LocalLinkProtocolInstanceProvider;Protocol802_3InstanceProvider LocalProtocol802_3InstanceProvider;Protocol802_11InstanceProvider LocalProtocol802_11InstanceProvider;/*ProtocolWwanInstanceProvider LocalProtocolWwanInstanceProvider;ProtocolCdmaInstanceProvider LocalProtocolCdmaInstanceProvider;ProtocolGprsInstanceProvider LocalProtocolGprsInstanceProvider;*///================================================================================PROVIDER_API IInstanceProvider* CreateInstanceProvider( const IntelMobileString& sType ){ //_Log(IntelMobileText("IInstanceProvider* CreateInstanceProvider(%s)"), sType.c_str()); if ( sType == IntelMobileText( "NetworkAdapter" ) ) return &LocalNetworkAdapterInstanceProvider; else if ( sType == IntelMobileText( "WiredAdapter" ) ) return &LocalWiredAdapterInstanceProvider; else if ( sType == IntelMobileText( "RadioAdapter" ) ) return &LocalRadioAdapterInstanceProvider; else if ( sType == IntelMobileText( "LinkProtocol" ) ) return &LocalLinkProtocolInstanceProvider; else if ( sType == IntelMobileText( "Protocol802_3" ) ) return &LocalProtocol802_3InstanceProvider; else if ( sType == IntelMobileText( "Protocol802_11" ) ) return &LocalProtocol802_11InstanceProvider;/* else if ( sType == IntelMobileText( "ProtocolWwan" ) ) return &LocalProtocolWwanInstanceProvider; else if ( sType == IntelMobileText( "ProtocolCdma" ) ) return &LocalProtocolCdmaInstanceProvider; else if ( sType == IntelMobileText( "ProtocolGprs" ) ) return &LocalProtocolGprsInstanceProvider; */ else return NULL;}//==============================================================================// Comment says that these should return references, not pointers. The calling// function will check to see if the key is null. This puts a lot of// responsibility on the calling function though.//// If they aren't references, it gets really tough to manage memory when an// instance provider is removed.ServerInstanceObject* NetworkAdapterInstanceProvider::CreateInstance( const IntelMobileString& szKey ){ // Returns the instance object if created now OR if has already been // created. If there are problems creating its associated instance // then delete the one we just created, but don't create the one that // already existed. ServerInstanceObject* pObject = NULL; pObject = GetLayer()->GetLayerClassObject( IntelMobileText("NetworkAdapter" )).GetInstance( szKey ); if ( pObject == NULL ) { pObject = new DefaultNetworkAdapterInstanceObject( szKey,GetLayer()->GetLog() ); if ( pObject->GetKey()[0] == NULL ) { delete pObject; pObject = NULL; } } return pObject;}//define in IntelMobileNetworkClassProvider.cppextern IntelMobileString GetAdapterInfo( const IntelMobileString& internalKey );//==============================================================================ServerInstanceObject* WiredAdapterInstanceProvider::CreateInstance( const IntelMobileString& szKey ){ //sanity check here IntelMobileString szTemp = szKey; if( GetAdapterInfo(szTemp) != IntelMobileText("WiredAdapter")) { return NULL; } ServerInstanceObject* pObject = NULL; pObject = GetLayer()->GetLayerClassObject( IntelMobileText("NetworkAdapter") ).GetInstance( szKey ); if ( pObject == NULL ) { pObject = new DefaultWiredAdapterInstanceObject( szKey,GetLayer()->GetLog() ); if ( pObject->GetKey()[0] == NULL ) { delete pObject; pObject = NULL; } } return pObject;}//===============================================================================ServerInstanceObject* RadioAdapterInstanceProvider::CreateInstance( const IntelMobileString& szKey ){ //sanity check here IntelMobileString szTemp = szKey; if( GetAdapterInfo(szTemp) != IntelMobileText("RadioAdapter")) { return NULL; } ServerInstanceObject* pObject = NULL; pObject = GetLayer()->GetLayerClassObject( IntelMobileText("NetworkAdapter") ).GetInstance( szKey ); if ( pObject == NULL ) { pObject = new DefaultRadioAdapterInstanceObject( szKey,GetLayer()->GetLog() ); if ( pObject->GetKey()[0] == NULL ) { delete pObject; pObject = NULL; } } return pObject;}//================================================================================ServerInstanceObject* LinkProtocolInstanceProvider::CreateInstance( const IntelMobileString& szKey ){ ServerInstanceObject* pObject = NULL; // if able to create it, find protocol pObject = GetLayer()->GetLayerClassObject( IntelMobileText("LinkProtocol") ).GetInstance( szKey ); // if not there, create a new one. if ( pObject == NULL ) { pObject = new DefaultLinkProtocolInstanceObject( szKey,GetLayer()->GetLog() ); if ( pObject->GetKey()[0] == NULL ) { delete pObject; pObject = NULL; } } return pObject;}//define in IntelMobileNetworkClassProvider.cppextern IntelMobileString GetProtocolInfo( const IntelMobileString& internalKey );//================================================================================ServerInstanceObject* Protocol802_3InstanceProvider::CreateInstance( const IntelMobileString& szKey ){ //do sanity check here IntelMobileString szTemp = szKey; if(GetProtocolInfo(szTemp) != IntelMobileText("Protocol802_3")) { return NULL; } ServerInstanceObject* pObject = NULL; pObject = GetLayer()->GetLayerClassObject( IntelMobileText("LinkProtocol") ).GetInstance( szKey ); if ( pObject == NULL ) { pObject = new DefaultProtocol802_3InstanceObject( szKey,GetLayer()->GetLog() ); if ( pObject->GetKey()[0] == NULL ) { delete pObject; pObject = NULL; } } return pObject;}ServerInstanceObject* Protocol802_11InstanceProvider::CreateInstance( const IntelMobileString& szKey ){ //do sanity check here IntelMobileString szTemp = szKey; if(GetProtocolInfo(szTemp) != IntelMobileText("Protocol802_11")) { return NULL; } ServerInstanceObject* pObject = NULL; pObject = GetLayer()->GetLayerClassObject( IntelMobileText("LinkProtocol") ).GetInstance( szKey ); if ( pObject == NULL ) { pObject = new DefaultProtocol802_11InstanceObject( szKey,GetLayer()->GetLog() ); if ( pObject->GetKey()[0] == NULL ) { delete pObject; pObject = NULL; } } return pObject;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -