1 | /* $Id: MediumFormatImpl.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * MediumFormat COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_MediumFormatImpl_h
|
---|
29 | #define MAIN_INCLUDED_MediumFormatImpl_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "MediumFormatWrap.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | struct VDBACKENDINFO;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * The MediumFormat class represents the backend used to store medium data
|
---|
41 | * (IMediumFormat interface).
|
---|
42 | *
|
---|
43 | * @note Instances of this class are permanently caller-referenced by Medium
|
---|
44 | * objects (through addCaller()) so that an attempt to uninitialize or delete
|
---|
45 | * them before all Medium objects are uninitialized will produce an endless
|
---|
46 | * wait!
|
---|
47 | */
|
---|
48 | class ATL_NO_VTABLE MediumFormat :
|
---|
49 | public MediumFormatWrap
|
---|
50 | {
|
---|
51 | public:
|
---|
52 |
|
---|
53 | struct Property
|
---|
54 | {
|
---|
55 | Utf8Str strName;
|
---|
56 | Utf8Str strDescription;
|
---|
57 | DataType_T type;
|
---|
58 | ULONG flags;
|
---|
59 | Utf8Str strDefaultValue;
|
---|
60 | };
|
---|
61 |
|
---|
62 | typedef std::vector<Property> PropertyArray;
|
---|
63 | typedef std::vector<com::Utf8Str> StrArray;
|
---|
64 |
|
---|
65 | DECLARE_COMMON_CLASS_METHODS(MediumFormat)
|
---|
66 |
|
---|
67 | HRESULT FinalConstruct();
|
---|
68 | void FinalRelease();
|
---|
69 |
|
---|
70 | // public initializer/uninitializer for internal purposes only
|
---|
71 | HRESULT init(const VDBACKENDINFO *aVDInfo);
|
---|
72 | void uninit();
|
---|
73 |
|
---|
74 | // public methods for internal purposes only
|
---|
75 | // (ensure there is a caller and a read lock before calling them!)
|
---|
76 |
|
---|
77 | /** Const, no need to lock */
|
---|
78 | const Utf8Str &i_getId() const { return m.strId; }
|
---|
79 | /** Const, no need to lock */
|
---|
80 | const Utf8Str &i_getName() const { return m.strName; }
|
---|
81 | /** Const, no need to lock */
|
---|
82 | const StrArray &i_getFileExtensions() const { return m.maFileExtensions; }
|
---|
83 | /** Const, no need to lock */
|
---|
84 | MediumFormatCapabilities_T i_getCapabilities() const { return m.capabilities; }
|
---|
85 | /** Const, no need to lock */
|
---|
86 | const PropertyArray &i_getProperties() const { return m.maProperties; }
|
---|
87 |
|
---|
88 | private:
|
---|
89 |
|
---|
90 | // wrapped IMediumFormat properties
|
---|
91 | HRESULT getId(com::Utf8Str &aId);
|
---|
92 | HRESULT getName(com::Utf8Str &aName);
|
---|
93 | HRESULT getCapabilities(std::vector<MediumFormatCapabilities_T> &aCapabilities);
|
---|
94 |
|
---|
95 | // wrapped IMediumFormat methods
|
---|
96 | HRESULT describeFileExtensions(std::vector<com::Utf8Str> &aExtensions,
|
---|
97 | std::vector<DeviceType_T> &aTypes);
|
---|
98 | HRESULT describeProperties(std::vector<com::Utf8Str> &aNames,
|
---|
99 | std::vector<com::Utf8Str> &aDescriptions,
|
---|
100 | std::vector<DataType_T> &aTypes,
|
---|
101 | std::vector<ULONG> &aFlags,
|
---|
102 | std::vector<com::Utf8Str> &aDefaults);
|
---|
103 |
|
---|
104 | // types
|
---|
105 | typedef std::vector<DeviceType_T> DeviceTypeArray;
|
---|
106 |
|
---|
107 | // data
|
---|
108 | struct Data
|
---|
109 | {
|
---|
110 | Data() : capabilities((MediumFormatCapabilities_T)0) {}
|
---|
111 |
|
---|
112 | const Utf8Str strId;
|
---|
113 | const Utf8Str strName;
|
---|
114 | const StrArray maFileExtensions;
|
---|
115 | const DeviceTypeArray maDeviceTypes;
|
---|
116 | const MediumFormatCapabilities_T capabilities;
|
---|
117 | const PropertyArray maProperties;
|
---|
118 | };
|
---|
119 |
|
---|
120 | Data m;
|
---|
121 | };
|
---|
122 |
|
---|
123 | #endif /* !MAIN_INCLUDED_MediumFormatImpl_h */
|
---|
124 |
|
---|
125 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|