KPublicTransport

rentalvehicleutil.cpp
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "rentalvehicleutil_p.h"
8 #include "rentalvehicle.h"
9 
10 using namespace KPublicTransport;
11 
12 RentalVehicleNetwork RentalVehicleUtil::merge(const RentalVehicleNetwork &lhs, const RentalVehicleNetwork &rhs)
13 {
14  // TODO
15  return lhs.isValid() ? lhs : rhs;
16 }
17 
18 RentalVehicleStation RentalVehicleUtil::merge(const RentalVehicleStation &lhs, const RentalVehicleStation &rhs)
19 {
20  auto s = lhs;
21  s.setNetwork(RentalVehicleUtil::merge(lhs.network(), rhs.network()));
22  s.setCapacity(std::max(lhs.capacity(), rhs.capacity()));
23  s.setAvailableVehicles(std::max(lhs.availableVehicles(), rhs.availableVehicles()));
24  return s;
25 }
26 
27 RentalVehicle RentalVehicleUtil::merge(const RentalVehicle &lhs, const RentalVehicle &rhs)
28 {
29  auto v = lhs;
30  v.setNetwork(RentalVehicleUtil::merge(lhs.network(), rhs.network()));
31  v.setType(std::max(lhs.type(), rhs.type()));
32  return v;
33 }
VehicleType type
Vehicle type.
Definition: rentalvehicle.h:45
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Additional information for a vehicle renting station, attached to Location objects.
Definition: rentalvehicle.h:72
A vehicle sharing system/network.
int availableVehicles
Number of available (rentable) vehicles at this station.
Definition: rentalvehicle.h:76
void setCapacity(RentalVehicle::VehicleType type, int capacity)
Set the capacity for a specific vehicle type.
int capacity
Number of dock positions at this station.
Definition: rentalvehicle.h:80
bool isValid
Not an empty/default constructed object.
An individual rental vehicle used on a JourneySection, ie.
Definition: rentalvehicle.h:27
KPublicTransport::RentalVehicleNetwork network
Sharing network operator.
Definition: rentalvehicle.h:48
KPublicTransport::RentalVehicleNetwork network
Sharing network operator.
Definition: rentalvehicle.h:83
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 23:07:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.