VirtualBox

source: vbox/trunk/src/VBox/Main/include/FloppyImageImpl.h@ 1830

Last change on this file since 1830 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
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_FLOPPYIMAGEIMPL
23#define ____H_FLOPPYIMAGEIMPL
24
25#include "VirtualBoxBase.h"
26#include "Collection.h"
27
28class VirtualBox;
29
30class ATL_NO_VTABLE FloppyImage :
31 public VirtualBoxSupportErrorInfoImpl <FloppyImage, IFloppyImage>,
32 public VirtualBoxSupportTranslation <FloppyImage>,
33 public VirtualBoxBase,
34 public IFloppyImage
35{
36public:
37
38 // to satisfy the ComObjPtr template (we have const members)
39 FloppyImage() {}
40
41 DECLARE_NOT_AGGREGATABLE(FloppyImage)
42
43 DECLARE_PROTECT_FINAL_CONSTRUCT()
44
45 BEGIN_COM_MAP(FloppyImage)
46 COM_INTERFACE_ENTRY(ISupportErrorInfo)
47 COM_INTERFACE_ENTRY(IFloppyImage)
48 END_COM_MAP()
49
50 NS_DECL_ISUPPORTS
51
52 HRESULT FinalConstruct();
53 void FinalRelease();
54
55 // public initializer/uninitializer for internal purposes only
56 HRESULT init (VirtualBox *parent, const BSTR filePath,
57 BOOL isRegistered, const Guid &id);
58 void uninit();
59
60 // IFloppyImage properties
61 STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT id);
62 STDMETHOD(COMGETTER(FilePath)) (BSTR *filePath);
63 STDMETHOD(COMGETTER(Accessible)) (BOOL *accessible);
64 STDMETHOD(COMGETTER(Size)) (ULONG *size);
65
66 // public methods for internal purposes only
67
68 const Bstr &filePath() { return mImageFile; }
69 const Bstr &filePathFull() { return mImageFileFull; }
70 const Guid &id() { return mUuid; }
71
72 void updatePath (const char *aNewFullPath, const char *aNewPath);
73
74 // for VirtualBoxSupportErrorInfoImpl
75 static const wchar_t *getComponentName() { return L"FloppyImage"; }
76
77private:
78
79 /** weak parent */
80 ComObjPtr <VirtualBox, ComWeakRef> mParent;
81
82 BOOL mAccessible;
83
84 const Guid mUuid;
85 const Bstr mImageFile;
86 const Bstr mImageFileFull;
87};
88
89COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (FloppyImage)
90
91 STDMETHOD(FindByPath) (INPTR BSTR path, IFloppyImage **floppyImage)
92 {
93 if (!path)
94 return E_INVALIDARG;
95 if (!floppyImage)
96 return E_POINTER;
97
98 *floppyImage = NULL;
99 Vector::value_type found;
100 Vector::iterator it = vec.begin();
101 while (it != vec.end() && !found)
102 {
103 Bstr filePath;
104 (*it)->COMGETTER(FilePath) (filePath.asOutParam());
105 if (filePath == path)
106 found = *it;
107 ++ it;
108 }
109
110 if (!found)
111 return setError (E_INVALIDARG, FloppyImageCollection::tr (
112 "The floppy image named '%ls' could not be found"), path);
113
114 return found.queryInterfaceTo (floppyImage);
115 }
116
117COM_DECL_READONLY_ENUM_AND_COLLECTION_END (FloppyImage)
118
119
120#endif // ____H_FLOPPYIMAGEIMPL
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette