コード例 #1
0
ファイル: controller.cpp プロジェクト: Reemjd/genius
void Controller::createConnections()
{
  connect(_clipboard,SIGNAL(changed(QClipboard::Mode)),this,SLOT(clipboardChanged(QClipboard::Mode)));

  connect(_history,SIGNAL(added(ClipboardEntity*,int)),this,SLOT(history_itemAdded(ClipboardEntity*,int)));
  connect(_history,SIGNAL(removed(int,int)),this,SLOT(history_removed(int,int)));
  connect(_history,SIGNAL(cleared()),this,SLOT(history_cleared()));
  connect(_history,SIGNAL(locationExchanged(int,int)),this,SLOT(locationExchanged(int,int)));

  connect(_manager,SIGNAL(shown()),this,SLOT(manager_shown()));
  connect(_manager,SIGNAL(hidden()),this,SLOT(manager_hidden()));
  connect(_manager,SIGNAL(hidden()),_trayIcon,SLOT(managerHidden()));
  connect(_manager,SIGNAL(shown()),_trayIcon,SLOT(managerShown()));
  connect(_manager,SIGNAL(settingsDialogRequested()),this,SLOT(settingsWindowRequested()));
  connect(_manager,SIGNAL(itemSelected(int)),this,SLOT(itemSelected(int)));
  connect(_manager,SIGNAL(showContentRequested(ClipboardEntity*)),this,SLOT(showContent(ClipboardEntity*)));
  connect(_manager,SIGNAL(locationExchangeRequested(int,int)),this,SLOT(locationExchangeRequested(int,int)));

  connect(_trayIcon,SIGNAL(showHideManagerTriggerd()),this,SLOT(showHideManagerRequest()));
  connect(_trayIcon,SIGNAL(itemSelected(int)),this,SLOT(itemSelected(int)));
  connect(_trayIcon,SIGNAL(settingsDialogRequested()),this,SLOT(settingsWindowRequested()));
  connect(_trayIcon,SIGNAL(turnOffGenius()),this,SLOT(turnOffRequest()));
  connect(_trayIcon,SIGNAL(turnOnGenius()),this,SLOT(turnOnRequest()));
  connect(_trayIcon,SIGNAL(exitRequested()),this,SLOT(exitRequested()));
  connect(_trayIcon,SIGNAL(pause()),this,SLOT(pauseRequested()));
  connect(_trayIcon,SIGNAL(resume()),this,SLOT(resumeRequested()));

  connect(_selector,SIGNAL(closing(int)),this,SLOT(selectorClosed(int)));
  connect(_settingsWindow,SIGNAL(hiding()),this,SLOT(settingsWindow_hidden()));

  if(_openSelectorHotkey)
    connect(_openSelectorHotkey,SIGNAL(activated()),this,SLOT(openSelectorHKtriggered()));

  if(_clearHistoryHotKey)
    connect(_clearHistoryHotKey,SIGNAL(activated()),this,SLOT(clearHistoryHKTrigered()));

  if(_pasteLastHotKey)
    connect(_pasteLastHotKey,SIGNAL(activated()),this,SLOT(pasteLasteHKTrigered()));

  if(_openManagerHotKey)
    connect(_openManagerHotKey,SIGNAL(activated()),this,SLOT(openManagerHKTriggered()));

  if(_openSettingsHotKey)
    connect(_openSettingsHotKey,SIGNAL(activated()),this,SLOT(openSettingsHKTriggered()));

  if(_historyMenuHotKey)
    connect(_historyMenuHotKey,SIGNAL(activated()),this,SLOT(historyMenuHotkeyActivated()));
}
コード例 #2
0
ファイル: mini437_JG_DS.c プロジェクト: l50/jdshell
void shellLoop()
{
    char *input, *originalInput;
    TokenContainer tc;
    bool running = true;

    while(running)
    {
        printf(YELLOW "λ mini437sh-JG-DS: " NORMAL_COLOR);
        input = getInput();
        originalInput = malloc(strlen(input) + 1);
        strcpy(originalInput, input);
        tc = parseInput(input);
        if (!emptyInput(&tc))
        {
            if (exitRequested(&tc))
                running = false;
            else
            {
                running = launchCommands(&tc, originalInput);
            }
        }
        free(input);
        free(originalInput);
    }
    killChildren();
    free(tc.tokens);
}
コード例 #3
0
ファイル: BaseApplication.cpp プロジェクト: franaisa/Gloom
	void CBaseApplication::run() 
	{
		assert(_clock && "Asegurate de haber creado un reloj en el init de la clase de tu aplicacion!");
		unsigned int resto;
		unsigned int multiplo;
		unsigned int fixedTick;

		// Actualizamos una primera vez el tiempo, antes de
		// empezar, para que el primer frame tenga un tiempo
		// de frame razonable.
		_clock->updateTime();
		// Ejecución del bucle principal. Simplemente miramos si
		// tenemos que hacer una transición de estado, y si no hay que
		// hacerla, ejecutamos la vuelta
		_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
		//_CrtSetBreakAlloc(598913);
		while (!exitRequested()) 
		{
			if (!_currentState ||
					(_nextState && (_currentState != _nextState)))
				changeState();

			_clock->updateTime();

			tick(_clock->getLastFrameDuration());
		
		}
		//_CrtDumpMemoryLeaks();
		
	} // run
コード例 #4
0
ファイル: BaseApplication.cpp プロジェクト: NoisyBass/Hulen
	void CBaseApplication::run() 
	{
		assert(_clock && "Asegurate de haber creado un reloj en el init de la clase de tu aplicacion!");

		// Actualizamos una primera vez el tiempo, antes de
		// empezar, para que el primer frame tenga un tiempo
		// de frame razonable.
		_clock->updateTime();

		// Ejecución del bucle principal. Simplemente miramos si
		// tenemos que hacer una transición de estado, y si no hay que
		// hacerla, ejecutamos la vuelta
		while (!exitRequested()) 
		{
			if (!_currentState ||
					(_nextState && (_currentState != _nextState)))
				changeState();

			_clock->updateTime();

			tick(_clock->getLastFrameDuration());
		}

	} // run
コード例 #5
0
ファイル: Scenario.cpp プロジェクト: spycrab/HadakaVM
uint32_t ScenarioRunner::getLogicVar(uint8_t scope,uint32_t key)
{
    if (exitRequested()) return 0;
    if (scope != 0x03 && scope != 0x06) ERROR("Invalid scope "+std::to_string(scope));
    return reg_logic[hexString(scope)+":"+hexString(key)];
}
コード例 #6
0
ファイル: Component.cpp プロジェクト: SEMAINE/SEMAINE-3.1
	void Component::run()
	{
		try {
			std::cerr << "starting component " << name << "..." << std::endl;
			startIO();
			std::cerr << "    ... " << name << " ready." << std::endl;
		} catch (std::exception & ex) {
			log->error("Cannot startup component:", &ex);
			try {
				state = STATE_FAILURE;
				meta.reportState(state, "Cannot startup component:", &ex);
			} catch (CMSException & me) {
				log->error("cannot report failure state", & me);
			}
			requestExit();
		}

		while (!exitRequested()) {
			// Report that we are alive before we check system ready status,
			// (in case we were stalled due to a long act() or react() this
			// means we "report back" to the rest of the system)
			meta.IamAlive();
      //printf("run %i\n",exitRequested());
			// Check at every loop that the total system is ready
			bool exitFlag = false;
			synchronized (&meta) {
				if (!meta.isSystemReady()) {
					log->info("waiting for system to become ready");
				}
				while (!meta.isSystemReady()) {
					try {
						meta.wait(1000);
					} catch (decaf::lang::Exception & ie) {
						ie.printStackTrace();
					}
					if (meta.isSystemReady()) {
						log->info("system ready - let's go");
					}
					if (exitRequested()) {
						exitFlag = true;
						break;
					}
				}
			}
			if (exitFlag) break;

			try {
				// Check if we should do something proactively:
				long long before = System::currentTimeMillis();
				act();
				long long timeSpentInAct = System::currentTimeMillis() - before;
				meta.statistics()->actTime((long)timeSpentInAct);
			} catch (std::exception & e) {
				log->error("error when trying to act", & e);
				try {
					state = STATE_FAILURE;
					meta.reportState(state, "error when trying to act", &e);
				} catch (CMSException & me) {
					log->error("cannot report failure state", & me);
				}
				requestExit();
				return;
			}

			Receiver * r = NULL;
			synchronized (&mutex) {
				if (inputWaiting.empty()) {
				// block until input becomes available
				mutex.wait(waitingTime);
				}
				// check again
				if (!inputWaiting.empty()) {
					r = inputWaiting.front();
					inputWaiting.pop();
				}
			}
			if (r == NULL) continue;
			//assert(receivers.contains(r)); // the receiver that alerted us is not one of our receivers;
			SEMAINEMessage * message = r->getMessage();
			assert(message != NULL); // Receiver alerted me but has no message
			meta.statistics()->countMessageReceived();

			try {
				// time that the message travelled, in "user" time (ms since system startup -- this should be independent of clock asynchrony)
				long long timeMessageTravelled = meta.getTime() - message->getUsertime();
				meta.statistics()->transmitTime((long)timeMessageTravelled);
				// Now, do something meaningful with the message,
				// and possibly send output via the Senders.
				long long before = System::currentTimeMillis();
				react(message);
				delete message;
				long long timeSpentInReact = System::currentTimeMillis() - before;
				meta.statistics()->reactTime((long)timeSpentInReact);
			} catch (std::exception & e) {
				log->error("error when trying to react", &e);
				try {
					state = STATE_FAILURE;
					std::string errMsg = CMSLogger::toLogMessageText("error when trying to react", &e)
						+ "(message was: " + CMSLogger::message2logString(message) + ")";
					meta.reportState(state, errMsg);
				} catch (CMSException & me) {
					log->error("cannot report failure state", & me);
				}
				requestExit();
				return;
			}
		}
	}