Ejemplo n.º 1
0
XnStatus PlayerNode::ProcessEachNodeLastData(XnUInt32 nIDToProcessLast)
{
	XnStatus nRetVal = XN_STATUS_OK;
	XnUInt32 nItNodeID = 0; //Node ID handled in each iteration.
	
	for (XnUInt32 i = 0; i < m_nMaxNodes; i++)
	{
		/*We switch positions between nIDToProcessLast and the last position, to make sure that nIDToProcessLast is 
		  handled last. This way the position at the end of our seek operation is right after the record we read
		  for nIDToProcessLast.*/
		if (i == nIDToProcessLast)
		{
			nItNodeID = m_nMaxNodes - 1;
		}
		else if (i == m_nMaxNodes - 1)
		{
			nItNodeID = nIDToProcessLast;
		}
		else
		{
			nItNodeID = i;
		}
		PlayerNodeInfo &pni = m_pNodeInfoMap[nItNodeID];
		if (pni.bIsGenerator)
		{
			if (!pni.bValid)
			{
				xnLogError(XN_MASK_OPEN_NI, "Node with ID %u is not valid", nItNodeID);
				XN_ASSERT(FALSE);
				return XN_STATUS_CORRUPT_FILE;
			}

			if (pni.nLastDataPos == 0)
			{
				/*This means we had to undo this node's data, but found no data frame before our main node's
			      data frame. In this case we push a 0 frame.*/
				memset(m_pRecordBuffer, 0, RECORD_MAX_SIZE);
				nRetVal = m_pNodeNotifications->OnNodeNewData(m_pNotificationsCookie, pni.strName, 0, 0, m_pRecordBuffer, RECORD_MAX_SIZE);
				XN_IS_STATUS_OK(nRetVal);
			}
			else
			{
				nRetVal = SeekStream(XN_OS_SEEK_SET, pni.nLastDataPos);
				XN_IS_STATUS_OK(nRetVal);
				nRetVal = ProcessRecord(TRUE);
				XN_IS_STATUS_OK(nRetVal);
			}
		}
	}
	//Now our position is right after the last data of the node with id nIDToProcessLast

	return XN_STATUS_OK;
}
Ejemplo n.º 2
0
XnStatus PlayerNode::ProcessUntilFirstData()
{
	XnStatus nRetVal = XN_STATUS_OK;
	//Loop until we get to the first 'data begin' marker in the file.

	while (!m_bDataBegun)
	{
		nRetVal = ProcessRecord(TRUE);	
		XN_IS_STATUS_OK(nRetVal);
	}
	
	return XN_STATUS_OK;
}
Ejemplo n.º 3
0
// PROCESS SOURCE FILE
local void ProcessSource( char *src_file ) // - starting file
{
    int kw;     // - current key-word

    ProcessMode = MODE_OUTPUT;
    SegStk = NULL;
    SourceText = NULL;
    Files = NULL;
    OpenFileNormal( src_file, "r" );
    while( Files != NULL ) {
        kw = ReadInput();
        if( kw == KW_EOF ) {
            CloseFile();
        } else {
            ProcessRecord( kw, Record );
        }
    }
}
Ejemplo n.º 4
0
void
VcfRecordBlocker::
ProcessRecordBuffer() {

    if (_recordBuffer.empty()) return;

    // every record buffer should contain an indel:
    assert(_indelIndex.size() > 0);

    const unsigned n_records(_recordBuffer.size());

    // if there's only one record, assume this is a simple insertion and don't process
    // it for overlap information:
    if (n_records>1) GroomRecordBuffer();

    // send recordbuffer on for printing/blocking:
    for (unsigned i(0); i<n_records; ++i) ProcessRecord(_recordBuffer[i]);
    _indelIndex.clear();
    _recordBuffer.clear();
}
Ejemplo n.º 5
0
XnStatus PlayerNode::HandleNodeAddedImpl(XnUInt32 nNodeID, XnProductionNodeType type, const XnChar* strName, XnCodecID compression, XnUInt32 nNumberOfFrames, XnUInt64 nMinTimestamp, XnUInt64 nMaxTimestamp)
{
	XN_VALIDATE_INPUT_PTR(m_pNodeNotifications);

	XnStatus nRetVal = XN_STATUS_OK;

	PlayerNodeInfo* pPlayerNodeInfo = GetPlayerNodeInfo(nNodeID);
	XN_VALIDATE_PTR(pPlayerNodeInfo, XN_STATUS_CORRUPT_FILE);

	//Notify node was added
	nRetVal = m_pNodeNotifications->OnNodeAdded(m_pNotificationsCookie, strName, type, compression);
	XN_IS_STATUS_OK(nRetVal);

	pPlayerNodeInfo->compression = compression;
	nRetVal = xnOSStrCopy(pPlayerNodeInfo->strName, strName, sizeof(pPlayerNodeInfo->strName));
	XN_IS_STATUS_OK(nRetVal);

	if (xnIsTypeGenerator(type))
	{
		pPlayerNodeInfo->bIsGenerator = TRUE;
	pPlayerNodeInfo->nFrames = nNumberOfFrames;
	pPlayerNodeInfo->nMaxTimeStamp = nMaxTimestamp;
	}

	//Mark this player node as valid
	pPlayerNodeInfo->bValid = TRUE;

	//Loop until this node's state is ready.
	//TODO: Check for eof
	while (!pPlayerNodeInfo->bStateReady)
	{
		nRetVal = ProcessRecord(TRUE);
		if (nRetVal != XN_STATUS_OK)
		{
			pPlayerNodeInfo->bValid = FALSE;
			return nRetVal;
		}
	}

	return (XN_STATUS_OK);
}
Ejemplo n.º 6
0
XnStatus PlayerNode::ReadNext()
{
	return ProcessRecord(TRUE);
}
Ejemplo n.º 7
0
XnStatus PlayerNode::SeekToFrameAbsolute(XnUInt32 nNodeID, XnUInt32 nDestFrame)
{
	XN_ASSERT((nNodeID != INVALID_NODE_ID) && (nNodeID < m_nMaxNodes));
	PlayerNodeInfo* pPlayerNodeInfo = &m_pNodeInfoMap[nNodeID];
	XN_ASSERT((nDestFrame > 0) && (nDestFrame <= pPlayerNodeInfo->nFrames));
	XN_VALIDATE_INPUT_PTR(m_pNodeNotifications);

	XnUInt32 nStartPos = TellStream();
	XnUInt32 nNextFrame = pPlayerNodeInfo->nCurFrame + 1;
	XnUInt32 nFrames = pPlayerNodeInfo->nFrames;
	XnStatus nRetVal = XN_STATUS_OK;

	if (nDestFrame == pPlayerNodeInfo->nCurFrame)
	{
		//Just go back to position of current frame
		nRetVal = SeekStream(XN_OS_SEEK_SET, pPlayerNodeInfo->nLastDataPos);
		XN_IS_STATUS_OK(nRetVal);
	}
	else if (nDestFrame < nNextFrame)
	{
		//Seek backwards
		XnUInt32 nDestRecordPos = pPlayerNodeInfo->newDataUndoInfo.nRecordPos;
		XnUInt32 nUndoRecordPos = pPlayerNodeInfo->newDataUndoInfo.nUndoRecordPos;
		NewDataRecordHeader record(m_pRecordBuffer, RECORD_MAX_SIZE);
		
		/*Scan back through the frames' undo positions until we get to a frame number that is smaller or equal
		  to nDestFrame. We put the position of the frame we find in nDestRecordPos. */
		do
		{
			if (nUndoRecordPos == 0)
			{
				/* The last frame we encountered doesn't have an undo frame. But this data frame can't be the first,
				   so the file is corrupt */
				XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Undo frame not found for frame in position %u", nDestRecordPos);
			}
			nRetVal = SeekStream(XN_OS_SEEK_SET, nUndoRecordPos);
			XN_IS_STATUS_OK(nRetVal);
			nDestRecordPos = nUndoRecordPos;
			record.ResetRead();
			nRetVal = ReadRecordHeader(record);
			XN_IS_STATUS_OK(nRetVal);
			if (record.GetType() != RECORD_NEW_DATA)
			{
				XN_ASSERT(FALSE);
				XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Unexpected record type: %u", record.GetType());
			}

			if (record.GetNodeID() != nNodeID)
			{
				XN_ASSERT(FALSE);
				XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Unexpected node id: %u", record.GetNodeID());
			}

			nRetVal = ReadRecordFields(record);
			XN_IS_STATUS_OK(nRetVal);
			nRetVal = record.Decode();
			XN_IS_STATUS_OK(nRetVal);
			nUndoRecordPos = record.GetUndoRecordPos();
		} while (record.GetFrameNumber() > nDestFrame);

		//Now handle the frame
		nRetVal = HandleNewDataRecord(record, FALSE);
		XnBool bUndone = FALSE;

		for (XnUInt32 i = 0; i < m_nMaxNodes; i++)
		{
			//Rollback all properties to match the state the stream was in at position nDestRecordPos
			PlayerNodeInfo &pni = m_pNodeInfoMap[i];
			for (RecordUndoInfoMap::Iterator it = pni.recordUndoInfoMap.begin(); 
				 it != pni.recordUndoInfoMap.end(); it++)
			{
				if ((it.Value().nRecordPos > nDestRecordPos) && (it.Value().nRecordPos < nStartPos))
				{
					//This property was set between nDestRecordPos and our start position, so we need to undo it.
					nRetVal = UndoRecord(it.Value(), nDestRecordPos, bUndone);
					XN_IS_STATUS_OK(nRetVal);
				}
			}

			if ((i != nNodeID) && pni.bIsGenerator)
			{
				//Undo all other generator nodes' data
				RecordUndoInfo &undoInfo = pni.newDataUndoInfo;
				if ((undoInfo.nRecordPos > nDestRecordPos) && (undoInfo.nRecordPos < nStartPos))
				{
					nRetVal = UndoRecord(undoInfo, nDestRecordPos, bUndone);
					XN_IS_STATUS_OK(nRetVal);
					if (!bUndone)
					{
						//We couldn't find a record that can undo this data record
						pni.nLastDataPos = 0;
						pni.newDataUndoInfo.Reset();
					}
				}
			}
		}

		/*Now, for each node, go to the position of the last encountered data record, and process that record
		  (including its payload).*/
		/*TODO: Optimization: remember each node's last data pos, and later, see if it changes. Only process data
		  frames of nodes whose last data pos actually changed.*/

		nRetVal = ProcessEachNodeLastData(nNodeID);
		XN_IS_STATUS_OK(nRetVal);
	}
	else //(nDestFrame >= nNextFrame)
	{
		//Skip all frames until we get to our frame number, but handle any properties we run into.
		while (pPlayerNodeInfo->nCurFrame < nDestFrame)
		{
			nRetVal = ProcessRecord(FALSE);
			XN_IS_STATUS_OK(nRetVal);
		}

		/*Now, for each node, go to the position of the last encountered data record, and process that record
		  (including its payload).*/
		/*TODO: Optimization: remember each node's last data pos, and later, see if it changes. Only process data
		  frames of nodes whose last data pos actually changed.*/
		nRetVal = ProcessEachNodeLastData(nNodeID);
		XN_IS_STATUS_OK(nRetVal);
	}

	return XN_STATUS_OK;
}
Ejemplo n.º 8
0
void 
CGenedocDoc::AutoShadeSearch(
	ShadeSegStc *pSegArr, 
	int RowCount, 
	int ShadeLevel, 
	CDisplayVars *DisplayVars, 
	ShadeSegStc *pConsensusRow
) 
{

	int i;

	DWORD OuterCount = pSegArr[0].pCGSeg->GetTextLength();
	
	// init locations
	for ( DWORD tCount = 0L; tCount < OuterCount; ++tCount ) {
	
		for ( i = 0; i < RowCount; ++i ) {

			// Lets Clear out old shades while here.
			GetLevelColors( DisplayVars, 0, 
				&(pSegArr[i].pGeneStor)[tCount].TextColor, 
				&(pSegArr[i].pGeneStor)[tCount].BackColor
			);

			char tChar = (pSegArr[i].pGeneStor)[tCount].CharGene;
			// Reset Display Char while here.
			if ( DisplayVars->GetResidueMode() == 0 ) {
				if ( m_UserVars.m_ResidueUpper == 1 ) {
					(pSegArr[i].pGeneStor)[tCount].CharDisplay = toupper(tChar);
				} else if ( m_UserVars.m_ResidueUpper == 2 ) {
					(pSegArr[i].pGeneStor)[tCount].CharDisplay = tolower(tChar);
				} else {
					(pSegArr[i].pGeneStor)[tCount].CharDisplay = tChar;
				}
			}
			if ( m_UserVars.m_TransTilde ) {
				if ( tChar == '~' ) (pSegArr[i].pGeneStor)[tCount].CharDisplay = ' ';
			}
		}
	}
			
	if ( !m_UserVars.m_ProSite ) {

		int iMXL = 0;

		POSITION sPOS = m_UserVars.listSearch.GetHeadPosition();
		while ( sPOS != NULL ) {

			stcSearch *pSearch = (stcSearch *)m_UserVars.listSearch.GetNext(sPOS);

			int iL = MotifLength( pSearch->strSearch );
			if ( iL > iMXL ) iMXL = iL;

		}

		// CByteArray
		for ( i=0; i < 26; ++i ) {
			Member[i].SetSize(iMXL);
		}
		Chosen.SetSize(iMXL);
		Max.SetSize(iMXL);
		Min.SetSize(iMXL);
		
		for ( i = 0; i < RowCount; ++i ) {

			if ( ShadeLevel != SHADELEVEL0 ) {
				// Do Search Strings ..
				POSITION sPOS = m_UserVars.listSearch.GetHeadPosition();
				while ( sPOS != NULL ) {
					stcSearch *pSearch = (stcSearch *)m_UserVars.listSearch.GetNext(sPOS);
					if ( pSearch->iEnabled ) {
						ProcessRecord( pSearch, pSegArr[i].pGeneStor, OuterCount );
					}
				}
			}
		}
		for ( i=0; i < 26; ++i ) {
			Member[i].RemoveAll();
		}
		Chosen.RemoveAll();
		Max.RemoveAll();
		Min.RemoveAll();
	} else {

		for ( i = 0; i < RowCount; ++i ) {

			if ( ShadeLevel != SHADELEVEL0 ) {
				// Do Search Strings ..
				POSITION sPOS = m_UserVars.listSearch.GetHeadPosition();
				while ( sPOS != NULL ) {
					stcSearch *pSearch = (stcSearch *)m_UserVars.listSearch.GetNext(sPOS);
					if ( pSearch->iEnabled ) {
						SearchRebase( pSearch, pSegArr[i].pGeneStor, OuterCount );
					}
				}
			}
		}
	}
}