void resolve(void (*operation)(Enigma *,char *)) { Enigma enigma; char character; init_enigma(&enigma); character = getchar(); while( (character != EOF) && (character != '\n') ) { operation(&enigma,&character); putchar(character); character = getchar(); } }
void LogData::attachFile( const QString& fileName ) { LOG(logDEBUG) << "LogData::attachFile " << fileName.toStdString(); if ( file_ ) { // Remove the current file from the watch list fileWatcher_.removeFile( file_->fileName() ); } workerThread_.interrupt(); // If an attach operation is already in progress, the new one will // be delayed untilthe current one is finished (canceled) std::shared_ptr<const LogDataOperation> operation( new AttachOperation( fileName ) ); enqueueOperation( std::move( operation ) ); }
void UmlCallOperationAction::write(FileOut & out) { write_begin(out, "CallOperationAction"); write_end(out, TRUE); UmlOperation * op = operation(); if (op != 0) { out.indent(); out << "<operation"; out.idref(op); out << "/>\n"; } write_close(out); }
MNcdLoadNodeOperation* CNcdNodeProxy::LoadL( MNcdLoadNodeOperationObserver& aObserver ) { DLTRACEIN(("")); CNcdLoadNodeOperationProxy* operation( NULL ); operation = iOperationManager.CreateLoadNodeOperationL( *this ); operation->AddObserverL( this ); operation->AddObserverL( &aObserver ); DLTRACEOUT(("")); return operation; }
void OpMap::Apply(Expression *expression, Calculator *calculator, int32 recursions) { if(expression->LeafCount() != 2) throw EvaluateException("Map expects 2 operands."); Expression *head = expression->Leaf(0); Expression *list = expression->Leaf(1); for(ExprVector::iterator leaf = list->Leaves().begin(); leaf != list->Leaves().end(); ++leaf) { ExprPtr operation(new Expression()); operation->Head(head->Clone()); operation->AppendLeaf(*leaf); *leaf = operation.release(); } expression->AssignLeaf(1); expression->Evaluate(calculator, recursions); }
void DeleteRangeOperation::perform(std::function<void()> completionCallback) { LOG(StorageAPI, "DeleteRangeOperation"); RefPtr<DeleteRangeOperation> operation(this); auto callback = [this, operation, completionCallback](PassRefPtr<IDBDatabaseError> error) { if (error) m_callbacks->onError(error); else m_callbacks->onSuccess(); completionCallback(); }; m_transaction->database().serverConnection().deleteRange(*m_transaction, *this, callback); }
int aecp_controller_state_machine::start_operation(void *¬ification_id, uint16_t operation_id, uint16_t operation_type, const uint8_t *frame, ssize_t frame_len) { struct jdksavdecc_frame cmd_frame; memcpy(cmd_frame.payload, frame, frame_len); operation oper = operation(&cmd_frame, operation_id, operation_type, notification_id, CMD_WITH_NOTIFICATION); active_operations.push_back(oper); log_imp_ref->post_log_msg(LOGGING_LEVEL_DEBUG, "Added new operation with type %x and id %d", operation_type, operation_id); return 0; }
void bimWorld::CameraManipulator::disableFirstPersonControl() { unbindKeyDownEvent(KEY_W); unbindKeyUpEvent(KEY_W); unbindKeyDownEvent(KEY_S); unbindKeyUpEvent(KEY_S); unbindKeyDownEvent(KEY_A); unbindKeyUpEvent(KEY_A); unbindKeyDownEvent(KEY_D); unbindKeyUpEvent(KEY_D); bindMouseEvent(MIDDLE_MOUSE_BUTTON, onPanModel); setModelCenterKeepViewPoint(m_host->ViewerData()->getModelRoot()); m_host->_RenderingThreads()->updateSeveralTimes(); return; //if (!m_isFirstPersonManipEnabled) //{ // return; //} //switchMatrixManipulator(ManipulatorType::Default); //m_isFirstPersonManipEnabled = false; //float totalFrame = 60.0f; //getBIMCameraManip()->setRotationHandleBtn(osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON); std::function<void(float)> prefunc = [this/*, totalFrame*/](float frame){ //static int frame = 1; //static float newF = 1;//-1 / totalFrame * frame*frame + frame; bimWorld::CameraOperation operation(getBIMCameraManip()); operation.zoomBackward(m_zoomForwardDelta, frame); //if (newF < (totalFrame / 2.0f)) //{ // frame++; // newF += frame; //} //else //{ // frame--; // newF -= frame; //} }; core::InstanceFunction<void(float)> pre(prefunc, this, "onPreDisableFirstPersonControl"); std::function<void(float)> postfunc = [](float /*frame*/){}; core::InstanceFunction<void(float)> post(postfunc, this, "onPostDisableFirstPersonControl"); m_host->_RenderingThreads()->setBlockAnimation((unsigned int)totalFrame_FP, pre, post); }
int main(int argc, char *argv[]){ reset_meas(&ts); N = atoi(argv[1]); x = malloc(N*sizeof(int16_t)); y = malloc(N*sizeof(int16_t)); z = malloc(N*sizeof(int16_t)); start_meas(&ts); for (j=0; j<1000; j++){ operation(x,y,z,N); } stop_meas(&ts); printf("%llu\n", (ts.diff)/1000); return(0); }
bool QNetworkAccessCacheBackend::sendCacheContents() { setCachingEnabled(false); QAbstractNetworkCache *nc = networkCache(); if (!nc) return false; QNetworkCacheMetaData item = nc->metaData(url()); if (!item.isValid()) return false; QNetworkCacheMetaData::AttributesMap attributes = item.attributes(); setAttribute(QNetworkRequest::HttpStatusCodeAttribute, attributes.value(QNetworkRequest::HttpStatusCodeAttribute)); setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true); // set the raw headers QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(), end = rawHeaders.constEnd(); for ( ; it != end; ++it) setRawHeader(it->first, it->second); // handle a possible redirect QVariant redirectionTarget = attributes.value(QNetworkRequest::RedirectionTargetAttribute); if (redirectionTarget.isValid()) { setAttribute(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); redirectionRequested(redirectionTarget.toUrl()); } // signal we're open metaDataChanged(); if (operation() == QNetworkAccessManager::GetOperation) { QIODevice *contents = nc->data(url()); if (!contents) return false; contents->setParent(this); writeDownstreamData(contents); } #if defined(QNETWORKACCESSCACHEBACKEND_DEBUG) qDebug() << "Successfully sent cache:" << url(); #endif return true; }
void QNetworkAccessDebugPipeBackend::pushFromUpstreamToSocket() { // FIXME if (operation() == QNetworkAccessManager::PutOperation) { if (hasUploadFinished) return; forever { if (socket.bytesToWrite() >= WriteBufferSize) return; qint64 haveRead; const char *readPointer = uploadByteDevice->readPointer(WriteBufferSize, haveRead); if (haveRead == -1) { // EOF hasUploadFinished = true; emitReplyUploadProgress(bytesUploaded, bytesUploaded); possiblyFinish(); break; } else if (haveRead == 0 || readPointer == 0) { // nothing to read right now, we will be called again later break; } else { qint64 haveWritten; haveWritten = socket.write(readPointer, haveRead); if (haveWritten < 0) { // write error! QString msg = QCoreApplication::translate("QNetworkAccessDebugPipeBackend", "Write error writing to %1: %2") .arg(url().toString(), socket.errorString()); error(QNetworkReply::ProtocolFailure, msg); finished(); return; } else { uploadByteDevice->advanceReadPointer(haveWritten); bytesUploaded += haveWritten; emitReplyUploadProgress(bytesUploaded, -1); } //QCoreApplication::processEvents(); } } } }
template<typename T> void SegmentTree<T>::update_dim(NVector pos, int level){ if(level<dim-1) update_dim(pos,level+1); pos[level]/=2; while(pos[level]>0){ NVector l=pos,r=pos; l[level]=2*l[level]; r[level]=2*r[level]+1; (*data)[pos]=operation((*data)[l],(*data)[r]); if(level<dim-1) update_dim(pos,level+1); pos[level]/=2; } }
void Reciever::success() { std::cout << "Operation \'" << operation(session->tag()) << "\', result: \'" << session->result().toAscii().data() << "\'\n"; switch(session->tag()) { case GetTorrentsList: std::cout << "torrents count: \'" << session->torrentsCount() << "\'\n"; std::cout << "Torrents:\n"; torrentsList(); break; /* case StopTorrents: break; case StartTorrents: break;*/ defaults: std::cout << "Unknown tag.\n"; } emit term(); };
void LogData::attachFile( const QString& fileName ) { LOG(logDEBUG) << "LogData::attachFile " << fileName.toStdString(); if ( attached_file_ ) { // We cannot reattach throw CantReattachErr(); } indexingFileName_ = fileName; attached_file_.reset( new QFile( fileName ) ); openFileByHandle( attached_file_.get() ); attached_file_id_ = getFileId( indexingFileName_ ); std::shared_ptr<const LogDataOperation> operation( new AttachOperation( fileName ) ); enqueueOperation( std::move( operation ) ); }
virtual void apply( const protocol::custom_binary_operation& outer_o ) override { try { vector< CustomOperationType > custom_operations; try { custom_operations = fc::raw::unpack< vector< CustomOperationType > >( outer_o.data ); } catch ( fc::exception& ) { custom_operations.push_back( fc::raw::unpack< CustomOperationType >( outer_o.data ) ); } apply_operations( custom_operations, operation( outer_o ) ); } FC_CAPTURE_AND_RETHROW( (outer_o) ) }
QString NutshSqlSaver::sqlStringFormat(const QString ¶m) { // convertion des chaines de caractères au format normal vers SQL (pour insertion dans les tables) QString operation(param); operation.replace(" ", "__replaced"); operation.replace("\"", "'_replaced"); operation.replace("/", "slash_replaced"); operation.replace("@", "arobase_replaced"); operation.replace("#", "diese_replaced"); operation.replace("$", "dollar_replaced"); operation.replace("%", "pourcent_replaced"); operation.replace("?", "interrogation_replaced"); operation.replace("&", "and_replaced"); operation.replace("*", "etoile_replaced"); operation.replace("(", "parentheseouv_replaced"); operation.replace(")", "parentheseferm_replaced"); operation.replace("=", "egal_replaced"); operation.replace("+", "plus_replaced"); return operation; }
float eval(char *expr) { STACK solution,temp; init_stack(&solution);init_stack(&temp); float value,operand1,operand2; while(*expr) { if(!is_permitted(*expr)){ fprintf(stderr,"error: invalid expression\n"); exit(1); } if(is_digit(*expr)) if(*expr == DECIMAL_PT) push(&temp, (float) DECIMAL_PT); else push(&temp, (float) (*expr - '0')); else if(is_delimiter(*expr)){ if(!is_empty(&temp)) push(&solution,process_data(&temp)); else { expr++;continue; } } else { operand2 = pop(&solution); operand1 = pop(&solution); value = operation(operand1,operand2,*expr); push(&solution,value); } expr++; } if(!is_empty(&temp)) push(&solution,process_data(&temp)); if(get_top(&solution)>0){ printf("error: invalid postfix expression\n"); exit(1); } return pop(&solution); }
void ClearObjectStoreOperation::perform(std::function<void()> completionCallback) { LOG(StorageAPI, "ClearObjectStoreOperation"); RefPtr<ClearObjectStoreOperation> operation(this); auto clearCallback = [this, operation, completionCallback](PassRefPtr<IDBDatabaseError> prpError) { RefPtr<IDBDatabaseError> error = prpError; if (error) { m_callbacks->onError(error); m_transaction->abort(error.release()); } else m_callbacks->onSuccess(); completionCallback(); }; m_transaction->database().serverConnection().clearObjectStore(*m_transaction, *this, clearCallback); }
void findOperations(char *operators, int numOperators, struct Scope *scope) { int i; char *operator; struct Token *token = scope->first, *newNext; for(; token != NULL && token->next != NULL; token = token->next) { for (i = 0, operator = operators; i < numOperators; i++, operator = &operators[i]) { if (strcmp(token->type, OP) == 0 && token->charVal == *operator) { if (token->previous == NULL || token->next == NULL || strcmp(token->next->type, NUM) || strcmp(token->previous->type, NUM)) { freeAll(scope); printf("Sytax error.\n"); exit(1); } /* * Rejig linked list * * NUM[1] OP[2] NUM[3] * 1 takes the value of NUM OP NUM * 2 and 3 are bypassed, freed as links are removed */ token->previous->intVal = operation(token->charVal, token->previous->intVal, token->next->intVal); newNext = token->next->next; token = token->previous; free(token->next->next); free(token->next); token->next = newNext; if (token->next != NULL) { token->next->previous = token; } break; } } } }
int ProgressStatus::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 8) qt_static_metacall(this, _c, _id, _a); _id -= 8; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = app(); break; case 1: *reinterpret_cast< int*>(_v) = currentValue(); break; case 2: *reinterpret_cast< int*>(_v) = endValue(); break; case 3: *reinterpret_cast< QString*>(_v) = error(); break; case 4: *reinterpret_cast< QString*>(_v) = item(); break; case 5: *reinterpret_cast< QString*>(_v) = operation(); break; case 6: *reinterpret_cast< QString*>(_v) = units(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
void CheckDevicePresenceFlow::checkDevice(uint16_t deviceAddress, uint16_t reportingPeer, uint8_t joinPriority) { LOG_TRACE("checkDevice() for (" << ToStr(deviceAddress) << ")"); this->deviceAddress = deviceAddress; this->reportingPeer = reportingPeer; Device& dev = commonData.networkEngine.getDevice(deviceAddress); // dev.setAction(NE::Model::DeviceAction::CHECK_PRESENCE); dev.setOnEvaluation(true); // prevent other eval flows longAddressDevice = commonData.networkEngine.getAddress64(deviceAddress); linkOperations.reset(new EngineOperations()); std::ostringstream stream; stream << "Check device " << ToStr(deviceAddress) << " presence"; linkOperations->reasonOfOperations = stream.str(); ///currentFlowState = VisibleEdgeFlowState::Initial; // set the device priority IEngineOperationPointer operation(new ChangePriorityEngineOperation((uint32_t) deviceAddress, joinPriority)); operation->setDependency(WaveDependency::FIRST); linkOperations->addOperation(operation); operations::WHEngineOperationsVisitor visitor(linkOperations, commonData); operationsQueue.generateWHOperations(linkOperations, linkWhOperations, visitor); // the operations are only into NM => so we have to log them here SMState::SMStateLog::logAllInfo(linkOperations->reasonOfOperations); SMState::SMStateLog::logOperations(linkOperations->reasonOfOperations, *linkOperations); if (operationsQueue.addOperations(linkOperations, linkWhOperations, linkOperationsEvent, linkOperations->reasonOfOperations, boost::bind(&CheckDevicePresenceFlow::ProcessConfirmedOperations, this, _1), NULL)) { operationsQueue.sendOperations(); } //currentFlowState = VisibleEdgeFlowState::LinkSent; // LOG_TRACE("checkDevice() for (" << ToStr(deviceAddress) << ") <= " // << VisibleEdgeFlowState::getDescription(currentFlowState)); }
virtual void apply( const protocol::custom_json_operation& outer_o ) override { try { fc::variant v = fc::json::from_string( outer_o.json ); std::vector< CustomOperationType > custom_operations; if( v.is_array() && v.size() > 0 && v.get_array()[0].is_array() ) { // it looks like a list from_variant( v, custom_operations ); } else { custom_operations.emplace_back(); from_variant( v, custom_operations[0] ); } apply_operations( custom_operations, operation( outer_o ) ); } FC_CAPTURE_AND_RETHROW( (outer_o) ) }
void QNetworkAccessDebugPipeBackend::open() { socket.connectToHost(url().host(), url().port(12345)); socket.setReadBufferSize(ReadBufferSize); // socket ready read -> we can push from socket to downstream connect(&socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError())); connect(&socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(&socket, SIGNAL(connected()), SLOT(socketConnected())); // socket bytes written -> we can push more from upstream to socket connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); bareProtocol = url().queryItemValue(QLatin1String("bare")) == QLatin1String("1"); if (operation() == QNetworkAccessManager::PutOperation) { uploadByteDevice = createUploadByteDevice(); QObject::connect(uploadByteDevice, SIGNAL(readyRead()), this, SLOT(uploadReadyReadSlot())); QMetaObject::invokeMethod(this, "uploadReadyReadSlot", Qt::QueuedConnection); } }
int Capteur::get() { int timeout = 0; reponse = false; operation(); //envoie la requete //attend la reponse struct timespec avant, apres; clock_gettime(CLOCK_REALTIME, &avant); int timeoutMilliSec = TIMEOUTSEC * 1000 + TIMEOUTUSEC / 1000; while (!reponse) //Ok car programmation multi-threade { clock_gettime(CLOCK_REALTIME, &apres); timeout = (apres.tv_sec - avant.tv_sec) * 1000 + (apres.tv_nsec - avant.tv_nsec) / 1000000; if (timeout > timeoutMilliSec) return -1; } return cmd[0]; }
// --------------------------------------------------------------------------- // CJavaApplicationService::IsSwInIdle // --------------------------------------------------------------------------- TBool CJavaApplicationService::IsSwInIdle(TInt aValue) { _DMEVNT_DEBUG(_L("CJavaApplicationService::IsSwInIdle, value = %d >> "), aValue); TBool ret (EFalse); TInt operation(aValue & KJavaOperationMask); TInt operationStatus(aValue & KJavaStatusMask); _DMEVNT_DEBUG(_L("operation %d, status %d"), operation, operationStatus); if (EJavaStatusSuccess == operationStatus) { switch (operation) { case EJavaInstall: { _DMEVNT_DEBUG(_L("Uninstallation in progress")); iOperation = EOpnInstall; } break; case EJavaUninstall: { _DMEVNT_DEBUG(_L("Restore in progress")); iOperation = EOpnUninstall; } break; default: { _DMEVNT_DEBUG(_L("Unknown operation")); iOperation = EOpnUnknown; } } } ret = (operation != Swi::ESwisNone)? ETrue:EFalse; _DMEVNT_DEBUG(_L("CJavaApplicationService::IsSwInIdle, ret = %d << "),ret); return ret; }
void CursorIterationOperation::perform(std::function<void()> completionCallback) { LOG(StorageAPI, "CursorIterationOperation"); RefPtr<CursorIterationOperation> operation(this); auto callback = [this, operation, completionCallback](PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassRefPtr<IDBDatabaseError> error) { if (error) { m_cursor->clear(); // FIXME: The LevelDB backend calls onSuccess even on failure. // This will probably have to change soon (for sanity) and will probably break LevelDB m_callbacks->onSuccess(static_cast<SharedBuffer*>(0)); } else { m_cursor->updateCursorData(key.get(), primaryKey.get(), value.get()); m_callbacks->onSuccess(key, primaryKey, value); } // FIXME: Cursor operations should be able to pass along an error instead of success completionCallback(); }; m_cursor->transaction().database().serverConnection().cursorIterate(*m_cursor, *this, callback); }
static PyObject * check2i(ProxyObject *self, PyObject *other, char *opname, binaryfunc operation) { PyObject *result = NULL; PyObject *object = Proxy_GET_OBJECT(self); result = operation(object, other); if (result == object) { /* If the operation was really carried out inplace, don't create a new proxy, but use the old one. */ Py_INCREF(self); Py_DECREF(object); result = (PyObject *)self; } #if 0 else if (result != NULL) /* ??? create proxy for result? */ ; #endif return result; }
void OpenCursorOperation::perform(std::function<void()> completionCallback) { LOG(StorageAPI, "OpenCursorOperation"); RefPtr<OpenCursorOperation> operation(this); auto callback = [this, operation, completionCallback](int64_t cursorID, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> valueBuffer, PassRefPtr<IDBDatabaseError> error) { if (error) { m_callbacks->onError(error); } else if (!key) { // If there's no error but also no key, then the cursor had no records. m_callbacks->onSuccess(static_cast<SharedBuffer*>(nullptr)); } else { RefPtr<IDBCursorBackend> cursor = IDBCursorBackend::create(cursorID, m_cursorType, m_taskType, *m_transaction, m_objectStoreID); cursor->updateCursorData(key.get(), primaryKey.get(), valueBuffer.get()); m_callbacks->onSuccess(cursor.release()); } completionCallback(); }; m_transaction->database().serverConnection().openCursor(*m_transaction, *this, callback); }
int EvaluateExpression() { int i = 0; Stack_num S; int ret = 0; int a = 0; int b = 0; CreateStack_num(&S); while (post[i] != '\0') { switch (judge_type(post[i])) { case 0: //读取的是符号 pop_num(&S, &b); //取除数字栈的栈顶元素 pop_num(&S,&a); //取除数字栈的栈顶元素 ret=operation(a,post[i],b); //对这两个数进行运算 push_num(&S, ret); //将运算结果入站 i++; ret = 0; break; case 1: while(judge_type(post[i])==1) { ret = ret * 10 + post[i] - '0'; //将字符数字转换成对应的整数 i++; } push_num(&S, ret); //将这个数字进行压栈 ret = 0; break; case -1: //读取的是空格 i++; break; } } ret = *(--(S.esp)); //弹出栈底数字 free(S.ebp); return ret; }
float evaluate(TNode *root) { float val, t1, t2; if(root == NULL) return 0; else { if(isdigit(root->data)) return (float)((root->data) - '0'); else if(isalpha(root->data)) { printf("Enter %c\n", root->data); scanf("%f", &val); return(val); } else { t1 = evaluate(root->lchild); t2 = evaluate(root->rchild); return operation(t1, t2, root->data); } } }