Exemple #1
0
comparison_result path_length::compare(const path_length& other, comparison_type comp) const {
	switch (comp) {
	case FULL:
		return compare_full(other);
	case SWITCH_COSTS:
		return compare_switch(other);
	case MULTIPLEX:
		return compare_multiplex(other);
	case SIMPLE:
		return compare_simple(other);
	}
	throw WrongParameterException("Wrong comparison type");
}
Exemple #2
0
//------------------------------------------------------------------------------
int MoveCommand::execute(Game& board, vector<string>& params)
{
  string direction = params.at(1);
  if((direction == Game::DIRECTION_MOVE_UP) ||
    (direction == Game::DIRECTION_MOVE_DOWN) ||
    (direction == Game::DIRECTION_MOVE_LEFT) ||
    (direction == Game::DIRECTION_MOVE_RIGHT))
  {
    if(board.isMazeLoaded() == false)
    {
      throw NoMazeLoadedException();
    }
    
    return board.movePlayer(direction);
  }
  else
  {
    throw WrongParameterException();
  }

}
Exemple #3
0
const sorted_random_map<node_id,NodeSharedPtr>& MLNetwork::neighbors(const NodeSharedPtr& node, edge_mode mode) const {
	if (mode==IN) {
		if (sidx_neighbors_in.count(node->id)==0) {
			return empty;
		}
		return sidx_neighbors_in.at(node->id);
	}
	else if (mode==OUT) {
		if (sidx_neighbors_out.count(node->id)==0) {
			return empty;
		}
		return sidx_neighbors_out.at(node->id);
	}
	else if (mode==INOUT) {
		if (sidx_neighbors_all.count(node->id)==0) {
			return empty;
		}
		return sidx_neighbors_all.at(node->id);
	}
	else throw WrongParameterException("neighborhood mode");
}
Exemple #4
0
void Instruction::AInstructionParams::end()
{
  std::list<std::string>::iterator  it;
  OperandFactory                    *factory;
  eOperandType                      type;
  std::string                       str_type;
  std::string                       str_value;

  if (this->params.size() == 2)
  {
    it = this->params.begin();
    factory = AbstractVM::getVM()->getOperandFactory();
    str_type = *it;
    it++;
    str_value = *it;
    type = factory->getTypeFromString(str_type);
    this->op = factory->createOperand(type, str_value);
    return ;
  }
  throw WrongParameterException("wrong parameters");
}