Ejemplo n.º 1
0
void CarDepotImpl::updateCar(boost::shared_ptr<Car> car, const CarProperties& properties)
{
    const std::string& oldPlateNo = car->getProperties().getPlateNo();
    const std::string& newPlateNo = properties.getPlateNo();

    //if plate no. changes, verify new plate no. has not been registered.
    if (oldPlateNo != newPlateNo &&
        carByPlateNo.find(newPlateNo) != carByPlateNo.end())
    {
        throw CarException((boost::format(DUPLICATE_PLATE_NO) % newPlateNo).str());
    }

    //keep the ID
    boost::shared_ptr<Car> newCar(new CarImpl(car->getId(), properties));

    CarIter it = carByPlateNo.find(oldPlateNo);
    if (oldPlateNo == newPlateNo)
    {
        it->second = newCar;
    }
    else
    {
        carByPlateNo.erase(it);
        carByPlateNo.insert(std::make_pair(newPlateNo, newCar));
    }
}
Ejemplo n.º 2
0
void CarGui::draw()
{
    QPolygonF newCar(this->points);

    if (this->currentCar) {
        this->currentCar->setPen(QPen(QColor(255,0,0)));
        this->drawnCars.append(this->currentCar);
        this->currentCar = 0;
    }
    std::cout << "CarGui::draw new car drawn, total drawn cars[" << this->drawnCars.size() << "]" << std::endl;
    this->currentCar = this->drawArea->scene()->addPolygon(newCar);
}