BOOL KTrackList::Save() { BOOL bResult = false; int nRetCode = 0; ITabFile* piTabFile = NULL; int nLine = 0; char szFileName[MAX_PATH]; snprintf(szFileName, sizeof(szFileName), "%s/%s/track.tab", SETTING_DIR, TRACK_DIR); szFileName[sizeof(szFileName) - 1] = '\0'; piTabFile = g_CreateTabFile(); KGLOG_PROCESS_ERROR(piTabFile); nRetCode = piTabFile->InsertNewCol(COL_ID); KGLOG_PROCESS_ERROR(nRetCode != -1); nRetCode = piTabFile->InsertNewCol(COL_MAP); KGLOG_PROCESS_ERROR(nRetCode != -1); nRetCode = piTabFile->InsertNewCol(COL_DESC); KGLOG_PROCESS_ERROR(nRetCode != -1); nLine = 2; for (KTRACK_TABLE::iterator it = m_TrackTable.begin(); it != m_TrackTable.end(); ++it) { DWORD dwID = it->first; KTRACK_INFO* pTrackInfo = &it->second; nRetCode = piTabFile->WriteInteger(nLine, COL_ID, dwID); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = piTabFile->WriteInteger(nLine, COL_MAP, pTrackInfo->dwMapID); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = piTabFile->WriteString(nLine, COL_DESC, pTrackInfo->szDesc); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = SaveTrack(dwID, pTrackInfo->Track); KGLOG_PROCESS_ERROR(nRetCode); nLine++; } nRetCode = piTabFile->Save(szFileName); KGLOG_PROCESS_ERROR(nRetCode); bResult = true; Exit0: KG_COM_RELEASE(piTabFile); return bResult; }
~CvBlobTrackGen1() { int i; for(i=m_TrackList.GetBlobNum();i>0;--i) { DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i-1); if(!pTrack->Saved) { /* Save track: */ SaveTrack(pTrack, m_pFileName, m_BlobSizeNorm); } /* Save track. */ /* Delete sequence: */ delete pTrack->pSeq; pTrack->pSeq = NULL; } /* Check next track. */ } /* Destructor. */
void Process(IplImage* /*pImg*/ = NULL, IplImage* /*pFG*/ = NULL) { int i; for(i=m_TrackList.GetBlobNum(); i>0; --i) { DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i-1); if(pTrack->FrameLast < m_Frame && !pTrack->Saved) { /* Save track: */ SaveTrack(pTrack, m_pFileName, m_BlobSizeNorm); if(pTrack->Saved) { /* delete sequence */ delete pTrack->pSeq; pTrack->pSeq = NULL; m_TrackList.DelBlob(i-1); } } /* Save track. */ } /* Check next track. */ m_Frame++; }
void MIDI::Save( const IDataStream& Stream ) const { ASSERT( m_Header.m_Header.m_ChunkID == 'MThd' ); ASSERT( m_Header.m_Header.m_ChunkSize == 6 ); ASSERT( m_Header.m_FormatType <= 2 ); SMIDIFileHeader HeaderCopy = m_Header; Endian::SwapInPlace( HeaderCopy.m_Header.m_ChunkID ); Endian::SwapInPlace( HeaderCopy.m_Header.m_ChunkSize ); Endian::SwapInPlace( HeaderCopy.m_FormatType ); Endian::SwapInPlace( HeaderCopy.m_NumTracks ); Endian::SwapInPlace( HeaderCopy.m_TimeDivision ); Stream.Write( 14, &HeaderCopy ); for( uint TrackIndex = 0; TrackIndex < m_Header.m_NumTracks; ++TrackIndex ) { //PRINTF( "======== Saving track %d ========\n", TrackIndex ); SaveTrack( Stream, m_Tracks[ TrackIndex ] ); } }