VirtualBox

source: vbox/trunk/src/VBox/Main/include/NetworkAdapterImpl.h@ 26156

Last change on this file since 26156 was 26156, checked in by vboxsync, 15 years ago

Main: get rid of isReallyChanged() voodoo in Machine and subclasses; instead check in the XML classes whether things really changed via operator==; documentation, cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: NetworkAdapterImpl.h 26156 2010-02-02 16:30:28Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_NETWORKADAPTER
25#define ____H_NETWORKADAPTER
26
27#include "VirtualBoxBase.h"
28
29class GuestOSType;
30
31namespace settings
32{
33 struct NetworkAdapter;
34}
35
36class ATL_NO_VTABLE NetworkAdapter :
37 public VirtualBoxBase,
38 public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,
39 public VirtualBoxSupportTranslation<NetworkAdapter>,
40 VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
41{
42public:
43
44 struct Data
45 {
46 Data() : mSlot(0), mEnabled(FALSE),
47 mAttachmentType(NetworkAttachmentType_Null),
48 mCableConnected(TRUE), mLineSpeed(0), mTraceEnabled(FALSE),
49 mHostInterface("") /* cannot be null */,
50 mNATNetwork("") /* cannot be null */
51 {}
52
53 bool operator== (const Data &that) const
54 {
55 return this == &that ||
56 (mSlot == that.mSlot &&
57 mEnabled == that.mEnabled &&
58 mMACAddress == that.mMACAddress &&
59 mAttachmentType == that.mAttachmentType &&
60 mCableConnected == that.mCableConnected &&
61 mLineSpeed == that.mLineSpeed &&
62 mTraceEnabled == that.mTraceEnabled &&
63 mHostInterface == that.mHostInterface &&
64 mInternalNetwork == that.mInternalNetwork &&
65 mNATNetwork == that.mNATNetwork);
66 }
67
68 NetworkAdapterType_T mAdapterType;
69 ULONG mSlot;
70 BOOL mEnabled;
71 Bstr mMACAddress;
72 NetworkAttachmentType_T mAttachmentType;
73 BOOL mCableConnected;
74 ULONG mLineSpeed;
75 BOOL mTraceEnabled;
76 Bstr mTraceFile;
77 Bstr mHostInterface;
78 Bstr mInternalNetwork;
79 Bstr mNATNetwork;
80 };
81
82 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
83
84 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
85
86 DECLARE_PROTECT_FINAL_CONSTRUCT()
87
88 BEGIN_COM_MAP(NetworkAdapter)
89 COM_INTERFACE_ENTRY (ISupportErrorInfo)
90 COM_INTERFACE_ENTRY (INetworkAdapter)
91 COM_INTERFACE_ENTRY2 (IDispatch, INetworkAdapter)
92 END_COM_MAP()
93
94 DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
95
96 HRESULT FinalConstruct();
97 void FinalRelease();
98
99 // public initializer/uninitializer for internal purposes only
100 HRESULT init (Machine *aParent, ULONG aSlot);
101 HRESULT init (Machine *aParent, NetworkAdapter *aThat);
102 HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
103 void uninit();
104
105 // INetworkAdapter properties
106 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
107 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
108 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
109 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
110 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
111 STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
112 STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
113 STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
114 STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
115 STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
116 STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
117 STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
118 STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
119 STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
120 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
121 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
122 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
123 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
124 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
125 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
126 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
127 STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
128
129 // INetworkAdapter methods
130 STDMETHOD(AttachToNAT)();
131 STDMETHOD(AttachToBridgedInterface)();
132 STDMETHOD(AttachToInternalNetwork)();
133 STDMETHOD(AttachToHostOnlyInterface)();
134 STDMETHOD(Detach)();
135
136 // public methods only for internal purposes
137
138 HRESULT loadSettings(const settings::NetworkAdapter &data);
139 HRESULT saveSettings(settings::NetworkAdapter &data);
140
141 bool isModified() { AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); return mData.isBackedUp(); }
142 bool rollback();
143 void commit();
144 void copyFrom (NetworkAdapter *aThat);
145 void applyDefaults (GuestOSType *aOsType);
146
147 // for VirtualBoxSupportErrorInfoImpl
148 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
149
150private:
151
152 void detach();
153 void generateMACAddress();
154
155 const ComObjPtr<Machine, ComWeakRef> mParent;
156 const ComObjPtr<NetworkAdapter> mPeer;
157
158 Backupable<Data> mData;
159};
160
161#endif // ____H_NETWORKADAPTER
162/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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