VirtualBox

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

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

Main: Fixed: Always save values of unused attributes of serial ports to preserve user's settings for later use.

File size: 4.0 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_SERIALPORTIMPL
19#define ____H_SERIALPORTIMPL
20
21#include "VirtualBoxBase.h"
22
23#include <VBox/cfgldr.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_DisconnectedPort)
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 bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
108 bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
109 bool rollback();
110 void commit();
111 void copyFrom (SerialPort *aThat);
112
113 // public methods for internal purposes only
114 // (ensure there is a caller and a read lock before calling them!)
115
116 HRESULT loadSettings (CFGNODE aMachine, ULONG aSlot);
117 HRESULT saveSettings (CFGNODE aMachine);
118
119 // for VirtualBoxSupportErrorInfoImpl
120 static const wchar_t *getComponentName() { return L"SerialPort"; }
121
122private:
123
124 HRESULT checkSetPath (BSTR aPath);
125
126 const ComObjPtr <Machine, ComWeakRef> mParent;
127 const ComObjPtr <SerialPort> mPeer;
128
129 Backupable <Data> mData;
130};
131
132#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