StorageControllerImpl.h revision c8faf7a704e698dec3679d7df43ae55b1bab3ead
af062818b47340eef15700d2f0211576ba3506eevboxsync/* $Id$ */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/** @file
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * VBox StorageController COM Class declaration.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2008 Sun Microsystems, Inc.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
af062818b47340eef15700d2f0211576ba3506eevboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * additional information or have any questions.
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifndef ____H_STORAGECONTROLLERIMPL
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#define ____H_STORAGECONTROLLERIMPL
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include "VirtualBoxBase.h"
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include <list>
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass Machine;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass ATL_NO_VTABLE StorageController :
af062818b47340eef15700d2f0211576ba3506eevboxsync public VirtualBoxBaseWithChildrenNEXT,
af062818b47340eef15700d2f0211576ba3506eevboxsync public VirtualBoxSupportErrorInfoImpl<StorageController, IStorageController>,
af062818b47340eef15700d2f0211576ba3506eevboxsync public VirtualBoxSupportTranslation<StorageController>,
af062818b47340eef15700d2f0211576ba3506eevboxsync VBOX_SCRIPTABLE_IMPL(IStorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsyncprivate:
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync struct Data
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Constructor. */
af062818b47340eef15700d2f0211576ba3506eevboxsync Data() : mStorageBus (StorageBus_IDE),
af062818b47340eef15700d2f0211576ba3506eevboxsync mStorageControllerType (StorageControllerType_PIIX4),
af062818b47340eef15700d2f0211576ba3506eevboxsync mInstance (0),
af062818b47340eef15700d2f0211576ba3506eevboxsync mPortCount (2),
af062818b47340eef15700d2f0211576ba3506eevboxsync mPortIde0Master (0),
af062818b47340eef15700d2f0211576ba3506eevboxsync mPortIde0Slave (1),
af062818b47340eef15700d2f0211576ba3506eevboxsync mPortIde1Master (2),
af062818b47340eef15700d2f0211576ba3506eevboxsync mPortIde1Slave (3) { }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync bool operator== (const Data &that) const
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync return this == &that
af062818b47340eef15700d2f0211576ba3506eevboxsync || ( (mStorageControllerType == that.mStorageControllerType)
af062818b47340eef15700d2f0211576ba3506eevboxsync && (strName == that.strName)
af062818b47340eef15700d2f0211576ba3506eevboxsync && (mPortCount == that.mPortCount)
af062818b47340eef15700d2f0211576ba3506eevboxsync && (mPortIde0Master == that.mPortIde0Master)
af062818b47340eef15700d2f0211576ba3506eevboxsync && (mPortIde0Slave == that.mPortIde0Slave)
af062818b47340eef15700d2f0211576ba3506eevboxsync && (mPortIde1Master == that.mPortIde1Master)
af062818b47340eef15700d2f0211576ba3506eevboxsync && (mPortIde1Slave == that.mPortIde1Slave));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Unique name of the storage controller. */
af062818b47340eef15700d2f0211576ba3506eevboxsync Utf8Str strName;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** The connection type of thestorage controller. */
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageBus_T mStorageBus;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Type of the Storage controller. */
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageControllerType_T mStorageControllerType;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Instance number of the storage controller. */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG mInstance;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Number of usable ports. */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG mPortCount;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /** The following is only for the SATA controller atm. */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Port which acts as primary master for ide emulation. */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG mPortIde0Master;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Port which acts as primary slave for ide emulation. */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG mPortIde0Slave;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Port which acts as secondary master for ide emulation. */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG mPortIde1Master;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Port which acts as secondary slave for ide emulation. */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG mPortIde1Slave;
af062818b47340eef15700d2f0211576ba3506eevboxsync };
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncpublic:
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (StorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync DECLARE_NOT_AGGREGATABLE (StorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync BEGIN_COM_MAP(StorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync COM_INTERFACE_ENTRY (ISupportErrorInfo)
af062818b47340eef15700d2f0211576ba3506eevboxsync COM_INTERFACE_ENTRY (IStorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync COM_INTERFACE_ENTRY2 (IDispatch, IStorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync END_COM_MAP()
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync DECLARE_EMPTY_CTOR_DTOR (StorageController)
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync HRESULT FinalConstruct();
af062818b47340eef15700d2f0211576ba3506eevboxsync void FinalRelease();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // public initializer/uninitializer for internal purposes only
af062818b47340eef15700d2f0211576ba3506eevboxsync HRESULT init(Machine *aParent,
af062818b47340eef15700d2f0211576ba3506eevboxsync const Utf8Str &aName,
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageBus_T aBus,
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG aInstance);
af062818b47340eef15700d2f0211576ba3506eevboxsync HRESULT init(Machine *aParent,
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageController *aThat,
af062818b47340eef15700d2f0211576ba3506eevboxsync bool aReshare = false);
af062818b47340eef15700d2f0211576ba3506eevboxsync HRESULT initCopy(Machine *aParent,
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageController *aThat);
af062818b47340eef15700d2f0211576ba3506eevboxsync void uninit();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // IStorageController properties
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(Name)) (BSTR *aName);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(Bus)) (StorageBus_T *aBus);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(ControllerType)) (StorageControllerType_T *aControllerType);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMSETTER(ControllerType)) (StorageControllerType_T aControllerType);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(MaxDevicesPerPortCount)) (ULONG *aMaxDevices);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(MinPortCount)) (ULONG *aMinPortCount);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(MaxPortCount)) (ULONG *aMaxPortCount);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(PortCount)) (ULONG *aPortCount);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMSETTER(PortCount)) (ULONG aPortCount);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(Instance)) (ULONG *aInstance);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMSETTER(Instance)) (ULONG aInstance);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // StorageController methods
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(GetIDEEmulationPort) (LONG DevicePosition, LONG *aPortNumber);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(SetIDEEmulationPort) (LONG DevicePosition, LONG aPortNumber);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // public methods only for internal purposes
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync const Utf8Str &name() const { return mData->strName; }
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageControllerType_T controllerType() const { return mData->mStorageControllerType; }
af062818b47340eef15700d2f0211576ba3506eevboxsync StorageBus_T storageBus() const { return mData->mStorageBus; }
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG instance() const { return mData->mInstance; }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
af062818b47340eef15700d2f0211576ba3506eevboxsync bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
af062818b47340eef15700d2f0211576ba3506eevboxsync bool rollback();
af062818b47340eef15700d2f0211576ba3506eevboxsync void commit();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // public methods for internal purposes only
af062818b47340eef15700d2f0211576ba3506eevboxsync // (ensure there is a caller and a read lock before calling them!)
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync void unshare();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /** @note this doesn't require a read lock since mParent is constant. */
af062818b47340eef15700d2f0211576ba3506eevboxsync const ComObjPtr<Machine, ComWeakRef> &parent() { return mParent; };
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync const Backupable<Data> &data() { return mData; }
af062818b47340eef15700d2f0211576ba3506eevboxsync ComObjPtr<StorageController> peer() { return mPeer; }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // for VirtualBoxSupportErrorInfoImpl
af062818b47340eef15700d2f0211576ba3506eevboxsync static const wchar_t *getComponentName() { return L"StorageController"; }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncprivate:
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync void printList();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Parent object. */
af062818b47340eef15700d2f0211576ba3506eevboxsync const ComObjPtr<Machine, ComWeakRef> mParent;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Peer object. */
af062818b47340eef15700d2f0211576ba3506eevboxsync const ComObjPtr<StorageController> mPeer;
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Data. */
af062818b47340eef15700d2f0211576ba3506eevboxsync Backupable<Data> mData;
af062818b47340eef15700d2f0211576ba3506eevboxsync};
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif //!____H_STORAGECONTROLLERIMPL
af062818b47340eef15700d2f0211576ba3506eevboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */
af062818b47340eef15700d2f0211576ba3506eevboxsync