Exemplo n.º 1
0
bool PlannerThread::plan_init()
{
    checkPause();
    if (!resetPlanVars())
    {
        return false;
    }
    checkPause();
    if (!updateState())
    {
        return false;
    }
    checkPause();
    if (!loadState())
    {
        return false;
    }
    checkPause();
    if (!groundRules())
    {
        return false;
    }
    checkPause();
    if (!completePlannerState())
    {
        return false;
    }
    checkPause();
    if (!preserveState())
    {
        return false;
    }
    checkPause();
    if (!compileGoal())
    {
        return false;
    }
    checkPause(); 
    if (!loadRules())
    {
        return false;
    }
    checkPause();
    if (!preserveRules())
    {
        return false;
    }
    checkPause();
    if (!goalUpdate())
    {
        return false;
    }
    checkPause();
    if (!loadGoal())
    {
        return false;
    }
    checkPause();
    return true;
}
Exemplo n.º 2
0
XkbRules::XkbRules(bool layoutsOnly)
{
#ifdef HAVE_XKLAVIER
	loadNewRules(layoutsOnly);
#else
	X11_DIR = X11Helper::findX11Dir();

   	if( X11_DIR == NULL ) {
        kError() << "Cannot find X11 directory!" << endl;
//        throw Exception();
		return;
   	}

	QString rulesFile = X11Helper::findXkbRulesFile(X11_DIR, QX11Info::display());

	if( rulesFile.isEmpty() ) {
  		kError() << "Cannot find rules file in " << X11_DIR << endl;
//		throw Exception();
		return;
	}

	loadRules(rulesFile, layoutsOnly);
#endif

}
Exemplo n.º 3
0
void LayoutConfig::defaults()
{
    loadRules();
    m_kxkbConfig.setDefaults();

    initUI();

    emit KCModule::changed(true);
}
Exemplo n.º 4
0
Game::Game(std::istream &stream)
{
    pleaseWait();

    loadPuzzle(solvedPuzzle, stream);
    loadRules(rules, stream);
    memcpy(savedSolvedPuzzle, solvedPuzzle, sizeof(solvedPuzzle));
    savedRules = rules;
    possibilities = new Possibilities(stream);
    puzzle = new Puzzle(iconSet, solvedPuzzle, possibilities);
    verHints = new VertHints(iconSet, rules, stream);
    horHints = new HorHints(iconSet, rules, stream);
    watch = new Watch(stream);
    hinted = true;
}
SimpleStochasticSimulator::SimpleStochasticSimulator( std::string rulesfile, std::string modelfile )
    :
    SimpleSimulator()
{
    loadRules(rulesfile);
    loadModel(modelfile);

    std::cout << "Prior to initialization there are "
              << getNumSpecies() << " species and " << getNumRxns() << " reactions" << std::endl;

    recordNewReactions();

    initialize();

    std::cout << "After initialization there are "
              << getNumSpecies() << " species and " << getNumRxns() << " reactions" << std::endl;
}
Exemplo n.º 6
0
 void RuleBlock::reloadRules(const Engine* engine) {
     unloadRules();
     loadRules(engine);
 }
Exemplo n.º 7
0
LayoutConfig::LayoutConfig(QWidget *parent, const char *name) : KCModule(parent, name), m_rules(NULL)
{
    QVBoxLayout *main = new QVBoxLayout(this, 0, KDialog::spacingHint());

    widget = new LayoutConfigWidget(this, "widget");
    main->addWidget(widget);

    connect(widget->chkEnable, SIGNAL(toggled(bool)), this, SLOT(changed()));
    connect(widget->chkShowSingle, SIGNAL(toggled(bool)), this, SLOT(changed()));
    connect(widget->chkShowFlag, SIGNAL(toggled(bool)), this, SLOT(changed()));
    connect(widget->comboModel, SIGNAL(activated(int)), this, SLOT(changed()));

    connect(widget->listLayoutsSrc, SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), this, SLOT(add()));
    connect(widget->btnAdd, SIGNAL(clicked()), this, SLOT(add()));
    connect(widget->btnRemove, SIGNAL(clicked()), this, SLOT(remove()));

    connect(widget->comboVariant, SIGNAL(activated(int)), this, SLOT(changed()));
    connect(widget->comboVariant, SIGNAL(activated(int)), this, SLOT(variantChanged()));
    connect(widget->listLayoutsDst, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(layoutSelChanged(QListViewItem *)));

    connect(widget->editDisplayName, SIGNAL(textChanged(const QString &)), this, SLOT(displayNameChanged(const QString &)));

    connect(widget->chkLatin, SIGNAL(clicked()), this, SLOT(changed()));
    connect(widget->chkLatin, SIGNAL(clicked()), this, SLOT(latinChanged()));

    widget->btnUp->setIconSet(SmallIconSet("1uparrow"));
    connect(widget->btnUp, SIGNAL(clicked()), this, SLOT(changed()));
    connect(widget->btnUp, SIGNAL(clicked()), this, SLOT(moveUp()));
    widget->btnDown->setIconSet(SmallIconSet("1downarrow"));
    connect(widget->btnDown, SIGNAL(clicked()), this, SLOT(changed()));
    connect(widget->btnDown, SIGNAL(clicked()), this, SLOT(moveDown()));

    connect(widget->grpSwitching, SIGNAL(clicked(int)), SLOT(changed()));

    connect(widget->chkEnableSticky, SIGNAL(toggled(bool)), this, SLOT(changed()));
    connect(widget->spinStickyDepth, SIGNAL(valueChanged(int)), this, SLOT(changed()));

    widget->listLayoutsSrc->setColumnText(LAYOUT_COLUMN_FLAG, "");
    widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_FLAG, "");
    widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_INCLUDE, "");
    //  widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_DISPLAY_NAME, "");

    widget->listLayoutsSrc->setColumnWidth(LAYOUT_COLUMN_FLAG, 28);
    widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_FLAG, 28);

    widget->listLayoutsDst->header()->setResizeEnabled(FALSE, LAYOUT_COLUMN_INCLUDE);
    widget->listLayoutsDst->header()->setResizeEnabled(FALSE, LAYOUT_COLUMN_DISPLAY_NAME);
    widget->listLayoutsDst->setColumnWidthMode(LAYOUT_COLUMN_INCLUDE, QListView::Manual);
    widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_INCLUDE, 0);
    //  widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_DISPLAY_NAME, 0);

    widget->listLayoutsDst->setSorting(-1);
#if 0
  widget->listLayoutsDst->setResizeMode(QListView::LastColumn);
  widget->listLayoutsSrc->setResizeMode(QListView::LastColumn);
#endif
    widget->listLayoutsDst->setResizeMode(QListView::LastColumn);

    // Read rules - we _must_ read _before_ creating xkb-options comboboxes
    loadRules();

    makeOptionsTab();

    load();
}
Exemplo n.º 8
0
bool PlannerThread::planning_cycle()
{
    checkPause();
    if (!updateState())
    {
        return false;
    }
    checkPause();
    if (!completePlannerState())
    {
        return false;
    }
    checkPause();
    if (!loadState())
    {
        return false;
    }
    checkPause();
    if (compareState())
    {
        checkPause();
        if (!adaptRules())
        {
            return false;
        }
        checkPause();
    }
    checkPause();
    if (!goalUpdate())
    {
        return false;
    }
    checkPause();
    if (!loadGoal())
    {
        return false;
    }
    checkPause();
    if (!planCompletion())
    {
        return true;
    }
    checkPause();
    if (!checkHoldingSymbols())
    {
        checkPause();
        jumpBack();
        checkPause();
        if (!resetConfig())
        {
            return false;
        }
        checkPause();
    }
    else 
    {
        checkPause();
        if (checkGoalCompletion())
        {
            checkPause();
            if (!resetRules())
            {
                return false;
            }
            checkPause();
            if (!resetConfig())
            {
                return false;
            }
            checkPause();
            if (!loadRules())
            {
                return false;
            }
            checkPause();
            if (!jumpForward())
            {
                return false;
            }
            checkPause();
            return true;
        }
        checkPause();
        int flag_prada = PRADA();
        checkPause();
        if (flag_prada == 0)
        {
            return false;
        }
        else if (flag_prada == 2)
        {
            if (!increaseHorizon())
            {
                return false;
            }
            checkPause();
            return true;
        }
        if (!loadUsedObjs())
        {
            return false;
        }
        checkPause();
        if (!codeAction())
        {
            return false;
        }
        checkPause();
        if (!execAction())
        {
            return false;
        }
        checkPause();
        if (!preserveState())
        {
            return false;
        }
        checkPause();
        if (!checkFailure())
        {
            return false;
        }
        checkPause();
    }
    checkPause();
    return true;
}    
Exemplo n.º 9
0
int main(int argc, const char * argv[])
{
	Bool result = TRUE;

	if ((argc < 2) || (argc > 3))
	{
		printf(USAGE);
		return -1;
	}


	if (strcmp(argv[1], LOAD_RULES) == 0)
	{
		if (argc != 3)
		{
			printf("A path to a rules file must be specified in order to load rules.\n");
			return -1;
		}
		else
		{
			result = loadRules(argv[2]);
			if (!result)
			{
				return -1;
			}
			return 0;
		}
	}
	else if (strcmp(argv[1], LOAD_HOSTS) == 0)
	{
		if (argc != 3)
		{
			printf("A path to a hosts file must be specified in order to load hosts.\n");
			return -1;
		}
		else
		{
			result = loadHosts(argv[2]);
			if (!result)
			{
				return -1;
			}
			return 0;
		}
	}
	else if (argc != 2)
	{
		printf("Any action other than %s, %s must not take any parameters.\n", LOAD_RULES, LOAD_HOSTS);
		return -1;
	}

	if (strcmp(argv[1], ACTIVATE) == 0)
	{
		result = activate();
	}
	else if (strcmp(argv[1], DEACTIVATE) == 0)
	{
		result = deactivate();
	}
	else if (strcmp(argv[1], SHOW_RULES) == 0)
	{
		result = showRules();
	}
	else if (strcmp(argv[1], CLEAR_RULES) == 0)
	{
		result = clearRules();
	}
	else if (strcmp(argv[1], SHOW_LOG) == 0)
	{
		result = showLog();
	}
	else if (strcmp(argv[1], CLEAR_LOG) == 0)
	{
		result = clearLog();
	}
	else if (strcmp(argv[1], SHOW_CONNECTION_TABLE) == 0)
	{
		result = showConnectionTable();
	}
	else if (strcmp(argv[1], SHOW_HOSTS) == 0)
	{
		result = showHosts();
	}
	else
	{
		printf("The only valid actions are: %s, %s, %s, %s, %s, %s, %s, %s\n",
			   ACTIVATE, DEACTIVATE, SHOW_RULES, CLEAR_RULES, LOAD_RULES, SHOW_LOG, 
			   CLEAR_LOG, SHOW_CONNECTION_TABLE, SHOW_HOSTS, LOAD_HOSTS);
	}

	if (result)
	{
		return 0;
	}
	else
	{
		return -1;
	}
}