VirtualBox

source: vbox/trunk/src/VBox/Main/include/SerialPortImpl.h@ 23223

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

API: big medium handling change and lots of assorted other cleanups and fixes

  • Property svn:eol-style set to native
File size: 4.4 KB
Line 
1/* $Id$ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2007 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_SERIALPORTIMPL
25#define ____H_SERIALPORTIMPL
26
27#include "VirtualBoxBase.h"
28
29class Machine;
30class GuestOSType;
31
32namespace settings
33{
34 struct SerialPort;
35}
36
37class ATL_NO_VTABLE SerialPort :
38 public VirtualBoxBase,
39 public VirtualBoxSupportErrorInfoImpl<SerialPort, ISerialPort>,
40 public VirtualBoxSupportTranslation<SerialPort>,
41 VBOX_SCRIPTABLE_IMPL(ISerialPort)
42{
43public:
44
45 struct Data
46 {
47 Data()
48 : mSlot (0)
49 , mEnabled (FALSE)
50 , mIRQ (4)
51 , mIOBase (0x3f8)
52 , mHostMode (PortMode_Disconnected)
53 , mServer (FALSE)
54 {}
55
56 bool operator== (const Data &that) const
57 {
58 return this == &that ||
59 (mSlot == that.mSlot &&
60 mEnabled == that.mEnabled &&
61 mIRQ == that.mIRQ &&
62 mIOBase == that.mIOBase &&
63 mHostMode == that.mHostMode &&
64 mPath == that.mPath &&
65 mServer == that.mServer);
66 }
67
68 ULONG mSlot;
69 BOOL mEnabled;
70 ULONG mIRQ;
71 ULONG mIOBase;
72 PortMode_T mHostMode;
73 Bstr mPath;
74 BOOL mServer;
75 };
76
77 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SerialPort)
78
79 DECLARE_NOT_AGGREGATABLE(SerialPort)
80
81 DECLARE_PROTECT_FINAL_CONSTRUCT()
82
83 BEGIN_COM_MAP(SerialPort)
84 COM_INTERFACE_ENTRY (ISupportErrorInfo)
85 COM_INTERFACE_ENTRY (ISerialPort)
86 COM_INTERFACE_ENTRY2 (IDispatch, ISerialPort)
87 END_COM_MAP()
88
89 DECLARE_EMPTY_CTOR_DTOR (SerialPort)
90
91 HRESULT FinalConstruct();
92 void FinalRelease();
93
94 // public initializer/uninitializer for internal purposes only
95 HRESULT init (Machine *aParent, ULONG aSlot);
96 HRESULT init (Machine *aParent, SerialPort *aThat);
97 HRESULT initCopy (Machine *parent, SerialPort *aThat);
98 void uninit();
99
100 // ISerialPort properties
101 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
102 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
103 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
104 STDMETHOD(COMGETTER(HostMode)) (PortMode_T *aHostMode);
105 STDMETHOD(COMSETTER(HostMode)) (PortMode_T aHostMode);
106 STDMETHOD(COMGETTER(IRQ)) (ULONG *aIRQ);
107 STDMETHOD(COMSETTER(IRQ)) (ULONG aIRQ);
108 STDMETHOD(COMGETTER(IOBase) ) (ULONG *aIOBase);
109 STDMETHOD(COMSETTER(IOBase)) (ULONG aIOBase);
110 STDMETHOD(COMGETTER(Path)) (BSTR *aPath);
111 STDMETHOD(COMSETTER(Path)) (IN_BSTR aPath);
112 STDMETHOD(COMGETTER(Server)) (BOOL *aServer);
113 STDMETHOD(COMSETTER(Server)) (BOOL aServer);
114
115 // public methods only for internal purposes
116
117 HRESULT loadSettings(const settings::SerialPort &data);
118 HRESULT saveSettings(settings::SerialPort &data);
119
120 bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
121 bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
122 bool rollback();
123 void commit();
124 void copyFrom (SerialPort *aThat);
125 void applyDefaults (GuestOSType *aOsType);
126
127 // public methods for internal purposes only
128 // (ensure there is a caller and a read lock before calling them!)
129
130 // for VirtualBoxSupportErrorInfoImpl
131 static const wchar_t *getComponentName() { return L"SerialPort"; }
132
133private:
134
135 HRESULT checkSetPath (CBSTR aPath);
136
137 const ComObjPtr<Machine, ComWeakRef> mParent;
138 const ComObjPtr<SerialPort> mPeer;
139
140 Backupable <Data> mData;
141};
142
143#endif // ____H_FLOPPYDRIVEIMPL
144/* 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