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 |
|
---|
29 | GuestOSType::GuestOSType()
|
---|
30 | : mOSType (VBOXOSTYPE_Unknown)
|
---|
31 | , mRAMSize (0), mVRAMSize (0)
|
---|
32 | , mHDDSize (0), mMonitorCount (0)
|
---|
33 | {
|
---|
34 | }
|
---|
35 |
|
---|
36 | GuestOSType::~GuestOSType()
|
---|
37 | {
|
---|
38 | }
|
---|
39 |
|
---|
40 | HRESULT GuestOSType::FinalConstruct()
|
---|
41 | {
|
---|
42 | return S_OK;
|
---|
43 | }
|
---|
44 |
|
---|
45 | void 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 | */
|
---|
64 | HRESULT GuestOSType::init (const char *aId, const char *aDescription, VBOXOSTYPE 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 | */
|
---|
95 | void 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 |
|
---|
106 | STDMETHODIMP 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 |
|
---|
120 | STDMETHODIMP 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 |
|
---|
134 | STDMETHODIMP 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 |
|
---|
148 | STDMETHODIMP 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 |
|
---|
162 | STDMETHODIMP 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 | }
|
---|