int MDBImageManager::admitRegisterPatient(const MPatient& patient, const MVisit& visit) { // first do sanity check if (!mDBInterface) return 0; if (patient.mapEmpty()) return -1; if (recordExists(patient)) updateRecord(patient); else addRecord(patient); if (visit.mapEmpty()) return -1; if (recordExists(visit)) updateRecord(visit); else addRecord(visit); return 0; }
bool GenericTab::initBinder(MapperRuleBinder* mapperBinderPtr) { // initialize rule binder and *connect* signals!! (on init()) //m_mapperBinderPtr=new MapperRuleBinder(m_ruleCheckerPtr, mapper); mapperBinderPtr->init(); //! This is are the signals of the rule binder we need to connect to: // addRecord, first stage record added and second stage record added (run and finish running post-triggers) // the pre triggers signals are connected in the binder classes; then we just need the stuff to show messages... // Default Rules connect(this, SIGNAL(addRecord()), mapperBinderPtr, SIGNAL(addRecord())); // Pre Submit Rules connect(this, SIGNAL(submit()), mapperBinderPtr, SIGNAL(submitRecord())); connect(mapperBinderPtr, SIGNAL(finishedPreSubmit(const bool)), this, SLOT(onPreSubmit(const bool))); // Messages connect(mapperBinderPtr, SIGNAL(showError(QString, const bool)), this, SIGNAL(showError(QString, const bool))); connect(mapperBinderPtr, SIGNAL(showStatus(QString)), this, SIGNAL(showStatus(QString))); return true; }
void TPDynamic::policy() { useconds_t usecs = 1, range = 1; #ifdef TRACE addRecord(getTime(), (void*) &TPDynamic::policy); #endif while (alive()) { //Check if we have any work in our deque tpClosure * tempClosure; if (!(tempClosure = popTP())) tempClosure = steal(); if (tempClosure) { usecs = range; // reset sleep time; #ifdef TRACE addRecord(getTime(), (void*) tempClosure->factory); #endif tempClosure->factory(tempClosure); #ifdef TRACE addRecord(getTime(), (void*) &TPDynamic::policy); #endif delete tempClosure; //Get the work ready! } else { usleep(usecs); if (usecs < 500) usecs *= 2; } //Lets do the work! Codelet * tempCodelet = popCodelet(); while (tempCodelet) { ThreadedProcedure * checkTP = tempCodelet->getTP(); bool deleteTP = (checkTP) ? checkTP->checkParent() : false; #ifdef TRACE addRecord(getTime(), tempCodelet->returnFunct()); #endif #ifdef COUNT if(getAffinity()) getAffinity()->startCounters(getID()); #endif tempCodelet->fire(); #ifdef COUNT if(getAffinity()) getAffinity()->incrementCounters(getID()); #endif #ifdef TRACE addRecord(getTime(), (void*) &TPDynamic::policy); #endif if (deleteTP) { if (checkTP->decRef()) delete checkTP; } tempCodelet = popCodelet(); } } }
void DatabaseManager::addRecordWithCount(const StringPimpl &key, const StringPimpl &value) { if(!recordCountExists(key, value)) { int size = getRecordTotalCount(key); addRecord(m_reserved + key + "_@size_@", StringPimpl::getString(size + 1)); //This enables us to do a fast lookup without having to loop through //the entire list just to check for the existence of the key addRecord(m_reserved + key + "_@existence_@" + value, value); } }
void NdefMessage::addEmptyRecord() { NdefRecord* r = new NdefRecord(); r->setTnf(TNF_EMPTY); addRecord(*r); delete(r); }
void* _ccMalloc(size_t size, const char* file, int line, const char* logTag) { // null pointer for zero size if (size == 0) return NULL; void* p = malloc(size); if (p) { ccMemoryRecord* r = (ccMemoryRecord*)malloc(sizeof(ccMemoryRecord)); if(!r) { free(p); p = NULL; } else { r->start = p; r->size = size; r->file = file; r->line = line; r->next = NULL; addRecord(r); } #if CC_CFLAG_ALLOCATION_LOG CCLOG("[%s](%p)(record=%p):%d [%s:%d]", logTag, r->start, r, size, r->file, r->line); #endif } return p; }
QList<QAction *> DataTableEditController::createEditActions() { Q_ASSERT(addAction==0); QList<QAction*> actions; addAction = new QAction(IconUtil::getIcon("add"), tr("Add record"), this); connect(addAction, SIGNAL(triggered()), this, SLOT(addRecord())); actions.append(addAction); deleteAction = new QAction(IconUtil::getIcon("delete"), tr("Delete record"), this); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRecord())); actions.append(deleteAction); actions.append(WidgetHelper::createSeparatorAction(this)); commitAction = new QAction(IconUtil::getIcon("commit"), tr("Commit changes"), this); connect(commitAction, SIGNAL(triggered()), this, SLOT(commit())); actions.append(commitAction); rollbackAction = new QAction(IconUtil::getIcon("rollback"), tr("Reset changes"), this); connect(rollbackAction, SIGNAL(triggered()), this, SLOT(reset())); actions.append(rollbackAction); showDmlAction = new QAction(IconUtil::getIcon("query"), tr("Show commit DML"), this); connect(showDmlAction, SIGNAL(triggered()), this, SLOT(showDml())); actions.append(showDmlAction); return actions; }
bool ConvertParser::processLine(const std::string& line, double& fraction, int& remainingTime){ remainingTime = -1; fraction = -1; RegexTools::Matcher matcher = colonTimeFormat.getMatcher(line); double aktime = aktualTime; if(matcher.find()){ std::string time = matcher.getGroup(1); aktime = toSecondTime(time); }else{ return false; } if(duration >= 0){ if(aktime > aktualTime){ long aktualWorldTime = getAktualTimeMikro(); double elapsed = (aktualWorldTime - lastWorldTime)/1000000.0; lastWorldTime = aktualWorldTime; double diff = aktime - aktualTime; aktualTime = aktime; addRecord(diff, elapsed); double speed = getNumSecPerSec(); double estimate = duration - aktualTime; remainingTime = estimate / speed; }else{ remainingTime = -1; } fraction = aktualTime / duration + 0.005; }else{ remainingTime = 0; fraction = 0; } return true; }
void RealTimeTableVisualization::update(IProject *project, UdpSocketAdapter *socketAdapter, QList<Format*> formats) { this->formats = formats; viewer->clear(); viewer->setRowCount(0); recordsCount = 0; currentProject = project; currentSocketAdapter = socketAdapter; argumentsNames.clear(); QStringList argumentsNamesFull = settings.value("Hidden/Gui/Project/Columns_names").value<QStringList>(); QStringList argumentsState = settings.value("Hidden/Gui/Project/Columns_state").value<QStringList>(); argumentsNames = argumentsNamesFull; viewer->setColumnCount(argumentsNames.size()); viewer->setHorizontalHeaderLabels(argumentsNames); for(int i = 0; i < argumentsNames.size(); i ++) { if(argumentsState[i] == "true") viewer->setColumnHidden(i, false); else viewer->setColumnHidden(i, true); } connect(currentSocketAdapter, SIGNAL(dataRecieved(QByteArray)), this, SLOT(addRecord(QByteArray))); }
std::shared_ptr< CSpectralSample > CSingleAngularMeasurement::Interpolate( double const t_Angle, std::shared_ptr< CSpectralSample > const& t_Data1, double const t_Angle1, std::shared_ptr< CSpectralSample > const& t_Data2, double const t_Angle2 ) const { auto aData = std::make_shared< CSpectralSampleData >(); auto wlv = t_Data1->getWavelengthsFromSample(); auto trans1 = *t_Data1->getMeasuredData()->properties( SampleData::T );; auto trans2 = *t_Data2->getMeasuredData()->properties( SampleData::T );; auto reflef1 = *t_Data1->getMeasuredData()->properties( SampleData::Rf );; auto reflef2 = *t_Data2->getMeasuredData()->properties( SampleData::Rf );; auto refleb1 = *t_Data1->getMeasuredData()->properties( SampleData::Rb );; auto refleb2 = *t_Data2->getMeasuredData()->properties( SampleData::Rb );; auto frac = ( t_Angle - t_Angle1 ) / ( t_Angle2 - t_Angle1 ); for ( size_t i = 0; i < wlv.size(); i++ ) { auto wl = wlv[ i ]; auto t1 = trans1[ i ].value(); auto t2 = trans2[ i ].value(); auto rf1 = reflef1[ i ].value(); auto rf2 = reflef2[ i ].value(); auto rb1 = refleb1[ i ].value(); auto rb2 = refleb2[ i ].value(); auto t = t1 + frac * ( t2 - t1 ); auto rf = rf1 + frac * ( rf2 - rf1 ); auto rb = rb1 + frac * ( rb2 - rb1 ); aData->addRecord( wl, t, rf, rb ); } auto aSample = std::make_shared< CSpectralSample >( aData, t_Data1->getSourceData() ); return aSample; }
void FrmTrip::createRecord() { //block the signals while introducing record, so we dont have to validate the units mismatch emit blockCatchUISignals(true); genericCreateRecord(); mapper1->toLast(); if(!m_tDateTime) return; m_tDateTime->select(); bool bDate, bTime; customDtStart->getIsDateTime(bDate,bTime); if (!m_tDateTime->insertNewRecord(customDtStart->getIsAuto(),bDate,bTime)){ emit showError(tr("Could not insert start date!")); return; } customDtEnd->getIsDateTime(bDate,bTime); if (!m_tDateTime->insertNewRecord(customDtStart->getIsAuto(),bDate,bTime)){ emit showError(tr("Could not insert start date!")); return; } customDtStart->setModelRow(m_tDateTime->rowCount()-2); customDtEnd->setModelRow(m_tDateTime->rowCount()-1); mapperStartDt->setCurrentIndex(m_tDateTime->rowCount()-2); mapperEndDt->setCurrentIndex(m_tDateTime->rowCount()-1); //IMPORTANT: do this after setting the model row! connect(m_tDateTime, SIGNAL(getDateType(QModelIndex,QVariant)), customDtStart, SLOT(adjustDateTime(QModelIndex,QVariant)),Qt::UniqueConnection); connect(m_tDateTime, SIGNAL(getDateType(QModelIndex,QVariant)), customDtEnd, SLOT(adjustDateTime(QModelIndex,QVariant)),Qt::UniqueConnection); while(tTrips->canFetchMore()) tTrips->fetchMore(); //Fields that we have to fill behind the scenes... QModelIndex idx=tTrips->index(tTrips->rowCount()-1,1); tTrips->setData(idx,m_sample->sampVesselId);//id_abstract_sampled_vessels //TODO: on sample fill the abstract landing site if (!m_sample->bLogBook){ cmbSite->setCurrentIndex(0); cmbSite->setEnabled(false); } tTripGears->setFilter(tr("")); uI4NewRecord();//init UI //signal for the rule checker default values emit addRecord(); emit blockCatchUISignals(false); }
bool Board_Move_Dataset_record::readAndAddRecordFromSGF(const std::string &filename) { shared_ptr<Record> record(new Record); if (SgfReader::readFromFile(filename, *record) != SgfReader::SGF_READ_OK) { cerr << "Failed to read record file: " << filename << endl; return false; } return addRecord(record); }
DWORD eventNotify_t::dumpNewRecords(void) { EVENTLOGRECORD* rec = nullptr; BYTE* ptr = nullptr; eventLogEntry_t* e = nullptr; wchar_t* wnam = nullptr; QString nam = ""; DWORD status = ERROR_SUCCESS; status = readRecord(ptr, 0, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ); if (ERROR_SUCCESS != status && ERROR_HANDLE_EOF != status) { if (nullptr != ptr) delete ptr; return status; } while (ERROR_HANDLE_EOF != status) { rec = reinterpret_cast< EVENTLOGRECORD* >(ptr); wnam = reinterpret_cast< wchar_t* >(reinterpret_cast< unsigned char* >(ptr + sizeof(EVENTLOGRECORD))); if (nullptr == wnam) { delete ptr; ptr = nullptr; return ERROR_INVALID_PARAMETER; // XXX JF FIXME } nam = QString::fromWCharArray(wnam); if (! nam.compare("WINHTTPD-Controller", Qt::CaseInsensitive) || ! nam.compare("WINHTTPD-Worker", Qt::CaseInsensitive)) { e = new eventLogEntry_t(*rec); //std::make_shared< eventLogEntry_t >(*rec); emit addRecord(e); //e = nullptr; } delete ptr; ptr = nullptr; status = readRecord(ptr, 0, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ); if (ERROR_SUCCESS != status && ERROR_HANDLE_EOF != status) { if (nullptr != ptr) delete ptr; return status; } } if (ERROR_HANDLE_EOF == status) status = ERROR_SUCCESS; return status; }
void RuntimeRecordClass::merge(const RuntimeRecordClass & c){ //transfer all values for(uint i = 0; i < c.records.size(); ++i){ records.push_back(c.records[i]); addRecord(c.records[i]); } }
Card::Card(QSqlQueryModel *personModel, QSqlQueryModel *responseModel, QWidget *parent) : CardUI(parent){ setFormPersonMap(personModel); setFormResponseMap(responseModel); connect(submitNew, SIGNAL(clicked()), this, SLOT(addRecord())); connect(submitEdit, SIGNAL(clicked()), this, SLOT(editRecord())); connect(submitReset, SIGNAL(clicked()), this, SLOT(clearFields())); connect(submitDelete,SIGNAL(clicked()), this, SLOT(deleteRecord())); }
void TPWorkPush::policy() { useconds_t usecs = 1, range = 1; #ifdef TRACE addRecord(getTime(), (void*) &TPWorkPush::policy); #endif while (alive()) { //Check if we have any work in our deque tpClosure * tempClosure = popTP(); if (tempClosure) { usecs = range; // reset sleep time #ifdef TRACE addRecord(getTime(), (void*) tempClosure->factory); #endif tempClosure->factory(tempClosure); #ifdef TRACE addRecord(getTime(), (void*) &TPWorkPush::policy); #endif delete tempClosure; //Get the work ready! } else { usleep(usecs); if (usecs < 500) usecs *= 2; } //Lets do the work! Codelet * tempCodelet = popCodelet(); while (tempCodelet) { //Here we are going to try to push bool fail = true; while (fail) { MScheduler * myCDS = static_cast<MScheduler*> (getSubScheduler(getSubIndexInc())); if (myCDS->pushCodelet(tempCodelet)) { fail = false; break; } } tempCodelet = popCodelet(); } } }
void mprof::CompactnessAnalysis::build( const struct MprofRecordAlloc * in_record, std::vector<size_t>::const_iterator in_orderBegin, std::vector<size_t>::const_iterator in_orderEnd ) { std::list<size_t> retryList; size_t lastIndex = *in_orderBegin; for( std::vector<size_t>::const_iterator orderItr = in_orderBegin; orderItr != in_orderEnd; ++orderItr ) { if( addRecord( in_record, *orderItr ) ) { lastIndex = *orderItr; //keep retrying--FIXME: handle realloc better( damn you realloc ) bool progress; do { progress = false; for( std::list<size_t>::iterator retryItr = retryList.begin(); retryItr != retryList.end(); ) { if( addRecord( in_record, *retryItr ) ) { if( olderThan( in_record + *retryItr, in_record + lastIndex ) ) { std::cerr << "Info: mprof::CompactnessAnalysis::build: detected scheduler/timestamp inversion at index '" << *orderItr << "' of " << deltaT( in_record + *retryItr, in_record + lastIndex ) << " microseconds" << std::endl; } lastIndex = *retryItr; retryItr = retryList.erase( retryItr ); progress = true; } else { ++retryItr; } } } while( progress ); } else { if( in_record[ *orderItr ].header.mode == MPROF_MODE_REALLOC ) { //std::cerr << "Info: mprof::CompactnessAnalysis::build: realloc record at index '" << *orderItr << "' may have been paritally processed." << std::endl; } retryList.push_back( *orderItr ); } } for( std::list<size_t>::iterator retryItr = retryList.begin(); retryItr != retryList.end(); retryItr = retryList.erase( retryItr ) ) { size_t address, size; if( getAlloc( in_record + *retryItr, address, size ) ) { std::cerr << "Warning: mprof::CompactnessAnalysis::build: found double alloc at index '" << *retryItr << "' for address '" << std::hex << address << std::dec << "'" << std::endl; } if( getFree( in_record + *retryItr, address ) ) { std::cerr << "Warning: mprof::CompactnessAnalysis::build: found unmatched free at index '" << *retryItr << "' for address '" << std::hex << address << std::dec << "'" << std::endl; } } }
AbstractRuleBinder::AbstractRuleBinder( RuleChecker* ruleChecker, Sample* sample, const QString strForm, QWidget *parent): QObject(parent), ruleCheckerPtr(ruleChecker), m_strForm(strForm), m_sample(sample){ // Let's not connect directly to Rulechecker, so establish all signal-slot dialog here! connect(this, SIGNAL(addRecord()), this, SLOT(getDefaultValues())); connect(this, SIGNAL(submitRecord()), this, SLOT(getPreSubmitValidation())); }
int main ( void ) { Person *begin; begin = malloc ( sizeof ( Person ) ) ; *begin = addRecord (); showPerson ( begin ); printf ( "begin = %d , (*begin).next = %d\n", begin, (*begin).next ); return ( 0 ); }
void Add() { if (!isFileLoaded()) return; system("cls"); puts("Добавление записи.\n"); Route route; strcpy(route.Number, EnterNumber()); route.CarsCount = EnterCarsCount(); route.RouteLength = EnterRouteLength(); addRecord(&route); }
bool Table::copyRecords(Table& source) { for (int index = 0; index < source.recordCount(); index++) { if (Record* record = source.getRecord(index)) { if (!addRecord(record)) return false; } } return true; }
void *fillTable(void *ptr) { for (int i = 0; i < 100; i++) { std::string id("000"); id.append(1, 'a' + i); std::list<std::string> record; record.push_back("some data"); addRecord(); } usleep(1000 * 1000); return NULL; }
void RealTimeTextVisualization::update(IProject *project, UdpSocketAdapter *socketAdapter, QList<Format*> formats) { this->formats = formats; viewer->clear(); recordsCount = 0; currentProject = project; currentSocketAdapter = socketAdapter; connect(currentSocketAdapter, SIGNAL(dataRecieved(QByteArray)), this, SLOT(addRecord(QByteArray))); }
void TPRoundRobin::policy() { useconds_t usecs = 1, range = 1; #ifdef TRACE addRecord(getTime(), (void*) &TPRoundRobin::policy); #endif while (alive()) { //Check if we have any work in our deque tpClosure * tempClosure; if (!(tempClosure = popTP())) tempClosure = steal(); if (tempClosure) { usecs = range; // reset sleep time #ifdef TRACE addRecord(getTime(), (void*) tempClosure->factory); #endif tempClosure->factory(tempClosure); #ifdef TRACE addRecord(getTime(), (void*) &TPRoundRobin::policy); #endif delete tempClosure; //Get the work ready! } else { usleep(usecs); if (usecs < 500) usecs *= 2; } //Lets do the work! Codelet * tempCodelet = popCodelet(); while (tempCodelet) { MScheduler * myCDS = static_cast<MScheduler*> (getSubScheduler(getSubIndexInc())); while (!myCDS->pushCodelet(tempCodelet)) { myCDS = static_cast<MScheduler*> (getSubScheduler(getSubIndexInc())); } tempCodelet = popCodelet(); } } }
void NdefMessage::addMimeMediaRecord(String mimeType, uint8_t* payload, int payloadLength) { NdefRecord r = NdefRecord(); r.setTnf(TNF_MIME_MEDIA); byte type[mimeType.length() + 1]; mimeType.getBytes(type, sizeof(type)); r.setType(type, mimeType.length()); r.setPayload(payload, payloadLength); addRecord(r); }
void NdefMessage::addAndroidApplicationRecord(char *packageName) { NdefRecord* r = new NdefRecord(); r->setTnf(TNF_EXTERNAL_TYPE); char *RTD_AAR = "android.com:pkg"; // TODO this should be a constant or preprocessor r->setType((uint8_t *)RTD_AAR, strlen(RTD_AAR)); r->setPayload((uint8_t *)packageName, strlen(packageName)); addRecord(*r); delete(r); }
void DatabaseManager::deleteRecordWithCount(const StringPimpl &key, const StringPimpl &value) { vector<StringPimpl> files; //decrement the size by one if(recordCountExists(key, value)) { int size = getRecordTotalCount(key); addRecord(m_reserved + key + "_@size_@", StringPimpl::getString(size - 1)); deleteRecord(m_reserved + key + "_@existence_@" + value); } }
void FrmOperation::createRecord() { emit blockCatchUISignals(true); genericCreateRecord(); mapper1->toLast(); if(!m_tDateTime) return; m_tDateTime->select(); bool bDate, bTime; customDtStart->getIsDateTime(bDate,bTime); if (!m_tDateTime->insertNewRecord(customDtStart->getIsAuto(),bDate,bTime)){ emit showError(tr("Could not insert start date!")); return; } customDtEnd->getIsDateTime(bDate,bTime); if (!m_tDateTime->insertNewRecord(customDtStart->getIsAuto(),bDate,bTime)){ emit showError(tr("Could not insert start date!")); return; } customDtStart->setModelRow(m_tDateTime->rowCount()-2); customDtEnd->setModelRow(m_tDateTime->rowCount()-1); mapperStartDt->setCurrentIndex(m_tDateTime->rowCount()-2); mapperEndDt->setCurrentIndex(m_tDateTime->rowCount()-1); //IMPORTANT: do this after setting the model row! connect(m_tDateTime, SIGNAL(getDateType(QModelIndex,QVariant)), customDtStart, SLOT(adjustDateTime(QModelIndex,QVariant)),Qt::UniqueConnection); connect(m_tDateTime, SIGNAL(getDateType(QModelIndex,QVariant)), customDtEnd, SLOT(adjustDateTime(QModelIndex,QVariant)),Qt::UniqueConnection); while(tOperations->canFetchMore()) tOperations->fetchMore(); //Fields that we have to fill behind the scenes... QModelIndex idx=tOperations->index(tOperations->rowCount()-1,1); tOperations->setData(idx,m_sample->tripId);//id_fishing_trip uI4NewRecord();//init UI //signal for the rule checker default values emit addRecord(); emit blockCatchUISignals(false); }
int main() { int choice; init_mass_struct(); for(;;) { printf("Hello, user. What do you want?\n\n"); printf("1. Create new DB.\n"); printf("2. Add record.\n"); printf("3. Delete record.\n"); printf("4. Sort DB.\n"); printf("5. Save DB.\n"); printf("6. Load DB.\n"); printf("0. Exit.\n"); scanf("%d", &choice); switch (choice) { case 1: createDB(); break; case 2: addRecord(); break; case 3: deleteRecord(); break; case 4: sortDB(); break; case 5: saveDB(); break; case 6: loadDB(); break; case 0: system("cls"); printf("Bye-bye, user."); return 0; break; default: system("cls"); printf("Error! Please, enter correct menu number, or 0 to exit.\n\n"); break; } } return 0; }
void FrmMinorStrata::createRecord() { genericCreateRecord(); mapper1->toLast(); //TODO: put dates from the frame as default QModelIndex idx=tRefMinorStrata->index(tRefMinorStrata->rowCount()-1,1); tRefMinorStrata->setData(idx,m_sample->frameTimeId);//id_frame_time uI4NewRecord();//init UI //signal for the rule checker default values emit addRecord(); }