VirtualBox

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

Last change on this file since 3411 was 3007, checked in by vboxsync, 17 years ago

Moved the template code out of cdefs.h, partly because it didn't belong there but mostly because it was at the end of the file and would screw up any attempts made by the object cache at avoid recompiling on cdefs.h changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
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 (OSTypeUnknown)
31 , mRAMSize (0), mVRAMSize (0)
32 , mHDDSize (0), mMonitorCount (0)
33{
34}
35
36GuestOSType::~GuestOSType()
37{
38}
39
40HRESULT GuestOSType::FinalConstruct()
41{
42 return S_OK;
43}
44
45void GuestOSType::FinalRelease()
46{
47 uninit();
48}
49
50// public initializer/uninitializer for internal purposes only
51/////////////////////////////////////////////////////////////////////////////
52
53/**
54 * Initializes the guest OS type object.
55 *
56 * @returns COM result indicator
57 * @param aId os short name string
58 * @param aDescription os name string
59 * @param aOSType global OS type ID
60 * @param aRAMSize recommended RAM size in megabytes
61 * @param aVRAMSize recommended video memory size in megabytes
62 * @param aHDDSize recommended HDD size in megabytes
63 */
64HRESULT GuestOSType::init (const char *aId, const char *aDescription, OSType aOSType,
65 uint32_t aRAMSize, uint32_t aVRAMSize, uint32_t aHDDSize)
66{
67 LogFlowThisFunc (("aId='%s', aDescription='%s', aType=%d, "
68 "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%d\n",
69 aId, aDescription, aOSType,
70 aRAMSize, aVRAMSize, aHDDSize));
71
72 ComAssertRet (aId && aDescription, E_INVALIDARG);
73
74 /* Enclose the state transition NotReady->InInit->Ready */
75 AutoInitSpan autoInitSpan (this);
76 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
77
78 unconst (mID) = aId;
79 unconst (mDescription) = aDescription;
80 unconst (mOSType) = aOSType;
81 unconst (mRAMSize) = aRAMSize;
82 unconst (mVRAMSize) = aVRAMSize;
83 unconst (mHDDSize) = aHDDSize;
84
85 /* Confirm a successful initialization when it's the case */
86 autoInitSpan.setSucceeded();
87
88 return S_OK;
89}
90
91/**
92 * Uninitializes the instance and sets the ready flag to FALSE.
93 * Called either from FinalRelease() or by the parent when it gets destroyed.
94 */
95void GuestOSType::uninit()
96{
97 /* Enclose the state transition Ready->InUninit->NotReady */
98 AutoUninitSpan autoUninitSpan (this);
99 if (autoUninitSpan.uninitDone())
100 return;
101}
102
103// IGuestOSType properties
104/////////////////////////////////////////////////////////////////////////////
105
106STDMETHODIMP GuestOSType::COMGETTER(Id) (BSTR *aId)
107{
108 if (!aId)
109 return E_POINTER;
110
111 AutoCaller autoCaller (this);
112 CheckComRCReturnRC (autoCaller.rc());
113
114 /* mID is constant during life time, no need to lock */
115 mID.cloneTo (aId);
116
117 return S_OK;
118}
119
120STDMETHODIMP GuestOSType::COMGETTER(Description) (BSTR *aDescription)
121{
122 if (!aDescription)
123 return E_POINTER;
124
125 AutoCaller autoCaller (this);
126 CheckComRCReturnRC (autoCaller.rc());
127
128 /* mDescription is constant during life time, no need to lock */
129 mDescription.cloneTo (aDescription);
130
131 return S_OK;
132}
133
134STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM) (ULONG *aRAMSize)
135{
136 if (!aRAMSize)
137 return E_POINTER;
138
139 AutoCaller autoCaller (this);
140 CheckComRCReturnRC (autoCaller.rc());
141
142 /* mRAMSize is constant during life time, no need to lock */
143 *aRAMSize = mRAMSize;
144
145 return S_OK;
146}
147
148STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM) (ULONG *aVRAMSize)
149{
150 if (!aVRAMSize)
151 return E_POINTER;
152
153 AutoCaller autoCaller (this);
154 CheckComRCReturnRC (autoCaller.rc());
155
156 /* mVRAMSize is constant during life time, no need to lock */
157 *aVRAMSize = mVRAMSize;
158
159 return S_OK;
160}
161
162STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD) (ULONG *aHDDSize)
163{
164 if (!aHDDSize)
165 return E_POINTER;
166
167 AutoCaller autoCaller (this);
168 CheckComRCReturnRC (autoCaller.rc());
169
170 /* mHDDSize is constant during life time, no need to lock */
171 *aHDDSize = mHDDSize;
172
173 return S_OK;
174}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use