void skelJointsRecorder::updatePlaying(int _mov, bool _loop) { if(!recording && playing) { playElapsed += _mov; if(playElapsed > getRecordLength()) { if(_loop) { playElapsed = 0; } else { playElapsed = getRecordLength(); } } } }
char* Page::getRecord ( int index ){ int offset = getRecordOffset( index ); int length = getRecordLength( index ); tempStrCounter = length; memcpy( tempStr, content + offset, sizeof( char ) * length ); tempStr[ length ] = '\0'; return tempStr; }
//compress a page, used for split page void Page::adjustPage( ){ int nextFree = 4; int slotSize = getSlotNumber(); int length, offset; int counter = getSlotNumber(); int location = 0; for ( int i = 0; i < slotSize; i ++ ) { length = getRecordLength( i ); //if the length is -1,it means that this data not in this page if ( length == -1 ) counter --; else{ bool flag = 0; //find a slot with record length of -1,if it succeed, then move the data into this slot for (int j = location; j < i; j ++ ) if ( getRecordLength( j ) == -1 ) { location = j; flag = 1; break; } if ( flag == 1 ){ offset = getRecordOffset( i ); memcpy( content + nextFree, content + offset, sizeof( char ) * length ); setRecordOffset( location, nextFree ); setRecordLength( location, length ); setRecordLength( i, -1 ); } nextFree += length; } } //update free offset and slot number setSlotNumber( counter ); setFreeOffset( nextFree ); }
//------------------------------------------------------------------------------ // openDatabaseFile() -- creates and opens the database file //------------------------------------------------------------------------------ bool Database::openDatabaseFile() { // Close any old files and set the record length db->setRecordLength(getRecordLength()); // create keys ncache = getMaxRecords(); if (rl != nullptr) delete[] rl; rl = new Key*[ncache]; if (isMessageEnabled(MSG_DEBUG)) { std::cout << "db = " << this << ", ncache = " << ncache << std::endl; } // open the database file db->open(); return db->isReady(); }