1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung 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_HOSTDVDDRIVEIMPL
|
---|
23 | #define ____H_HOSTDVDDRIVEIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 | #include "Collection.h"
|
---|
27 |
|
---|
28 | class ATL_NO_VTABLE HostDVDDrive :
|
---|
29 | public VirtualBoxSupportErrorInfoImpl <HostDVDDrive, IHostDVDDrive>,
|
---|
30 | public VirtualBoxSupportTranslation <HostDVDDrive>,
|
---|
31 | public VirtualBoxBase,
|
---|
32 | public IHostDVDDrive
|
---|
33 | {
|
---|
34 | public:
|
---|
35 |
|
---|
36 | HostDVDDrive();
|
---|
37 | virtual ~HostDVDDrive();
|
---|
38 |
|
---|
39 | DECLARE_NOT_AGGREGATABLE(HostDVDDrive)
|
---|
40 |
|
---|
41 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
42 |
|
---|
43 | BEGIN_COM_MAP(HostDVDDrive)
|
---|
44 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
45 | COM_INTERFACE_ENTRY(IHostDVDDrive)
|
---|
46 | END_COM_MAP()
|
---|
47 |
|
---|
48 | NS_DECL_ISUPPORTS
|
---|
49 |
|
---|
50 | // public initializer/uninitializer for internal purposes only
|
---|
51 | HRESULT init (INPTR BSTR driveName);
|
---|
52 |
|
---|
53 | // IHostDVDDrive properties
|
---|
54 | STDMETHOD(COMGETTER(Name)) (BSTR *driveName);
|
---|
55 |
|
---|
56 | // public methods for internal purposes only
|
---|
57 |
|
---|
58 | const Bstr &driveName() const { return mDriveName; }
|
---|
59 |
|
---|
60 | // for VirtualBoxSupportErrorInfoImpl
|
---|
61 | static const wchar_t *getComponentName() { return L"HostDVDDrive"; }
|
---|
62 |
|
---|
63 | private:
|
---|
64 |
|
---|
65 | Bstr mDriveName;
|
---|
66 | };
|
---|
67 |
|
---|
68 | COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostDVDDrive)
|
---|
69 |
|
---|
70 | STDMETHOD(FindByName) (INPTR BSTR name, IHostDVDDrive **drive)
|
---|
71 | {
|
---|
72 | if (!name)
|
---|
73 | return E_INVALIDARG;
|
---|
74 | if (!drive)
|
---|
75 | return E_POINTER;
|
---|
76 |
|
---|
77 | *drive = NULL;
|
---|
78 | Vector::value_type found;
|
---|
79 | Vector::iterator it = vec.begin();
|
---|
80 | while (it != vec.end() && !found)
|
---|
81 | {
|
---|
82 | Bstr n;
|
---|
83 | (*it)->COMGETTER(Name) (n.asOutParam());
|
---|
84 | if (n == name)
|
---|
85 | found = *it;
|
---|
86 | ++ it;
|
---|
87 | }
|
---|
88 |
|
---|
89 | if (!found)
|
---|
90 | return setError (E_INVALIDARG, HostDVDDriveCollection::tr (
|
---|
91 | "The host DVD drive named '%ls' could not be found"), name);
|
---|
92 |
|
---|
93 | return found.queryInterfaceTo (drive);
|
---|
94 | }
|
---|
95 |
|
---|
96 | COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostDVDDrive)
|
---|
97 |
|
---|
98 | #endif // ____H_HOSTDVDDRIVEIMPL
|
---|