本文整理汇总了C++中GuestEventTypes类的典型用法代码示例。如果您正苦于以下问题:C++ GuestEventTypes类的具体用法?C++ GuestEventTypes怎么用?C++ GuestEventTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GuestEventTypes类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AssertPtrReturn
int GuestFile::i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS,
void *pvData, uint32_t cbData, uint32_t *pcbWritten)
{
AssertPtrReturn(pvData, VERR_INVALID_POINTER);
AssertReturn(cbData, VERR_INVALID_PARAMETER);
LogFlowThisFunc(("uOffset=%RU64, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n",
uOffset, uTimeoutMS, pvData, cbData));
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
eventTypes.push_back(VBoxEventType_OnGuestFileWrite);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[8];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setUInt32(mData.mID /* File handle */);
paParms[i++].setUInt64(uOffset /* Offset where to starting writing */);
paParms[i++].setUInt32(cbData /* Size (in bytes) to write */);
paParms[i++].setPointer(pvData, cbData);
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_WRITE_AT, i, paParms);
if (RT_SUCCESS(vrc))
{
uint32_t cbWritten = 0;
vrc = i_waitForWrite(pEvent, uTimeoutMS, &cbWritten);
if (RT_SUCCESS(vrc))
{
LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten));
if (cbWritten)
*pcbWritten = cbWritten;
}
}
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例2: LogFlowThisFuncEnter
int GuestFile::openFile(uint32_t uTimeoutMS, int *pGuestRc)
{
LogFlowThisFuncEnter();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32, uOffset=%RU64\n",
mData.mOpenInfo.mFileName.c_str(), mData.mOpenInfo.mOpenMode.c_str(),
mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode, mData.mOpenInfo.mInitialOffset));
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[8];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(),
(ULONG)mData.mOpenInfo.mFileName.length() + 1);
paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(),
(ULONG)mData.mOpenInfo.mOpenMode.length() + 1);
paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(),
(ULONG)mData.mOpenInfo.mDisposition.length() + 1);
paParms[i++].setPointer((void*)mData.mOpenInfo.mSharingMode.c_str(),
(ULONG)mData.mOpenInfo.mSharingMode.length() + 1);
paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset);
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_OPEN, i, paParms);
if (RT_SUCCESS(vrc))
vrc = waitForStatusChange(pEvent, uTimeoutMS,
NULL /* FileStatus */, pGuestRc);
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例3: LogFlowThisFuncEnter
int GuestFile::i_openFile(uint32_t uTimeoutMS, int *pGuestRc)
{
LogFlowThisFuncEnter();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("strFile=%s, enmAccessMode=%d (%s) enmOpenAction=%d (%s) uCreationMode=%RU32, mfOpenEx=%RU32\n",
mData.mOpenInfo.mFileName.c_str(), mData.mOpenInfo.mAccessMode, mData.mOpenInfo.mpszAccessMode,
mData.mOpenInfo.mOpenAction, mData.mOpenInfo.mpszOpenAction, mData.mOpenInfo.mCreationMode,
mData.mOpenInfo.mfOpenEx));
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[8];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(),
(ULONG)mData.mOpenInfo.mFileName.length() + 1);
paParms[i++].setString(mData.mOpenInfo.mpszAccessMode);
paParms[i++].setString(mData.mOpenInfo.mpszOpenAction);
paParms[i++].setString(""); /** @todo sharing mode. */
paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
paParms[i++].setUInt64(0 /* initial offset */);
/** @todo Next protocol version: add flags, replace strings, remove initial offset. */
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_OPEN, i, paParms);
if (RT_SUCCESS(vrc))
vrc = i_waitForStatusChange(pEvent, uTimeoutMS,
NULL /* FileStatus */, pGuestRc);
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例4: AssertPtrReturn
int GuestBase::registerWaitEvent(uint32_t uSessionID, uint32_t uObjectID,
const GuestEventTypes &lstEvents,
GuestWaitEvent **ppEvent)
{
AssertPtrReturn(ppEvent, VERR_INVALID_POINTER);
uint32_t uContextID;
int rc = generateContextID(uSessionID, uObjectID, &uContextID);
if (RT_FAILURE(rc))
return rc;
rc = RTCritSectEnter(&mWaitEventCritSect);
if (RT_SUCCESS(rc))
{
try
{
GuestWaitEvent *pEvent = new GuestWaitEvent(uContextID, lstEvents);
AssertPtr(pEvent);
LogFlowThisFunc(("New event=%p, CID=%RU32\n", pEvent, uContextID));
/* Insert event into matching event group. This is for faster per-group
* lookup of all events later. */
for (GuestEventTypes::const_iterator itEvents = lstEvents.begin();
itEvents != lstEvents.end(); itEvents++)
{
mWaitEventGroups[(*itEvents)].insert(
std::pair<uint32_t, GuestWaitEvent*>(uContextID, pEvent));
/** @todo Check for key collision. */
}
/* Register event in regular event list. */
/** @todo Check for key collisions. */
mWaitEvents[uContextID] = pEvent;
*ppEvent = pEvent;
}
catch(std::bad_alloc &)
{
rc = VERR_NO_MEMORY;
}
int rc2 = RTCritSectLeave(&mWaitEventCritSect);
if (RT_SUCCESS(rc))
rc = rc2;
}
return rc;
}
示例5: LogFlowThisFunc
int GuestFile::i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType,
uint32_t uTimeoutMS, uint64_t *puOffset)
{
LogFlowThisFunc(("iOffset=%RI64, uTimeoutMS=%RU32\n",
iOffset, uTimeoutMS));
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
eventTypes.push_back(VBoxEventType_OnGuestFileOffsetChanged);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[4];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setUInt32(mData.mID /* File handle */);
paParms[i++].setUInt32(eSeekType /* Seek method */);
/** @todo uint64_t vs. int64_t! */
paParms[i++].setUInt64((uint64_t)iOffset /* Offset (in bytes) to start reading */);
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_SEEK, i, paParms);
if (RT_SUCCESS(vrc))
vrc = i_waitForOffsetChange(pEvent, uTimeoutMS, puOffset);
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例6: RTCritSectEnter
void GuestBase::unregisterWaitEvent(GuestWaitEvent *pEvent)
{
if (!pEvent) /* Nothing to unregister. */
return;
int rc = RTCritSectEnter(&mWaitEventCritSect);
if (RT_SUCCESS(rc))
{
LogFlowThisFunc(("pEvent=%p\n", pEvent));
const GuestEventTypes lstTypes = pEvent->Types();
for (GuestEventTypes::const_iterator itEvents = lstTypes.begin();
itEvents != lstTypes.end(); itEvents++)
{
/** @todo Slow O(n) lookup. Optimize this. */
GuestWaitEvents::iterator itCurEvent = mWaitEventGroups[(*itEvents)].begin();
while (itCurEvent != mWaitEventGroups[(*itEvents)].end())
{
if (itCurEvent->second == pEvent)
{
mWaitEventGroups[(*itEvents)].erase(itCurEvent++);
break;
}
else
itCurEvent++;
}
}
delete pEvent;
pEvent = NULL;
int rc2 = RTCritSectLeave(&mWaitEventCritSect);
if (RT_SUCCESS(rc))
rc = rc2;
}
}