本文整理汇总了C++中ComAssertRet函数的典型用法代码示例。如果您正苦于以下问题:C++ ComAssertRet函数的具体用法?C++ ComAssertRet怎么用?C++ ComAssertRet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ComAssertRet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adep
HRESULT USBDeviceFilters::insertDeviceFilter(ULONG aPosition,
const ComPtr<IUSBDeviceFilter> &aFilter)
{
#ifdef VBOX_WITH_USB
/* the machine needs to be mutable */
AutoMutableStateDependency adep(m->pParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
IUSBDeviceFilter *iFilter = aFilter;
ComObjPtr<USBDeviceFilter> pFilter = static_cast<USBDeviceFilter*>(iFilter);
if (pFilter->mInList)
return setError(VBOX_E_INVALID_OBJECT_STATE,
tr("The given USB device pFilter is already in the list"));
/* backup the list before modification */
m->llDeviceFilters.backup();
/* iterate to the position... */
DeviceFilterList::iterator it;
if (aPosition < m->llDeviceFilters->size())
{
it = m->llDeviceFilters->begin();
std::advance(it, aPosition);
}
else
it = m->llDeviceFilters->end();
/* ...and insert */
m->llDeviceFilters->insert(it, pFilter);
pFilter->mInList = true;
/* notify the proxy (only when it makes sense) */
if (pFilter->i_getData().mActive && Global::IsOnline(adep.machineState())
&& pFilter->i_getData().mRemote.isMatch(false))
{
USBProxyService *pProxySvc = m->pHost->i_usbProxyService();
ComAssertRet(pProxySvc, E_FAIL);
ComAssertRet(pFilter->i_getId() == NULL, E_FAIL);
pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
}
alock.release();
AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
m->pParent->i_setModified(Machine::IsModified_USB);
mlock.release();
return S_OK;
#else /* VBOX_WITH_USB */
NOREF(aPosition);
NOREF(aFilter);
ReturnComNotImplemented();
#endif /* VBOX_WITH_USB */
}
示例2: autoCaller
/**
* Called by setter methods of all USB device filters.
*
* @note Locks nothing.
*/
HRESULT USBController::onDeviceFilterChange (USBDeviceFilter *aFilter,
BOOL aActiveChanged /* = FALSE */)
{
AutoCaller autoCaller(this);
AssertComRCReturnRC(autoCaller.rc());
/* we need the machine state */
AutoAnyStateDependency adep(m->pParent);
AssertComRCReturnRC(adep.rc());
/* nothing to do if the machine isn't running */
if (!Global::IsOnline (adep.machineState()))
return S_OK;
/* we don't modify our data fields -- no need to lock */
if ( aFilter->mInList
&& m->pParent->isRegistered())
{
USBProxyService *service = m->pHost->usbProxyService();
ComAssertRet(service, E_FAIL);
if (aActiveChanged)
{
if (aFilter->getData().mRemote.isMatch (false))
{
/* insert/remove the filter from the proxy */
if (aFilter->getData().mActive)
{
ComAssertRet(aFilter->getId() == NULL, E_FAIL);
aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter);
}
else
{
ComAssertRet(aFilter->getId() != NULL, E_FAIL);
service->removeFilter(aFilter->getId());
aFilter->getId() = NULL;
}
}
}
else
{
if (aFilter->getData().mActive)
{
/* update the filter in the proxy */
ComAssertRet(aFilter->getId() != NULL, E_FAIL);
service->removeFilter(aFilter->getId());
if (aFilter->getData().mRemote.isMatch (false))
{
aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter);
}
}
}
}
return S_OK;
}
示例3: LogFlowThisFunc
/**
* Initializes the audio adapter object.
*
* @param aParent Handle of the parent object.
*/
HRESULT AudioAdapter::init (Machine *aParent)
{
LogFlowThisFunc(("aParent=%p\n", aParent));
ComAssertRet(aParent, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
/* Get the default audio driver out of the system properties */
ComPtr<IVirtualBox> VBox;
HRESULT rc = aParent->COMGETTER(Parent)(VBox.asOutParam());
if (FAILED(rc)) return rc;
ComPtr<ISystemProperties> sysProps;
rc = VBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
if (FAILED(rc)) return rc;
AudioDriverType_T defaultAudioDriver;
rc = sysProps->COMGETTER(DefaultAudioDriver)(&defaultAudioDriver);
if (FAILED(rc)) return rc;
unconst(mParent) = aParent;
/* mPeer is left null */
mData.allocate();
mData->mAudioDriver = defaultAudioDriver;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例4: adep
HRESULT USBDeviceFilter::setRemote(const com::Utf8Str &aRemote)
{
/* the machine needs to be mutable */
AutoMutableOrSavedOrRunningStateDependency adep(mParent->i_getMachine());
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
Bstr bRemote = Bstr(aRemote).raw();
if (bd->mRemote.string() != bRemote)
{
BackupableUSBDeviceFilterData::BOOLFilter flt = bRemote;
ComAssertRet(!flt.isNull(), E_FAIL);
if (!flt.isValid())
return setError(E_INVALIDARG,
tr("Remote state filter string '%s' is not valid (error at position %d)"),
aRemote.c_str(), flt.errorPosition() + 1);
m_fModified = true;
ComObjPtr<Machine> pMachine = mParent->i_getMachine();
bd.backup();
bd->mRemote = flt;
// leave the lock before informing callbacks
alock.release();
AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
pMachine->i_setModified(Machine::IsModified_USB);
mlock.release();
return mParent->i_onDeviceFilterChange(this);
}
return S_OK;
}
示例5: LogFlowThisFunc
/**
* Initializes the guest object given another guest object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*
* @note Locks @a aThat object for reading.
*/
HRESULT USBDeviceFilter::initCopy(USBDeviceFilters *aParent, USBDeviceFilter *aThat)
{
LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
ComAssertRet(aParent && aThat, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
unconst(mParent) = aParent;
/* mPeer is left null */
m_fModified = false;
/* sanity */
AutoCaller thatCaller(aThat);
AssertComRCReturnRC(thatCaller.rc());
AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
bd.attachCopy(aThat->bd);
/* reset the arbitrary ID field
* (this field is something unique that two distinct objects, even if they
* are deep copies of each other, should not share) */
bd->mId = NULL;
mInList = aThat->mInList;
/* Confirm successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例6: LogFlowThisFunc
/**
* Initializes the USB controller object.
*
* @returns COM result indicator.
* @param aParent Pointer to our parent object.
* @param aName The name of the USB controller.
* @param enmType The USB controller type.
*/
HRESULT USBController::init(Machine *aParent, const Utf8Str &aName, USBControllerType_T enmType)
{
LogFlowThisFunc(("aParent=%p aName=\"%s\"\n", aParent, aName.c_str()));
ComAssertRet(aParent && !aName.isEmpty(), E_INVALIDARG);
if ( (enmType <= USBControllerType_Null)
|| (enmType > USBControllerType_XHCI))
return setError(E_INVALIDARG,
tr("Invalid USB controller type"));
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data(aParent);
/* mPeer is left null */
m->bd.allocate();
m->bd->strName = aName;
m->bd->enmType = enmType;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例7: LogFlowThisFunc
/**
* Initializes the machine debugger object.
*
* @returns COM result indicator
* @param aParent handle of our parent object
*/
HRESULT MachineDebugger::init(Console *aParent)
{
LogFlowThisFunc(("aParent=%p\n", aParent));
ComAssertRet(aParent, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
unconst(mParent) = aParent;
for (unsigned i = 0; i < RT_ELEMENTS(maiQueuedEmExecPolicyParams); i++)
maiQueuedEmExecPolicyParams[i] = UINT8_MAX;
mSingleStepQueued = -1;
mRecompileUserQueued = -1;
mRecompileSupervisorQueued = -1;
mPatmEnabledQueued = -1;
mCsamEnabledQueued = -1;
mLogEnabledQueued = -1;
mVirtualTimeRateQueued = UINT32_MAX;
mFlushMode = false;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例8: LogFlowThisFunc
/**
* Initializes the medium attachment object given another guest object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*/
HRESULT MediumAttachment::initCopy(Machine *aParent, MediumAttachment *aThat)
{
LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
ComAssertRet(aParent && aThat, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data(aParent);
/* m->pPeer is left null */
AutoCaller thatCaller(aThat);
AssertComRCReturnRC(thatCaller.rc());
AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
m->bd.attachCopy(aThat->m->bd);
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
/* Construct a short log name for this attachment. */
i_updateLogName();
LogFlowThisFunc(("LEAVE - %s\n", i_getLogName()));
return S_OK;
}
示例9: LogFlowThisFunc
HRESULT DisplaySourceBitmap::init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo)
{
LogFlowThisFunc(("[%u]\n", uScreenId));
ComAssertRet(!pDisplay.isNull(), E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m.pDisplay = pDisplay;
m.uScreenId = uScreenId;
m.pFBInfo = pFBInfo;
m.pu8Allocated = NULL;
m.pu8Address = NULL;
m.ulWidth = 0;
m.ulHeight = 0;
m.ulBitsPerPixel = 0;
m.ulBytesPerLine = 0;
m.bitmapFormat = BitmapFormat_Opaque;
int rc = initSourceBitmap(uScreenId, pFBInfo);
if (RT_FAILURE(rc))
return E_FAIL;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例10: LogFlowThisFunc
/**
* Initializes the bandwidth group object.
*
* @returns COM result indicator.
* @param aParent Pointer to our parent object.
* @param aName Name of the bandwidth group.
* @param aType Type of the bandwidth group (net, disk).
* @param aMaxBytesPerSec Maximum bandwidth for the bandwidth group.
*/
HRESULT BandwidthGroup::init(BandwidthControl *aParent,
const Utf8Str &aName,
BandwidthGroupType_T aType,
LONG64 aMaxBytesPerSec)
{
LogFlowThisFunc(("aParent=%p aName=\"%s\"\n",
aParent, aName.c_str()));
ComAssertRet(aParent && !aName.isEmpty(), E_INVALIDARG);
if ( (aType <= BandwidthGroupType_Null)
|| (aType > BandwidthGroupType_Network))
return setError(E_INVALIDARG,
tr("Invalid bandwidth group type type"));
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data(aParent);
/* m->pPeer is left null */
m->bd.allocate();
m->bd->strName = aName;
m->bd->enmType = aType;
m->bd->cReferences = 0;
m->bd->aMaxBytesPerSec = aMaxBytesPerSec;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例11: ComAssertRet
HRESULT Guest::facilityUpdate(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus)
{
ComAssertRet(enmFacility < INT32_MAX, E_INVALIDARG);
HRESULT rc;
RTTIMESPEC tsNow;
RTTimeNow(&tsNow);
FacilityMapIter it = mData.mFacilityMap.find((AdditionsFacilityType_T)enmFacility);
if (it != mData.mFacilityMap.end())
{
AdditionsFacility *pFac = it->second;
rc = pFac->update((AdditionsFacilityStatus_T)enmStatus, tsNow);
}
else
{
ComObjPtr<AdditionsFacility> pFacility;
pFacility.createObject();
ComAssert(!pFacility.isNull());
rc = pFacility->init(this,
(AdditionsFacilityType_T)enmFacility,
(AdditionsFacilityStatus_T)enmStatus);
if (SUCCEEDED(rc))
mData.mFacilityMap.insert(std::make_pair((AdditionsFacilityType_T)enmFacility, pFacility));
}
LogFlowFunc(("Returned with rc=%Rrc\n"));
return rc;
}
示例12: LogFlowThisFunc
/**
* Initializes the USB controller object given another guest object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*/
HRESULT USBDeviceFilters::initCopy(Machine *aParent, USBDeviceFilters *aPeer)
{
LogFlowThisFunc(("aParent=%p, aPeer=%p\n", aParent, aPeer));
ComAssertRet(aParent && aPeer, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data(aParent);
/* mPeer is left null */
AutoWriteLock thatlock(aPeer COMMA_LOCKVAL_SRC_POS);
#ifdef VBOX_WITH_USB
/* create private copies of all filters */
m->llDeviceFilters.allocate();
DeviceFilterList::const_iterator it = aPeer->m->llDeviceFilters->begin();
while (it != aPeer->m->llDeviceFilters->end())
{
ComObjPtr<USBDeviceFilter> pFilter;
pFilter.createObject();
pFilter->initCopy(this, *it);
m->llDeviceFilters->push_back(pFilter);
++it;
}
#endif /* VBOX_WITH_USB */
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例13: LogFlowThisFunc
/**
* Initializes the Serial Port object given another serial port object
* (a kind of copy constructor). This object shares data with
* the object passed as an argument.
*
* @note This object must be destroyed before the original object
* it shares data with is destroyed.
*
* @note Locks @a aThat object for reading.
*/
HRESULT SerialPort::init(Machine *aParent, SerialPort *aThat)
{
LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
ComAssertRet(aParent && aThat, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data();
unconst(m->pMachine) = aParent;
unconst(m->pPeer) = aThat;
AutoCaller thatCaller (aThat);
AssertComRCReturnRC(thatCaller.rc());
AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
m->bd.share (aThat->m->bd);
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例14: LogFlowThisFunc
/**
* Initializes the guest OS type object.
*
* @returns COM result indicator
* @param aFamilyId os family short name string
* @param aFamilyDescription os family name string
* @param aId os short name string
* @param aDescription os name string
* @param aOSType global OS type ID
* @param aOSHint os configuration hint
* @param aRAMSize recommended RAM size in megabytes
* @param aVRAMSize recommended video memory size in megabytes
* @param aHDDSize recommended HDD size in bytes
*/
HRESULT GuestOSType::init(const Global::OSType &ostype)/*const char *aFamilyId, const char *aFamilyDescription,
const char *aId, const char *aDescription,
VBOXOSTYPE aOSType, uint32_t aOSHint,
uint32_t aRAMSize, uint32_t aVRAMSize, uint64_t aHDDSize,
NetworkAdapterType_T aNetworkAdapterType,
uint32_t aNumSerialEnabled,
StorageControllerType_T aDVDStorageControllerType,
StorageBus_T aDVDStorageBusType,
StorageControllerType_T aHDStorageControllerType,
StorageBus_T aHDStorageBusType,
ChipsetType_T aChipsetType
AudioControllerType_T aAudioControllerType*/
{
#if 0
LogFlowThisFunc(("aFamilyId='%s', aFamilyDescription='%s', "
"aId='%s', aDescription='%s', "
"aType=%d, aOSHint=%x, "
"aRAMSize=%d, aVRAMSize=%d, aHDDSize=%lld, "
"aNetworkAdapterType=%d, aNumSerialEnabled=%d, "
"aStorageControllerType=%d\n",
aFamilyId, aFamilyDescription,
aId, aDescription,
aOSType, aOSHint,
aRAMSize, aVRAMSize, aHDDSize,
aNetworkAdapterType,
aNumSerialEnabled,
aStorageControllerType));
#endif
ComAssertRet(ostype.familyId && ostype.familyDescription && ostype.id && ostype.description, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
unconst(mFamilyID) = ostype.familyId;
unconst(mFamilyDescription) = ostype.familyDescription;
unconst(mID) = ostype.id;
unconst(mDescription) = ostype.description;
unconst(mOSType) = ostype.osType;
unconst(mOSHint) = ostype.osHint;
unconst(mRAMSize) = ostype.recommendedRAM;
unconst(mVRAMSize) = ostype.recommendedVRAM;
unconst(mHDDSize) = ostype.recommendedHDD;
unconst(mNetworkAdapterType) = ostype.networkAdapterType;
unconst(mNumSerialEnabled) = ostype.numSerialEnabled;
unconst(mDVDStorageControllerType) = ostype.dvdStorageControllerType;
unconst(mDVDStorageBusType) = ostype.dvdStorageBusType;
unconst(mHDStorageControllerType) = ostype.hdStorageControllerType;
unconst(mHDStorageBusType) = ostype.hdStorageBusType;
unconst(mChipsetType) = ostype.chipsetType;
unconst(mAudioControllerType) = ostype.audioControllerType;
unconst(mAudioCodecType) = ostype.audioCodecType;
/* Confirm a successful initialization when it's the case */
autoInitSpan.setSucceeded();
return S_OK;
}
示例15: LogFlowThisFunc
HRESULT PCIDeviceAttachment::initCopy(IMachine *aParent, PCIDeviceAttachment *aThat)
{
LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
ComAssertRet(aParent && aThat, E_INVALIDARG);
return init(aParent, aThat->m->DevName, aThat->m->HostAddress, aThat->m->GuestAddress, aThat->m->fPhysical);
}