1 | /* $Id: MediumFormatImpl.h 33524 2010-10-27 16:44:37Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2008-2010 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef ____H_MEDIUMFORMAT
|
---|
21 | #define ____H_MEDIUMFORMAT
|
---|
22 |
|
---|
23 | #include "VirtualBoxBase.h"
|
---|
24 |
|
---|
25 | #include <VBox/com/array.h>
|
---|
26 |
|
---|
27 | #include <list>
|
---|
28 |
|
---|
29 | struct VDBACKENDINFO;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * The MediumFormat class represents the backend used to store medium data
|
---|
33 | * (IMediumFormat interface).
|
---|
34 | *
|
---|
35 | * @note Instances of this class are permanently caller-referenced by Medium
|
---|
36 | * objects (through addCaller()) so that an attempt to uninitialize or delete
|
---|
37 | * them before all Medium objects are uninitialized will produce an endless
|
---|
38 | * wait!
|
---|
39 | */
|
---|
40 | class ATL_NO_VTABLE MediumFormat :
|
---|
41 | public VirtualBoxBase,
|
---|
42 | VBOX_SCRIPTABLE_IMPL(IMediumFormat)
|
---|
43 | {
|
---|
44 | public:
|
---|
45 |
|
---|
46 | struct Property
|
---|
47 | {
|
---|
48 | Utf8Str strName;
|
---|
49 | Utf8Str strDescription;
|
---|
50 | DataType_T type;
|
---|
51 | ULONG flags;
|
---|
52 | Utf8Str strDefaultValue;
|
---|
53 | };
|
---|
54 |
|
---|
55 | typedef std::list<Utf8Str> StrList;
|
---|
56 | typedef std::list<DeviceType_T> DeviceTypeList;
|
---|
57 | typedef std::list<Property> PropertyList;
|
---|
58 |
|
---|
59 | struct Data
|
---|
60 | {
|
---|
61 | Data() : capabilities(0) {}
|
---|
62 |
|
---|
63 | const Utf8Str strId;
|
---|
64 | const Utf8Str strName;
|
---|
65 | const StrList llFileExtensions;
|
---|
66 | const DeviceTypeList llDeviceTypes;
|
---|
67 | const uint64_t capabilities;
|
---|
68 | const PropertyList llProperties;
|
---|
69 | };
|
---|
70 |
|
---|
71 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumFormat, IMediumFormat)
|
---|
72 |
|
---|
73 | DECLARE_NOT_AGGREGATABLE(MediumFormat)
|
---|
74 |
|
---|
75 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
76 |
|
---|
77 | BEGIN_COM_MAP(MediumFormat)
|
---|
78 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
79 | COM_INTERFACE_ENTRY(IMediumFormat)
|
---|
80 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
81 | END_COM_MAP()
|
---|
82 |
|
---|
83 | DECLARE_EMPTY_CTOR_DTOR(MediumFormat)
|
---|
84 |
|
---|
85 | HRESULT FinalConstruct();
|
---|
86 | void FinalRelease();
|
---|
87 |
|
---|
88 | // public initializer/uninitializer for internal purposes only
|
---|
89 | HRESULT init(const VDBACKENDINFO *aVDInfo);
|
---|
90 | void uninit();
|
---|
91 |
|
---|
92 | // IMediumFormat properties
|
---|
93 | STDMETHOD(COMGETTER(Id))(BSTR *aId);
|
---|
94 | STDMETHOD(COMGETTER(Name))(BSTR *aName);
|
---|
95 | STDMETHOD(COMGETTER(Capabilities))(ULONG *aCaps);
|
---|
96 |
|
---|
97 | // IMediumFormat methods
|
---|
98 | STDMETHOD(DescribeFileExtensions)(ComSafeArrayOut(BSTR, aFileExtensions),
|
---|
99 | ComSafeArrayOut(DeviceType_T, aDeviceTypes));
|
---|
100 | STDMETHOD(DescribeProperties)(ComSafeArrayOut(BSTR, aNames),
|
---|
101 | ComSafeArrayOut(BSTR, aDescriptions),
|
---|
102 | ComSafeArrayOut(DataType_T, aTypes),
|
---|
103 | ComSafeArrayOut(ULONG, aFlags),
|
---|
104 | ComSafeArrayOut(BSTR, aDefaults));
|
---|
105 |
|
---|
106 | // public methods only for internal purposes
|
---|
107 |
|
---|
108 | // public methods for internal purposes only
|
---|
109 | // (ensure there is a caller and a read lock before calling them!)
|
---|
110 |
|
---|
111 | /** Const, no need to lock */
|
---|
112 | const Utf8Str& getId() const { return m.strId; }
|
---|
113 | /** Const, no need to lock */
|
---|
114 | const StrList& getFileExtensions() const { return m.llFileExtensions; }
|
---|
115 | /** Const, no need to lock */
|
---|
116 | uint64_t getCapabilities() const { return m.capabilities; }
|
---|
117 | /** Const, no need to lock */
|
---|
118 | const PropertyList& getProperties() const { return m.llProperties; }
|
---|
119 |
|
---|
120 | private:
|
---|
121 |
|
---|
122 | Data m;
|
---|
123 | };
|
---|
124 |
|
---|
125 | #endif // ____H_MEDIUMFORMAT
|
---|
126 |
|
---|
127 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|