QGroupBox* MainWindow::createAlbumGroupBox() { QGroupBox *box = new QGroupBox(tr("Album")); albumView = new QTableView; albumView->setEditTriggers(QAbstractItemView::NoEditTriggers); albumView->setSortingEnabled(true); albumView->setSelectionBehavior(QAbstractItemView::SelectRows); albumView->setSelectionMode(QAbstractItemView::SingleSelection); albumView->setShowGrid(false); albumView->verticalHeader()->hide(); albumView->setAlternatingRowColors(true); albumView->setModel(model); adjustHeader(); QLocale locale = albumView->locale(); locale.setNumberOptions(QLocale::OmitGroupSeparator); albumView->setLocale(locale); connect(albumView, SIGNAL(clicked(QModelIndex)), this, SLOT(showAlbumDetails(QModelIndex))); connect(albumView, SIGNAL(activated(QModelIndex)), this, SLOT(showAlbumDetails(QModelIndex))); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(albumView, 0, 0); box->setLayout(layout); return box; }
void* stack::allocate(ui32 size, ui8 align) { assert(size != 0); ui8 adjust = adjustHeader(data, align, sizeof(allocHeader)); if (usedMemory + adjust + size > totalSize) { return nullptr; } uintptr_t alignedAddress = (uintptr_t)curPos + adjust; allocHeader* head = (allocHeader*) (alignedAddress - sizeof(allocHeader)); head->head = adjust; curPos = (void*)(alignedAddress + size); usedMemory += size + adjust; numOfAllocations++; return (void*)alignedAddress; }
void MainWindow::updateHeader(QModelIndex, int, int) { adjustHeader(); }
void* list::allocate(ui32 size, ui8 align) { assert(size != 0); block* prevBlock = nullptr; block* freeBlocks = freeBlock; while(freeBlocks) { ui8 adjust = adjustHeader(freeBlocks, align, sizeof(allocHeader)); if (freeBlocks->size < size + adjust) { prevBlock = freeBlocks; freeBlocks = freeBlocks->next; continue; // HERE >:( } assert(sizeof(allocHeader) >= sizeof(freeBlocks)); if(freeBlocks->size - size - adjust <= sizeof(allocHeader)) { size = freeBlocks->size; if(prevBlock != nullptr) { prevBlock = freeBlocks->next; } else { freeBlocks = freeBlocks->next; } } else { block* nextBlock = (block*)((uintptr_t)freeBlocks + size +adjust); nextBlock->size = freeBlocks->size - size - adjust; nextBlock->next = freeBlocks->next; if(prevBlock != nullptr) { prevBlock = nextBlock; } else { freeBlock = nextBlock; } } uintptr_t alignedAddress = (uintptr_t)freeBlocks + adjust; allocHeader* header = (allocHeader*)(alignedAddress - sizeof(allocHeader)); header->size = size + adjust; header->adjust = adjust; usedMemory += adjust + size; numOfAllocations++; return (void*)alignedAddress; } return nullptr; }
void operator()() { auto data = producer_.get(); char *stdout_buf = (char*)malloc(stdout_buffer_size); char *stderr_buf = (char*)malloc(stderr_buffer_size); size_t stdout_buff_off{0}, stderr_buff_off{0}; while (!data.empty()) { size_t polyalen; for (auto &fa : data) { const Matrix<int> &path = hmm_.calculateVirtabi(fa.seq_.rbegin(), fa.seq_.size()); for (polyalen = 0; polyalen < path.size(); ++polyalen) { /* cannot use binary search because polyA might appear in the middle */ if (path[polyalen] == PolyAHmmMode::States::NONPOLYA) { break; } } if (isoSeqFormat) { // static decision if (polyalen) adjustHeader(fa.name_, polyalen); } stderr_buff_off += sprintf(stderr_buf + stderr_buff_off, "%s\t%zu\n", fa.name_.c_str(), polyalen); if (stderr_buff_off * 5 > stderr_buffer_size * 4) { /* manually flush stderr */ std::lock_guard<std::mutex> lock(k_io_mx); fwrite(stderr_buf, 1, stderr_buff_off, stderr); stderr_buff_off = 0; } if (showColor) { // static decision; always print stdout_buff_off += sprintf(stdout_buf + stdout_buff_off, ">%s\n%s" KERNAL_RED "%s \n" KERNAL_RESET, fa.name_.c_str(), fa.seq_.substr(0, fa.seq_.size() - polyalen).c_str(), fa.seq_.substr(fa.seq_.size() - polyalen).c_str() ); } if (!showColor) { // static decision if (polyalen < fa.size()) { // print only when there are at least some non-polyA region stdout_buff_off += sprintf(stdout_buf + stdout_buff_off, ">%s\n%s\n", fa.name_.c_str(), fa.seq_.substr(0, fa.seq_.size() - polyalen).c_str() ); } } if (stdout_buff_off * 5 > stdout_buffer_size * 4) { /* manually flush stdout */ std::lock_guard<std::mutex> lock(k_io_mx); fwrite(stdout_buf, 1, stdout_buff_off, stdout); stdout_buff_off = 0; } } /* end of for loop to process each fasta in data */ { /* flush buffer */ std::lock_guard<std::mutex> lock(k_io_mx); fwrite(stdout_buf, 1, stdout_buff_off, stdout); fwrite(stderr_buf, 1, stderr_buff_off, stderr); } stdout_buff_off = stderr_buff_off = 0; data = producer_.get(); /* get new chulk of data */ } free(stdout_buf); free(stderr_buf); }