VirtualBoxImpl.h revision eeab73cfabc939c13e9e2491035489cf2a027570
/* $Id$ */
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ____H_VIRTUALBOXIMPL
#define ____H_VIRTUALBOXIMPL
#include "VirtualBoxBase.h"
#include "VBox/com/EventQueue.h"
#include <list>
#include <vector>
#include <map>
#ifdef RT_OS_WINDOWS
# include "win/resource.h"
#endif
#ifdef VBOX_WITH_RESOURCE_USAGE_API
#include "PerformanceImpl.h"
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
#ifdef RT_OS_WINDOWS
#endif
struct VMClientWatcherData;
#ifdef RT_OS_WINDOWS
#endif
{
VirtualBox();
~VirtualBox();
void FinalRelease();
/* public initializer/uninitializer for internal purposes only */
void uninit();
/* IVirtualBox properties */
/* IVirtualBox methods */
// STDMETHOD(CreateDHCPServerForInterface) (/*IHostNetworkInterface * aIinterface, */IDHCPServer ** aServer);
// STDMETHOD(FindDHCPServerForInterface) (IHostNetworkInterface * aIinterface, IDHCPServer ** aServer);
/* public methods only for internal purposes */
#ifdef RT_OS_WINDOWS
#endif
void updateClientWatcher();
/** Shortcut to #getOpenedMachines (aMachines, &aControls). */
{
}
{ return mData.mSystemProperties; }
#ifdef VBOX_WITH_RESOURCE_USAGE_API
{ return mData.mPerformanceCollector; }
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
/** Returns the VirtualBox home directory */
bool aValidate,
bool aCatchLoadErrors,
bool aAddDefaults,
/**
* Shortcut to loadSettingsTree (aTree, aFile, true, true, true).
*
* Used when the settings file is to be loaded for the first time for the
* given object in order to recreate it from the stored settings.
*
* @param aFormatVersion Where to store the current format version of the
* loaded settings tree.
*/
{
}
/**
* Shortcut to loadSettingsTree (aTree, aFile, true, false, true).
*
* Used when the settings file is loaded again (after it has been fully
* checked and validated by #loadSettingsTree_FirstTime()) in order to
* look at settings that don't have any representation within object's
* data fields.
*/
{
}
/**
* Shortcut to loadSettingsTree (aTree, aFile, true, false, false).
*
* Used when the settings file is loaded again (after it has been fully
* checked and validated by #loadSettingsTree_FirstTime()) in order to
* update some settings and then save them back.
*/
{
}
const Utf8Str &aOldFormat,
Bstr &aBakFileName);
/**
* Returns a lock handle used to protect changes to the hard disk hierarchy
* (e.g. serialize access to the HardDisk::mParent fields and methods
* be obeyed:
*
* 1. The write lock on this handle must be either held alone on the thread
* or requested *after* the VirtualBox object lock. Mixing with other
* locks is prohibited.
*
* 2. The read lock on this handle may be intermixed with any other lock
* with the exception that it must be requested *after* the VirtualBox
* object lock.
*/
/* for VirtualBoxSupportErrorInfoImpl */
/**
* Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a
* dedicated lock instead of the main object lock. The dedicated lock for
* child map operations frees callers of init() methods of these children
* from acquiring a write parent (VirtualBox) lock (which would be mandatory
* otherwise). Since VirtualBox has a lot of heterogenous children which
* init() methods are called here and there, it definitely makes sense.
*/
bool aSaveRegistry = true);
bool aSaveRegistry = true);
/** @note This method is not thread safe */
/**
* Main VirtualBox data structure.
* @note |const| members are persistent during lifetime so can be accessed
* without locking.
*/
struct Data
{
Data();
struct CfgFile
{
/** Flag indicating that the config file is read-only. */
};
// const data members not requiring locking
// const objects not requiring locking
#ifdef VBOX_WITH_RESOURCE_USAGE_API
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
/// @todo NEWMEDIA do we really need this map? Used only in
/// find() it seems
};
/** Client watcher thread data structure */
struct ClientWatcherData
{
#if defined(RT_OS_WINDOWS)
: mUpdateReq (NULL)
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
#else
# error "Port me!"
#endif
, mThread (NIL_RTTHREAD) {}
// const objects not requiring locking
#if defined(RT_OS_WINDOWS)
const HANDLE mUpdateReq;
const RTSEMEVENT mUpdateReq;
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
const RTSEMEVENT mUpdateReq;
#else
# error "Port me!"
#endif
};
const RTTHREAD mAsyncEventThread;
EventQueue * const mAsyncEventQ;
/**
* "Safe" lock. May only be used if guaranteed that no other locks are
* requested while holding it and no functions that may do so are called.
* Currently, protects the following:
*
* - mProgressOperations
*/
static Bstr sPackageType;
static Bstr sSettingsFormatVersion;
#ifdef RT_OS_WINDOWS
#endif
};
////////////////////////////////////////////////////////////////////////////////
/**
* Abstract callback event class to asynchronously call VirtualBox callbacks
* on a dedicated event thread. Subclasses reimplement #handleCallback()
* to call appropriate IVirtualBoxCallback methods depending on the event
* to be dispatched.
*
* @note The VirtualBox instance passed to the constructor is strongly
* referenced, so that the VirtualBox singleton won't be released until the
* event gets handled by the event thread.
*/
{
{
}
void *handler();
/*
* Note that this is a weak ref -- the CallbackEvent handler thread
* is bound to the lifetime of the VirtualBox instance, so it's safe.
*/
};
#endif // ____H_VIRTUALBOXIMPL
/* vi: set tabstop=4 shiftwidth=4 expandtab: */