当前位置: 首页>>代码示例>>C++>>正文


C++ AbstractCommand类代码示例

本文整理汇总了C++中AbstractCommand的典型用法代码示例。如果您正苦于以下问题:C++ AbstractCommand类的具体用法?C++ AbstractCommand怎么用?C++ AbstractCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AbstractCommand类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadPuzzle

void GamePlayScene::loadGameState(const std::vector<char> *data) {
	union change {
		int i;
		unsigned char buf[4];
	} itoc;
	itoc.buf[0] = data->at(0);
	itoc.buf[1] = data->at(1);
	itoc.buf[2] = data->at(2);
	itoc.buf[3] = data->at(3);
	loadPuzzle(itoc.i);
	m_sudoku->loadGameFromBuffer(data);

	AbstractCommand *cmd;
	int pos = SUDOKU_SIZE * SUDOKU_SIZE * 3 + 4;

	while (pos < data->size()) {
		cmd = AbstractCommand::loadFromBuffer(this, data, pos);
		m_logStack.push_back(cmd);
		if (cmd->isPuzzleCmd()) {
			m_undoStack.push_back(cmd->clone());
		}
		pos += cmd->getCommandBufSize();
	}

	m_puzzleLayer->resetValues();
	m_inputLayer->setUndoButton(hasSomethingToUndo());
	m_inputLayer->setNumberCompleted();
}
开发者ID:SpiritRain,项目名称:sudosudoku,代码行数:28,代码来源:GamePlayScene.cpp

示例2: receiveData

void BattleInput::receiveData(QByteArray inf)
{
    if (inf.isEmpty()) {
        if (paused()) {
            delayedCommands.push_back(inf);
            return;
        }

        /* An empty array means raw Command */
        if (commands.size() > 0) {
            AbstractCommand *command = *commands.begin();
            commands.pop_front();
            command->apply();
            delete command;
            return;
        }
    }

    if (paused() && inf[0] != char(BC::BattleChat) && inf[0] != char(BC::SpectatorChat) && inf[0] != char(BC::ClockStart)
            && inf[0] != char(BC::ClockStop)
            && inf[0] != char(BC::Spectating)) {
        delayedCommands.push_back(inf);
        return;
    }

    DataStream in (&inf, QIODevice::ReadOnly);

    uchar command;
    qint8 player;

    in >> command >> player;

    dealWithCommandInfo(in, command, player);
}
开发者ID:Mangoxylic,项目名称:pokemon-online,代码行数:34,代码来源:battleinput.cpp

示例3: getCommandByName

AbstractCommand* Terminal::getCommandByName(char* commandName)
{
	for(uint8_t q = 0 ; q < commands->getSize() ; q ++)
	{
		AbstractCommand* command = commands->get(q);
		if(strcmp_P(commandName, (char*)command->getName()) == 0)
		{
			return command;
		}
	}

	return 0;
}
开发者ID:wmarkow,项目名称:arduino-terminal,代码行数:13,代码来源:Terminal.cpp

示例4: processHelp

void Terminal::processHelp()
{
	if(commands->getSize() == 0)
	{
		serial->println(F("No commands available."));
		return;
	}

	for(uint8_t q = 0 ; q < commands->getSize() ; q ++)
	{
		AbstractCommand* command = commands->get(q);
		serial->println(command->getName());
	}
}
开发者ID:wmarkow,项目名称:arduino-terminal,代码行数:14,代码来源:Terminal.cpp

示例5: parseCommand

AbstractCommand *CommandFactory::parseCommand(QString const &command)
{
	QString const normalizedCommand = command.toLower().trimmed();
	QStringList const parts = normalizedCommand.split(" ", QString::SkipEmptyParts);
	if (parts.isEmpty()) {
		return 0;
	}
	AbstractCommand *result = parseCommand(parts);
	if (result) {
		result->setParent(this);
	} else {
		qDebug() << "Error while parsing command" << command;
	}
	return result;
}
开发者ID:romikmomik,项目名称:car-demo,代码行数:15,代码来源:CommandFactory.cpp

示例6: while

void RegularBattleScene::unpause()
{
    pauseCount -= 1;

    if (pauseCount == 0 && !unpausing) {
        unpausing = true;
        while (commands.size() > 0) {
            AbstractCommand *command = *commands.begin();
            commands.pop_front();
            command->apply();
            delete command;
        }
        unpausing = false;
    }

    baseClass::unpause();
}
开发者ID:awecat,项目名称:pokemon-online,代码行数:17,代码来源:regularbattlescene.cpp

示例7: debugOutput

void Connection::receiveCommand()
{
    QByteArray arr = m_connection->readAll();
    debugOutput(1, QString::fromLatin1("Command received: ") + (arr));
    QList<CommandInfo> commands = availableCommands();
    for(QList<CommandInfo>::iterator it = commands.begin(); it != commands.end(); ++it) {
        if (it->commandName == QString::fromLatin1(arr)) {
            debugOutput(1, "Found command in list");
            disconnect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand()));
            AbstractCommand* command = (*it).commandFunc();
            command->setSocket(m_connection);
            m_command = command;
            return;
        }
    }
    debugOutput(2, QString::fromLatin1("Unknown command received: ") + (arr));
}
开发者ID:maxxant,项目名称:qt,代码行数:17,代码来源:connectionmanager.cpp

示例8:

AbstractCommand * Pilot::BuildOne(DataType data, CommandType command, const std::string & commandName){
	// instanciate data
	AbstractData *    d = DataFactory::Create(data);
	if ( !d ){
		Logger::Instance() << "Error data not built";
		return NULL;
	}
	// instanciate Command
	AbstractCommand * c = CommandFactory::Create(command);
	if ( !c ){
		Logger::Instance() << "Error command not built";
		return NULL;
	}
	// link data with command and delegate ownership
	c->SetData(d);
	// append to container (take ownership, will be deleted automatically)
    _containerContainer.Set(commandName,c);	
	return c;
}
开发者ID:tryingsomestuff,项目名称:pilot,代码行数:19,代码来源:Pilot.cpp

示例9: getCommand

/*
* Return the index number of occurrence of this command. If doesn't exists return NULL;
* The first command has number 0.
*/
AbstractCommand* SyncMLProcessor::getCommand(SyncBody* syncBody, const char*commandName, int index) {

    int iterator = 0, found = 0;
    ArrayList* list     = syncBody->getCommands();
    AbstractCommand* a  = NULL;
    const char* name = NULL;
    do {
        a = (AbstractCommand*)getArrayElement(list, iterator);
        if (a) {
            name = a->getName();    // is returned the pointer to the element not a new element
            if (name && strcmp(name, commandName) == 0) {
                if (found == index)
                    break;
                else
                    found++;
            }
        }
        ++iterator;
    } while(a);

    return a;
}
开发者ID:ruphy,项目名称:kfunambol,代码行数:26,代码来源:SyncMLProcessor.cpp

示例10: useCommand

void BattleScene::useCommand()
{
    if (commands.size() > 0) {
        AbstractCommand *command = *commands.begin();

        int val = command->val();

        if (!onPeek(val)) {
            return;
        }

        commands.pop_front();
        command->apply();
        delete command;

        if (replayCount > 0 && misReplayingCommands) {
            replayCount --;

            if (replayCount == 0) {
                misReplayingCommands = false;
            }
        }
    }
}
开发者ID:Airisu,项目名称:pokemon-online,代码行数:24,代码来源:battlescene.cpp

示例11: qDebug

void Service::invokeCommand (const QString& cmd)
{
    qDebug() << "[DesktopControl::Service::invokeCommand()] Heard " << cmd << "from the user.";
    AbstractCategory* glbl = AbstractCategory::global();
    CommandList commands = glbl->matchAllCommands (cmd);

    if (!commands.isEmpty()) {
        if (commands.count() == 1) {
            AbstractCommand* onlyCommand = commands.first();
            qDebug() << "[DesktopControl::Service::invokeCommand()] Only matched a command " << onlyCommand->id() << "matched with statements" << onlyCommand->statements();
            emit commandFound (cmd, onlyCommand);
            onlyCommand->invoke (cmd);
            return;
        }
        else {
            emit multipleCommandsFound (cmd, commands);

            Q_FOREACH (AbstractCommand * command, commands) {
                qDebug() << "[DesktopControl::Service::invokeCommand()] Command " << command->id() << "matched with statements" << command->statements();
            }
        }

    }
    else {
开发者ID:itnavigate,项目名称:speechcontrol,代码行数:24,代码来源:service.cpp

示例12: testExecute

    void testExecute(){
        Sequence sequence( "foo", 1, 4, 4, 500000 );
        Track track( "name", "singer" );
        track.events()->clear();
        Event singer( 0, EventType::SINGER );
        track.events()->add( singer, 1 );
        Event note( 1920, EventType::NOTE );
        note.note = 60;
        track.events()->add( note, 2 );
        *sequence.track(0) = track;

        Event editedNote = note;
        editedNote.note = 61;
        EditEventCommand command( 0, 2, editedNote );
        AbstractCommand *inverseCommand = command.execute( &sequence );

        CPPUNIT_ASSERT_EQUAL(61, sequence.track(0)->events()->findFromId(2)->note);

        AbstractCommand *garbage = inverseCommand->execute( &sequence );
        CPPUNIT_ASSERT_EQUAL(60, sequence.track(0)->events()->findFromId(2)->note);

        delete inverseCommand;
        delete garbage;
    }
开发者ID:cadencii,项目名称:cadencii-nt,代码行数:24,代码来源:EditEventCommandTest.cpp

示例13: performBackgroundCommands

void Terminal::loop() {
	performBackgroundCommands();

	// check for incoming commands
	if(!readString())
	{
		return;
	}

	char* command = commandParams.getParam(0);
	if(strcmp_P(command, (char*)F("break")) == 0)
	{
		cancelBackgroundCommands();

		commandParams.reset();
		printTerminalReadyIfNeeded();

		return;
	}

	if(areBackgroundCommands())
	{
		commandParams.reset();
		serial->println(F("terminal busy"));

		return;
	}

	if(strcmp_P(command, (char*)F("")) == 0)
	{
		commandParams.reset();
		printTerminalReadyIfNeeded();
		return;
	}

	if(strcmp_P(command, (char*)F("help")) == 0)
	{
		processHelp();

		commandParams.reset();
		printTerminalReadyIfNeeded();
		return;
	}

	AbstractCommand* commandToExecute = getCommandByName(command);
	if(commandToExecute != 0)
	{
		commandToExecute->process(&commandParams, this->serial);
		commandParams.reset();

		if(commandToExecute->isBackground())
		{
			this->backgroundCommand = commandToExecute;
		}
		else
		{
			printTerminalReadyIfNeeded();
		}

		return;
	}

	serial->print(command);
	serial->println(F(": unknown command"));

	commandParams.reset();
	printTerminalReady();
}
开发者ID:wmarkow,项目名称:arduino-terminal,代码行数:68,代码来源:Terminal.cpp


注:本文中的AbstractCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。