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 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ____H_SERIALPORTIMPL
|
---|
23 | #define ____H_SERIALPORTIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 |
|
---|
27 | #include <VBox/cfgldr.h>
|
---|
28 |
|
---|
29 | class Machine;
|
---|
30 |
|
---|
31 | class ATL_NO_VTABLE SerialPort :
|
---|
32 | public VirtualBoxBaseNEXT,
|
---|
33 | public VirtualBoxSupportErrorInfoImpl <SerialPort, ISerialPort>,
|
---|
34 | public VirtualBoxSupportTranslation <SerialPort>,
|
---|
35 | public ISerialPort
|
---|
36 | {
|
---|
37 | public:
|
---|
38 |
|
---|
39 | struct Data
|
---|
40 | {
|
---|
41 | Data()
|
---|
42 | : mSlot (0)
|
---|
43 | , mEnabled(FALSE)
|
---|
44 | , mIRQ (4)
|
---|
45 | , mIOBase (0x3f8)
|
---|
46 | {}
|
---|
47 |
|
---|
48 | bool operator== (const Data &that) const
|
---|
49 | {
|
---|
50 | return this == &that ||
|
---|
51 | (mSlot == that.mSlot &&
|
---|
52 | mEnabled == that.mEnabled &&
|
---|
53 | mIRQ == that.mIRQ &&
|
---|
54 | mIOBase == that.mIOBase);
|
---|
55 | }
|
---|
56 |
|
---|
57 | ULONG mSlot;
|
---|
58 | BOOL mEnabled;
|
---|
59 | ULONG mIRQ;
|
---|
60 | ULONG mIOBase;
|
---|
61 | Bstr mPipe;
|
---|
62 | BOOL mServer;
|
---|
63 | };
|
---|
64 |
|
---|
65 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SerialPort)
|
---|
66 |
|
---|
67 | DECLARE_NOT_AGGREGATABLE(SerialPort)
|
---|
68 |
|
---|
69 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
70 |
|
---|
71 | BEGIN_COM_MAP(SerialPort)
|
---|
72 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
73 | COM_INTERFACE_ENTRY(ISerialPort)
|
---|
74 | END_COM_MAP()
|
---|
75 |
|
---|
76 | NS_DECL_ISUPPORTS
|
---|
77 |
|
---|
78 | DECLARE_EMPTY_CTOR_DTOR (SerialPort)
|
---|
79 |
|
---|
80 | HRESULT FinalConstruct();
|
---|
81 | void FinalRelease();
|
---|
82 |
|
---|
83 | // public initializer/uninitializer for internal purposes only
|
---|
84 | HRESULT init (Machine *aParent, ULONG aSlot);
|
---|
85 | HRESULT init (Machine *aParent, SerialPort *aThat);
|
---|
86 | HRESULT initCopy (Machine *parent, SerialPort *aThat);
|
---|
87 | void uninit();
|
---|
88 |
|
---|
89 | // ISerialPort properties
|
---|
90 | STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
|
---|
91 | STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
|
---|
92 | STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
|
---|
93 | STDMETHOD(COMGETTER(IRQ)) (ULONG *aIRQ);
|
---|
94 | STDMETHOD(COMSETTER(IRQ)) (ULONG aIRQ);
|
---|
95 | STDMETHOD(COMGETTER(IOBase)) (ULONG *aIOBase);
|
---|
96 | STDMETHOD(COMSETTER(IOBase)) (ULONG aIOBase);
|
---|
97 | STDMETHOD(COMGETTER(Pipe)) (BSTR *aPipe);
|
---|
98 | STDMETHOD(COMSETTER(Pipe)) (INPTR BSTR aPipe);
|
---|
99 | STDMETHOD(COMGETTER(Server)) (BOOL *aServer);
|
---|
100 | STDMETHOD(COMSETTER(Server)) (BOOL aServer);
|
---|
101 |
|
---|
102 | // public methods only for internal purposes
|
---|
103 | bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
|
---|
104 | bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
|
---|
105 | bool rollback();
|
---|
106 | void commit();
|
---|
107 | void copyFrom (SerialPort *aThat);
|
---|
108 |
|
---|
109 | // public methods for internal purposes only
|
---|
110 | // (ensure there is a caller and a read lock before calling them!)
|
---|
111 |
|
---|
112 | HRESULT loadSettings (CFGNODE aMachine, ULONG aSlot);
|
---|
113 | HRESULT saveSettings (CFGNODE aMachine);
|
---|
114 |
|
---|
115 | // for VirtualBoxSupportErrorInfoImpl
|
---|
116 | static const wchar_t *getComponentName() { return L"SerialPort"; }
|
---|
117 |
|
---|
118 | private:
|
---|
119 |
|
---|
120 | const ComObjPtr <Machine, ComWeakRef> mParent;
|
---|
121 | const ComObjPtr <SerialPort> mPeer;
|
---|
122 |
|
---|
123 | Backupable <Data> mData;
|
---|
124 | };
|
---|
125 |
|
---|
126 | #endif // ____H_FLOPPYDRIVEIMPL
|
---|