VirtualBoxImpl.h revision ac523f8922c3a3574c8b7d94bc96871b7928fe2c
/* $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 */
IMedium **aFloppyImage);
// 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 */
const Utf8Str& getDefaultMachineFolder() const;
const Utf8Str& getDefaultHardDiskFolder() const;
const Utf8Str& getDefaultHardDiskFormat() const;
/** Returns the VirtualBox home directory */
const Utf8Str& settingsFilePath()
{
return m_strSettingsFilePath;
}
/**
* Returns a lock handle used to protect changes to the hard disk hierarchy
* (e.g. serialize access to the Medium::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);
// VirtualBox main settings file
const Utf8Str m_strSettingsFilePath;
/**
* Main VirtualBox data structure.
* @note |const| members are persistent during lifetime so can be accessed
* without locking.
*/
struct Data
{
Data();
// 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
};
#if defined(RT_OS_WINDOWS)
#define UPDATEREQARG NULL
#define UPDATEREQTYPE HANDLE
#define UPDATEREQARG NIL_RTSEMEVENT
#define UPDATEREQTYPE RTSEMEVENT
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
#define UPDATEREQARG
#define UPDATEREQTYPE RTSEMEVENT
#else
# error "Port me!"
#endif
/** Client watcher thread data structure */
struct ClientWatcherData
{
{}
// const objects not requiring locking
const UPDATEREQTYPE mUpdateReq;
};
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 variables (defined in VirtualBoxImpl.cpp) */
static Bstr sPackageType;
#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