/*Prints the list by cycling through and calling the print record function. The printRecord function returns a string with the info of the individal record, which is then printed by the printList function*/ void printList(struct car * theList, char printType, FILE * playlist) { char * theString; struct car * temp; temp = theList; if(printType == 'e') { while(temp != NULL) { theString = printRecord(temp, printType); printf("%s\n", theString); temp = temp->next; // free(theString); } } else { while(temp != NULL) { theString = printRecord(temp, printType); fprintf(playlist,"%s", theString); temp = temp->next; // free(theString); } } }
void printMathRds(char *fileName) { printf("\nMean==================\n"); printRecord(fileName, 0); printf("\nMin==================\n"); printRecord(fileName, 1); printf("\nMax==================\n"); printRecord(fileName, 2); printf("\nOverMean==================\n"); printRecord(fileName, 3); printf("\n"); printRecordNum(fileName); }
void RecordOutputMgr::printRecord(RecordKeyVector &keyList) { if (keyList.getKey()->getType() == FileRecordTypeChecker::BAM_RECORD_TYPE) { RecordKeyVector blockList(keyList.getKey()); bool deleteBlocks = false; _bamBlockMgr->getBlocks(blockList, deleteBlocks); printRecord(keyList, &blockList); if (deleteBlocks) { _bamBlockMgr->deleteBlocks(blockList); } return; } printRecord(keyList, NULL); }
void ComplementFile::processHits(RecordOutputMgr *outputMgr, RecordKeyVector &hits) { _outputMgr = outputMgr; const Record *rec = hits.getKey(); //test for chrom change. const QuickString &newChrom = rec->getChrName(); if (_currChrom != newChrom) { outPutLastRecordInPrevChrom(); //if record's chrom doesn't exist in the genome file, do //nothing if (!fastForward(newChrom)) return; //we've switched to a new chromosome that is in both the DB //and genome file. _currStartPos = 0; _currChrom = newChrom; _outRecord.setChrName(newChrom); } int endPos = rec->getStartPos(); printRecord(endPos); _currStartPos = rec->getEndPos(); }
/* void run_query1(UAKGQueryManager_ptr queryManager) { static const char* query_text = "select TNAME,TABTYPE from tab where 1=1"; UAKGCollection_var collection_ = queryManager->create_collection("F1,F2,F1", "UAKGTEST", "1=1", NULL); UAKGIterator_var iterator = collection_->create_uakgiterator(true); CORBA_Boolean more; RecordSeq_var recordSeq = iterator->fetch_records(10, more); OctSeq_var octSeq = collection_->retrieve_by_pattern(recordSeq[0]); // collection_->remove_records_by_pattern(recordSeq[0]); printRC(cout,octSeq.in()); iterator->destroy(); collection_->destroy(); } */ void run_query(UAKGQueryManager_ptr queryManager) { UAKGKeyCollection_var key_collection_ = queryManager->create_key_collection_by_fields( "F1,F2,F1", "UAKGTEST", "1=1", "\0", "F_key"); cerr << "We are in!"<< endl; // UAKGKeyCollection_var key_collection_ = queryManager->create_key_collection_by_query( // "select F1,F2,F1 from UAKGTEST where 1=1 with key F_key"); cerr << "We are out!"<< endl; String_var key_val = string_dup("first"); key_val += '\0'; String_var new_val = string_dup("new"); new_val += '\0'; cerr << "We are getting records number!"<< endl; ULong num = key_collection_->get_number_of_records(); cerr << "We've got records number!"<< endl; Record_var inpRecord = new Record; inpRecord->length(1); FieldValueAccess::setString(inpRecord[0], key_val.in()); Record_var record = key_collection_->retrieve_record_with_key(inpRecord); printRecord(cout, record.in()); RecordDescription_var recordDescription = new RecordDescription; OctSeq_var params = new OctSeq; key_collection_->evaluate_rc("select @,F2 from UAKGTEST, where @ and 2=2", "", recordDescription, params ); key_collection_->destroy(); }
void printList( MusicRec * theList ) { MusicRec * nextNode; char ** printString; int x = 0, y = 0; nextNode = theList; printString = malloc(sizeof(char)*1024); x = 0; do { printString[x] = printRecord( nextNode ); x++; nextNode = nextNode->next; } while ( nextNode != NULL ); for ( y = 0; y <= x-1; y++ ) { printf("%s\n", printString[y]); } for( y = 0; y <= x; y++ ) { free(printString[x]); } free(printString); return; }
void ComplementFile::processHits(RecordOutputMgr *outputMgr, RecordKeyVector &hits) { _outputMgr = outputMgr; const Record *rec = hits.getKey(); //test for chrom change. const string &newChrom = rec->getChrName(); if (_currChrom != newChrom) { outPutLastRecordInPrevChrom(); //if record's chrom doesn't exist in the genome file, do //nothing if (!fastForward(newChrom)) return; //we've switched to a new chromosome that is in both the DB //and genome file. _currStartPos = 0; _currChrom = newChrom; _outRecord.setChrName(newChrom); } // warn if the record's interval is beyond the // length of the chromosome checkCoordinatesAgainstChromLength(rec); // safe guard against the first record for the chrom // starting with 0. if (rec->getStartPos() != 0) { CHRPOS endPos = rec->getStartPos(); printRecord(endPos); } _currStartPos = rec->getEndPos(); }
void ComplementFile::outPutLastRecordInPrevChrom() { const QuickString &chrom = _outRecord.getChrName(); //do nothing if triggered by first record in DB. At this point, //there was no prev chrom, so nothing is stored in the output Record yet. if (chrom.empty()) return; int maxChromSize = _genomeFile->getChromSize(chrom); if (_currStartPos >= maxChromSize) return; //chrom already covered and reported. printRecord(maxChromSize); }
void RecordOutputMgr::printRecord(const Record *record, const QuickString & value) { _afterVal = value; printRecord(record); if (!value.empty()) { tab(); _outBuf.append(value); } newline(); if (needsFlush()) flush(); }
void printList(Food * theList) { Food * tempPtr; char * printFood; tempPtr = theList; while (tempPtr != NULL) { printFood = printRecord(tempPtr); printf("%s",printFood); tempPtr = tempPtr->next; } }
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 RecordOutputMgr::printRecord(const Record *record, const QuickString & value) { _afterVal = value; bool recordPrinted = false; if (record != NULL) { printRecord(record); recordPrinted = true; } if (!value.empty()) { if (recordPrinted) tab(); _outBuf.append(value); } newline(); if (needsFlush()) flush(); }
int main(int argc, char *argv[]) { int sizeRegs = 54; Record regs[sizeRegs]; char buffer[8 * 1024]; int flagLower = 1; int fd = 0; initializeRecord(sizeRegs,regs); printf("-------------------FREQ-----------------\n"); if(argc == 1){ process(fd,regs,buffer,sizeRegs,flagLower); }else if(argc == 2){ switch (strcmp(argv[1],"-i")){ case 0: flagLower = 0; process(fd,regs,buffer,sizeRegs,flagLower); break; default: fd = openFile(fd,argv[1]); process(fd,regs,buffer,sizeRegs,flagLower); close(fd); } }else if(argc == 3){ switch (strcmp(argv[1],"-i")){ case 0: flagLower = 0; fd = openFile(fd,argv[2]); process(fd,regs,buffer,sizeRegs,flagLower); close(fd); break; default: err(1,"wrong options"); } }else{ err(1,"wrong options"); exit(EXIT_FAILURE); } tidyRecord(sizeRegs,regs); printRecord(sizeRegs,regs); exit(EXIT_SUCCESS); }
int main(int argc, char** argv) { if ( argc != 2 ) usage(); time_t t; int fd = hlt_profiler_file_open(argv[1], &t); if ( fd < 0 ) { fprintf(stderr, "error opening input file\n"); return 1; } char tag[HLT_PROFILER_MAX_TAG_LENGTH]; hlt_profiler_record rec; printHeader(t); while ( 1 ) { int ret = hlt_profiler_file_read(fd, tag, &rec); if ( ret == 0 ) // Eof. break; if ( ret < 0 ) { perror("cannot read profiler record"); return 1; } printRecord(tag, &rec); } hlt_profiler_file_close(fd); return 0; }
int main(){ int N, p; scanf("%d", &N); getchar(); struct record r[102]; char buf[100], *str, *tok; while(N != 0){ p = 0; while(p < N){ fgets(buf, sizeof(buf), stdin); str = buf; tok = strtok(str, " \n"); strcpy(r[p].name, tok); tok = strtok(NULL, " \n"); r[p].year = atoi(tok); tok = strtok(NULL, " \n"); r[p].price = atoi(tok); p++; } fgets(buf, sizeof(buf), stdin); if(!strcmp(buf, "Name\n")) qsort(r, N, sizeof(struct record), cmpName); else if(!strcmp(buf, "Year\n")) qsort(r, N, sizeof(struct record), cmpYear); else qsort(r, N, sizeof(struct record), cmpPrice); for(p=0; p<N; p++) printRecord(&r[p]); scanf("%d", &N); getchar(); if(N) printf("\n"); } return 0; }
bool ComplementFile::fastForward(const QuickString &newChrom) { if (!newChrom.empty() && !_genomeFile->hasChrom(newChrom)) return false; int i= _currPosInGenomeList +1; while (i < (int)_chromList.size() && _chromList[i] != newChrom) { _outRecord.setChrName(_chromList[i]); _currStartPos = 0; int endPos = _genomeFile->getChromSize(_chromList[i]); printRecord(endPos); i++; } if (newChrom.empty()) return true; if (i== (int)_chromList.size()) { //reached end but didn't find new chrom. Genome and DB are not sorted in same order. cerr << "***** ERROR: genome file and input file are not sorted in same order. Exiting..." << endl; exit(1); //this is where we'd return false if we weren't exiting. } _currChrom = newChrom; _currPosInGenomeList = i; return true; }
/********************************* * * * printTerm * * * *********************************/ static void printTerm(PE_TERM *term) { assert(term); switch (term->tag) { case T_STRUCTOR: printf("%s", term->info.struct_name); break; case T_MACRO: printf("%s", term->info.macro->macro_name); break; case T_FUNCTION: printf("%s", term->info.function->fun_name); break; case T_CASE: printCase(term->info.cases); break; case T_RECORD: printRecord(term->info.records); break; case T_FOLD: printFold(term->info.folds); break; case T_MAP: printMap(term->info.maps); break; case T_UNFOLD: printUnfold(term->info.unfolds); break; default: printf("printTerm(): term not recognized\n"); exit(-1); break; } }
void TransRecord::output() { printHeader(); printRecord(); printFooter(); }
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; }
// main function int main(void) { // the array of given names char* given[] = { "Billy", "Mary", "Percy", "Zach", "Amanda", "Jill", "Ben", "Marcus", "Peter", "Samantha" }; // the array of surnames char* surname[] = { "Griffin", "Smith", "Nicholas", "Lewis", "Kearney", "Simpson", "Booker", "Burns", "Monroe", "Luchterhand" }; // the array of hire years int hire_year[] = { 1998, 2012, 2013, 2003, 1983, 2007, 2005, 1995, 2000, 2004 }; // the number of records represented in our arrays int recordCount = 10; // the index of the current record int curRecord; // sort the arrays sortGiven(given, surname, hire_year, recordCount); // print the records for (curRecord = 0; curRecord < recordCount; curRecord++) { printRecord(given[curRecord], surname[curRecord]); } // return "success" return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); qDebug()<<"Begin Program\n"; QFontDatabase fontDB; fontDB.addApplicationFont(":/Fonts/CMR_Regular.ttf"); fontDB.addApplicationFont(":/Fonts/CMR_Bold.ttf"); fontDB.addApplicationFont(":/Fonts/CMR_Italic.ttf"); fontDB.addApplicationFont(":/Fonts/CMR_BoldItalic.ttf"); QFont CMRFont = QFont("Computer Modern Roman"); QApplication::setFont(CMRFont); //Create the central widget where the other frames will be inserted QWidget *wdgMain = new QWidget(this); qDebug()<<"Widget Initaited"; setCentralWidget(wdgMain); //Create the outermost Layout to divide between the table, the preview and the buttons //QGridLayout *mainLayout = new QGridLayout; QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setSpacing(10); mainLayout->setContentsMargins(15,5,15,10); //The frame for the buttons is created and the ADD Record REMOVE Record and MODIFY Button are added in a QHBOX QFrame *frmButtons = new QFrame(); frmButtons->setFrameStyle(QFrame::Box | QFrame::Raised); frmButtons->setLineWidth(1); //QPushButton *btnAddRecord = new QPushButton("AddRecord",frmButtons); btnAddRecord->setEnabled(false); //QPushButton *btnRemoveRecord = new QPushButton("Remove Record",frmButtons); btnRemoveRecord->setEnabled(false); //QPushButton *btnModifyRecord = new QPushButton("Modify Record",frmButtons); btnModifyRecord->setEnabled(false); //QPushButton *btnPrint = new QPushButton("Export",frmButtons); btnPrint->setEnabled(false); QHBoxLayout *btnLayout = new QHBoxLayout; btnLayout->addWidget(btnAddRecord); btnLayout->addWidget(btnRemoveRecord); btnLayout->addWidget(btnModifyRecord); btnLayout->addWidget(btnPrint); frmButtons->setLayout(btnLayout); //The frame for the preview is created frmPreview->setLayout(prwLayout); //The Table viewer is created without grid and is added to the main layout dbTableView=new QTableView(this); dbTableView->setShowGrid(false); dbTableView->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); //mainLayout->addWidget(dbTableView,0,0,5,4); //The left frame is created and the table and button frames are added QVBoxLayout *lftLayout = new QVBoxLayout; lftLayout->addWidget(dbTableView); lftLayout->addWidget(frmButtons); //The main layout is created by adding the left layout and the preview widget mainLayout->addLayout(lftLayout); mainLayout->addWidget(scrPreview); //A value is given to the database and a connetion is made using the custom CreatConnection //dbName="/Users/Castro/Documents/Svago/Programmazione/Qt/database/movies.sqlite"; //CreateConnection(dbName); //Go to method, return bool //QSqlQuery querytest (q.createUpdate("Main_table",Update,Where),db); //Ther preview frame is populated with the labeled text //preview field is enabeled in order to navigate throught he preview fields array //The scroll area is set to a fixed width wich allowes to view the whole contents without scrolling to the side frmPreview->setMinimumWidth(prwLayout->sizeHint().width()); scrPreview->setWidget(frmPreview); scrPreview->setFixedWidth(frmPreview->width()+20); wdgMain->setLayout(mainLayout); wdgMain->show(); createActions(); createMenu(); //The table view signal "current changed" is connected to the slot which changes the selected record //connect(dbTableView->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)), //SLOT(currentSelectionChanged(const QModelIndex &))); connect(dbTableView,SIGNAL(doubleClicked(QModelIndex)),SLOT(recordDoubleClicked(const QModelIndex))); connect(dbmodel, SIGNAL(modelReset()), this, SLOT(modelHasReset())); connect(dbmodel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(dataChangeEmitted())); //connect(dbmodel,SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInsertedEmitted(QModelIndex,int,int))); connect(btnAddRecord,SIGNAL(clicked()),SLOT(createNewRecord())); connect(btnRemoveRecord,SIGNAL(clicked()),SLOT(deleteRecord())); connect(btnModifyRecord,SIGNAL(clicked()),SLOT(updateRecord())); connect(btnPrint,SIGNAL(clicked()),this,SLOT(printRecord())); QDesktopWidget dw; QRect dwRect = dw.availableGeometry(this); //dw.availablegeometry(this); resize(dwRect.size()*0.7); //QRect mwRect = this->geometry(); move(0.15*dwRect.width(),0.15*dwRect.height()); }
void RecordOutputMgr::printRecord(const Record *record) { RecordKeyVector keyList(record); printRecord(keyList); }