COMDefs.h revision a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fc
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* Various COM definitions and COM wrapper class declarations
*
* This header is used in conjunction with the header generated from
* XIDL expressed interface definitions to provide cross-platform Qt-based
* interface wrapper classes.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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.
*/
#ifndef __COMDefs_h__
#define __COMDefs_h__
* Either of them can be already included here, so try to shut them up. */
#include <qglobal.h>
#include <qstring.h>
#include <quuid.h>
/*
* Additional COM / XPCOM defines and includes
*/
#if !defined (VBOX_WITH_XPCOM)
#else /* !defined (VBOX_WITH_XPCOM) */
#include <nsXPCOM.h>
#include <nsMemory.h>
#include <nsIComponentManager.h>
#endif /* !defined (VBOX_WITH_XPCOM) */
/* VirtualBox interfaces declarations */
#if !defined (VBOX_WITH_XPCOM)
#include <VirtualBox.h>
#else /* !defined (VBOX_WITH_XPCOM) */
#include <VirtualBox_XPCOM.h>
#endif /* !defined (VBOX_WITH_XPCOM) */
#include "VBoxDefs.h"
/////////////////////////////////////////////////////////////////////////////
/** Represents extended error information */
{
: mIsNull (true)
, mIsBasicAvailable (false), mIsFullAvailable (false)
, mResultCode (S_OK) {}
/* the default copy ctor and assignment op are ok */
bool isBasicAvailable() const { return mIsBasicAvailable; }
bool isFullAvailable() const { return mIsFullAvailable; }
bool mIsNull : 1;
bool mIsBasicAvailable : 1;
bool mIsFullAvailable : 1;
};
/////////////////////////////////////////////////////////////////////////////
/**
* Base COM class the CInterface template and all wrapper classes are derived
* from. Provides common functionality for all COM wrappers.
*/
{
static HRESULT initializeCOM();
static HRESULT cleanupCOM();
#if !defined (VBOX_WITH_XPCOM)
/** Converts a GUID value to QUuid */
{
}
#else /* !defined (VBOX_WITH_XPCOM) */
/** Converts a GUID value to QUuid */
{
}
#endif /* !defined (VBOX_WITH_XPCOM) */
/**
* Returns the result code of the last interface method called
* by the wrapper instance or the result of CInterface::createInstance()
* operation.
*/
/**
* Returns error info set by the last unsuccessfully invoked interface
* method. Returned error info is useful only if CInterface::lastRC()
* represents a failure (i.e. CInterface::isOk() is false).
*/
/* no arbitrary instance creations */
#if defined (VBOX_WITH_XPCOM)
static XPCOMEventQSocketListener *sSocketListener;
#endif
/** Adapter to pass QString as input BSTR params */
{
~BSTRIn()
{
if (bstr)
}
};
/** Adapter to pass QString as output BSTR params */
{
~BSTROut()
{
if (bstr) {
}
}
};
/** Adapter to pass CEnums enums as output VirtualBox enum params (*_T) */
{
};
#if !defined (VBOX_WITH_XPCOM)
/** Adapter to pass QUuid as input GUID params */
/** Adapter to pass QUuid as output GUID params */
{
{
}
~GUIDOut()
{
}
};
#else /* !defined (VBOX_WITH_XPCOM) */
/** Adapter to pass QUuid as input GUID params */
{
}
/** Adapter to pass QUuid as output GUID params */
{
~GUIDOut()
{
if (nsid)
{
}
}
};
#endif /* !defined (VBOX_WITH_XPCOM) */
};
/////////////////////////////////////////////////////////////////////////////
/**
* Alternative base class for the CInterface template that adds
* the errorInfo() method for providing extended error info about
* unsuccessful invocation of the last called interface method.
*/
{
/**
* Returns error info set by the last unsuccessfully invoked interface
* method. Returned error info is useful only if CInterface::lastRC()
* represents a failure (i.e. CInterface::isOk() is false).
*/
/* no arbitrary instance creations */
COMBaseWithEI() : COMBase () {};
{
}
};
/////////////////////////////////////////////////////////////////////////////
/**
* Simple class that encapsulates the result code and COMErrorInfo.
*/
{
/** Queries the current result code and error info from the given component */
{
}
/** Queries the current result code and error info from the given component */
{
return *this;
}
};
/////////////////////////////////////////////////////////////////////////////
/**
* Wrapper template class for all interfaces.
*
* All interface methods named as they are in the original, i.e. starting
* with the capital letter. All utility non-interface methods are named
* starting with the small letter. Utility methods should be not normally
* called by the end-user client application.
*
* @param I interface class (i.e. IUnknown/nsISupports derivant)
* @param B base class, either COMBase (by default) or COMBaseWithEI
*/
{
typedef B Base;
typedef I Iface;
/* constructors & destructor */
{
}
/* utility methods */
{
if (!mIface)
{
#if !defined (VBOX_WITH_XPCOM)
_ATL_IIDOF (I), (void **) &mIface);
#else /* !defined (VBOX_WITH_XPCOM) */
(void **) &mIface);
#endif /* !defined (VBOX_WITH_XPCOM) */
/* fetch error info, but don't assert if it's missing -- many other
* reasons can lead to an error (w/o providing error info), not only
* the instance initialization code (that should always provide it) */
}
}
void attach (I *i)
{
/* be aware of self (from COM point of view) assignment */
mIface = i;
};
void attachUnknown (IUnknown *i)
{
/* be aware of self (from COM point of view) assignment */
if (i)
#if !defined (VBOX_WITH_XPCOM)
#else /* !defined (VBOX_WITH_XPCOM) */
#endif /* !defined (VBOX_WITH_XPCOM) */
};
/* utility operators */
{
return *this;
}
};
/////////////////////////////////////////////////////////////////////////////
{
{
#if !defined (VBOX_WITH_XPCOM)
#else /* !defined (VBOX_WITH_XPCOM) */
#endif /* !defined (VBOX_WITH_XPCOM) */
{
}
}
/* specialization for CUnknown */
{
}
{
/* be aware of self (from COM point of view) assignment */
#if !defined (VBOX_WITH_XPCOM)
#else /* !defined (VBOX_WITH_XPCOM) */
#endif /* !defined (VBOX_WITH_XPCOM) */
{
}
return *this;
}
/* specialization for CUnknown */
{
return *this;
}
/* @internal Used in wrappers. */
};
/* inlined CInterface methods that use CUnknown */
{
}
{
return *this;
}
/////////////////////////////////////////////////////////////////////////////
/* include the generated header containing concrete wrapper definitions */
#include "COMWrappers.h"
#endif // __COMDefs_h__