VirtualBox

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

Last change on this file since 13538 was 8155, checked in by vboxsync, 16 years ago

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 (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.
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.
20 */
21
22#ifndef ____H_FLOPPYIMAGEIMPL
23#define ____H_FLOPPYIMAGEIMPL
24
25#include "VirtualBoxBase.h"
26#include "Collection.h"
27
28#include <iprt/path.h>
29
30class VirtualBox;
31
32class ATL_NO_VTABLE FloppyImage :
33 public VirtualBoxBaseNEXT,
34 public VirtualBoxSupportErrorInfoImpl <FloppyImage, IFloppyImage>,
35 public VirtualBoxSupportTranslation <FloppyImage>,
36 public IFloppyImage
37{
38public:
39
40 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (FloppyImage)
41
42 DECLARE_NOT_AGGREGATABLE(FloppyImage)
43
44 DECLARE_PROTECT_FINAL_CONSTRUCT()
45
46 BEGIN_COM_MAP(FloppyImage)
47 COM_INTERFACE_ENTRY(ISupportErrorInfo)
48 COM_INTERFACE_ENTRY(IFloppyImage)
49 END_COM_MAP()
50
51 NS_DECL_ISUPPORTS
52
53 DECLARE_EMPTY_CTOR_DTOR (FloppyImage)
54
55 HRESULT FinalConstruct();
56 void FinalRelease();
57
58 // public initializer/uninitializer for internal purposes only
59 HRESULT init (VirtualBox *aParent, const BSTR aFilePath,
60 BOOL aRegistered, const Guid &aId);
61 void uninit();
62
63 // IFloppyImage properties
64 STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT aId);
65 STDMETHOD(COMGETTER(FilePath)) (BSTR *aFilePath);
66 STDMETHOD(COMGETTER(Accessible)) (BOOL *aAccessible);
67 STDMETHOD(COMGETTER(Size)) (ULONG *aSize);
68
69 // public methods for internal purposes only
70 // (ensure there is a caller and a read lock before calling them!)
71
72 const Bstr &filePath() { return mImageFile; }
73 const Bstr &filePathFull() { return mImageFileFull; }
74 const Guid &id() { return mUuid; }
75
76 void updatePath (const char *aNewFullPath, const char *aNewPath);
77
78 // for VirtualBoxSupportErrorInfoImpl
79 static const wchar_t *getComponentName() { return L"FloppyImage"; }
80
81private:
82
83 /** weak parent */
84 const ComObjPtr <VirtualBox, ComWeakRef> mParent;
85
86 BOOL mAccessible;
87
88 const Guid mUuid;
89 const Bstr mImageFile;
90 const Bstr mImageFileFull;
91};
92
93COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (FloppyImage)
94
95 STDMETHOD(FindByPath) (INPTR BSTR aPath, IFloppyImage **aFloppyImage)
96 {
97 if (!aPath)
98 return E_INVALIDARG;
99 if (!aFloppyImage)
100 return E_POINTER;
101
102 Utf8Str path = aPath;
103 *aFloppyImage = NULL;
104 Vector::value_type found;
105 Vector::iterator it = vec.begin();
106 while (it != vec.end() && !found)
107 {
108 Bstr filePath;
109 (*it)->COMGETTER(FilePath) (filePath.asOutParam());
110 if (RTPathCompare (Utf8Str (filePath), path) == 0)
111 found = *it;
112 ++ it;
113 }
114
115 if (!found)
116 return setError (E_INVALIDARG, FloppyImageCollection::tr (
117 "The floppy image named '%ls' could not be found"), aPath);
118
119 return found.queryInterfaceTo (aFloppyImage);
120 }
121
122COM_DECL_READONLY_ENUM_AND_COLLECTION_END (FloppyImage)
123
124
125#endif // ____H_FLOPPYIMAGEIMPL
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use