1 | /* $Id: UIGuestOSType.h 102282 2023-11-23 19:52:48Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIGuestOSType class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 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 FEQT_INCLUDED_SRC_globals_UIGuestOSType_h
|
---|
29 | #define FEQT_INCLUDED_SRC_globals_UIGuestOSType_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QMap>
|
---|
36 | #include <QString>
|
---|
37 | #include <QVector>
|
---|
38 |
|
---|
39 | /* COM includes: */
|
---|
40 | #include "COMEnums.h"
|
---|
41 | #include "CGuestOSType.h"
|
---|
42 |
|
---|
43 | /** A wrapper around CGuestOSType. Some of the properties are cached here for performance. */
|
---|
44 | class SHARED_LIBRARY_STUFF UIGuestOSType
|
---|
45 | {
|
---|
46 |
|
---|
47 | public:
|
---|
48 |
|
---|
49 | UIGuestOSType(const CGuestOSType &comGuestOSType);
|
---|
50 | UIGuestOSType();
|
---|
51 |
|
---|
52 | const QString &getFamilyId() const;
|
---|
53 | const QString &getFamilyDescription() const;
|
---|
54 | const QString &getId() const;
|
---|
55 | const QString &getSubtype() const;
|
---|
56 | const QString &getDescription() const;
|
---|
57 |
|
---|
58 | /** @name Wrapper getters for CGuestOSType member.
|
---|
59 | * @{ */
|
---|
60 | KStorageBus getRecommendedHDStorageBus() const;
|
---|
61 | ULONG getRecommendedRAM() const;
|
---|
62 | KStorageBus getRecommendedDVDStorageBus() const;
|
---|
63 | ULONG getRecommendedCPUCount() const;
|
---|
64 | KFirmwareType getRecommendedFirmware() const;
|
---|
65 | bool getRecommendedFloppy() const;
|
---|
66 | LONG64 getRecommendedHDD() const;
|
---|
67 | KGraphicsControllerType getRecommendedGraphicsController() const;
|
---|
68 | KStorageControllerType getRecommendedDVDStorageController() const;
|
---|
69 | bool is64Bit() const;
|
---|
70 | KPlatformArchitecture getPlatformArchitecture() const;
|
---|
71 | /** @} */
|
---|
72 |
|
---|
73 | bool isOk() const;
|
---|
74 |
|
---|
75 | private:
|
---|
76 |
|
---|
77 | /** @name CGuestOSType properties. Cached here for a faster access.
|
---|
78 | * @{ */
|
---|
79 | mutable QString m_strFamilyId;
|
---|
80 | mutable QString m_strFamilyDescription;
|
---|
81 | mutable QString m_strId;
|
---|
82 | mutable QString m_strSubtype;
|
---|
83 | mutable QString m_strDescription;
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 | CGuestOSType m_comGuestOSType;
|
---|
87 | };
|
---|
88 |
|
---|
89 |
|
---|
90 | /** A wrapper and manager class for Guest OS types (IGuestOSType). Logically we structure os types into families
|
---|
91 | * e.g. Window, Linux etc. Some families have so-called subtypes which for Linux corresponds to distros, while some
|
---|
92 | * families have no subtype. Under subtypes (and when no subtype exists direcly under family) we have guest os
|
---|
93 | * types, e.g. Debian12_x64 etc. */
|
---|
94 | class SHARED_LIBRARY_STUFF UIGuestOSTypeManager
|
---|
95 | {
|
---|
96 | public:
|
---|
97 |
|
---|
98 | /** OS info pair. 'first' is id and 'second' is description. */
|
---|
99 | typedef QPair<QString, QString> UIGuestInfoPair;
|
---|
100 | /** A list of all OS family pairs. */
|
---|
101 | typedef QVector<UIGuestInfoPair> UIGuestOSFamilyInfo;
|
---|
102 | /** A list of all OS type pairs. */
|
---|
103 | typedef QVector<UIGuestInfoPair> UIGuestOSTypeInfo;
|
---|
104 |
|
---|
105 | /** Constructs guest OS type manager. */
|
---|
106 | UIGuestOSTypeManager() {}
|
---|
107 | /** Prohibits to copy guest OS type manager. */
|
---|
108 | UIGuestOSTypeManager(const UIGuestOSTypeManager &other) = delete;
|
---|
109 |
|
---|
110 | /** Re-create the guest OS type database. */
|
---|
111 | void reCacheGuestOSTypes();
|
---|
112 |
|
---|
113 | /** Returns a list of all families (id and description). */
|
---|
114 | UIGuestOSFamilyInfo getFamilies(KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
115 | /** Returns the list of subtypes for @p strFamilyId. This may be an empty list. */
|
---|
116 | QStringList getSubtypeListForFamilyId(const QString &strFamilyId,
|
---|
117 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
118 | /** Returns a list of OS types for the @p strFamilyId. */
|
---|
119 | UIGuestOSTypeInfo getTypeListForFamilyId(const QString &strFamilyId,
|
---|
120 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
121 | /** Returns a list of OS types for the @p strSubtype. */
|
---|
122 | UIGuestOSTypeInfo getTypeListForSubtype(const QString &strSubtype,
|
---|
123 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
124 |
|
---|
125 | /** Returns whether specified @a strOSTypeId is of DOS type. */
|
---|
126 | static bool isDOSType(const QString &strOSTypeId);
|
---|
127 |
|
---|
128 | /** @name Getters for UIGuestOSType properties.
|
---|
129 | * They utilize a map for faster access to UIGuestOSType instance with @p strTypeId.
|
---|
130 | * @{ */
|
---|
131 | QString getFamilyId(const QString &strTypeId) const;
|
---|
132 | QString getSubtype(const QString &strTypeId) const;
|
---|
133 | KGraphicsControllerType getRecommendedGraphicsController(const QString &strTypeId) const;
|
---|
134 | ULONG getRecommendedRAM(const QString &strTypeId) const;
|
---|
135 | ULONG getRecommendedCPUCount(const QString &strTypeId) const;
|
---|
136 | KFirmwareType getRecommendedFirmware(const QString &strTypeId) const;
|
---|
137 | QString getDescription(const QString &strTypeId) const;
|
---|
138 | LONG64 getRecommendedHDD(const QString &strTypeId) const;
|
---|
139 | KStorageBus getRecommendedHDStorageBus(const QString &strTypeId) const;
|
---|
140 | KStorageBus getRecommendedDVDStorageBus(const QString &strTypeId) const;
|
---|
141 | bool getRecommendedFloppy(const QString &strTypeId) const;
|
---|
142 | KStorageControllerType getRecommendedDVDStorageController(const QString &strTypeId) const;
|
---|
143 | bool isLinux(const QString &strTypeId) const;
|
---|
144 | bool isWindows(const QString &strTypeId) const;
|
---|
145 | bool is64Bit(const QString &strOSTypeId) const;
|
---|
146 | KPlatformArchitecture getPlatformArchitecture(const QString &strTypeId) const;
|
---|
147 | /** @} */
|
---|
148 |
|
---|
149 | private:
|
---|
150 |
|
---|
151 | /** Adds certain @a comType to internal cache. */
|
---|
152 | void addGuestOSType(const CGuestOSType &comType);
|
---|
153 |
|
---|
154 | /** The type list. Here it is a pointer to QVector to delay definition of UIGuestOSType. */
|
---|
155 | QVector<UIGuestOSType> m_guestOSTypes;
|
---|
156 | /** A map to prevent linear search of UIGuestOSType instances wrt. typeId. Key is typeId and value
|
---|
157 | * is index to m_guestOSTypes list. */
|
---|
158 | QMap<QString, int> m_typeIdIndexMap;
|
---|
159 | /** First item of the pair is family id and the 2nd is family description. */
|
---|
160 | UIGuestOSFamilyInfo m_guestOSFamilies;
|
---|
161 |
|
---|
162 | /** Caches arch types on per-family basis. */
|
---|
163 | QMap<QString, KPlatformArchitecture> m_guestOSFamilyArch;
|
---|
164 | /** Caches arch types on per-subtype basis. */
|
---|
165 | QMap<QString, KPlatformArchitecture> m_guestOSSubtypeArch;
|
---|
166 | };
|
---|
167 |
|
---|
168 | #endif /* !FEQT_INCLUDED_SRC_globals_UIGuestOSType_h */
|
---|