SerialPortImpl.h revision 46f059bea92bedbd395793702c73946ead235586
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* $Id$ */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @file
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox COM class implementation
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * available from http://www.virtualbox.org. This file is free software;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * General Public License (GPL) as published by the Free Software
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * additional information or have any questions.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#ifndef ____H_SERIALPORTIMPL
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#define ____H_SERIALPORTIMPL
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include "VirtualBoxBase.h"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncclass Machine;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncclass ATL_NO_VTABLE SerialPort :
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync public VirtualBoxBaseNEXT,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync public VirtualBoxSupportErrorInfoImpl <SerialPort, ISerialPort>,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync public VirtualBoxSupportTranslation <SerialPort>,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync public ISerialPort
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync{
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncpublic:
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync struct Data
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync {
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Data()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync : mSlot (0)
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync , mEnabled (FALSE)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync , mIRQ (4)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync , mIOBase (0x3f8)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync , mHostMode (PortMode_Disconnected)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync , mServer (FALSE)
7d6ce198fd361f58bd1ebdeee7772f76b4e58966vboxsync {}
2fce40121ae472df2fd959fbe19775ed43304a0bvboxsync
edde275acba04aca58db4172a163741e3abadfbcvboxsync bool operator== (const Data &that) const
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync {
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return this == &that ||
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync (mSlot == that.mSlot &&
40839c441cb305d84420565f7ca25403d8177413vboxsync mEnabled == that.mEnabled &&
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mIRQ == that.mIRQ &&
7d6ce198fd361f58bd1ebdeee7772f76b4e58966vboxsync mIOBase == that.mIOBase &&
7d6ce198fd361f58bd1ebdeee7772f76b4e58966vboxsync mHostMode == that.mHostMode &&
7d6ce198fd361f58bd1ebdeee7772f76b4e58966vboxsync mPath == that.mPath &&
7d6ce198fd361f58bd1ebdeee7772f76b4e58966vboxsync mServer == that.mServer);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync }
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ULONG mSlot;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync BOOL mEnabled;
edde275acba04aca58db4172a163741e3abadfbcvboxsync ULONG mIRQ;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ULONG mIOBase;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync PortMode_T mHostMode;
a1d9d394b49969e730c5a8e037ea2d672a48dbf6vboxsync Bstr mPath;
edde275acba04aca58db4172a163741e3abadfbcvboxsync BOOL mServer;
edde275acba04aca58db4172a163741e3abadfbcvboxsync };
edde275acba04aca58db4172a163741e3abadfbcvboxsync
edde275acba04aca58db4172a163741e3abadfbcvboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SerialPort)
a1d9d394b49969e730c5a8e037ea2d672a48dbf6vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync DECLARE_NOT_AGGREGATABLE(SerialPort)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync BEGIN_COM_MAP(SerialPort)
2fce40121ae472df2fd959fbe19775ed43304a0bvboxsync COM_INTERFACE_ENTRY(ISupportErrorInfo)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync COM_INTERFACE_ENTRY(ISerialPort)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync END_COM_MAP()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync NS_DECL_ISUPPORTS
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync DECLARE_EMPTY_CTOR_DTOR (SerialPort)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
2fce40121ae472df2fd959fbe19775ed43304a0bvboxsync HRESULT FinalConstruct();
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync void FinalRelease();
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // public initializer/uninitializer for internal purposes only
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT init (Machine *aParent, ULONG aSlot);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT init (Machine *aParent, SerialPort *aThat);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT initCopy (Machine *parent, SerialPort *aThat);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync void uninit();
30f07af559efcbd967e801903746fc21f81ee533vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // ISerialPort properties
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(HostMode)) (PortMode_T *aHostMode);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMSETTER(HostMode)) (PortMode_T aHostMode);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(IRQ)) (ULONG *aIRQ);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMSETTER(IRQ)) (ULONG aIRQ);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(IOBase) ) (ULONG *aIOBase);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMSETTER(IOBase)) (ULONG aIOBase);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(Path)) (BSTR *aPath);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMSETTER(Path)) (INPTR BSTR aPath);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMGETTER(Server)) (BOOL *aServer);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(COMSETTER(Server)) (BOOL aServer);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // public methods only for internal purposes
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT loadSettings (const settings::Key &aPortNode);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT saveSettings (settings::Key &aPortNode);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync bool rollback();
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync void commit();
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync void copyFrom (SerialPort *aThat);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // public methods for internal purposes only
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // (ensure there is a caller and a read lock before calling them!)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // for VirtualBoxSupportErrorInfoImpl
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync static const wchar_t *getComponentName() { return L"SerialPort"; }
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncprivate:
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync HRESULT checkSetPath (const BSTR aPath);
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync const ComObjPtr <Machine, ComWeakRef> mParent;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync const ComObjPtr <SerialPort> mPeer;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Backupable <Data> mData;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync};
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif // ____H_FLOPPYDRIVEIMPL
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync