void engineHandleCommand(struct android_app* app, int32_t cmd) { ARUserData * data = (ARUserData*) app->userData; Engine* engine = data->engine; LOGD(LOGTAG_INPUT,"Handling OS cmd: %d",cmd); switch (cmd) { case APP_CMD_INIT_WINDOW: LOGI(LOGTAG_MAIN,"OS Has Initialized Window"); initializeEngine(app, engine); initializeWindow(app, engine); break; case APP_CMD_TERM_WINDOW: LOGI(LOGTAG_MAIN,"Terminated Window"); shutdownEngine(engine); break; case APP_CMD_GAINED_FOCUS: LOGI(LOGTAG_MAIN,"Gained focus"); engine->animating = 1; break; case APP_CMD_LOST_FOCUS: LOGI(LOGTAG_MAIN,"Lost focus, pausing animation"); engine->animating = 0; break; } }
SSMRESULT CEvaluationEngine::finalConstruct() { SSMRESULT res = SSM_E_FAIL; m_pSQLite3 = NULL; m_mtxTriggerId.lock(); m_iTriggerId = 0; m_mtxTriggerId.unlock(); SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, (IBase **)&m_pTasker)); SSM_CLEANUP_ASSERT(initializeEngine()); CLEANUP: return res; }
// Initialize engine template <class TYPE> StatusCode Engine<TYPE>::initialize() { m_seeds.erase(m_seeds.begin(), m_seeds.end()); StatusCode status = RndmEngine::initialize(); if ( m_seeds.size() == 0 ) { // Default seeds long theSeed = 1234567; m_seeds.push_back(theSeed); m_seeds.push_back(0); } MsgStream log(msgSvc(), name()); if ( status.isSuccess() ) { status = initializeEngine(); if ( status.isSuccess() ) { log << MSG::INFO << "Generator engine type:" << System::typeinfoName(typeid(TYPE)) << endmsg; if ( m_useTable ) { if ( m_row > 214 || m_col > 1 ) { log << MSG::ERROR << "Generator engine seed table has dimension [215][2], you gave:" << " Row=" << m_row << " Column:" << m_col << endmsg; status = StatusCode::FAILURE; } else { log << MSG::INFO << "Generator engine seeds from table." << " Row=" << m_row << " Column:" << m_col << endmsg; } } log << "Current Seed:" << m_hepEngine->getSeed(); log << " Luxury:" << m_lux; log << endmsg; // Use the default static engine if required (e.g. for GEANT4) if ( m_setSingleton ) { HepRandom::setTheEngine(m_hepEngine); log << "This is the GEANT4 engine!" << endmsg; } return status; } } log << MSG::ERROR << "Cannot initialze random engine of type:" << System::typeinfoName(typeid(TYPE)) << endmsg; return status; }
void KviCryptController::okClicked() { if(m_pEnableCheck->isChecked()) { if(m_pLastItem) { if(m_pEnableEncrypt->isChecked() || m_pEnableDecrypt->isChecked()) { m_pSessionInfo = allocateCryptSessionInfo(); // Reregister the module in case that it has been unloaded // while this dialog was open if(!m_pLastItem->m_szModuleName.isEmpty())(void)g_pModuleManager->getModule(m_pLastItem->m_szModuleName.toUtf8().data()); m_pSessionInfo->m_pEngine = g_pCryptEngineManager->allocateEngine(m_pLastItem->m_szName.toUtf8().data()); if(!m_pSessionInfo->m_pEngine) { m_pWindow->output(KVI_OUT_SYSTEMERROR,__tr2qs("Crypt: Can't create an engine instance: crypting disabled")); delete m_pSessionInfo; m_pSessionInfo = 0; } else { // initialize the engine if(!initializeEngine(m_pSessionInfo->m_pEngine)) { QString szErrStr = m_pSessionInfo->m_pEngine->lastError(); g_pCryptEngineManager->deallocateEngine(m_pSessionInfo->m_pEngine); delete m_pSessionInfo; m_pSessionInfo = 0; m_pWindow->output(KVI_OUT_SYSTEMERROR,__tr2qs("Crypt: Can't initialize the engine :%s"),szErrStr.toUtf8().data()); } else { // ok, engine ready and waiting... m_pSessionInfo->m_szEngineName = m_pLastItem->m_szName; m_pSessionInfo->m_bDoEncrypt = m_pEnableEncrypt->isChecked(); m_pSessionInfo->m_bDoDecrypt = m_pEnableDecrypt->isChecked(); } } } else m_pWindow->output(KVI_OUT_SYSTEMERROR,__tr2qs("Crypt: You have to enable encryption and/or decryption for the engine to work")); } } emit done(); }
void android_main(struct android_app* state) { LOG_INTRO(); if (!envInitialized) { LOGE("ERROR! JAVA DID NOT INITIALIZE FIRST. Exiting!"); return; } pthread_mutex_init(&incomingMutex,NULL); jniDataVector.clear(); Engine mainEngine = Engine(); AmplifyRunner myRunner = AmplifyRunner(&mainEngine); struct ARUserData myData; memset(&myData,0,sizeof(ARUserData)); myData.engine = &mainEngine; myData.runner = &myRunner; state->userData = &myData; initializeEngine(state, &mainEngine); bool running = true; while (running) { // Read all pending events. int ident; int events; struct android_poll_source* source; // If not animating, we will block forever waiting for events. // If animating, we loop until all events are read, then continue to draw the next frame of animation. while ((ident = ALooper_pollAll(mainEngine.animating ? 0 : -1, NULL, &events, (void**) &source)) >= 0) { // Process this event. if (source != NULL) { source->process(state, source); } //Process sensor events if (ident == LOOPER_ID_USER) { mainEngine.sensorCollector->ProcessSensorEvents(); } // Check if we are exiting. if (state->destroyRequested != 0) { LOGI(LOGTAG_MAIN,"Engine thread destroy requested!"); shutdownEngine(&mainEngine); return; } } if (mainEngine.animating == 1) { mainEngine.communicator->Update(javaVM); //Check for messages in JNI queue if ( pthread_mutex_trylock(&incomingMutex) == 0) { int count = 0; while (!jniDataVector.empty()) { count++; mainEngine.communicator->AddIncomingMessage(jniDataVector.back()); jniDataVector.pop_back(); } if (count > 0) LOGD(LOGTAG_NETWORKING,"Got %d messages from JNI queue",count); pthread_mutex_unlock(&incomingMutex); } try { myRunner.DoFrame(&mainEngine); } catch (exception & e) { LOGE("Exiting due to caught exception. Message=%s",e.what()); myRunner.Teardown(&mainEngine); shutdownEngine(&mainEngine); } } //Check if state has changed during animation loop if (mainEngine.animating == 0) { LOGW(LOGTAG_MAIN,"Exiting due to internal user command."); ANativeActivity_finish(state->activity); } } myRunner.~AmplifyRunner(); shutdownEngine(&mainEngine); //ANativeActivity_finish(state->activity); }
RockyEngineBase::RockyEngineBase(RockyProcessor& inProcessor) : juce::Thread("Rocky Engine") , mProcessor(inProcessor) { initializeEngine(); }
RockyPresetSaver::RockyPresetSaver(RockyProcessor& inProcessor, const juce::File& inFile) : RockyEngineBase(inProcessor) , mFile(inFile) { initializeEngine(); }