/** * @brief calls "get_objects_of_class" service * * @return nothing */ void callService () { ROS_INFO("waiting for server to start"); ros::service::waitForService ("get_objects_of_class"); //build message cob_3d_mapping_msgs::GetObjectsOfClassRequest req; cob_3d_mapping_msgs::GetObjectsOfClassResponse res; get_tables_client_.call (req, res); ROS_INFO("Service call finished"); saveTables (res); }
void createTable(TableManager *tm, char *tableName) { char *fileName = buildNameToTablesFiles(tm->path, tableName); setArrayListObject(tm->names, (char *) fileName, tm->names->length); Table *t = newTable(fileName); setArrayListObject(tm->tables, (Table *) t, tm->tables->length); InsertionHandler *ih = newInsertionHandler(t); setArrayListObject(tm->insert, (InsertionHandler *) ih, tm->insert->length); SelectionHandler *sh = newSelectionHandler(t); setArrayListObject(tm->select, (SelectionHandler *) sh, tm->select->length); DeletionHandler *dh = newDeletionHandler(t); setArrayListObject(tm->deleter, (DeletionHandler *) dh, tm->deleter->length); saveTables(tm); }
void HighScore::loadTables() { char buff[1024]; // open the file, on error set up the default table FILE *fp = fopen( QFile::encodeName(highScoreFile()), "r"); if (fp == NULL) goto error; // check magic fscanf(fp, "%1023s\n", buff); if (highScoreMagic1_1 != buff) { goto error; } int num; fscanf(fp, "%d\n", &num); for (int p=0; p<num; p++) { TableInstance *t = new TableInstance; t->next = tables; tables = t; fgets(buff, sizeof(buff), fp); if (buff[strlen(buff)-1] == '\n') buff[strlen(buff)-1] = '\0'; t->name = buff; combo->insertItem(t->name); setComboTo(t->name); for (int e=0; e<numScores; e++) { fscanf(fp, "%ld\n", &(t->entries[e].score)); fscanf(fp, "%ld\n", &(t->entries[e].elapsed)); fscanf(fp, "%ld\n", &(t->entries[e].board)); fgets(buff, sizeof(buff), fp); if (buff[strlen(buff)-1] == '\n') buff[strlen(buff)-1] = '\0'; t->entries[e].name=QString::fromUtf8(buff,-1); } } fclose(fp); return; error: selectTable("default"); saveTables(); return; }
void HighScore::checkHighScore(int s, int e, long gameNum, QString &name) { int pos; QString board; getBoardName(name, board); // make this board name the current one! // creates it if it does not exist selectTable(board); for (pos=0; pos <numScores; pos++) { if (s > currTable->entries[pos].score) { break; } } if (pos >= numScores) { return; } for (int move= numScores-1; move >pos; move--) { currTable->entries[move].score = currTable->entries[move-1].score; currTable->entries[move].name = currTable->entries[move-1].name; currTable->entries[move].board = currTable->entries[move-1].board; currTable->entries[move].elapsed = currTable->entries[move-1].elapsed; } currTable->entries[pos].score = s; currTable->entries[pos].board = gameNum; currTable->entries[pos].elapsed = e; lineEdit->setEnabled(true); lineEdit->setGeometry( 40, 75+(pos*30), 150, 30 ); lineEdit->setFocus(); lineEdit->setText(""); selectedLine = pos; nameChanged(""); // no board change when entering data combo->setEnabled(false); exec(board); combo->setEnabled(true); selectedLine = -1; lineEdit->setGeometry( 40, 75+(20*30), 150, 30); lineEdit->setEnabled(false); // sync the hiscore table to disk now saveTables(); }