VirtualBox

source: vbox/trunk/src/VBox/Main/GuestOSTypeImpl.cpp@ 14579

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

Main: VirtualBoxBase::addCaller() now returns E_ACCESSDENIED. Also replaced E_UNEXPECTED with E_FAIL in all Assert* statements (for consistency).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 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#include "GuestOSTypeImpl.h"
23#include "Logging.h"
24#include <iprt/cpputils.h>
25
26// constructor / destructor
27/////////////////////////////////////////////////////////////////////////////
28
29GuestOSType::GuestOSType()
30 : mOSType (VBOXOSTYPE_Unknown)
31 , mIs64Bit (false)
32 , mRAMSize (0), mVRAMSize (0)
33 , mHDDSize (0), mMonitorCount (0)
34{
35}
36
37GuestOSType::~GuestOSType()
38{
39}
40
41HRESULT GuestOSType::FinalConstruct()
42{
43 return S_OK;
44}
45
46void GuestOSType::FinalRelease()
47{
48 uninit();
49}
50
51// public initializer/uninitializer for internal purposes only
52/////////////////////////////////////////////////////////////////////////////
53
54/**
55 * Initializes the guest OS type object.
56 *
57 * @returns COM result indicator
58 * @param aFamilyId os family short name string
59 * @param aFamilyDescription os family name string
60 * @param aId os short name string
61 * @param aDescription os name string
62 * @param aOSType global OS type ID
63 * @param aIs64Bit returns true if the given OS is 64-bit
64 * @param aRAMSize recommended RAM size in megabytes
65 * @param aVRAMSize recommended video memory size in megabytes
66 * @param aHDDSize recommended HDD size in megabytes
67 */
68HRESULT GuestOSType::init (const char *aFamilyId, const char *aFamilyDescription,
69 const char *aId, const char *aDescription,
70 VBOXOSTYPE aOSType, bool aIs64Bit,
71 uint32_t aRAMSize, uint32_t aVRAMSize, uint32_t aHDDSize)
72{
73 LogFlowThisFunc (("aFamilyId='%s', aFamilyDescription='%s', "
74 "aId='%s', aDescription='%s', "
75 "aType=%d, aIs64Bit=%d, "
76 "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%d\n",
77 aFamilyId, aFamilyDescription,
78 aId, aDescription,
79 aOSType, aIs64Bit,
80 aRAMSize, aVRAMSize, aHDDSize));
81
82 ComAssertRet (aFamilyId && aFamilyDescription && aId && aDescription, E_INVALIDARG);
83
84 /* Enclose the state transition NotReady->InInit->Ready */
85 AutoInitSpan autoInitSpan (this);
86 AssertReturn (autoInitSpan.isOk(), E_FAIL);
87
88 unconst (mFamilyID) = aFamilyId;
89 unconst (mFamilyDescription) = aFamilyDescription;
90 unconst (mID) = aId;
91 unconst (mDescription) = aDescription;
92 unconst (mOSType) = aOSType;
93 unconst (mIs64Bit) = aIs64Bit;
94 unconst (mRAMSize) = aRAMSize;
95 unconst (mVRAMSize) = aVRAMSize;
96 unconst (mHDDSize) = aHDDSize;
97
98 /* Confirm a successful initialization when it's the case */
99 autoInitSpan.setSucceeded();
100
101 return S_OK;
102}
103
104/**
105 * Uninitializes the instance and sets the ready flag to FALSE.
106 * Called either from FinalRelease() or by the parent when it gets destroyed.
107 */
108void GuestOSType::uninit()
109{
110 /* Enclose the state transition Ready->InUninit->NotReady */
111 AutoUninitSpan autoUninitSpan (this);
112 if (autoUninitSpan.uninitDone())
113 return;
114}
115
116// IGuestOSType properties
117/////////////////////////////////////////////////////////////////////////////
118
119STDMETHODIMP GuestOSType::COMGETTER(FamilyId) (BSTR *aFamilyId)
120{
121 if (!aFamilyId)
122 return E_POINTER;
123
124 AutoCaller autoCaller (this);
125 CheckComRCReturnRC (autoCaller.rc());
126
127 /* mFamilyID is constant during life time, no need to lock */
128 mFamilyID.cloneTo (aFamilyId);
129
130 return S_OK;
131}
132
133STDMETHODIMP GuestOSType::COMGETTER(FamilyDescription) (BSTR *aFamilyDescription)
134{
135 if (!aFamilyDescription)
136 return E_POINTER;
137
138 AutoCaller autoCaller (this);
139 CheckComRCReturnRC (autoCaller.rc());
140
141 /* mFamilyDescription is constant during life time, no need to lock */
142 mFamilyDescription.cloneTo (aFamilyDescription);
143
144 return S_OK;
145}
146
147STDMETHODIMP GuestOSType::COMGETTER(Id) (BSTR *aId)
148{
149 if (!aId)
150 return E_POINTER;
151
152 AutoCaller autoCaller (this);
153 CheckComRCReturnRC (autoCaller.rc());
154
155 /* mID is constant during life time, no need to lock */
156 mID.cloneTo (aId);
157
158 return S_OK;
159}
160
161STDMETHODIMP GuestOSType::COMGETTER(Description) (BSTR *aDescription)
162{
163 if (!aDescription)
164 return E_POINTER;
165
166 AutoCaller autoCaller (this);
167 CheckComRCReturnRC (autoCaller.rc());
168
169 /* mDescription is constant during life time, no need to lock */
170 mDescription.cloneTo (aDescription);
171
172 return S_OK;
173}
174
175STDMETHODIMP GuestOSType::COMGETTER(Is64Bit) (BOOL *aIs64Bit)
176{
177 if (!aIs64Bit)
178 return E_POINTER;
179
180 AutoCaller autoCaller (this);
181 CheckComRCReturnRC (autoCaller.rc());
182
183 /* mIs64Bit is constant during life time, no need to lock */
184 *aIs64Bit = mIs64Bit;
185
186 return S_OK;
187}
188
189STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM) (ULONG *aRAMSize)
190{
191 if (!aRAMSize)
192 return E_POINTER;
193
194 AutoCaller autoCaller (this);
195 CheckComRCReturnRC (autoCaller.rc());
196
197 /* mRAMSize is constant during life time, no need to lock */
198 *aRAMSize = mRAMSize;
199
200 return S_OK;
201}
202
203STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM) (ULONG *aVRAMSize)
204{
205 if (!aVRAMSize)
206 return E_POINTER;
207
208 AutoCaller autoCaller (this);
209 CheckComRCReturnRC (autoCaller.rc());
210
211 /* mVRAMSize is constant during life time, no need to lock */
212 *aVRAMSize = mVRAMSize;
213
214 return S_OK;
215}
216
217STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD) (ULONG *aHDDSize)
218{
219 if (!aHDDSize)
220 return E_POINTER;
221
222 AutoCaller autoCaller (this);
223 CheckComRCReturnRC (autoCaller.rc());
224
225 /* mHDDSize is constant during life time, no need to lock */
226 *aHDDSize = mHDDSize;
227
228 return S_OK;
229}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use