GuestOSTypeImpl.cpp revision 9a2923915af7ea9a11f9a50dca2ebe24daf18173
1096N/A/** @file
2362N/A *
1096N/A * VirtualBox COM class implementation
1096N/A */
1096N/A
1096N/A/*
2362N/A * Copyright (C) 2006-2007 Sun Microsystems, Inc.
1096N/A *
2362N/A * This file is part of VirtualBox Open Source Edition (OSE), as
1096N/A * available from http://www.virtualbox.org. This file is free software;
1096N/A * you can redistribute it and/or modify it under the terms of the GNU
1096N/A * General Public License (GPL) as published by the Free Software
1096N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
1096N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1096N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1096N/A *
1096N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1096N/A * Clara, CA 95054 USA or visit http://www.sun.com if you need
1096N/A * additional information or have any questions.
1096N/A */
2362N/A
2362N/A#include "GuestOSTypeImpl.h"
2362N/A#include "Logging.h"
1096N/A#include <iprt/cpputils.h>
1096N/A
1096N/A// constructor / destructor
1096N/A/////////////////////////////////////////////////////////////////////////////
1096N/A
1096N/AGuestOSType::GuestOSType()
1096N/A : mOSType (VBOXOSTYPE_Unknown)
2080N/A , mIs64Bit (false)
1096N/A , mRAMSize (0), mVRAMSize (0)
1096N/A , mHDDSize (0), mMonitorCount (0)
1096N/A{
1096N/A}
1096N/A
1096N/AGuestOSType::~GuestOSType()
1096N/A{
1096N/A}
1096N/A
1096N/AHRESULT GuestOSType::FinalConstruct()
1096N/A{
1096N/A return S_OK;
1096N/A}
1096N/A
1096N/Avoid GuestOSType::FinalRelease()
1096N/A{
1096N/A uninit();
1096N/A}
1096N/A
1096N/A// public initializer/uninitializer for internal purposes only
1096N/A/////////////////////////////////////////////////////////////////////////////
1096N/A
1096N/A/**
1096N/A * Initializes the guest OS type object.
1096N/A *
1096N/A * @returns COM result indicator
1096N/A * @param aFamilyId os family short name string
1096N/A * @param aFamilyDescription os family name string
1096N/A * @param aId os short name string
1096N/A * @param aDescription os name string
1096N/A * @param aOSType global OS type ID
1096N/A * @param aIs64Bit returns true if the given OS is 64-bit
1096N/A * @param aRAMSize recommended RAM size in megabytes
1096N/A * @param aVRAMSize recommended video memory size in megabytes
1096N/A * @param aHDDSize recommended HDD size in megabytes
1096N/A */
1096N/AHRESULT GuestOSType::init (const char *aFamilyId, const char *aFamilyDescription,
1096N/A const char *aId, const char *aDescription,
1096N/A VBOXOSTYPE aOSType, bool aIs64Bit,
1096N/A uint32_t aRAMSize, uint32_t aVRAMSize, uint32_t aHDDSize)
1096N/A{
1096N/A LogFlowThisFunc (("aFamilyId='%s', aFamilyDescription='%s', "
1096N/A "aId='%s', aDescription='%s', "
1096N/A "aType=%d, aIs64Bit=%d, "
1096N/A "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%d\n",
1096N/A aFamilyId, aFamilyDescription,
1096N/A aId, aDescription,
1096N/A aOSType, aIs64Bit,
1096N/A aRAMSize, aVRAMSize, aHDDSize));
1096N/A
ComAssertRet (aFamilyId && aFamilyDescription && aId && aDescription, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
unconst (mFamilyID) = aFamilyId;
unconst (mFamilyDescription) = aFamilyDescription;
unconst (mID) = aId;
unconst (mDescription) = aDescription;
unconst (mOSType) = aOSType;
unconst (mIs64Bit) = aIs64Bit;
unconst (mRAMSize) = aRAMSize;
unconst (mVRAMSize) = aVRAMSize;
unconst (mHDDSize) = aHDDSize;
/* Confirm a successful initialization when it's the case */
autoInitSpan.setSucceeded();
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void GuestOSType::uninit()
{
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan (this);
if (autoUninitSpan.uninitDone())
return;
}
// IGuestOSType properties
/////////////////////////////////////////////////////////////////////////////
STDMETHODIMP GuestOSType::COMGETTER(FamilyId) (BSTR *aFamilyId)
{
if (!aFamilyId)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mFamilyID is constant during life time, no need to lock */
mFamilyID.cloneTo (aFamilyId);
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(FamilyDescription) (BSTR *aFamilyDescription)
{
if (!aFamilyDescription)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mFamilyDescription is constant during life time, no need to lock */
mFamilyDescription.cloneTo (aFamilyDescription);
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(Id) (BSTR *aId)
{
if (!aId)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mID is constant during life time, no need to lock */
mID.cloneTo (aId);
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(Description) (BSTR *aDescription)
{
if (!aDescription)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mDescription is constant during life time, no need to lock */
mDescription.cloneTo (aDescription);
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(Is64Bit) (BOOL *aIs64Bit)
{
if (!aIs64Bit)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mIs64Bit is constant during life time, no need to lock */
*aIs64Bit = mIs64Bit;
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM) (ULONG *aRAMSize)
{
if (!aRAMSize)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mRAMSize is constant during life time, no need to lock */
*aRAMSize = mRAMSize;
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM) (ULONG *aVRAMSize)
{
if (!aVRAMSize)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mVRAMSize is constant during life time, no need to lock */
*aVRAMSize = mVRAMSize;
return S_OK;
}
STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD) (ULONG *aHDDSize)
{
if (!aHDDSize)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* mHDDSize is constant during life time, no need to lock */
*aHDDSize = mHDDSize;
return S_OK;
}