示例#1
0
/** Add a new key->id pair.
 *  @param key is the key for which an id is required
 *  @param id is the requested id that the key is to be mapped to
 *  @return the new id or 0 if the key is already mapped or the
 *  id is already in use or the operation fails
 */
int IdMap::addPair(uint64_t key, int id) {
	if (validKey(key) || validId(id)) return 0;
	if (!ht->insert(key,id)) return 0;
	ids->swap(id);
	cnt++;
	return id;
}
示例#2
0
/** Add a new key->id pair.
 *  @param key is the key for which an id is required
 *  @return the new id or 0 if the key is already mapped or the
 *  operation fails
 */
int IdMap::addPair(uint64_t key) {
	if (validKey(key) || (ids->firstOut() == 0)) return 0;
	int id = ids->firstOut(); 
	if (!ht->insert(key,id)) return 0;
	ids->swap(id);
	cnt++;
	return id;
}
示例#3
0
Transposition::Transposition(const string& key)
{
    if ( !validKey(key) )
        throw InvalidKeyException();

    _key = key;
    _cols = key.length();
    _rows = 0;
}
示例#4
0
//========================= Main =========================//
int main( int argc, char** argv)
{

//FILE* filePtr = fopen("debug.txt", "w" );
//freopen("debug.txt", "w", stdout); 

#ifdef CHECK_FOR_KEY
	if ( !validKey() )
	{
		printf( "Invalid Reg Key\n" );
		printf( "Press Enter to Exit\n" );
		char str[256];
		gets( str );
		exit(0);
	}
#endif
	
	airPtr = new Aircraft();

	if ( batchMode( argc, argv, airPtr ) )
	    exit(0);

	screenMgrPtr = new ScreenMgr(airPtr);

	//==== Link Objects ====//
	airPtr->setScreenMgr( screenMgrPtr );

	// if only 1 argument it is the input filename
	if (argc == 2)
	{
		screenMgrPtr->s_open(ScriptMgr::GUI, argv[argc-1]);
	}

	// this works better after the 
	if (timerFlag) 
	{
		screenMgrPtr->showGui();
		Fl::add_timeout(timerTime, ScriptMgr::staticTimeoutHandler, scriptMgr);
		scriptMgr->setTimeout(timerTime, timerScriptFile);
	} 
	else 
	{
		Fl::add_timeout( AUTO_SAVE_TIME, autoSaveTimeoutHandler, airPtr );
		screenMgrPtr->showGui( argc-1, argv );
	}

	return Fl::run();
		
//fclose(filePtr);

}
示例#5
0
static int _ReadCharFromKeyboard(void)
{
    int key = EOF;

    if (!kbd_initted) {
	kbd_init();
    }
    if (!kbd_isatty) {
	return (getc(stdin));
    }
    do {
        if (_lnxfb_waiting_to_switch_console)
	    _LnxfbSwitchConsoleAndWait();

	if (kbd_lastchr != EOF) {
	    key = kbd_lastchr;
	    kbd_lastchr = EOF;
	    break;
	}
	if (kbd_mode == test) {
	    /* we're in test mode. Look for key without mode switch ... */
	    _CheckKeyboardHit();
	    if (kbd_lastchr != EOF) {
		key = kbd_lastchr;
		kbd_lastchr = EOF;
		break;
	    }
	}
	/* no key till now. Wait of it ... */
	if (kbd_mode != wait) {
	    kbd_setup.c_cc[VMIN] = 0;
	    kbd_setup.c_cc[VTIME] = 1;
	    if (ioctl(kbd_filedsc, TCSETAW, &kbd_setup) == EOF)
		return (EOF);
	    kbd_mode = wait;
	}
	if ((key = inkey()) != EOF) break;
    } while (1);
    return validKey(key, GrKey_OutsideValidRange);
}
示例#6
0
static int _CheckKeyboardHit(void)
{
    if (_lnxfb_waiting_to_switch_console)
	_LnxfbSwitchConsoleAndWait();

    if (!kbd_initted) {
	kbd_init();
    }
    if (!kbd_isatty) {
	return (TRUE);
    }
    if (kbd_lastchr != EOF) {
	return (TRUE);
    }
    if (kbd_mode != test) {
	kbd_setup.c_cc[VMIN] = 0;
	kbd_setup.c_cc[VTIME] = 0;
	if (ioctl(kbd_filedsc, TCSETAW, &kbd_setup) == EOF)
	    return (FALSE);
	kbd_mode = test;
    }
    kbd_lastchr = validKey(inkey(), EOF);
    return (kbd_lastchr != EOF);
}