USBControllerImpl.h revision e8871fef9d6f6292a68e2d42bf44f4805f191907
3895N/A/** @file
3895N/A *
3895N/A * VBox USBController COM Class declaration.
3895N/A */
3895N/A
3895N/A/*
3895N/A * Copyright (C) 2006 InnoTek Systemberatung GmbH
3895N/A *
3895N/A * This file is part of VirtualBox Open Source Edition (OSE), as
3895N/A * available from http://www.virtualbox.org. This file is free software;
3895N/A * you can redistribute it and/or modify it under the terms of the GNU
3895N/A * General Public License as published by the Free Software Foundation,
3895N/A * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
3895N/A * distribution. VirtualBox OSE is distributed in the hope that it will
3895N/A * be useful, but WITHOUT ANY WARRANTY of any kind.
3895N/A *
3895N/A * If you received this file as part of a commercial VirtualBox
3895N/A * distribution, then only the terms of your commercial VirtualBox
3895N/A * license agreement apply instead of the previous paragraph.
3895N/A */
3895N/A
3895N/A#ifndef ____H_USBCONTROLLERIMPL
3895N/A#define ____H_USBCONTROLLERIMPL
3895N/A
5203N/A#include "VirtualBoxBase.h"
6306N/A#include "USBDeviceFilterImpl.h"
3895N/A
3895N/A#include <VBox/cfgldr.h>
3895N/A
3895N/A#include <list>
3895N/A
3895N/Aclass Machine;
4708N/Aclass HostUSBDevice;
3895N/A
3895N/A/**
3895N/A * @note we cannot use VirtualBoxBaseWithTypedChildren <USBDeviceFilter> as a
3895N/A * base class, because we want a quick (map-based) way of validating
3895N/A * IUSBDeviceFilter pointers passed from outside as method parameters that
3895N/A * VirtualBoxBaseWithChildren::getDependentChild() gives us.
3895N/A */
3895N/A
3895N/Aclass ATL_NO_VTABLE USBController :
3895N/A public VirtualBoxBaseWithChildrenNEXT,
3895N/A public VirtualBoxSupportErrorInfoImpl <USBController, IUSBController>,
4129N/A public VirtualBoxSupportTranslation <USBController>,
3895N/A public IUSBController
3895N/A{
3895N/Aprivate:
3895N/A
3895N/A struct Data
3895N/A {
3895N/A /* Constructor. */
3895N/A Data() : mEnabled (FALSE) { }
3895N/A
4129N/A bool operator== (const Data &that) const
4129N/A {
3895N/A return this == &that || mEnabled == that.mEnabled;
4708N/A }
4708N/A
4708N/A /** Enabled indicator. */
4708N/A BOOL mEnabled;
4708N/A };
4708N/A
4708N/Apublic:
4708N/A
4708N/A VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
4708N/A
4708N/A DECLARE_NOT_AGGREGATABLE (USBController)
3895N/A
3895N/A DECLARE_PROTECT_FINAL_CONSTRUCT()
3895N/A
3895N/A BEGIN_COM_MAP(USBController)
3895N/A COM_INTERFACE_ENTRY (ISupportErrorInfo)
3999N/A COM_INTERFACE_ENTRY (IUSBController)
3999N/A END_COM_MAP()
3895N/A
3895N/A NS_DECL_ISUPPORTS
3895N/A
3895N/A DECLARE_EMPTY_CTOR_DTOR (USBController)
3895N/A
3895N/A HRESULT FinalConstruct();
4163N/A void FinalRelease();
4163N/A
4163N/A // public initializer/uninitializer for internal purposes only
6306N/A HRESULT init (Machine *aParent);
4163N/A HRESULT init (Machine *aParent, USBController *aThat);
4163N/A HRESULT initCopy (Machine *aParent, USBController *aThat);
4163N/A void uninit();
4163N/A
3895N/A // IUSBController properties
3895N/A STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
3895N/A STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
3895N/A STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
3895N/A STDMETHOD(COMGETTER(DeviceFilters)) (IUSBDeviceFilterCollection **aDevicesFilters);
4708N/A
3895N/A // IUSBController methods
4708N/A STDMETHOD(CreateDeviceFilter) (INPTR BSTR aName, IUSBDeviceFilter **aFilter);
4708N/A STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
4708N/A STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
4708N/A
4708N/A // public methods only for internal purposes
4708N/A
4708N/A const ComObjPtr <Machine, ComWeakRef> &parent() { return mParent; };
4708N/A
4708N/A HRESULT loadSettings (CFGNODE aMachine);
4708N/A HRESULT saveSettings (CFGNODE aMachine);
4708N/A
4708N/A bool isModified();
4708N/A bool isReallyModified();
4708N/A bool rollback();
4708N/A void commit();
4708N/A void copyFrom (USBController *aThat);
4708N/A
4708N/A const Backupable<Data> &data() { return mData; }
4708N/A
4708N/A HRESULT onMachineRegistered (BOOL aRegistered);
4708N/A
4708N/A HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
4708N/A BOOL aActiveChanged = FALSE);
4708N/A
4708N/A bool hasMatchingFilter (ComObjPtr <HostUSBDevice> &aDevice);
4708N/A bool hasMatchingFilter (IUSBDevice *aUSBDevice);
4708N/A
4708N/A HRESULT notifyProxy (bool aInsertFilters);
4708N/A
4708N/A // for VirtualBoxSupportErrorInfoImpl
4708N/A static const wchar_t *getComponentName() { return L"USBController"; }
4708N/A
4708N/Aprivate:
4708N/A
4708N/A /** specialization for IUSBDeviceFilter */
4708N/A ComObjPtr <USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
3895N/A {
3895N/A VirtualBoxBase *child = VirtualBoxBaseWithChildren::
3895N/A getDependentChild (ComPtr <IUnknown> (aFilter));
3895N/A return child ? static_cast <USBDeviceFilter *> (child)
3895N/A : NULL;
3895N/A }
4129N/A
3895N/A void printList();
3895N/A
3895N/A /** Parent object. */
3895N/A const ComObjPtr<Machine, ComWeakRef> mParent;
3895N/A /** Peer object. */
3895N/A const ComObjPtr <USBController> mPeer;
3895N/A /** Data. */
3895N/A Backupable <Data> mData;
3895N/A
3895N/A // the following fields need special backup/rollback/commit handling,
3895N/A // so they cannot be a part of Data
3895N/A
3895N/A typedef std::list <ComObjPtr <USBDeviceFilter> > DeviceFilterList;
3895N/A Backupable <DeviceFilterList> mDeviceFilters;
4129N/A};
3895N/A
3999N/A#endif //!____H_USBCONTROLLERIMPL
3895N/A