[1] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VirtualBox COM class implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[8155] | 7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
[1] | 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
|
---|
[5999] | 12 | * General Public License (GPL) as published by the Free Software
|
---|
| 13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[8155] | 16 | *
|
---|
| 17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
| 18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
| 19 | * additional information or have any questions.
|
---|
[1] | 20 | */
|
---|
| 21 |
|
---|
| 22 | #ifndef ____H_HOSTDVDDRIVEIMPL
|
---|
| 23 | #define ____H_HOSTDVDDRIVEIMPL
|
---|
| 24 |
|
---|
| 25 | #include "VirtualBoxBase.h"
|
---|
| 26 | #include "Collection.h"
|
---|
| 27 |
|
---|
| 28 | class ATL_NO_VTABLE HostDVDDrive :
|
---|
[2929] | 29 | public VirtualBoxBaseNEXT,
|
---|
[1] | 30 | public VirtualBoxSupportErrorInfoImpl <HostDVDDrive, IHostDVDDrive>,
|
---|
| 31 | public VirtualBoxSupportTranslation <HostDVDDrive>,
|
---|
| 32 | public IHostDVDDrive
|
---|
| 33 | {
|
---|
| 34 | public:
|
---|
| 35 |
|
---|
[2929] | 36 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostDVDDrive)
|
---|
[1] | 37 |
|
---|
[2929] | 38 | DECLARE_NOT_AGGREGATABLE (HostDVDDrive)
|
---|
[1] | 39 |
|
---|
| 40 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
| 41 |
|
---|
| 42 | BEGIN_COM_MAP(HostDVDDrive)
|
---|
| 43 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
| 44 | COM_INTERFACE_ENTRY(IHostDVDDrive)
|
---|
| 45 | END_COM_MAP()
|
---|
| 46 |
|
---|
| 47 | NS_DECL_ISUPPORTS
|
---|
| 48 |
|
---|
[2929] | 49 | DECLARE_EMPTY_CTOR_DTOR (HostDVDDrive)
|
---|
| 50 |
|
---|
| 51 | HRESULT FinalConstruct();
|
---|
| 52 | void FinalRelease();
|
---|
| 53 |
|
---|
[1] | 54 | // public initializer/uninitializer for internal purposes only
|
---|
[15051] | 55 | HRESULT init (IN_BSTR aName, IN_BSTR aUdi = NULL,
|
---|
| 56 | IN_BSTR aDescription = NULL);
|
---|
[2929] | 57 | void uninit();
|
---|
[1] | 58 |
|
---|
| 59 | // IHostDVDDrive properties
|
---|
[2929] | 60 | STDMETHOD(COMGETTER(Name)) (BSTR *aName);
|
---|
[2957] | 61 | STDMETHOD(COMGETTER(Udi)) (BSTR *aUdi);
|
---|
[2929] | 62 | STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
|
---|
[1] | 63 |
|
---|
| 64 | // public methods for internal purposes only
|
---|
| 65 |
|
---|
[2929] | 66 | /* @note Must be called from under the object read lock. */
|
---|
| 67 | const Bstr &name() const { return mName; }
|
---|
[2961] | 68 |
|
---|
| 69 | /* @note Must be called from under the object read lock. */
|
---|
[2957] | 70 | const Bstr &udi() const { return mUdi; }
|
---|
[2961] | 71 |
|
---|
| 72 | /* @note Must be called from under the object read lock. */
|
---|
[2957] | 73 | const Bstr &description() const { return mDescription; }
|
---|
[1] | 74 |
|
---|
| 75 | // for VirtualBoxSupportErrorInfoImpl
|
---|
| 76 | static const wchar_t *getComponentName() { return L"HostDVDDrive"; }
|
---|
| 77 |
|
---|
| 78 | private:
|
---|
| 79 |
|
---|
[2929] | 80 | const Bstr mName;
|
---|
| 81 | const Bstr mDescription;
|
---|
[2957] | 82 | const Bstr mUdi;
|
---|
[1] | 83 | };
|
---|
| 84 |
|
---|
| 85 | COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostDVDDrive)
|
---|
| 86 |
|
---|
[15051] | 87 | STDMETHOD(FindByName) (IN_BSTR aName, IHostDVDDrive **aDrive)
|
---|
[1] | 88 | {
|
---|
[2929] | 89 | if (!aName)
|
---|
[1] | 90 | return E_INVALIDARG;
|
---|
[2929] | 91 | if (!aDrive)
|
---|
[1] | 92 | return E_POINTER;
|
---|
| 93 |
|
---|
[2929] | 94 | *aDrive = NULL;
|
---|
[1] | 95 | Vector::value_type found;
|
---|
| 96 | Vector::iterator it = vec.begin();
|
---|
| 97 | while (it != vec.end() && !found)
|
---|
| 98 | {
|
---|
| 99 | Bstr n;
|
---|
| 100 | (*it)->COMGETTER(Name) (n.asOutParam());
|
---|
[2929] | 101 | if (n == aName)
|
---|
[1] | 102 | found = *it;
|
---|
| 103 | ++ it;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | if (!found)
|
---|
| 107 | return setError (E_INVALIDARG, HostDVDDriveCollection::tr (
|
---|
[2929] | 108 | "The host DVD drive named '%ls' could not be found"), aName);
|
---|
[1] | 109 |
|
---|
[2929] | 110 | return found.queryInterfaceTo (aDrive);
|
---|
[1] | 111 | }
|
---|
| 112 |
|
---|
| 113 | COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostDVDDrive)
|
---|
| 114 |
|
---|
| 115 | #endif // ____H_HOSTDVDDRIVEIMPL
|
---|
[14949] | 116 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|