VirtualBox

source: vbox/trunk/src/VBox/Main/include/Global.h@ 26624

Last change on this file since 26624 was 26548, checked in by vboxsync, 15 years ago

Main, FE: HPET review feedback

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 6.4 KB
Line 
1/* $Id: Global.h 26548 2010-02-15 15:26:04Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM global declarations
6 */
7
8/*
9 * Copyright (C) 2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_GLOBAL
25#define ____H_GLOBAL
26
27/* generated header */
28#include "SchemaDefs.h"
29
30/* interface definitions */
31#include "VBox/com/VirtualBox.h"
32
33#include <VBox/ostypes.h>
34
35#include <iprt/types.h>
36
37#define VBOXOSHINT_NONE 0
38#define VBOXOSHINT_64BIT RT_BIT(0)
39#define VBOXOSHINT_HWVIRTEX RT_BIT(1)
40#define VBOXOSHINT_IOAPIC RT_BIT(2)
41#define VBOXOSHINT_EFI RT_BIT(3)
42#define VBOXOSHINT_PAE RT_BIT(4)
43#define VBOXOSHINT_USBHID RT_BIT(5)
44#define VBOXOSHINT_HPET RT_BIT(6)
45
46/**
47 * Contains global static definitions that can be referenced by all COM classes
48 * regardless of the apartment.
49 */
50class Global
51{
52public:
53
54 /** Represents OS Type <-> string mappings. */
55 struct OSType
56 {
57 const char *familyId; /* utf-8 */
58 const char *familyDescription; /* utf-8 */
59 const char *id; /* utf-8 */
60 const char *description; /* utf-8 */
61 const VBOXOSTYPE osType;
62 const uint32_t osHint;
63 const uint32_t recommendedRAM;
64 const uint32_t recommendedVRAM;
65 const uint32_t recommendedHDD;
66 const NetworkAdapterType_T networkAdapterType;
67 const uint32_t numSerialEnabled;
68 const StorageControllerType_T storageControllerType;
69 };
70
71 static const OSType sOSTypes[SchemaDefs::OSTypeId_COUNT];
72
73 static const char *OSTypeId(VBOXOSTYPE aOSType);
74
75 /**
76 * Returns @c true if the given machine state is an online state. This is a
77 * recommended way to detect if the VM is online (being executed in a
78 * dedicated process) or not. Note that some online states are also
79 * transitional states (see #IsTransitional()).
80 *
81 * @remarks Saving may actually be an offline state according to the
82 * documentation (offline snapshot).
83 */
84 static bool IsOnline(MachineState_T aState)
85 {
86#if 0
87 return aState >= MachineState_FirstOnline &&
88 aState <= MachineState_LastOnline;
89#else
90 switch (aState)
91 {
92 case MachineState_Running:
93 case MachineState_Paused:
94 case MachineState_Teleporting:
95 case MachineState_LiveSnapshotting:
96 case MachineState_Stuck:
97 case MachineState_Starting:
98 case MachineState_Stopping:
99 case MachineState_Saving:
100 case MachineState_Restoring:
101 case MachineState_TeleportingPausedVM:
102 case MachineState_TeleportingIn:
103 return true;
104 default:
105 return false;
106 }
107#endif
108 }
109
110 /**
111 * Returns @c true if the given machine state is a transient state. This is
112 * a recommended way to detect if the VM is performing some potentially
113 * lengthy operation (such as starting, stopping, saving, discarding
114 * snapshot, etc.). Note some (but not all) transitional states are also
115 * online states (see #IsOnline()).
116 */
117 static bool IsTransient(MachineState_T aState)
118 {
119#if 0
120 return aState >= MachineState_FirstTransient &&
121 aState <= MachineState_LastTransient;
122#else
123 switch (aState)
124 {
125 case MachineState_Teleporting:
126 case MachineState_LiveSnapshotting:
127 case MachineState_Starting:
128 case MachineState_Stopping:
129 case MachineState_Saving:
130 case MachineState_Restoring:
131 case MachineState_TeleportingPausedVM:
132 case MachineState_TeleportingIn:
133 case MachineState_RestoringSnapshot:
134 case MachineState_DeletingSnapshot:
135 case MachineState_SettingUp:
136 return true;
137 default:
138 return false;
139 }
140#endif
141 }
142
143 /**
144 * Shortcut to <tt>IsOnline(aState) || IsTransient(aState)</tt>. When it returns
145 * @false, the VM is turned off (no VM process) and not busy with
146 * another exclusive operation.
147 */
148 static bool IsOnlineOrTransient(MachineState_T aState)
149 {
150 return IsOnline(aState) || IsTransient(aState);
151 }
152
153 /**
154 * Stringify a machine state.
155 *
156 * @returns Pointer to a read only string.
157 * @param aState Valid machine state.
158 */
159 static const char *stringifyMachineState(MachineState_T aState);
160
161 /**
162 * Stringify a session state.
163 *
164 * @returns Pointer to a read only string.
165 * @param aState Valid session state.
166 */
167 static const char *stringifySessionState(SessionState_T aState);
168
169 /**
170 * Stringify a device type.
171 *
172 * @returns Pointer to a read only string.
173 * @param aType The device type.
174 */
175 static const char *stringifyDeviceType(DeviceType_T aType);
176
177 /**
178 * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
179 *
180 * @returns VBox status code.
181 * @param aComStatus COM status code.
182 */
183 static int vboxStatusCodeFromCOM(HRESULT aComStatus);
184
185 /**
186 * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
187 *
188 * This is mainly inteded for dealing with vboxStatusCodeFromCOM() return
189 * values. If used on anything else, it won't be able to cope with most of the
190 * input!
191 *
192 * @returns COM status code.
193 * @param aVBoxStatus VBox status code.
194 */
195 static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
196};
197
198#endif /* !____H_GLOBAL */
199/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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