DocumentSource::GetNextResult DocumentSourceMergeCursors::getNext() { // We don't expect or support tailable cursors to be executing through this stage. invariant(pExpCtx->tailableMode == TailableModeEnum::kNormal); if (!_arm) { _arm.emplace(pExpCtx->opCtx, _executor, std::move(*_armParams)); _armParams = boost::none; } auto next = uassertStatusOK(_arm->blockingNext()); if (next.isEOF()) { return GetNextResult::makeEOF(); } return Document::fromBsonWithMetaData(*next.getResult()); }
LRESULT CGroupSearchResultPage::OnWizardNext() { GROUP_INFO *info = getResult(); if (!info) return -1; CGroupSearchWizard *wiz = (CGroupSearchWizard *) GetParent(); GROUP_TYPE_INFO *type = icqLink->getGroupTypeInfo(info->type); if (!GroupPlugin::get(type->name.c_str())) return -1; return CPropertyPage::OnWizardNext(); }
//计时刷新 void CenterWidget::update() { int countdown=questionMax*30000-time.elapsed(); if(countdown<=0) { getResult(); return; } QString text = QString("%1:%2").arg(countdown/60000).arg(countdown%60000/1000); if(text.section(':',1,1).size()<2) text.insert(text.size()-1,"0"); showtime->display(text); }
void createTHResource() { TH.m_humid = 0; TH.m_temp = 0; OCStackResult res = OCCreateResource(&TH.m_handle, "SSManager.Sensor", OC_RSRVD_INTERFACE_DEFAULT, "/Thing_TempHumSensor", OCEntityHandlerCb, OC_DISCOVERABLE | OC_OBSERVABLE); OC_LOG_V(INFO, TAG, "Created TH resource with result: %s", getResult(res)); }
void createTHResource() { TH.m_humid = 0; TH.m_temp = 0; OCStackResult res = OCCreateResource(&TH.m_handle, "SoftSensorManager.Sensor", "oc.mi.def", "/Thing_TempHumSensor1", OCEntityHandlerCb, OC_DISCOVERABLE | OC_OBSERVABLE); OC_LOG_V(INFO, TAG, "Created TH resource with result: %s", getResult(res)); }
OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse) { OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully"); if(clientResponse) { OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber); OC_LOG_V(INFO, TAG, "JSON = %s =============> Get Response", clientResponse->resJSONPayload); } return OC_STACK_DELETE_TRANSACTION; }
void testGenerateGameMap() { int n = 6; int** map; srand( (unsigned)time(NULL) ); freopen("maps.html", "w", stdout); printf("<html><br/>\n\t<head>\n\t\t<title>Jeu du network</title>\n\t</head>\n<body>"); map = generateGameMap( n ); displayMapInGraph( map, n ); getResult( map, n ); displayMapInGraph( map, n ); printf("\t</body></html>"); fclose(stdout); }
/** \fn getNextFrame \brief */ bool vdpauVideoFilterDeint::getNextFrame(uint32_t *fn,ADMImage *image) { bool r=true; if(eof) { ADM_warning("[VdpauDeint] End of stream\n"); return false; } #define FAIL {r=false;goto endit;} if(passThrough) return previousFilter->getNextFrame(fn,image); // top field has already been sent, grab bottom field if((secondField)&&(configuration.deintMode==ADM_KEEP_BOTH)) { secondField=false; *fn=nextFrame*2+1; if(false==getResult(image)) return false; if(ADM_NO_PTS==nextPts) image->Pts=nextPts; else image->Pts=nextPts-info.frameIncrement; aprintf("2ndField : Pts=%s\n",ADM_us2plain(image->Pts)); return true; } // shift frames;... free slot[0] rotateSlots(); // our first frame, we need to preload one frame if(!nextFrame) { aprintf("This is our first image, filling slot 1\n"); ADMImage *prev= vidCache->getImageAs(ADM_HW_VDPAU,0); if(false==fillSlot(1,prev)) { vidCache->unlockAll(); return false; } if(false==fillSlot(0,prev)) { vidCache->unlockAll(); return false; } } // regular image, in fact we get the next image here ADMImage *next= vidCache->getImageAs(ADM_HW_VDPAU,nextFrame+1); if(next) { if(false==fillSlot(2,next)) { vidCache->unlockAll(); FAIL } }
OCStackResult CreateProvisioningResource() { g_prov.ps = 1; // need to provisioning g_prov.tnt = CT_ADAPTER_IP; sprintf(g_prov.tnn, "Unknown"); sprintf(g_prov.cd, "Unknown"); OCStackResult res = OCCreateResource(&g_prov.handle, "oic.r.prov", OC_RSRVD_INTERFACE_DEFAULT, OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb, NULL, OC_DISCOVERABLE | OC_OBSERVABLE); OC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res)); return res; }
double SQLiteQuery::executeGetDouble(const std::string &sql) { double val = 0; if (getResult(sql)) { if (fetchNext()) { val = getDouble(); } freeResults(); } return val; }
// function main begins program execution int main( void ) { int sum; // sum of rolled dice // enumeration constants represent game status enum Status { CONTINUE, WON, LOST }; enum Status gameStatus; // can contain CONTINUE, WON, or LOST sum = rollDice(); // first roll of the dice int realStatus = compareDiceNumber(sum); getResult(realStatus); system("pause"); return 0; } // end main
void *presenceNotificationGenerator(void *param) { sleep(5); (void)param; OCDoHandle presenceNotificationHandles[numPresenceResources]; OCStackResult res = OC_STACK_OK; std::array<std::string, numPresenceResources> presenceNotificationResources { { std::string("core.fan"), std::string("core.led") } }; std::array<std::string, numPresenceResources> presenceNotificationUris { { std::string("/a/fan"), std::string("/a/led") } }; for(int i=0; i<numPresenceResources; i++) { if(res == OC_STACK_OK) { sleep(1); res = OCCreateResource(&presenceNotificationHandles[i], presenceNotificationResources.at(i).c_str(), "oc.mi.def", presenceNotificationUris.at(i).c_str(), OCNOPEntityHandlerCb, OC_DISCOVERABLE|OC_OBSERVABLE); } if(res != OC_STACK_OK) { OC_LOG_V(ERROR, TAG, "\"Presence Notification Generator\" failed to create resource " "%s with result %s.", presenceNotificationResources.at(i).c_str(), getResult(res)); break; } } sleep(5); for(int i=0; i<numPresenceResources; i++) { if(res == OC_STACK_OK) { res = OCDeleteResource(presenceNotificationHandles[i]); } if(res != OC_STACK_OK) { OC_LOG_V(ERROR, TAG, "\"Presence Notification Generator\" failed to delete "\ "resource %s.", presenceNotificationResources.at(i).c_str()); break; } } return NULL; }
Object c_SetResultToRefWaitHandle::ti_create(CObjRef wait_handle, VRefParam ref) { TypedValue* var_or_cell = ref->asTypedValue(); if (wait_handle.isNull()) { tvSetNull(*var_or_cell); return wait_handle; } if (!wait_handle.get()->getAttribute(ObjectData::IsWaitHandle)) { Object e(SystemLib::AllocInvalidArgumentExceptionObject( "Expected wait_handle to be an instance of WaitHandle or null")); throw e; } auto wh = static_cast<c_WaitHandle*>(wait_handle.get()); // succeeded? set result to ref and give back succeeded wait handle if (wh->isSucceeded()) { tvSet(wh->getResult(), *var_or_cell); return wh; } // failed? reset ref and give back failed wait handle if (wh->isFailed()) { tvSetNull(*var_or_cell); return wh; } // it's still running so it must be WaitableWaitHandle auto child = static_cast<c_WaitableWaitHandle*>(wh); // import child into the current context, detect cross-context cycles auto session = AsioSession::Get(); if (session->isInContext()) { child->enterContext(session->getCurrentContextIdx()); } // make sure the reference is properly boxed so that we can store cell pointer if (UNLIKELY(var_or_cell->m_type != KindOfRef)) { tvBox(var_or_cell); } p_SetResultToRefWaitHandle my_wh = NEWOBJ(c_SetResultToRefWaitHandle)(); my_wh->initialize(child, var_or_cell->m_data.pref); if (UNLIKELY(session->hasOnSetResultToRefCreateCallback())) { session->onSetResultToRefCreate(my_wh.get(), child); } return my_wh; }
Color GodRaysSampler::apply(const Color &raw, const Color &atmosphered, const Vector3 &location) { if (enabled) { GodRaysResult result = getResult(SpaceSegment(*camera_location, location)); GodRaysResult::GodRaysParams params; params.penetration = definition->propPenetration()->getValue(); params.resistance = definition->propResistance()->getValue(); params.boost = definition->propBoost()->getValue(); return result.apply(raw, atmosphered, params); } else { return atmosphered; } }
long SQLiteQuery::executeGetLong(const std::string &sql) { long val = 0; if (getResult(sql)) { if (fetchNext()) { val = getLong(); } freeResults(); } return val; }
OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse) { if(ctx == (void*)DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully"); } if(clientResponse) { OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); OC_LOG_V(INFO, TAG, "JSON = %s =============> Put Response", clientResponse->resJSONPayload); } return OC_STACK_DELETE_TRANSACTION; }
Object c_GenVectorWaitHandle::ti_create(const Variant& dependencies) { if (UNLIKELY(!dependencies.instanceof(c_Vector::classof()))) { Object e(SystemLib::AllocInvalidArgumentExceptionObject( "Expected dependencies to be an instance of Vector")); throw e; } assert(dependencies.getObjectData()->instanceof(c_Vector::classof())); auto deps = p_Vector::attach(c_Vector::Clone(dependencies.getObjectData())); for (int64_t iter_pos = 0; iter_pos < deps->size(); ++iter_pos) { Cell* current = deps->at(iter_pos); if (UNLIKELY(!c_WaitHandle::fromCell(current))) { Object e(SystemLib::AllocInvalidArgumentExceptionObject( "Expected dependencies to be a vector of WaitHandle instances")); throw e; } } Object exception; for (int64_t iter_pos = 0; iter_pos < deps->size(); ++iter_pos) { Cell* current = tvAssertCell(deps->at(iter_pos)); assert(current->m_type == KindOfObject); assert(current->m_data.pobj->instanceof(c_WaitHandle::classof())); auto child = static_cast<c_WaitHandle*>(current->m_data.pobj); if (child->isSucceeded()) { cellSet(child->getResult(), *current); } else if (child->isFailed()) { putException(exception, child->getException()); } else { assert(child->instanceof(c_WaitableWaitHandle::classof())); auto child_wh = static_cast<c_WaitableWaitHandle*>(child); p_GenVectorWaitHandle my_wh = NEWOBJ(c_GenVectorWaitHandle)(); my_wh->initialize(exception, deps.get(), iter_pos, child_wh); AsioSession* session = AsioSession::Get(); if (UNLIKELY(session->hasOnGenVectorCreateCallback())) { session->onGenVectorCreate(my_wh.get(), dependencies); } return my_wh; } } if (exception.isNull()) { return c_StaticResultWaitHandle::Create(make_tv<KindOfObject>(deps.get())); } else { return c_StaticExceptionWaitHandle::Create(exception.get()); } }
OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse) { if(!clientResponse) { OIC_LOG_V(INFO, TAG, "obsReqCB received NULL response"); } if(ctx == (void*)DEFAULT_CONTEXT_VALUE) { OIC_LOG(INFO, TAG, "Callback Context recvd successfully"); } OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber); OIC_LOG_V(INFO, TAG, "OBSERVE notification %d recvd", gNumObserveNotifies); OIC_LOG_PAYLOAD(INFO, clientResponse->payload); gNumObserveNotifies++; if (gNumObserveNotifies == maxNotification) { if (OCCancel (gObserveDoHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "Observe cancel error"); } return OC_STACK_DELETE_TRANSACTION; } if (gNumObserveNotifies == 1 && TEST_CASE == TEST_OBS_REQ_NON_CANCEL_IMM) { if (OCCancel (gObserveDoHandle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "Observe cancel error"); } } if(clientResponse->sequenceNumber == OC_OBSERVE_REGISTER) { OIC_LOG(INFO, TAG, "Registration confirmed"); } else if(clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER) { OIC_LOG(INFO, TAG, "de-registration confirmed"); return OC_STACK_DELETE_TRANSACTION; } else if(clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION) { OIC_LOG(INFO, TAG, "Registration/deregistration failed"); return OC_STACK_DELETE_TRANSACTION; } SET_BUT_NOT_USED(handle); return OC_STACK_KEEP_TRANSACTION; }
//http://acm.fzu.edu.cn/log.php?pid=1000&user=bnuvjudge&language=1 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "fzu.cookie"); string url=(string)"http://acm.fzu.edu.cn/log.php?user="******"&pid="+pid; //cout<<url<<endl; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); //cout<<ts; if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; if (result=="Accepted") { tu=getUsedTime(ts); mu=getUsedMem(ts); } return true; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->operation->addItem("+"); ui->operation->addItem("-"); ui->operation->addItem("*"); ui->operation->addItem("/"); connect(ui->arg1, SIGNAL(valueChanged(int)), this, SLOT(getResult())); connect(ui->operation, SIGNAL(currentTextChanged(QString)), this, SLOT(getResult())); connect(ui->arg2, SIGNAL(valueChanged(int)), this, SLOT(getResult())); }
int main(){ int t,i,j,k,a,n; int value[N]; int result; scanf("%d\n",&n); for(j=0;j<n;j++) scanf("%d",&value[j]); j=0; k=n-1; a=1; result=getResult(value, j, k, a); printf("%d\n",result); return 0; }
vector<string> letterCombinations(string digits) { // Start typing your C/C++ solution below // DO NOT write int main() function res.clear(); if(digits.size() == 0) { res.push_back(""); return res; } tmp = string(digits.size(),'a'); getResult(digits,0); //vector<string>::const_iterator lookfor = find(res.begin(),res.end(),""); //if(lookfor != res.end()) res.erase(lookfor); return res; }
void GlobalOptionsDialog::close() { if (getResult()) { // Savepath ConfMan.set("savepath", _savePath->getLabel(), _domain); String themePath(_themePath->getLabel()); if (!themePath.empty() && (themePath != "None")) ConfMan.set("themepath", themePath, _domain); String extraPath(_extraPath->getLabel()); if (!extraPath.empty() && (extraPath != "None")) ConfMan.set("extrapath", extraPath, _domain); } OptionsDialog::close(); }
void c_AsyncFunctionWaitHandle::resume() { auto const child = m_children[0].getChild(); assert(getState() == STATE_READY); assert(child->isFinished()); setState(STATE_RUNNING); if (LIKELY(child->isSucceeded())) { // child succeeded, pass the result to the async function g_context->resumeAsyncFunc(resumable(), child, child->getResult()); } else { // child failed, raise the exception inside the async function g_context->resumeAsyncFuncThrow(resumable(), child, child->getException()); } }
void TestWindow::saveResult() { std::ofstream output; QString path=QApplication::applicationDirPath()+"/Result.txt"; output.open(path.toLocal8Bit().data(), std::ios_base::app); char buffer[80]; time_t seconds = time(NULL); tm* timeinfo = localtime(&seconds); //char* format = "%A, %B %d, %Y %H:%M:%S"; strftime(buffer, 80, "%A, %B %d, %Y %H:%M:%S", timeinfo); output<<"---------------------------------------"<<std::endl; output<<buffer<<std::endl; output<< getResult().toStdString() <<std::endl; output.close(); }
void inputTestCases() { struct testcases { long long int X; long long int Y; long long int Z; long long int result; }test[5] = { {8,11,3,2}, //normal condition {0,3,4,0}, //x value is 0 {2,0,4,1}, //y value is 0 {6,3,4,0}, //x,z having commmon multiple hence result is 0 {57577,585,58858,43331}, //some bigger numbers }; int i; for(i=0;i<5;i++) { if(getResult(test[i].X,test[i].Y,test[i].Z)==test[i].result) printf("pass\n"); else printf("%ld fail\n",getResult(test[i].X,test[i].Y,test[i].Z)); } }
const char *SQLiteQuery::executeGetString(const std::string &sql) { m_tempString = ""; if (getResult(sql)) { if (fetchNext()) { m_tempString = getString(); } freeResults(); } return m_tempString.c_str(); }
void c_GenMapWaitHandle::onUnblocked() { assert(getState() == STATE_BLOCKED); for (; m_deps->iter_valid(m_iterPos); m_iterPos = m_deps->iter_next(m_iterPos)) { auto* current = tvAssertCell(m_deps->iter_value(m_iterPos)); assert(current->m_type == KindOfObject); assert(current->m_data.pobj->instanceof(c_WaitHandle::classof())); auto child = static_cast<c_WaitHandle*>(current->m_data.pobj); if (child->isSucceeded()) { auto k = m_deps->iter_key(m_iterPos); m_deps->set(k.asCell(), &child->getResult()); } else if (child->isFailed()) { putException(m_exception, child->getException()); } else { assert(child->instanceof(c_WaitHandle::classof())); auto child_wh = static_cast<c_WaitableWaitHandle*>(child); try { if (isInContext()) { child_wh->enterContext(getContextIdx()); } detectCycle(child_wh); blockOn(child_wh); return; } catch (const Object& cycle_exception) { putException(m_exception, cycle_exception.get()); } } } auto const parentChain = getFirstParent(); if (m_exception.isNull()) { setState(STATE_SUCCEEDED); tvWriteObject(m_deps.get(), &m_resultOrException); } else { setState(STATE_FAILED); tvWriteObject(m_exception.get(), &m_resultOrException); m_exception = nullptr; } m_deps = nullptr; UnblockChain(parentChain); decRefObj(this); }
void HTTPClientTestObject::test<3>() { LLSD sd; sd["list"][0]["one"] = 1; sd["list"][0]["two"] = 2; sd["list"][1]["three"] = 3; sd["list"][1]["four"] = 4; setupTheServer(); LLHTTPClient::post("http://localhost:8888/web/echo", sd, newResult()); runThePump(); ensureStatusOK(); ensure_equals("echoed result matches", getResult(), sd); }
std::shared_ptr<ResultSet> getAsyncResult() { PGresult *result = getResult(); if ( !result || (PQresultStatus(result) != PGRES_TUPLES_OK)) { std::string err_msg = "Postgis Plugin: "; err_msg += status(); err_msg += "in getAsyncResult"; clearAsyncResult(result); // We need to be guarded against losing the connection // (i.e db restart), we invalidate the full connection close(); throw mapnik::datasource_exception(err_msg); } return std::make_shared<ResultSet>(result); }