VirtualBox

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

Last change on this file since 7466 was 7207, checked in by vboxsync, 17 years ago

Main: Reworked enums to avoid 1) weird duplication of enum name when referring to enum values in cross-platform code; 2) possible clashes on Win32 due to putting identifiers like Paused or Disabled to the global namespace (via C enums). In the new style, enums are used like this: a) USBDeviceState_T v = USBDeviceState_Busy from cross-platform non-Qt code; b) KUSBDeviceState v = KUSBDeviceState_Busy from Qt code; c) USBDeviceState v = USBDeviceState_Busy from plain Win32 and d) PRUInt32 USBDeviceState v = USBDeviceState::Busy from plain XPCOM.

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