Ejemplo n.º 1
0
 void generateMediumQuestion()
 {
 int altWord;
 usednum=0;
 questions++;
 UpdateQuestionText();
 printf("Question %d\n",questions);
 resetOptions();
 //Chose correct word
 int word=getRandomQuestion();
 answer=Words[word].english[getRandomNumber(Words[word].numenglish-1)];
 question=Words[word].latin[getRandomNumber(Words[word].numlatin-1)];
 int position=getRandomNumber(6);
 int i;
 for(i=0;i<6;i++)
 {
 if(i==position)
 {
 createOption(answer,false);
 }
 else
 {
 altWord=getRandomWordIndex();
 createOption(Words[altWord].english[getRandomNumber(Words[altWord].numenglish-1)],false);
 }
 }
 createOption(question,true);
 }
Ejemplo n.º 2
0
  bool JastrowBuilder::put(xmlNodePtr cur) {

    myNode=cur;

    resetOptions();

    OhmmsAttributeSet oAttrib;
    oAttrib.add(typeOpt,"type");
    oAttrib.add(nameOpt,"name");
    oAttrib.add(funcOpt,"function");
    oAttrib.add(transformOpt,"transform");
    oAttrib.add(sourceOpt,"source");
    oAttrib.add(spinOpt,"spin");
    oAttrib.put(cur);

    if(nameOpt[0] == '0')
    {
      app_warning() << "  JastrowBuilder::put does not have name "<< endl;
      return false;
    }

    if(typeOpt.find("One") < typeOpt.size()) 
      return addOneBody(cur);

    if(typeOpt.find("Two") < typeOpt.size()) 
      return addTwoBody(cur);

    if(typeOpt.find("Three") < typeOpt.size()) 
      return addThreeBody(cur);

    return false;
  }
Ejemplo n.º 3
0
 void generateEasyQuestion()
 {
 usednum=0;
 questions++;
 UpdateQuestionText();
 printf("Question %d\n",questions);
 printf("Score: %d\n",score);
 resetOptions();
 //Chose correct word
 int word=getRandomQuestion();
 answer=Words[word].english[0];
 question=Words[word].latin[0];
 int position=getRandomNumber(6);
 int i;
 for(i=0;i<6;i++)
 {
 if(i==position)
 {
 createOption(answer,false);
 }
 else
 {
 createOption(Words[getRandomWordIndex()].english[0],false);
 }
 }
 createOption(question,true);
 }
FrostedGlassFilter::FrostedGlassFilter() : 
		QtImageFilter(),
		m_brushSizeSlider(0)
{
	setThreadedPreviewEnabled(true);
	resetOptions();
}
Ejemplo n.º 5
0
Group::Group(Pool *_pool, const Options &_options)
	: pool(_pool),
	  uuid(generateUuid(_pool))
{
	info.context = _pool->getContext();
	info.group = this;
	info.name = _options.getAppGroupName().toString();
	generateSecret(_pool, info.secret);
	resetOptions(_options);
	enabledCount   = 0;
	disablingCount = 0;
	disabledCount  = 0;
	nEnabledProcessesTotallyBusy = 0;
	spawner        = getContext()->getSpawningKitFactory()->create(options);
	restartsInitiated = 0;
	processesBeingSpawned = 0;
	m_spawning     = false;
	m_restarting   = false;
	lifeStatus.store(ALIVE, boost::memory_order_relaxed);
	lastRestartFileMtime = 0;
	lastRestartFileCheckTime = 0;
	alwaysRestartFileExists = false;
	if (options.restartDir.empty()) {
		restartFile = options.appRoot + "/tmp/restart.txt";
		alwaysRestartFile = options.appRoot + "/tmp/always_restart.txt";
	} else if (options.restartDir[0] == '/') {
		restartFile = options.restartDir + "/restart.txt";
		alwaysRestartFile = options.restartDir + "/always_restart.txt";
	} else {
		restartFile = options.appRoot + "/" + options.restartDir + "/restart.txt";
		alwaysRestartFile = options.appRoot + "/" + options.restartDir + "/always_restart.txt";
	}

	detachedProcessesCheckerActive = false;
}
Ejemplo n.º 6
0
Group::Group(const SuperGroupPtr &_superGroup, const Options &options, const ComponentInfo &info)
	: superGroup(_superGroup),
	  name(_superGroup->name + "#" + info.name),
	  secret(generateSecret(_superGroup)),
	  componentInfo(info)
{
	enabledCount   = 0;
	disablingCount = 0;
	disabledCount  = 0;
	spawner        = getPool()->spawnerFactory->create(options);
	restartsInitiated = 0;
	processesBeingSpawned = 0;
	m_spawning     = false;
	m_restarting   = false;
	lifeStatus     = ALIVE;
	if (options.restartDir.empty()) {
		restartFile = options.appRoot + "/tmp/restart.txt";
		alwaysRestartFile = options.appRoot + "/tmp/always_restart.txt";
	} else if (options.restartDir[0] == '/') {
		restartFile = options.restartDir + "/restart.txt";
		alwaysRestartFile = options.restartDir + "/always_restart.txt";
	} else {
		restartFile = options.appRoot + "/" + options.restartDir + "/restart.txt";
		alwaysRestartFile = options.appRoot + "/" + options.restartDir + "/always_restart.txt";
	}
	resetOptions(options);

	detachedProcessesCheckerActive = false;
}
Ejemplo n.º 7
0
bool KonfUpdate::checkFile(const QString &filename)
{
    m_currentFilename = filename;
    int i = m_currentFilename.lastIndexOf('/');
    if (i != -1) {
        m_currentFilename = m_currentFilename.mid(i + 1);
    }
    m_skip = true;
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly)) {
        return false;
    }

    QTextStream ts(&file);
    ts.setCodec(QTextCodec::codecForName("ISO-8859-1"));
    int lineCount = 0;
    resetOptions();
    QString id;
    while (!ts.atEnd()) {
        QString line = ts.readLine().trimmed();
        lineCount++;
        if (line.isEmpty() || (line[0] == '#')) {
            continue;
        }
        if (line.startsWith("Id=")) {
            id = m_currentFilename + ':' + line.mid(3);
        } else if (line.startsWith("File=")) {
            checkGotFile(line.mid(5), id);
        }
    }

    return true;
}
Ejemplo n.º 8
0
        void generateHardQuestion()
    {
    //printf("%f",getSimilarity("abcdef","aabcdegf"));


    usednum=0;
    questions++;
    UpdateQuestionText();
    //printf("Question %d\n",questions);
    //printf("Score: %d\n",score);
    resetOptions();
    //Chose correct word
    int word=getRandomQuestion();
    answer=Words[word].english[0];
    question=Words[word].latin[0];

    //Chose alternative(wrong) options
    int position=getRandomNumber(6);
    int i;
    for(i=0;i<6;i++)
    {
    if(i==position)//Place correct answer at random location
    {
    createOption(answer,false);
    }
    else
    {
    createSimilarWord(question);
    }
    }
    createOption(question,true);

    }
Ejemplo n.º 9
0
void
CSecondaryScreen::open()
{
	try {
		// subclass hook
		onPreOpen();

		// open the screen
		getScreen()->open();

		// create and prepare our window.  pretend we're active so
		// we don't try to show our window until later.
		{
			CLock lock(&m_mutex);
			assert(m_active == false);
			m_active = true;
		}
		createWindow();
		{
			CLock lock(&m_mutex);
			m_active = false;
		}

		// subclass hook
		onPostOpen();

		// reset options
		resetOptions();
	}
	catch (...) {
		close();
		throw;
	}
}
Ejemplo n.º 10
0
void setup() {
	
	// variable init
	resetOptions();
	
	triggerTO = new ToggleOptions(true);
	triggers.push_back(new Alarm(9, 45, true));
	triggers.push_back(new Alarm(20, 30, false));
	triggers.push_back(new Light(true, 90, false));

	// setup toggles
	stateTO->add("aberto", 0);
	stateTO->add("fechado", 1);
	modeTO->add("hora =", 0);
	modeTO->add("luz <", 1);
	modeTO->add("luz >", 2);
	
	// setup menu
	menu->setRoot(mainMenu);
	
	// main menu setup
	mainMenu->addRow(new MenuRowSubmenu("Triggers", triggerMenu));
	mainMenu->addRow(new MenuRowSubmenu("Monitor", monitorMenu));
	mainMenu->addRow(new MenuRowSubmenu("Config", configMenu));
	mainMenu->addRow(new MenuRow("Sobre"));
		
	// trigger menu setup
	newTriggerMenu = new MenuItem(triggerMenu);
	triggerMenu->addRow(new MenuRowSubmenu("Novo", newTriggerMenu));
	triggerMenu->addRow(new MenuRowToggle("Del", triggerTO, &option1));
	
	// new trigger menu setup
	newTriggerMenu->addRow(new MenuRowToggle("Acao", stateTO, &option1));
	newTriggerMenu->addRow(new MenuRowToggle("Modo", modeTO, &option5));
	newTriggerMenu->addRow(new MenuRowVar("Horas", &option2, "", 0, 23));
	newTriggerMenu->addRow(new MenuRowVar("Minutos", &option3, "", 0, 59));
	newTriggerMenu->addRow(new MenuRowVar("Luz", &option4, "", 0, 100));
	newTriggerMenu->addRow(new MenuRow("Confirmar"));
	
	// monitor menu setup
	monitorMenu->addRow(new MenuRowToggle("Estado", stateTO, &option1));
	monitorMenu->addRow(new MenuRowVar("Horas", &option2, "", 23, 23));
	monitorMenu->addRow(new MenuRowVar("Minutos", &option3, "", 59, 59));
	monitorMenu->addRow(new MenuRowVar("Luz", &option4, "", 100, 100));
	
	// config menu setup
	configMenu->addRow(new MenuRowVar("Horas", &option2, "", 0, 23));
	configMenu->addRow(new MenuRowVar("Minutos", &option3, "", 0, 59));
	configMenu->addRow(new MenuRow("Confirmar"));
	
	// display root menu and help
	menu->refresh();
	cout << endl << 
		" WASD: setas, K: cancel, L: select" << endl <<
		" aperte enter para confirmar sua escolha" <<
		endl << endl;

}
Ejemplo n.º 11
0
    void displayMainMenu()
    {
    resetOptions();
    createOption("Quit",false);
    createOption("-",false);
      createOption("Hard",false);
       createOption("Medium",false);
        createOption("Easy",false);
         createOption("-",false);
        createOption("Latin Game!",true);

    }
Ejemplo n.º 12
0
CScreen::CScreen(IPlatformScreen* platformScreen) :
	m_screen(platformScreen),
	m_isPrimary(platformScreen->isPrimary()),
	m_enabled(false),
	m_entered(m_isPrimary),
	m_screenSaverSync(true),
	m_fakeInput(false)
{
	assert(m_screen != NULL);

	// reset options
	resetOptions();

	LOG((CLOG_DEBUG "opened display"));
}
Ejemplo n.º 13
0
 void showScore()
 {
 questionnum=0;
 resetOptions();
 createOption("Return to menu",false);
 createOption("-",false);
 createOption("100",true);
 createOption("Out of a possible:",false);
 char scorestore[6];
 char* scorestr=(char*)scorestore;
 scorestr=displayscore(score);
 createOption(scorestr,true);
 createOption("You scored:",false);
 createOption("Finished!",false);
 }
Ejemplo n.º 14
0
Screen::Screen(IPlatformScreen* platformScreen, IEventQueue* events) :
	m_screen(platformScreen),
	m_isPrimary(platformScreen->isPrimary()),
	m_enabled(false),
	m_entered(m_isPrimary),
	m_screenSaverSync(true),
	m_fakeInput(false),
	m_events(events),
	m_mock(false),
	m_enableDragDrop(false)
{
	assert(m_screen != NULL);

	// reset options
	resetOptions();

	LOG((CLOG_DEBUG "opened display"));
}
Ejemplo n.º 15
0
namespace embedded {

MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(EmbeddedOptions)(InitializerContext* context) {
    return addOptions(&optionenvironment::startupOptions);
}

GlobalInitializerRegisterer embeddedOptionsInitializer(
    "EmbeddedOptions",
    {"BeginStartupOptionValidation", "AllFailPointsRegistered"},
    {"EndStartupOptionValidation"},
    [](InitializerContext* context) {
        // Run validation, but tell the Environment that we don't want it to be set as "valid",
        // since we may be making it invalid in the canonicalization process.
        Status ret = optionenvironment::startupOptionsParsed.validate(false);
        if (!ret.isOK()) {
            return ret;
        }
        ret = canonicalizeOptions(&optionenvironment::startupOptionsParsed);
        if (!ret.isOK()) {
            return ret;
        }
        ret = optionenvironment::startupOptionsParsed.validate();
        if (!ret.isOK()) {
            return ret;
        }
        return Status::OK();
    },
    [](DeinitializerContext* context) { return Status::OK(); });

GlobalInitializerRegisterer embeddedOptionsStore("EmbeddedOptions_Store",
                                                 {"BeginStartupOptionStorage"},
                                                 {"EndStartupOptionStorage"},
                                                 [](InitializerContext* context) {
                                                     return storeOptions(
                                                         optionenvironment::startupOptionsParsed);
                                                 },
                                                 [](DeinitializerContext* context) {
                                                     resetOptions();
                                                     return Status::OK();
                                                 });

}  // namespace embedded
Ejemplo n.º 16
0
// The 'self' parameter is for keeping the current Group object alive while this thread is running.
void
Group::finalizeRestart(GroupPtr self, Options options, RestartMethod method,
	SpawnerFactoryPtr spawnerFactory, unsigned int restartsInitiated,
	vector<Callback> postLockActions)
{
	TRACE_POINT();

	Pool::runAllActions(postLockActions);
	postLockActions.clear();

	this_thread::disable_interruption di;
	this_thread::disable_syscall_interruption dsi;

	// Create a new spawner.
	SpawnerPtr newSpawner = spawnerFactory->create(options);
	SpawnerPtr oldSpawner;

	UPDATE_TRACE_POINT();
	PoolPtr pool = getPool();

	Pool::DebugSupportPtr debug = pool->debugSupport;
	if (debug != NULL && debug->restarting) {
		this_thread::restore_interruption ri(di);
		this_thread::restore_syscall_interruption rsi(dsi);
		this_thread::interruption_point();
		debug->debugger->send("About to end restarting");
		debug->messages->recv("Finish restarting");
	}

	ScopedLock l(pool->syncher);
	if (!isAlive()) {
		P_DEBUG("Group " << name << " is shutting down, so aborting restart");
		return;
	}
	if (restartsInitiated != this->restartsInitiated) {
		// Before this restart could be finalized, another restart command was given.
		// The spawner we just created might be out of date now so we abort.
		P_DEBUG("Restart of group " << name << " aborted because a new restart was initiated concurrently");
		if (debug != NULL && debug->restarting) {
			debug->debugger->send("Restarting aborted");
		}
		return;
	}

	// Run some sanity checks.
	pool->fullVerifyInvariants();
	assert(m_restarting);
	UPDATE_TRACE_POINT();
	
	// Atomically swap the new spawner with the old one.
	resetOptions(options);
	oldSpawner = spawner;
	spawner    = newSpawner;

	m_restarting = false;
	if (shouldSpawn()) {
		spawn();
	} else if (isWaitingForCapacity()) {
		P_INFO("Group " << name << " is waiting for capacity to become available. "
			"Trying to shutdown another idle process to free capacity...");
		if (pool->forceFreeCapacity(this, postLockActions) != NULL) {
			spawn();
		} else {
			P_INFO("There are no processes right now that are eligible "
				"for shutdown. Will try again later.");
		}
	}
	verifyInvariants();

	l.unlock();
	oldSpawner.reset();
	Pool::runAllActions(postLockActions);
	P_DEBUG("Restart of group " << name << " done");
	if (debug != NULL && debug->restarting) {
		debug->debugger->send("Restarting done");
	}
}
Ejemplo n.º 17
0
/**
 * Syntax:
 * # Comment
 * Id=id
 * File=oldfile[,newfile]
 * AllGroups
 * Group=oldgroup[,newgroup]
 * RemoveGroup=oldgroup
 * Options=[copy,][overwrite,]
 * Key=oldkey[,newkey]
 * RemoveKey=ldkey
 * AllKeys
 * Keys= [Options](AllKeys|(Key|RemoveKey)*)
 * ScriptArguments=arguments
 * Script=scriptfile[,interpreter]
 *
 * Sequence:
 * (Id,(File(Group,Keys)*)*)*
 **/
bool KonfUpdate::updateFile(const QString &filename)
{
    m_currentFilename = filename;
    int i = m_currentFilename.lastIndexOf('/');
    if (i != -1) {
        m_currentFilename = m_currentFilename.mid(i + 1);
    }
    m_skip = true;
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly)) {
        return false;
    }

    log() << "Checking update-file '" << filename << "' for new updates" << endl;

    QTextStream ts(&file);
    ts.setCodec(QTextCodec::codecForName("ISO-8859-1"));
    m_lineCount = 0;
    resetOptions();
    while (!ts.atEnd()) {
        m_line = ts.readLine().trimmed();
        m_lineCount++;
        if (m_line.isEmpty() || (m_line[0] == '#')) {
            continue;
        }
        if (m_line.startsWith(QLatin1String("Id="))) {
            gotId(m_line.mid(3));
        } else if (m_skip) {
            continue;
        } else if (m_line.startsWith(QLatin1String("Options="))) {
            gotOptions(m_line.mid(8));
        } else if (m_line.startsWith(QLatin1String("File="))) {
            gotFile(m_line.mid(5));
        } else if (m_skipFile) {
            continue;
        } else if (m_line.startsWith(QLatin1String("Group="))) {
            gotGroup(m_line.mid(6));
        } else if (m_line.startsWith(QLatin1String("RemoveGroup="))) {
            gotRemoveGroup(m_line.mid(12));
            resetOptions();
        } else if (m_line.startsWith(QLatin1String("Script="))) {
            gotScript(m_line.mid(7));
            resetOptions();
        } else if (m_line.startsWith(QLatin1String("ScriptArguments="))) {
            gotScriptArguments(m_line.mid(16));
        } else if (m_line.startsWith(QLatin1String("Key="))) {
            gotKey(m_line.mid(4));
            resetOptions();
        } else if (m_line.startsWith(QLatin1String("RemoveKey="))) {
            gotRemoveKey(m_line.mid(10));
            resetOptions();
        } else if (m_line == "AllKeys") {
            gotAllKeys();
            resetOptions();
        } else if (m_line == "AllGroups") {
            gotAllGroups();
            resetOptions();
        } else {
            logFileError() << "Parse error" << endl;
        }
    }
    // Flush.
    gotId(QString());

    KDE_struct_stat buff;
    KDE::stat(filename, &buff);
    KConfigGroup cg(m_config, m_currentFilename);
    cg.writeEntry("ctime", int(buff.st_ctime));
    cg.writeEntry("mtime", int(buff.st_mtime));
    cg.sync();
    return true;
}
Ejemplo n.º 18
0
ServerProxy::EResult
ServerProxy::parseMessage(const UInt8* code)
{
	if (memcmp(code, kMsgDMouseMove, 4) == 0) {
		mouseMove();
	}

	else if (memcmp(code, kMsgDMouseRelMove, 4) == 0) {
		mouseRelativeMove();
	}

	else if (memcmp(code, kMsgDMouseWheel, 4) == 0) {
		mouseWheel();
	}

	else if (memcmp(code, kMsgDKeyDown, 4) == 0) {
		keyDown();
	}

	else if (memcmp(code, kMsgDKeyUp, 4) == 0) {
		keyUp();
	}

	else if (memcmp(code, kMsgDMouseDown, 4) == 0) {
		mouseDown();
	}

	else if (memcmp(code, kMsgDMouseUp, 4) == 0) {
		mouseUp();
	}

	else if (memcmp(code, kMsgDKeyRepeat, 4) == 0) {
		keyRepeat();
	}

	else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
		// echo keep alives and reset alarm
		ProtocolUtil::writef(m_stream, kMsgCKeepAlive);
		resetKeepAliveAlarm();
	}

	else if (memcmp(code, kMsgCNoop, 4) == 0) {
		// accept and discard no-op
	}

	else if (memcmp(code, kMsgCEnter, 4) == 0) {
		enter();
	}

	else if (memcmp(code, kMsgCLeave, 4) == 0) {
		leave();
	}

	else if (memcmp(code, kMsgCClipboard, 4) == 0) {
		grabClipboard();
	}

	else if (memcmp(code, kMsgCScreenSaver, 4) == 0) {
		screensaver();
	}

	else if (memcmp(code, kMsgQInfo, 4) == 0) {
		queryInfo();
	}

	else if (memcmp(code, kMsgCInfoAck, 4) == 0) {
		infoAcknowledgment();
	}

	else if (memcmp(code, kMsgDClipboard, 4) == 0) {
		setClipboard();
	}

	else if (memcmp(code, kMsgCResetOptions, 4) == 0) {
		resetOptions();
	}

	else if (memcmp(code, kMsgDSetOptions, 4) == 0) {
		setOptions();
	}

	else if (memcmp(code, kMsgDFileTransfer, 4) == 0) {
		fileChunkReceived();
	}
	else if (memcmp(code, kMsgDDragInfo, 4) == 0) {
		dragInfoReceived();
	}

	else if (memcmp(code, kMsgCClose, 4) == 0) {
		// server wants us to hangup
		LOG((CLOG_DEBUG1 "recv close"));
		m_client->disconnect(NULL);
		return kDisconnect;
	}
	else if (memcmp(code, kMsgEBad, 4) == 0) {
		LOG((CLOG_ERR "server disconnected due to a protocol error"));
		m_client->disconnect("server reported a protocol error");
		return kDisconnect;
	}
	else {
		return kUnknown;
	}

	// send a reply.  this is intended to work around a delay when
	// running a linux server and an OS X (any BSD?) client.  the
	// client waits to send an ACK (if the system control flag
	// net.inet.tcp.delayed_ack is 1) in hopes of piggybacking it
	// on a data packet.  we provide that packet here.  i don't
	// know why a delayed ACK should cause the server to wait since
	// TCP_NODELAY is enabled.
	ProtocolUtil::writef(m_stream, kMsgCNoop);

	return kOkay;
}
Ejemplo n.º 19
0
ServerProxy::EResult
ServerProxy::parseHandshakeMessage(const UInt8* code)
{
	if (memcmp(code, kMsgQInfo, 4) == 0) {
		queryInfo();
	}

	else if (memcmp(code, kMsgCInfoAck, 4) == 0) {
		infoAcknowledgment();
	}

	else if (memcmp(code, kMsgDSetOptions, 4) == 0) {
		setOptions();

		// handshake is complete
		m_parser = &ServerProxy::parseMessage;
		m_client->handshakeComplete();
	}

	else if (memcmp(code, kMsgCResetOptions, 4) == 0) {
		resetOptions();
	}

	else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
		// echo keep alives and reset alarm
		ProtocolUtil::writef(m_stream, kMsgCKeepAlive);
		resetKeepAliveAlarm();
	}

	else if (memcmp(code, kMsgCNoop, 4) == 0) {
		// accept and discard no-op
	}

	else if (memcmp(code, kMsgCClose, 4) == 0) {
		// server wants us to hangup
		LOG((CLOG_DEBUG1 "recv close"));
		m_client->disconnect(NULL);
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEIncompatible, 4) == 0) {
		SInt32 major, minor;
		ProtocolUtil::readf(m_stream,
						kMsgEIncompatible + 4, &major, &minor);
		LOG((CLOG_ERR "server has incompatible version %d.%d", major, minor));
		m_client->disconnect("server has incompatible version");
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEBusy, 4) == 0) {
		LOG((CLOG_ERR "server already has a connected client with name \"%s\"", m_client->getName().c_str()));
		m_client->disconnect("server already has a connected client with our name");
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEUnknown, 4) == 0) {
		LOG((CLOG_ERR "server refused client with name \"%s\"", m_client->getName().c_str()));
		m_client->disconnect("server refused client with our name");
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEBad, 4) == 0) {
		LOG((CLOG_ERR "server disconnected due to a protocol error"));
		m_client->disconnect("server reported a protocol error");
		return kDisconnect;
	}
	else {
		return kUnknown;
	}

	return kOkay;
}
Ejemplo n.º 20
0
PosterizeFilter::PosterizeFilter() 
		: QtImageFilter()
		, m_levelsSlider(0)
{
	resetOptions();
}
Ejemplo n.º 21
0
void loop() {

	// variable init
	string s;
	char ch;

	while (ch != 'x') {
		
		getline(cin, s);
		
		for (int i = 0; i < s.length(); i++) {
			
			ch = s[i];
			
			switch (ch) {
				case 'u': triggerCheck(); continue;	break; // UPDATE		
				case 'w': menu->up(); 				break;
				case 'a': menu->left();				break;
				case 's': menu->down(); 			break;
				case 'd': menu->right(); 			break;
				case 'k': menu->cancel(); 			break;
					break;
				case 'l': 
											
					// change new trigger menu content based on mode
					if (menu->nextMenu() == newTriggerMenu) {
						newTriggerMenu->getRow(2, true)->hidden = !(option5 == 0);
						newTriggerMenu->getRow(3, true)->hidden = !(option5 == 0);
						newTriggerMenu->getRow(4, true)->hidden = (option5 == 0);
					}		
					
					// trigger created message	
					if (menu->currentMenu == newTriggerMenu && menu->lastRow()) {
						if (option5 == 0)	// TIME
							triggers.push_back(new Alarm(option2, option3, triggerTO->getValue(option1)));
						else 				// LIGHT	
							triggers.push_back(new Light(triggerTO->getValue(option5) == 0, option4, triggerTO->getValue(option1)));
						menu->message("Trigger criado com sucesso!  ");
						resetOptions();
					}
					
					// delete trigger
					else if (menu->currentMenu == triggerMenu && menu->getCurrentRow() == 1 && menu->getCurrentMode() == TOGGLE) {
						menu->message("Tem certeza?", triggerMenu);
						menu->customMenuId = 1;
					}
						
					// populate trigger list toggle
					else if (menu->nextMenu() == triggerMenu) {
						triggerTO->clear();
						if (triggers.size() == 0)
							triggerMenu->getRow(1, true)->hidden = true;
						else {
							triggerMenu->getRow(1, true)->hidden = false;
							for (int i = 0; i < triggers.size(); i++)
								triggerTO->add(triggers[i]->text(), i);
						}
						menu->select(); 
						resetOptions();
					}
					
					// end message when removing trigger
					else if (menu->customMenuId == 1) {
						menu->customMenuId = 0;
						triggers.erase(triggers.begin() + option1);
						menu->message("Trigger remov. com sucesso!");
					}
					
					// about
					else if (menu->currentMenu == mainMenu && menu->lastRow())
						menu->message("Denis I F     Homero F S M  Teresa C      2015");
					
					// confirm new time
					else if (menu->currentMenu == configMenu && menu->lastRow()) {
						sensor->setTime(option2, option3);
						menu->message("Dados atual.  com sucesso!");
					}
						
					// refresh variables on monitor and config menus
					else if (menu->nextMenu() == monitorMenu || (menu->currentMenu != configMenu && menu->nextMenu() == configMenu)) {
						option2 = sensor->hours();
						option3 = sensor->minutes();
						option4 = sensor->ldrValue();
						menu->select(); 
					}
					
					// all other cases
					else
						menu->select(); 
						
					break;
			}
				
			menu->refresh();
			
			// debug
			// cout << "debug";
			
		}
		
	}

}
Ejemplo n.º 22
0
 JastrowBuilder::JastrowBuilder(ParticleSet& p, TrialWaveFunction& psi, PtclPoolType& psets):
   OrbitalBuilderBase(p,psi), ptclPool(psets)
 {
   resetOptions();
 }
Ejemplo n.º 23
0
/**
 * main function.  Parses command-line arguments.
 */
int hisat2_build(int argc, const char **argv) {
    string outfile;
	try {
		// Reset all global state, including getopt state
		opterr = optind = 1;
		resetOptions();

		string infile;
		EList<string> infiles(MISC_CAT);

		parseOptions(argc, argv);
		argv0 = argv[0];
		if(showVersion) {
			cout << argv0 << " version " << string(HISAT2_VERSION).c_str() << endl;
			if(sizeof(void*) == 4) {
				cout << "32-bit" << endl;
			} else if(sizeof(void*) == 8) {
				cout << "64-bit" << endl;
			} else {
				cout << "Neither 32- nor 64-bit: sizeof(void*) = " << sizeof(void*) << endl;
			}
			cout << "Built on " << BUILD_HOST << endl;
			cout << BUILD_TIME << endl;
			cout << "Compiler: " << COMPILER_VERSION << endl;
			cout << "Options: " << COMPILER_OPTIONS << endl;
			cout << "Sizeof {int, long, long long, void*, size_t, off_t}: {"
				 << sizeof(int)
				 << ", " << sizeof(long) << ", " << sizeof(long long)
				 << ", " << sizeof(void *) << ", " << sizeof(size_t)
				 << ", " << sizeof(off_t) << "}" << endl;
			return 0;
		}

		// Get input filename
		if(optind >= argc) {
			cerr << "No input sequence or sequence file specified!" << endl;
			printUsage(cerr);
			return 1;
		}
		infile = argv[optind++];
        
		// Get output filename
		if(optind >= argc) {
			cerr << "No output file specified!" << endl;
			printUsage(cerr);
			return 1;
		}
		outfile = argv[optind++];

		tokenize(infile, ",", infiles);
		if(infiles.size() < 1) {
			cerr << "Tokenized input file list was empty!" << endl;
			printUsage(cerr);
			return 1;
		}
        
        if(!lineRate_provided) {
            if(snp_fname == "" && ss_fname == "" && exon_fname == "") {
                lineRate = GFM<TIndexOffU>::default_lineRate_fm;
            } else {
                lineRate = GFM<TIndexOffU>::default_lineRate_gfm;
            }
        }

		// Optionally summarize
		if(verbose) {
			cerr << "Settings:" << endl
				 << "  Output files: \"" << outfile.c_str() << ".*." << gfm_ext << "\"" << endl
				 << "  Line rate: " << lineRate << " (line is " << (1<<lineRate) << " bytes)" << endl
				 << "  Lines per side: " << linesPerSide << " (side is " << ((1<<lineRate)*linesPerSide) << " bytes)" << endl
				 << "  Offset rate: " << offRate << " (one in " << (1<<offRate) << ")" << endl
				 << "  FTable chars: " << ftabChars << endl
				 << "  Strings: " << (packed? "packed" : "unpacked") << endl
                 << "  Local offset rate: " << localOffRate << " (one in " << (1<<localOffRate) << ")" << endl
                 << "  Local fTable chars: " << localFtabChars << endl
                 << "  Local sequence length: " << local_index_size << endl
                 << "  Local sequence overlap between two consecutive indexes: " << local_index_overlap << endl;
#if 0
			if(bmax == OFF_MASK) {
				cerr << "  Max bucket size: default" << endl;
			} else {
				cerr << "  Max bucket size: " << bmax << endl;
			}
			if(bmaxMultSqrt == OFF_MASK) {
				cerr << "  Max bucket size, sqrt multiplier: default" << endl;
			} else {
				cerr << "  Max bucket size, sqrt multiplier: " << bmaxMultSqrt << endl;
			}
			if(bmaxDivN == 0xffffffff) {
				cerr << "  Max bucket size, len divisor: default" << endl;
			} else {
				cerr << "  Max bucket size, len divisor: " << bmaxDivN << endl;
			}
			cerr << "  Difference-cover sample period: " << dcv << endl;
#endif
			cerr << "  Endianness: " << (bigEndian? "big":"little") << endl
				 << "  Actual local endianness: " << (currentlyBigEndian()? "big":"little") << endl
				 << "  Sanity checking: " << (sanityCheck? "enabled":"disabled") << endl;
	#ifdef NDEBUG
			cerr << "  Assertions: disabled" << endl;
	#else
			cerr << "  Assertions: enabled" << endl;
	#endif
			cerr << "  Random seed: " << seed << endl;
			cerr << "  Sizeofs: void*:" << sizeof(void*) << ", int:" << sizeof(int) << ", long:" << sizeof(long) << ", size_t:" << sizeof(size_t) << endl;
			cerr << "Input files DNA, " << file_format_names[format].c_str() << ":" << endl;
			for(size_t i = 0; i < infiles.size(); i++) {
				cerr << "  " << infiles[i].c_str() << endl;
			}
		}
		// Seed random number generator
        srand(seed);
        {
            Timer timer(cerr, "Total time for call to driver() for forward index: ", verbose);
            try {
                driver<SString<char> >(infile, infiles, snp_fname, ht_fname, ss_fname, exon_fname, sv_fname, outfile, false, REF_READ_FORWARD);
            } catch(bad_alloc& e) {
                if(autoMem) {
                    cerr << "Switching to a packed string representation." << endl;
                    packed = true;
                } else {
                    throw e;
                }
            }
        }
        return 0;
    } catch(std::exception& e) {
		cerr << "Error: Encountered exception: '" << e.what() << "'" << endl;
		cerr << "Command: ";
		for(int i = 0; i < argc; i++) cerr << argv[i] << " ";
		cerr << endl;
		deleteIdxFiles(outfile, writeRef || justRef, justRef);
		return 1;
	} catch(int e) {
		if(e != 0) {
			cerr << "Error: Encountered internal HISAT2 exception (#" << e << ")" << endl;
			cerr << "Command: ";
			for(int i = 0; i < argc; i++) cerr << argv[i] << " ";
			cerr << endl;
		}
		deleteIdxFiles(outfile, writeRef || justRef, justRef);
		return e;
	}
}
Ejemplo n.º 24
0
/**
 * main function.  Parses command-line arguments.
 */
  int bowtie_build(int argc, const char **argv) {
	try {
		// Reset all global state, including getopt state
		opterr = optind = 1;
		resetOptions();

		string infile;
		vector<string> infiles;
		string outfile;

		parseOptions(argc, argv);
		argv0 = argv[0];
		if(showVersion) {
			cout << argv0 << " version " << BOWTIE_VERSION << endl;
			if(sizeof(void*) == 4) {
				cout << "32-bit" << endl;
			} else if(sizeof(void*) == 8) {
				cout << "64-bit" << endl;
			} else {
				cout << "Neither 32- nor 64-bit: sizeof(void*) = " << sizeof(void*) << endl;
			}
			cout << "Built on " << BUILD_HOST << endl;
			cout << BUILD_TIME << endl;
			cout << "Compiler: " << COMPILER_VERSION << endl;
			cout << "Options: " << COMPILER_OPTIONS << endl;
			cout << "Sizeof {int, long, long long, void*, size_t, off_t}: {"
				 << sizeof(int)
				 << ", " << sizeof(long) << ", " << sizeof(long long)
				 << ", " << sizeof(void *) << ", " << sizeof(size_t)
				 << ", " << sizeof(off_t) << "}" << endl;
			return 0;
		}

		// Get input filename
		if(optind >= argc) {
			cerr << "No input sequence or sequence file specified!" << endl;
			printUsage(cerr);
			return 1;
		}
		infile = argv[optind++];

		// Get output filename
		if(optind >= argc) {
			cerr << "No output file specified!" << endl;
			printUsage(cerr);
			return 1;
		}
		outfile = argv[optind++];

		tokenize(infile, ",", infiles);
		if(infiles.size() < 1) {
			cerr << "Tokenized input file list was empty!" << endl;
			printUsage(cerr);
			return 1;
		}

		// Optionally summarize
		if(verbose) {
			cout << "Settings:" << endl
				 << "  Output files: \"" << outfile << ".*." + gEbwt_ext + "\"" << endl
				 << "  Line rate: " << lineRate << " (line is " << (1<<lineRate) << " bytes)" << endl
				 << "  Lines per side: " << linesPerSide << " (side is " << ((1<<lineRate)*linesPerSide) << " bytes)" << endl
				 << "  Offset rate: " << offRate << " (one in " << (1<<offRate) << ")" << endl
				 << "  FTable chars: " << ftabChars << endl
				 << "  Strings: " << (packed? "packed" : "unpacked") << endl
				 ;
			if(bmax == OFF_MASK) {
				cout << "  Max bucket size: default" << endl;
			} else {
				cout << "  Max bucket size: " << bmax << endl;
			}
			if(bmaxMultSqrt == OFF_MASK) {
				cout << "  Max bucket size, sqrt multiplier: default" << endl;
			} else {
				cout << "  Max bucket size, sqrt multiplier: " << bmaxMultSqrt << endl;
			}
			if(bmaxDivN == 0xffffffff) {
				cout << "  Max bucket size, len divisor: default" << endl;
			} else {
				cout << "  Max bucket size, len divisor: " << bmaxDivN << endl;
			}
			cout << "  Difference-cover sample period: " << dcv << endl;
			cout << "  Endianness: " << (bigEndian? "big":"little") << endl
				 << "  Actual local endianness: " << (currentlyBigEndian()? "big":"little") << endl
				 << "  Sanity checking: " << (sanityCheck? "enabled":"disabled") << endl;
	#ifdef NDEBUG
			cout << "  Assertions: disabled" << endl;
	#else
			cout << "  Assertions: enabled" << endl;
	#endif
			cout << "  Random seed: " << seed << endl;
			cout << "  Sizeofs: void*:" << sizeof(void*) << ", int:" << sizeof(int) << ", long:" << sizeof(long) << ", size_t:" << sizeof(size_t) << endl;
			cout << "Input files DNA, " << file_format_names[format] << ":" << endl;
			for(size_t i = 0; i < infiles.size(); i++) {
				cout << "  " << infiles[i] << endl;
			}
		}
		// Seed random number generator
		srand(seed);
		{
			Timer timer(cout, "Total time for call to driver() for forward index: ", verbose);
			if(!packed) {
				try {
					driver<String<Dna, Alloc<> > >(infile, infiles, outfile);
				} catch(bad_alloc& e) {
					if(autoMem) {
						cerr << "Switching to a packed string representation." << endl;
						packed = true;
					} else {
						throw e;
					}
				}
			}
			if(packed) {
				driver<String<Dna, Packed<Alloc<> > > >(infile, infiles, outfile);
			}
		}
		if(doubleEbwt) {
			srand(seed);
			Timer timer(cout, "Total time for backward call to driver() for mirror index: ", verbose);
			if(!packed) {
				try {
					driver<String<Dna, Alloc<> > >(infile, infiles, outfile + ".rev", true);
				} catch(bad_alloc& e) {
					if(autoMem) {
						cerr << "Switching to a packed string representation." << endl;
						packed = true;
					} else {
						throw e;
					}
				}
			}
			if(packed) {
				driver<String<Dna, Packed<Alloc<> > > >(infile, infiles, outfile + ".rev", true);
			}
		}
		return 0;
	} catch(std::exception& e) {
		cerr << "Command: ";
		for(int i = 0; i < argc; i++) cerr << argv[i] << " ";
		cerr << endl;
		return 1;
	} catch(int e) {
		if(e != 0) {
			cerr << "Command: ";
			for(int i = 0; i < argc; i++) cerr << argv[i] << " ";
			cerr << endl;
		}
		return e;
	}
  }
Ejemplo n.º 25
0
void OptionEngine::queryResetOptions()
{
    emit resetOptions();
}