VirtualBox

source: vbox/trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h@ 10753

Last change on this file since 10753 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_HOSTNETWORKINTERFACEIMPL
23#define ____H_HOSTNETWORKINTERFACEIMPL
24
25#ifndef RT_OS_WINDOWS
26#error This is Windows only stuff!
27#endif
28
29#include "VirtualBoxBase.h"
30#include "Collection.h"
31
32class ATL_NO_VTABLE HostNetworkInterface :
33 public VirtualBoxSupportErrorInfoImpl <HostNetworkInterface, IHostNetworkInterface>,
34 public VirtualBoxSupportTranslation <HostNetworkInterface>,
35 public VirtualBoxBase,
36 public IHostNetworkInterface
37{
38public:
39 HostNetworkInterface();
40 virtual ~HostNetworkInterface();
41
42 DECLARE_NOT_AGGREGATABLE(HostNetworkInterface)
43
44 DECLARE_PROTECT_FINAL_CONSTRUCT()
45
46 BEGIN_COM_MAP(HostNetworkInterface)
47 COM_INTERFACE_ENTRY(ISupportErrorInfo)
48 COM_INTERFACE_ENTRY(IHostNetworkInterface)
49 END_COM_MAP()
50
51 NS_DECL_ISUPPORTS
52
53 // public initializer/uninitializer for internal purposes only
54 HRESULT init (Bstr interfaceName, Guid guid);
55
56 // IHostNetworkInterface properties
57 STDMETHOD(COMGETTER(Name)) (BSTR *interfaceName);
58 STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT guid);
59
60 // for VirtualBoxSupportErrorInfoImpl
61 static const wchar_t *getComponentName() { return L"HostNetworkInterface"; }
62
63private:
64 Bstr mInterfaceName;
65 Guid mGuid;
66};
67
68COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostNetworkInterface)
69
70 STDMETHOD(FindByName) (INPTR BSTR name, IHostNetworkInterface **networkInterface)
71 {
72 if (!name)
73 return E_INVALIDARG;
74 if (!networkInterface)
75 return E_POINTER;
76
77 *networkInterface = NULL;
78 Vector::value_type found;
79 Vector::iterator it = vec.begin();
80 while (it != vec.end() && !found)
81 {
82 Bstr n;
83 (*it)->COMGETTER(Name) (n.asOutParam());
84 if (n == name)
85 found = *it;
86 ++ it;
87 }
88
89 if (!found)
90 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
91 "The host network interface with the given name could not be found"));
92
93 return found.queryInterfaceTo (networkInterface);
94 }
95
96 STDMETHOD(FindById) (INPTR GUIDPARAM id, IHostNetworkInterface **networkInterface)
97 {
98 if (Guid(id).isEmpty())
99 return E_INVALIDARG;
100 if (!networkInterface)
101 return E_POINTER;
102
103 *networkInterface = NULL;
104 Vector::value_type found;
105 Vector::iterator it = vec.begin();
106 while (it != vec.end() && !found)
107 {
108 Guid g;
109 (*it)->COMGETTER(Id) (g.asOutParam());
110 if (g == Guid(id))
111 found = *it;
112 ++ it;
113 }
114
115 if (!found)
116 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
117 "The host network interface with the given GUID could not be found"));
118
119 return found.queryInterfaceTo (networkInterface);
120 }
121
122
123COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostNetworkInterface)
124
125
126#endif // ____H_H_HOSTNETWORKINTERFACEIMPL
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette