VirtualBox

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

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

Main: Enable a serial port for OS/2 guests by default.

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