HostNetworkInterfaceImpl.h revision b77cd15f5cf027341f2a126e3659e16092e11dd5
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* $Id $ */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/** @file
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * VirtualBox COM class implementation
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Copyright (C) 2006-2008 Sun Microsystems, Inc.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * available from http://www.virtualbox.org. This file is free software;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * General Public License (GPL) as published by the Free Software
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * additional information or have any questions.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef ____H_HOSTNETWORKINTERFACEIMPL
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define ____H_HOSTNETWORKINTERFACEIMPL
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "VirtualBoxBase.h"
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "Collection.h"
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncclass ATL_NO_VTABLE HostNetworkInterface :
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync public VirtualBoxBaseNEXT,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync public VirtualBoxSupportErrorInfoImpl <HostNetworkInterface, IHostNetworkInterface>,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync public VirtualBoxSupportTranslation <HostNetworkInterface>,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync public IHostNetworkInterface
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync{
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncpublic:
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostNetworkInterface)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DECLARE_NOT_AGGREGATABLE (HostNetworkInterface)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync BEGIN_COM_MAP (HostNetworkInterface)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync COM_INTERFACE_ENTRY (ISupportErrorInfo)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync COM_INTERFACE_ENTRY (IHostNetworkInterface)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync END_COM_MAP()
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync NS_DECL_ISUPPORTS
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync DECLARE_EMPTY_CTOR_DTOR (HostNetworkInterface)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync HRESULT FinalConstruct();
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync void FinalRelease();
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync // public initializer/uninitializer for internal purposes only
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync HRESULT init (Bstr interfaceName, Guid guid);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync // IHostNetworkInterface properties
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync STDMETHOD(COMGETTER(Name)) (BSTR *aInterfaceName);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT aGuid);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync // for VirtualBoxSupportErrorInfoImpl
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync static const wchar_t *getComponentName() { return L"HostNetworkInterface"; }
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncprivate:
const Bstr mInterfaceName;
const Guid mGuid;
};
COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostNetworkInterface)
STDMETHOD(FindByName) (INPTR BSTR name, IHostNetworkInterface **networkInterface)
{
if (!name)
return E_INVALIDARG;
if (!networkInterface)
return E_POINTER;
*networkInterface = NULL;
Vector::value_type found;
Vector::iterator it = vec.begin();
while (it != vec.end() && !found)
{
Bstr n;
(*it)->COMGETTER(Name) (n.asOutParam());
if (n == name)
found = *it;
++ it;
}
if (!found)
return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
"The host network interface with the given name could not be found"));
return found.queryInterfaceTo (networkInterface);
}
STDMETHOD(FindById) (INPTR GUIDPARAM id, IHostNetworkInterface **networkInterface)
{
if (Guid(id).isEmpty())
return E_INVALIDARG;
if (!networkInterface)
return E_POINTER;
*networkInterface = NULL;
Vector::value_type found;
Vector::iterator it = vec.begin();
while (it != vec.end() && !found)
{
Guid g;
(*it)->COMGETTER(Id) (g.asOutParam());
if (g == Guid(id))
found = *it;
++ it;
}
if (!found)
return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
"The host network interface with the given GUID could not be found"));
return found.queryInterfaceTo (networkInterface);
}
COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostNetworkInterface)
#endif // ____H_H_HOSTNETWORKINTERFACEIMPL