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 (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 |
|
---|
18 | #include "GuestOSTypeImpl.h"
|
---|
19 | #include "Logging.h"
|
---|
20 | #include <iprt/cpputils.h>
|
---|
21 |
|
---|
22 | // constructor / destructor
|
---|
23 | /////////////////////////////////////////////////////////////////////////////
|
---|
24 |
|
---|
25 | GuestOSType::GuestOSType()
|
---|
26 | : mOSType (VBOXOSTYPE_Unknown)
|
---|
27 | , mRAMSize (0), mVRAMSize (0)
|
---|
28 | , mHDDSize (0), mMonitorCount (0)
|
---|
29 | {
|
---|
30 | }
|
---|
31 |
|
---|
32 | GuestOSType::~GuestOSType()
|
---|
33 | {
|
---|
34 | }
|
---|
35 |
|
---|
36 | HRESULT GuestOSType::FinalConstruct()
|
---|
37 | {
|
---|
38 | return S_OK;
|
---|
39 | }
|
---|
40 |
|
---|
41 | void GuestOSType::FinalRelease()
|
---|
42 | {
|
---|
43 | uninit();
|
---|
44 | }
|
---|
45 |
|
---|
46 | // public initializer/uninitializer for internal purposes only
|
---|
47 | /////////////////////////////////////////////////////////////////////////////
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Initializes the guest OS type object.
|
---|
51 | *
|
---|
52 | * @returns COM result indicator
|
---|
53 | * @param aId os short name string
|
---|
54 | * @param aDescription os name string
|
---|
55 | * @param aOSType global OS type ID
|
---|
56 | * @param aRAMSize recommended RAM size in megabytes
|
---|
57 | * @param aVRAMSize recommended video memory size in megabytes
|
---|
58 | * @param aHDDSize recommended HDD size in megabytes
|
---|
59 | */
|
---|
60 | HRESULT GuestOSType::init (const char *aId, const char *aDescription, VBOXOSTYPE aOSType,
|
---|
61 | uint32_t aRAMSize, uint32_t aVRAMSize, uint32_t aHDDSize)
|
---|
62 | {
|
---|
63 | LogFlowThisFunc (("aId='%s', aDescription='%s', aType=%d, "
|
---|
64 | "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%d\n",
|
---|
65 | aId, aDescription, aOSType,
|
---|
66 | aRAMSize, aVRAMSize, aHDDSize));
|
---|
67 |
|
---|
68 | ComAssertRet (aId && aDescription, E_INVALIDARG);
|
---|
69 |
|
---|
70 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
71 | AutoInitSpan autoInitSpan (this);
|
---|
72 | AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
|
---|
73 |
|
---|
74 | unconst (mID) = aId;
|
---|
75 | unconst (mDescription) = aDescription;
|
---|
76 | unconst (mOSType) = aOSType;
|
---|
77 | unconst (mRAMSize) = aRAMSize;
|
---|
78 | unconst (mVRAMSize) = aVRAMSize;
|
---|
79 | unconst (mHDDSize) = aHDDSize;
|
---|
80 |
|
---|
81 | /* Confirm a successful initialization when it's the case */
|
---|
82 | autoInitSpan.setSucceeded();
|
---|
83 |
|
---|
84 | return S_OK;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
89 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
90 | */
|
---|
91 | void GuestOSType::uninit()
|
---|
92 | {
|
---|
93 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
94 | AutoUninitSpan autoUninitSpan (this);
|
---|
95 | if (autoUninitSpan.uninitDone())
|
---|
96 | return;
|
---|
97 | }
|
---|
98 |
|
---|
99 | // IGuestOSType properties
|
---|
100 | /////////////////////////////////////////////////////////////////////////////
|
---|
101 |
|
---|
102 | STDMETHODIMP GuestOSType::COMGETTER(Id) (BSTR *aId)
|
---|
103 | {
|
---|
104 | if (!aId)
|
---|
105 | return E_POINTER;
|
---|
106 |
|
---|
107 | AutoCaller autoCaller (this);
|
---|
108 | CheckComRCReturnRC (autoCaller.rc());
|
---|
109 |
|
---|
110 | /* mID is constant during life time, no need to lock */
|
---|
111 | mID.cloneTo (aId);
|
---|
112 |
|
---|
113 | return S_OK;
|
---|
114 | }
|
---|
115 |
|
---|
116 | STDMETHODIMP GuestOSType::COMGETTER(Description) (BSTR *aDescription)
|
---|
117 | {
|
---|
118 | if (!aDescription)
|
---|
119 | return E_POINTER;
|
---|
120 |
|
---|
121 | AutoCaller autoCaller (this);
|
---|
122 | CheckComRCReturnRC (autoCaller.rc());
|
---|
123 |
|
---|
124 | /* mDescription is constant during life time, no need to lock */
|
---|
125 | mDescription.cloneTo (aDescription);
|
---|
126 |
|
---|
127 | return S_OK;
|
---|
128 | }
|
---|
129 |
|
---|
130 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM) (ULONG *aRAMSize)
|
---|
131 | {
|
---|
132 | if (!aRAMSize)
|
---|
133 | return E_POINTER;
|
---|
134 |
|
---|
135 | AutoCaller autoCaller (this);
|
---|
136 | CheckComRCReturnRC (autoCaller.rc());
|
---|
137 |
|
---|
138 | /* mRAMSize is constant during life time, no need to lock */
|
---|
139 | *aRAMSize = mRAMSize;
|
---|
140 |
|
---|
141 | return S_OK;
|
---|
142 | }
|
---|
143 |
|
---|
144 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM) (ULONG *aVRAMSize)
|
---|
145 | {
|
---|
146 | if (!aVRAMSize)
|
---|
147 | return E_POINTER;
|
---|
148 |
|
---|
149 | AutoCaller autoCaller (this);
|
---|
150 | CheckComRCReturnRC (autoCaller.rc());
|
---|
151 |
|
---|
152 | /* mVRAMSize is constant during life time, no need to lock */
|
---|
153 | *aVRAMSize = mVRAMSize;
|
---|
154 |
|
---|
155 | return S_OK;
|
---|
156 | }
|
---|
157 |
|
---|
158 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD) (ULONG *aHDDSize)
|
---|
159 | {
|
---|
160 | if (!aHDDSize)
|
---|
161 | return E_POINTER;
|
---|
162 |
|
---|
163 | AutoCaller autoCaller (this);
|
---|
164 | CheckComRCReturnRC (autoCaller.rc());
|
---|
165 |
|
---|
166 | /* mHDDSize is constant during life time, no need to lock */
|
---|
167 | *aHDDSize = mHDDSize;
|
---|
168 |
|
---|
169 | return S_OK;
|
---|
170 | }
|
---|