void Card::deleteRecord(void){ QSqlDatabase db; db.removeDatabase("qt_sql_default_connection"); db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("www.themindspot.com"); db.setPort(3306); db.setDatabaseName("themind1_AMS"); db.setUserName("themind1_ams"); db.setPassword("nerdsrule"); db.open(); QSqlQuery record; record.prepare("DELETE FROM SurveyPerson WHERE surveyPersonID = ?"); record.addBindValue(cardID->text().toInt()); record.exec(); record.clear(); db.close(); clearFields(); emit newRecord(); return; }
StatusWith<DiskLoc> HeapRecordStore::updateRecord(OperationContext* txn, const DiskLoc& loc, const char* data, int len, bool enforceQuota, UpdateMoveNotifier* notifier ) { HeapRecord* oldRecord = recordFor( loc ); int oldLen = oldRecord->size; if (_isCapped && len > oldLen) { return StatusWith<DiskLoc>( ErrorCodes::InternalError, "failing update: objects in a capped ns cannot grow", 10003 ); } HeapRecord newRecord(len); memcpy(newRecord.data.get(), data, len); txn->recoveryUnit()->registerChange(new RemoveChange(_data, loc, *oldRecord)); _data->dataSize += len - oldLen; *oldRecord = newRecord; cappedDeleteAsNeeded(txn); return StatusWith<DiskLoc>(loc); }
void CSMTools::FixLandsAndLandTexturesMergeStage::perform (int stage, CSMDoc::Messages& messages) { if (stage < mState.mTarget->getData().getLand().getSize()) { CSMWorld::IdTable& landTable = dynamic_cast<CSMWorld::IdTable&>( *mState.mTarget->getData().getTableModel(CSMWorld::UniversalId::Type_Lands)); CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&>( *mState.mTarget->getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures)); std::string id = mState.mTarget->getData().getLand().getId(stage); CSMWorld::TouchLandCommand cmd(landTable, ltexTable, id); cmd.redo(); // Get rid of base data const CSMWorld::Record<CSMWorld::Land>& oldRecord = mState.mTarget->getData().getLand().getRecord (stage); CSMWorld::Record<CSMWorld::Land> newRecord(CSMWorld::RecordBase::State_ModifiedOnly, nullptr, &oldRecord.get()); mState.mTarget->getData().getLand().setRecord(stage, newRecord); } }
Status HeapRecordStore::updateWithDamages( OperationContext* txn, const DiskLoc& loc, const RecordData& oldRec, const char* damageSource, const mutablebson::DamageVector& damages ) { HeapRecord* oldRecord = recordFor( loc ); const int len = oldRecord->size; HeapRecord newRecord(len); memcpy(newRecord.data.get(), oldRecord->data.get(), len); txn->recoveryUnit()->registerChange(new RemoveChange(_data, loc, *oldRecord)); *oldRecord = newRecord; cappedDeleteAsNeeded(txn); char* root = newRecord.data.get(); mutablebson::DamageVector::const_iterator where = damages.begin(); const mutablebson::DamageVector::const_iterator end = damages.end(); for( ; where != end; ++where ) { const char* sourcePtr = damageSource + where->sourceOffset; char* targetPtr = root + where->targetOffset; std::memcpy(targetPtr, sourcePtr, where->size); } *oldRecord = newRecord; return Status::OK(); }
bool PoitemTableModel::insertRowIntoTable(const QSqlRecord& record) { if (record.isEmpty()) return true; bool isNull = true; for (int i = 0; i < record.count(); i++) { if (i == record.indexOf("poitem_pohead_id") || (record.value(i).toString().isEmpty() && (i == record.indexOf("poitem_status") || i == record.indexOf("poitem_vend_item_descrip") || i == record.indexOf("poitem_vend_uom") || i == record.indexOf("poitem_vend_item_number") || i == record.indexOf("poitem_comments") ))) continue; isNull &= record.isNull(i); } if (isNull) return true; QSqlRecord newRecord(record); if (! validRow(newRecord)) return false; return QSqlRelationalTableModel::insertRowIntoTable(newRecord); }
void MainWindow::setWindowFields(void){ //card->setMaximumWidth(460); card->setMaximumHeight(450); //cardList->setMaximumWidth(175); connect(card, SIGNAL(newRecord()), this, SLOT(update()));// Refresh list with new entry. connect(cardList->theList, SIGNAL(doubleClicked(QModelIndex)), card, SLOT(editFormMapItem(QModelIndex)));// load selected list item to card. }
int main() { FILE *cfPtr; /* credit.dat file pointer */ int choice; /* user's choice */ /* fopen opens the file; exits if file cannot be opened */ if ( ( cfPtr = fopen( "credit.dat", "rb+" ) ) == NULL ) { printf( "File could not be opened.\n" ); } /* end if */ else { /* enable user to specify action */ while ( ( choice = enterChoice() ) != 6 ) { switch ( choice ) { /* create text file from record file */ case 1: textFile( cfPtr ); break; /* update record */ case 2: updateRecord( cfPtr ); break; /* create record */ case 3: newRecord( cfPtr ); break; /* delete existing record */ case 4: deleteRecord( cfPtr ); break; /* sum up balances of valid records and record sum in text file */ case 5: sumRecords( cfPtr ); break; /* display message if user does not select valid choice */ default: printf( "Incorrect choice\n" ); break; } /* end switch */ } /* end while */ fclose( cfPtr ); /* fclose closes the file */ } /* end else */ return 0; /* indicates successful termination */ } /* end main */
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Returns a new record that can be inserted in the // folder // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// ptr<directoryRecord> dicomDir::getNewRecord() { ptr<data> recordsTag(m_pDataSet->getTag(0x0004, 0, 0x1220, true)); ptr<dataSet> recordDataSet(new dataSet); recordsTag->appendDataSet(recordDataSet); ptr<directoryRecord> newRecord(new directoryRecord(recordDataSet)); m_recordsList.push_back(newRecord); return newRecord; }
bool PoitemTableModel::updateRowInTable(int row, const QSqlRecord& record) { // touch everything so we can distinguish unchanged fields from NULL/0 as new val for (int i = 0; i < columnCount(); i++) setData(index(row, i), data(index(row, i))); QSqlRecord newRecord(record); if (! validRow(newRecord)) return false; return QSqlRelationalTableModel::updateRowInTable(row, newRecord); }
void CSMWorld::RefIdData::copyTo (int index, RefIdData& target) const { LocalIndex localIndex = globalToLocalIndex (index); RefIdDataContainerBase *source = mRecordContainers.find (localIndex.second)->second; std::string id = source->getId (localIndex.first); std::auto_ptr<CSMWorld::RecordBase> newRecord (source->getRecord (localIndex.first).modifiedCopy()); target.insertRecord (*newRecord, localIndex.second, id); }
int main() { srand(time(0)); Process* arrivalQueue = randomProcessQueue(PROCESS_COUNT); sortProcessesByArrival(arrivalQueue, 0, PROCESS_COUNT - 1); Process* readyQueue = (Process*) malloc(PROCESS_COUNT * sizeof(Process)); int i = 0, size = 0; int shortestProcessIndex = 0; int currentProcessIndex = 0; bool okToEnd = false; Record record = newRecord(); while(!okToEnd) { Timeslice* timeslice = (Timeslice*) malloc(sizeof(Timeslice)); (*timeslice).index = i; updateReadyQueue(arrivalQueue, readyQueue, i, &size); findShortestProcessIndex(readyQueue, &shortestProcessIndex, size); if(size > 0 && (readyQueue[shortestProcessIndex].timeRemaining > 0)) { (*timeslice).pid = (char) (65 + shortestProcessIndex); readyQueue[shortestProcessIndex].id = (*timeslice).pid; if(readyQueue[shortestProcessIndex].runtime == readyQueue[shortestProcessIndex].timeRemaining) { readyQueue[shortestProcessIndex].responseTime = ((float) i) - readyQueue[shortestProcessIndex].arrival; } readyQueue[shortestProcessIndex].timeRemaining = readyQueue[shortestProcessIndex].timeRemaining - 1.0f; int j; for(j = 0; j < size; j++) { if(j != shortestProcessIndex) readyQueue[j].waitTime += 1.0f; } if(readyQueue[shortestProcessIndex].timeRemaining <= 0) { readyQueue[shortestProcessIndex].timeFinished = i + 1; readyQueue[shortestProcessIndex].turnaroundTime = ((float) i + 1) - readyQueue[shortestProcessIndex].arrival + readyQueue[shortestProcessIndex].timeRemaining; addProcess(&record, readyQueue[shortestProcessIndex]); if(i >= SIMULATION_LENGTH) { okToEnd = true; } } } else { (*timeslice).pid = '-'; } addTimeslice(&record, (*timeslice)); i++; } printRecord(record); return 0; }
void Card::addRecord(void){ if ( readyToSubmit() == false){ return; } QSqlDatabase db; db.removeDatabase("qt_sql_default_connection"); db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("www.themindspot.com"); db.setPort(3306); db.setDatabaseName("themind1_AMS"); db.setUserName("themind1_ams"); db.setPassword("nerdsrule"); db.open(); QSqlQuery record; record.prepare("INSERT INTO `SurveyPerson` (`surveyPersonID`, `surveyID`, `firstName`, `middleInitial`, `lastName`, `emailAddress`, `emailDomain`, `isMember`)" "VALUES (:id, :sid, :f, :mi, :l, :ea, :ed, :member)"); record.bindValue(":id", NULL); record.bindValue(":sid", 1); record.bindValue(":f",fnText->text()); record.bindValue(":mi",miText->text()); record.bindValue(":l",lnText->text()); record.bindValue(":ea",eaText->text()); record.bindValue(":ed",edText->text()); record.bindValue(":member",isMember->isChecked()); record.exec(); int spid = record.lastInsertId().toInt(); record.prepare("INSERT INTO `SurveyResult` (`surveyResultID`, `surveyPersonID`, `q0`, `q1`, `q2`, `q3`, `q4`, `q5`)" "VALUES (:id, :spid, :q0, :q1, :q2, :q3, :q4, :q5)"); record.bindValue(":id", NULL); record.bindValue(":spid", spid); record.bindValue(":q0",q0->isChecked()); record.bindValue(":q1",q1->isChecked()); record.bindValue(":q2",q2->isChecked()); record.bindValue(":q3",q3->isChecked()); record.bindValue(":q4",q4->isChecked()); record.bindValue(":q5",q5->isChecked()); record.exec(); db.close(); clearFields(); emit newRecord(); return; }
bool BodhiSubtitle::split(int sequence, long timeOffset) { if (timeOffset < m_minTimeLength) return false; SrtRecordPtr record = getRecord(sequence); Q_ASSERT(record); if (record->endTime - timeOffset < m_minTimeLength) return false; SrtRecordPtr newRecord(new SrtRecord(sequence+1, record->startTime + timeOffset, record->endTime)); record->endTime = newRecord->startTime; updateSequence(newRecord->sequence, 1); m_data.insert(newRecord->sequence, newRecord); m_changed = true; return true; }
void Card::editRecord(void){ if ( readyToSubmit() == false){ return; } QSqlDatabase db; db.removeDatabase("qt_sql_default_connection"); db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("www.themindspot.com"); db.setPort(3306); db.setDatabaseName("themind1_AMS"); db.setUserName("themind1_ams"); db.setPassword("nerdsrule"); db.open(); QSqlQuery record; record.prepare("UPDATE SurveyPerson SET firstName = ?, middleInitial = ?, lastName = ?, emailAddress = ?, emailDomain = ?, isMember = ? WHERE surveyPersonID = ?"); record.addBindValue(fnText->text()); record.addBindValue(miText->text()); record.addBindValue(lnText->text()); record.addBindValue(eaText->text()); record.addBindValue(edText->text()); record.addBindValue(isMember->isChecked()); record.addBindValue(cardID->text().toInt()); record.exec(); record.prepare("UPDATE SurveyResult SET q0 = ?, q1 = ?, q2 = ?, q3 = ?, q4 = ?, q5 = ? WHERE surveyPersonID = ?"); record.addBindValue(q0->isChecked()); record.addBindValue(q1->isChecked()); record.addBindValue(q2->isChecked()); record.addBindValue(q3->isChecked()); record.addBindValue(q4->isChecked()); record.addBindValue(q5->isChecked()); record.addBindValue(cardID->text().toInt()); record.exec(); record.clear(); db.close(); clearFields(); emit newRecord(); return; }
void* JMemoryManager::New ( const size_t size, const JCharacter* file, const JUInt32 line, const JBoolean isArray ) { if (theAbortUnknownAllocFlag && line == 0) { cout << "Memory allocated by unknown code, aborting...\n" << endl; abort(); } const size_t trueSize = size ? size : 1; void* newBlock = malloc(trueSize); if (newBlock == NULL) { cout << "failed to allocate block of size " << trueSize << endl; } assert(newBlock != NULL); if (theInitializeFlag) { memset(newBlock, theAllocateGarbage, trueSize); } const JBoolean isManager = JI2B(theConstructingFlag || Instance()->itsRecursionDepth > 0 || theInternalFlag); JMMRecord newRecord(GetNewID(), newBlock, trueSize, file, line, isArray, isManager); if (theConstructingFlag || Instance()->itsRecursionDepth > 0) { assert(theAllocStackSize < theStackMax); theAllocStack[theAllocStackSize] = newRecord; theAllocStackSize++; } else { Instance()->AddNewRecord(newRecord); } return newBlock; }
/* * ---------------------------------------------------------- * RJRead() * ---------------------------------------------------------- */ int RJRead( RJFILE *rf ) // untill empty { int i; char *p; newRecord( rf ); for( i=0; i<keynum; i++ ) { if (!(cfg_readLine( rf->handle, rf->buffer, line_buf_size ))) return 0; // end if ( strnicmp( rf->buffer, FieldName[i].qkey, strlen(FieldName[i].qkey)) != 0 ) return 0; // error journal record p = strchr( rf->buffer, '=' ); if ( p == NULL ) return 0; p++; trim(p); writeContent( rf, 100+i, p ); } return 1; }
int main(int argc, const char * argv[]) { //test list List *StudentSystem = (List *)malloc(sizeof(List)); initList(StudentSystem, matchRecord, cmpRecord); StudentRecord *studentData = (StudentRecord *)malloc(sizeof(StudentRecord)); newRecord(studentData); showRecord(studentData); insertListElmtNext(StudentSystem, StudentSystem->tail, (void *)studentData); showList(StudentSystem); removeListElmtNext(StudentSystem, StudentSystem->head, (void **)&studentData); showList(StudentSystem); /*test record.h Student func Student *studentA = (Student *)malloc(sizeof(Student)); newRecord(studentA); showRecord(studentA); free(studentA); if (studentA) { printf("existing %d", studentA->iNumber); } */ return 0; }
TractionTypeView::TractionTypeView(Configuration *cfg, QObject *parent) : QObject(parent) { m_parent = parent; config = Configuration::instance(); //sql->setConfig(config); sql = SQL::instance(); mainWindow* myParent = qobject_cast<mainWindow*>(m_parent); tableView = myParent->ui->tblTractionTypes; tableView->verticalHeader()->resize(2,20); QSqlDatabase db = QSqlDatabase::database(); qDebug()<<db.databaseName(); connect(tableView->verticalHeader(), SIGNAL(sectionCountChanged(int,int)), this, SLOT(Resize(int,int))); tableView->setAlternatingRowColors(true); model = new MyTractionTypesTableModel(this, db); model->setTable("TractionTypes"); model->setEditStrategy(QSqlTableModel::OnFieldChange); model->query().setForwardOnly(false); model->select(); QString name = model->record(0).value("description").toString(); tableView->setModel(model); menu = new QMenu(); addAct = new QAction(tr("Add Traction Type"),this); addAct->setToolTip(tr("Add a new traction type")); connect(addAct, SIGNAL(triggered()), this, SLOT(newRecord())); delAct = new QAction(tr("Delete Traction Type"),this); delAct->setToolTip(tr("Delete an existing traction type")); connect(delAct, SIGNAL(triggered()), this, SLOT(delRecord())); tableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(tableView, SIGNAL(customContextMenuRequested( const QPoint& )), this, SLOT(tablev_customContextMenu( const QPoint& ))); tableView->show(); }
int main( void ) { FILE *cfPtr; // credit.dat file pointer unsigned int choice; // user's choice // fopen opens the file; exits if file cannot be opened if ( ( cfPtr = fopen( "/home/abubakr/test.txt", "rb+" ) ) == NULL ) { puts( "File could not be opened." ); } // end if else { // enable user to specify action while ( ( choice = enterChoice() ) != 5 ) { switch ( choice ) { // create text file from record file case 1: textFile( cfPtr ); break; // update record case 2: updateRecord( cfPtr ); break; // create record case 3: newRecord( cfPtr ); break; // delete existing record case 4: deleteRecord( cfPtr ); break; // display message if user does not select valid choice default: puts( "Incorrect choice" ); break; } // end switch } // end while fclose( cfPtr ); // fclose closes the file } // end else } // end main
// - try to open existing DB file according to params set with setFileInfo bferr TBinFileBase::open(uInt32 aExtraHeadersize, void *aExtraHeaderP, TUpdateFunc aUpdateFunc) { // make sure it is closed first close(); // save extra header info fExtraHeaderSize=aExtraHeadersize; fExtraHeaderP=aExtraHeaderP; // try to open file for (binary) update if (!platformOpenFile(fFilename.c_str(),fopm_update)) return BFE_NOTFOUND; // read header fHeaderDirty=false; platformSeekFile(0); if (!platformReadFile(&fBinFileHeader,sizeof(fBinFileHeader))) { close(); return BFE_BADSTRUCT; } // check type and Version if (fBinFileHeader.idword!=fIdWord) { close(); return BFE_BADTYPE; } // remember the version we found when trying to open fFoundVersion = fBinFileHeader.version; // check need for upgrade if (fBinFileHeader.version!=fVersion) { // try to update file if update-func is provided if (aUpdateFunc) { // check if we can update (no data provided for update) uInt32 newrecordsize=aUpdateFunc(fFoundVersion,fVersion,NULL,NULL,0); if (newrecordsize) { // we can update from current to requested version // - allocate buffer for all records uInt32 numrecords = fBinFileHeader.numrecords; uInt32 oldrecordsize = fBinFileHeader.recordsize; void *oldrecords = malloc(numrecords * oldrecordsize); if (!oldrecords) return BFE_MEMORY; // - read all current records into memory (relative to old headersize) readRecord(0,oldrecords,numrecords); // Update header because extra header might have changed in size if (fExtraHeaderP && (fBinFileHeader.headersize!=sizeof(TBinFileHeader)+fExtraHeaderSize)) { // (extra) header has changed in size // - read old extra header (or part of it that will be retained in case it shrinks between versions) uInt32 oldEHdrSz = fBinFileHeader.headersize-sizeof(TBinFileHeader); platformSeekFile(sizeof(TBinFileHeader)); platformReadFile(fExtraHeaderP,oldEHdrSz<=fExtraHeaderSize ? oldEHdrSz : fExtraHeaderSize); // - adjust the overall header size fBinFileHeader.headersize = sizeof(TBinFileHeader)+fExtraHeaderSize; // - let the update function handle init of the extra header aUpdateFunc(fFoundVersion,fVersion,NULL,fExtraHeaderP,0); // - make sure new extra header gets written fExtraHeaderDirty = true; } // - modify header fields fBinFileHeader.version=fVersion; // update version fBinFileHeader.recordsize=newrecordsize; // update record size fHeaderDirty=true; // header must be updated // - write new header (to make sure file is at least as long as header+extraheader) flushHeader(); // - truncate the file (taking new extra header size into account already, in case it has changed) truncate(); // - now convert buffered records void *newrecord = malloc(newrecordsize); for (uInt32 i=0; i<numrecords; i++) { // call updatefunc to convert record if (aUpdateFunc(fFoundVersion,fVersion,(void *)((uInt8 *)oldrecords+i*oldrecordsize),newrecord,oldrecordsize)) { // save new record uInt32 newi; newRecord(newi,newrecord); } } // - forget buffers free(newrecord); free(oldrecords); // - flush new header flushHeader(); } else { // cannot update close(); return BFE_BADVERSION; } } else { // cannot update close(); return BFE_BADVERSION; } } // check record compatibility if (fExpectedRecordSize && fExpectedRecordSize!=fBinFileHeader.recordsize) { close(); return BFE_BADSTRUCT; } // check extra header compatibility if (fBinFileHeader.headersize<sizeof(TBinFileHeader)+fExtraHeaderSize) { close(); return BFE_BADSTRUCT; } // read extra header if (fExtraHeaderP && fExtraHeaderSize>0) { platformSeekFile(sizeof(TBinFileHeader)); platformReadFile(fExtraHeaderP,fExtraHeaderSize); fExtraHeaderDirty=false; } return BFE_OK; } // TBinFileBase::open
int main() { srand(time(0)); Process* queue = randomProcessQueue(PROCESS_COUNT); sortProcessesByArrival(queue, 0, PROCESS_COUNT - 1); int i = 0; float timer = 0; int RevIndex = PROCESS_COUNT - 1; int currentProcessIndex = 0; bool okToEnd = false; float wait = 0; Record record = newRecord(); while(!okToEnd) { Timeslice* timeslice = (Timeslice*) malloc(sizeof(Timeslice)); (*timeslice).index = i; if(queue[currentProcessIndex].arrival < i) { (*timeslice).pid = (char) (65 + currentProcessIndex); if((*timeslice).pid > 65+25){ (*timeslice).pid += 6; } int j; for(j = currentProcessIndex+1; j < PROCESS_COUNT; j++){ if(queue[j].arrival < i){ queue[j].waitTime +=1.0f; queue[j].responseTime += 1.0f; if(queue[j].priority < queue[currentProcessIndex].priority){ printf("current time %d, swap priority %d with priority %d\n", i, queue[currentProcessIndex].priority, queue[j].priority); int indexOfNextMin = j; currentProcessIndex = indexOfNextMin; } } } queue[currentProcessIndex].timeRemaining = queue[currentProcessIndex].timeRemaining - 1.0f; if(queue[currentProcessIndex].timeRemaining <= 0) { queue[currentProcessIndex].turnaroundTime = queue[currentProcessIndex].runtime + queue[currentProcessIndex].waitTime; queue[currentProcessIndex].timeFinished += i; queue[currentProcessIndex].id = (*timeslice).pid; addProcess(&record, queue[currentProcessIndex]); if(i >= SIMULATION_LENGTH) { okToEnd = true; } else { timer = timer + queue[currentProcessIndex].turnaroundTime; currentProcessIndex++; int x = 0; bool swapped = false; int indexOfNextMin = currentProcessIndex; for(x = currentProcessIndex; x < PROCESS_COUNT - 1; x++) { if(queue[x].arrival < i) if(queue[indexOfNextMin].priority > queue[x].priority) { printf("current time %d, swap priority %d with priority %d\n", i, queue[currentProcessIndex].priority, queue[x].priority); indexOfNextMin = x; currentProcessIndex = indexOfNextMin; } } } } } else { (*timeslice).pid = '-'; } addTimeslice(&record, (*timeslice)); i++; } printRecord(record); return 0; }
void CCodeCheckpointDebugMgr::UpdateRecords() { //Retrieve the latest snapshot ICodeCheckpointMgr* pCodeCheckpointMgr = gEnv->pCodeCheckpointMgr; if (pCodeCheckpointMgr) { size_t nextSnapshotCount = pCodeCheckpointMgr->GetTotalCount(); size_t currIdx = 0; TCheckpointDebugList::iterator unwatchedIt = m_unwatchedPoints.begin(),watchedIt = m_watchedPoints.begin(); ///Update existing points with their snapshot size_t currSnapShotcount = m_watchedPoints.size() + m_unwatchedPoints.size(); while( currIdx < currSnapShotcount && currIdx < nextSnapshotCount) { string name = pCodeCheckpointMgr->GetCheckPointName(currIdx); const CCodeCheckpoint* pCheckpoint = pCodeCheckpointMgr->GetCheckpoint(currIdx); ///Check if we are a watched point if(watchedIt != m_watchedPoints.end() && (name == watchedIt->m_name)) { CheckpointDebugRecord& currentRec = *watchedIt; UpdateRecord(pCheckpoint, currentRec); ++watchedIt; } //Otherwise checked if we are unwatched point else if(unwatchedIt != m_unwatchedPoints.end() && (name == unwatchedIt->m_name)) { CheckpointDebugRecord& currentRec = *unwatchedIt; UpdateRecord(pCheckpoint, currentRec); ++unwatchedIt; } ///This should never happen, as each existing point should already have been inserted into either the watched or unwatched vector. else { CRY_ASSERT(false); } ++currIdx; } ///Add entities that are new to this snapshot while(currIdx < nextSnapshotCount) { const char* name = pCodeCheckpointMgr->GetCheckPointName(currIdx); const CCodeCheckpoint* pCheckpoint = pCodeCheckpointMgr->GetCheckpoint(currIdx); CheckpointDebugRecord newRecord(pCheckpoint, name, currIdx); //If we have a current request to watch this point, make sure it goes into watched points TBookmarkMap::iterator bookmarkedIt = m_bookmarkedNames.find(name); if(bookmarkedIt != m_bookmarkedNames.end()) { newRecord.UpdateWatched(bookmarkedIt->second); m_watchedPoints.push_back(newRecord); //Clean up the bookmark as its already been hit m_bookmarkedNames.erase(bookmarkedIt); } else m_unwatchedPoints.push_back(newRecord); ++currIdx; } } }
void HumanoidDataLogger::logData() { dataMutex.Lock(); newRecord(); assignItem(TIME, simThread->sim_time); assignItem(STATE_CODE, state); assignItem(CONTROL_TIME, controlTime); assignGroup(JOINT_ANGLES, q); assignGroup(JOINT_RATES, qd); assignGroup(JOINT_TORQUES, tau); Vector6F force; force.head(3) = grfInfo.fCoPs[0]; force.segment(3,2) = grfInfo.pCoPs[0].head(2); force(5) = grfInfo.nCoPs[0]; assignGroup(RIGHT_FOOT_WRENCH, force); assignItem(RCONT_STATE, contactState[0]); assignItem(RSLIDE_STATE, slidingState[0]); force.head(3) = grfInfo.fCoPs[1]; force.segment(3,2) = grfInfo.pCoPs[1].head(2); force(5) = grfInfo.nCoPs[1]; assignGroup(LEFT_FOOT_WRENCH, force); assignItem(LCONT_STATE, contactState[1]); assignItem(LSLIDE_STATE, slidingState[1]); force.head(3) = grfInfo.fZMP; force.segment(3,2) = grfInfo.pZMP.head(2); force(5) = grfInfo.nZMP; assignGroup(ZMP_WRENCH, force); assignGroup(ZMP_WRENCH_OPT, zmpWrenchOpt); assignGroup(ZMP_POS_OPT, zmpPosOpt); assignGroup(COM_POSITION, pCom); assignGroup(COM_POSITION_DES, pComDes); assignGroup(COM_VELOCITY, vCom); assignGroup(COM_VELOCITY_DES, vComDes); assignGroup(CENTROIDAL_MOMENTUM, centMom); assignGroup(HDES, hDes); assignGroup(HDOT_DES, hDotDes); assignGroup(HDOT_OPT, hDotOpt); assignGroup(QDD_OPT, qdd); assignGroup(QDD_ACT, qddA); assignGroup(RIGHT_FOOT_POS, pFoot[0]); assignGroup(RIGHT_FOOT_POS_DES, pDesFoot[0]); assignGroup(RIGHT_FOOT_VEL, vFoot[0]); assignGroup(RIGHT_FOOT_VEL_DES, vDesFoot[0]); assignGroup(RIGHT_FOOT_ACC, aFoot[0]); assignGroup(RIGHT_FOOT_ACC_DES, aDesFoot[0]); assignGroup(LEFT_FOOT_POS, pFoot[1]); assignGroup(LEFT_FOOT_POS_DES, pDesFoot[1]); assignGroup(LEFT_FOOT_VEL, vFoot[1]); assignGroup(LEFT_FOOT_VEL_DES, vDesFoot[1]); assignGroup(LEFT_FOOT_ACC, aFoot[1]); assignGroup(LEFT_FOOT_ACC_DES, aDesFoot[1]); assignGroup(RWRENCH_OPT, fs.head(6)); assignGroup(LWRENCH_OPT, fs.tail(6)); assignMatrixGroup(JRF, grfInfo.footJacs[0]); assignMatrixGroup(JLF, grfInfo.footJacs[1]); assignGroup(RIGHT_FOOT_SPATIAL_WRENCH, grfInfo.footWrenches[0]); assignGroup(LEFT_FOOT_SPATIAL_WRENCH, grfInfo.footWrenches[1]); assignGroup(CANDG, artic->CandG); assignMatrixGroup(HMAT,artic->H); dataMutex.Unlock(); }
DbRecord DbFile::newRecord(const char* key, const char* value, RecordType type) { switch (type) { case Normal: { size_t size = DbRecord::getSize(key, value, type); // Record size too large if (size > DbPage::maxFreeSpace) return newRecord(key, value, Long); return getNewRecord(key, value, type); } case Long: { // Check value length size_t size = DbRecord::getSize(key, value, type); int valueLen = strlen(value); int leftValueLen = size - DbPage::maxFreeSpace; // Record size too small if (leftValueLen <= 0) return newRecord(key, value, Normal); // Split the first value str std::string currentStr(value, valueLen - leftValueLen); // Init iterators DbRecord firstRecord(getPage(0), 0); DbRecord currentRecord(getPage(0), 0); DbRecord lastRecord(getPage(0), 0); // Create records while (leftValueLen > 0) { lastRecord = currentRecord; currentRecord = getNewRecord(key, currentStr.c_str(), type); // Update record iterator and next record cursor if (type != Long) { lastRecord.nextExtendedRecord(currentRecord.getPage()->getId(), currentRecord.getCursor()); leftValueLen -= currentStr.size(); } else { firstRecord = currentRecord; type = LongExtended; } // Get the size of next value in the new record if (leftValueLen > 0) { size = DbRecord::getSize(key, value + (valueLen - leftValueLen), type); if (size > DbPage::maxFreeSpace) currentStr = std::string(value + (valueLen - leftValueLen), leftValueLen - (size - DbPage::maxFreeSpace)); else currentStr = std::string(value + (valueLen - leftValueLen), leftValueLen); } } currentRecord.nextExtendedRecord(0, 0); return firstRecord; } default: error("Not known record type"); return DbRecord(getPage(0), 0); // Avoid warning } }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Constructor // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// dicomDir::dicomDir(ptr<dataSet> pDataSet): m_pDataSet(pDataSet) { if(m_pDataSet == 0) { m_pDataSet =new dataSet; } // Parse the dataset /////////////////////////////////////////////////////////// lockObject lockDataSet(pDataSet); // Get the DICOMDIR sequence /////////////////////////////////////////////////////////// typedef std::map<std::uint32_t, ptr<directoryRecord> > tOffsetsToRecords; tOffsetsToRecords offsetsToRecords; for(std::uint32_t scanItems(0); ; ++scanItems) { ptr<dataSet> pDataSet(m_pDataSet->getSequenceItem(0x0004, 0, 0x1220, scanItems)); if(pDataSet == 0) { break; } ptr<directoryRecord> newRecord(new directoryRecord(pDataSet)); offsetsToRecords[pDataSet->getItemOffset()] = newRecord; m_recordsList.push_back(newRecord); } // Scan all the records and update the pointers /////////////////////////////////////////////////////////// for(tOffsetsToRecords::iterator scanRecords(offsetsToRecords.begin()); scanRecords != offsetsToRecords.end(); ++scanRecords) { std::uint32_t nextRecordOffset(scanRecords->second->getRecordDataSet()->getUnsignedLong(0x0004, 0, 0x1400, 0)); std::uint32_t childRecordOffset(scanRecords->second->getRecordDataSet()->getUnsignedLong(0x0004, 0, 0x1420, 0)); std::uint32_t referencedRecordOffset(scanRecords->second->getRecordDataSet()->getUnsignedLong(0x0004, 0, 0x1504, 0)); tOffsetsToRecords::iterator findNextRecord(offsetsToRecords.find(nextRecordOffset)); if(findNextRecord != offsetsToRecords.end()) { scanRecords->second->setNextRecord(findNextRecord->second); } tOffsetsToRecords::iterator findChildRecord(offsetsToRecords.find(childRecordOffset)); if(findChildRecord != offsetsToRecords.end()) { scanRecords->second->setFirstChildRecord(findChildRecord->second); } tOffsetsToRecords::iterator findReferencedRecord(offsetsToRecords.find(referencedRecordOffset)); if(findReferencedRecord != offsetsToRecords.end()) { scanRecords->second->setReferencedRecord(findReferencedRecord->second); } } // Get the position of the first record /////////////////////////////////////////////////////////// tOffsetsToRecords::iterator findRecord(offsetsToRecords.find(m_pDataSet->getUnsignedLong(0x0004, 0, 0x1200, 0))); if(findRecord == offsetsToRecords.end()) { return; } setFirstRootRecord(findRecord->second); }