Traffic Flow Dynamics Model
Vehicle Class Reference

Vehicle class. More...

#include <Vehicle.hpp>

Public Member Functions

 Vehicle (int)
 create a vehicle of a type in _vehicleType More...
 
 Vehicle (const Vehicle &v)
 
uint8_t getType () const noexcept
 Get the vehicle type index. More...
 
void setPosition (int)
 Set the position of the vehicle. More...
 
uint16_t getPosition () const noexcept
 Get the position of the vehicle. More...
 
int getPreviousPosition () const noexcept
 Get the previous position of the vehicle. More...
 
void setStreet (int)
 Set the street of the vehicle. More...
 
int getStreet () const
 Get the street of the vehicle. More...
 
uint16_t getDestination () const noexcept
 Get the destination of the vehicle. More...
 
void setTimePenalty (int)
 Set the time penalty of the vehicle. More...
 
int getTimePenalty () const noexcept
 Get the time penalty of the vehicle. More...
 
void setVelocity (double)
 Set the velocity of the vehicle. More...
 
double getVelocity () const noexcept
 Get the velocity of the vehicle. More...
 
void incrementTimeTraveled () noexcept
 Increment the time traveled by the vehicle.
 
int getTimeTraveled () const noexcept
 Get the time traveled by the vehicle. More...
 
void resetTimeTraveled () noexcept
 Reset the time traveled by the vehicle, setting it to 0.
 

Static Public Member Functions

static void addVehicleType (int, int)
 add a vehicle type in _vehicleType More...
 
static void addVehicleType (std::string)
 add many vehicle types in _vehicleType from file More...
 
static std::shared_ptr< VehicleTypegetVehicleType (int8_t const)
 get a vehicle type from _vehicleType More...
 
static uint8_t getNVehicleType ()
 get the number of vehicle types in _vehicleType More...
 

Detailed Description

Vehicle class.

This class is used to represent a vehicle. It contains the vehicle type, the position, the street, the time penalty, the velocity and the time traveled.

Constructor & Destructor Documentation

◆ Vehicle()

Vehicle::Vehicle ( int  type)

create a vehicle of a type in _vehicleType

Create a new Vehicle object.

Parameters
typeThe index of the vehicle type in _vehicleType.
Exceptions
std::invalid_argumentif the vehicle type index is out of range.

Member Function Documentation

◆ addVehicleType() [1/2]

void Vehicle::addVehicleType ( int  src,
int  dst 
)
static

add a vehicle type in _vehicleType

Add a vehicle type in _vehicleType.

Parameters
srcThe source node.
dstThe destination node.
Exceptions
std::invalid_argumentif the vehicle type already exists.

◆ addVehicleType() [2/2]

void Vehicle::addVehicleType ( std::string  fName)
static

add many vehicle types in _vehicleType from file

Add many vehicle types in _vehicleType from file.

Parameters
fNameThe file name.
Exceptions
std::runtime_errorif the file is not found or empty.
std::invalid_argumentif the vehicle type already exists.

◆ getDestination()

uint16_t Vehicle::getDestination ( ) const
noexcept

Get the destination of the vehicle.

Returns
The destination of the vehicle.

◆ getNVehicleType()

uint8_t Vehicle::getNVehicleType ( )
static

get the number of vehicle types in _vehicleType

Get the number of vehicle types.

Returns
The number of vehicle types.

◆ getPosition()

uint16_t Vehicle::getPosition ( ) const
noexcept

Get the position of the vehicle.

Returns
The position of the vehicle, i.e. a positive integrer representing the index of the node.

◆ getPreviousPosition()

int Vehicle::getPreviousPosition ( ) const
noexcept

Get the previous position of the vehicle.

Returns
The previous position of the vehicle, i.e. a positive integrer representing the index of the node. The previous position is -1 if the vehicle has not moved yet.

◆ getStreet()

int Vehicle::getStreet ( ) const

Get the street of the vehicle.

Returns
The street of the vehicle, i.e. a positive integrer representing the index of the street.

◆ getTimePenalty()

int Vehicle::getTimePenalty ( ) const
noexcept

Get the time penalty of the vehicle.

Returns
The time penalty of the vehicle.

◆ getTimeTraveled()

int Vehicle::getTimeTraveled ( ) const
noexcept

Get the time traveled by the vehicle.

Returns
The time traveled by the vehicle.

◆ getType()

uint8_t Vehicle::getType ( ) const
noexcept

Get the vehicle type index.

Returns
The vehicle type index.

◆ getVehicleType()

std::shared_ptr< VehicleType > Vehicle::getVehicleType ( int8_t const  index)
static

get a vehicle type from _vehicleType

Get the vehicle type.

Returns
A pointer to the vehicle type object.
Exceptions
std::invalid_argumentif the vehicle type index is out of range.

◆ getVelocity()

double Vehicle::getVelocity ( ) const
noexcept

Get the velocity of the vehicle.

Returns
The velocity of the vehicle.

◆ setPosition()

void Vehicle::setPosition ( int  pos)

Set the position of the vehicle.

Parameters
posThe position of the vehicle, i.e. a positive integrer representing the index of the node.
Exceptions
std::invalid_argumentif the position is negative.

◆ setStreet()

void Vehicle::setStreet ( int  street)

Set the street of the vehicle.

Parameters
streetThe street of the vehicle, i.e. a positive integrer representing the index of the street. The -1 is a jolly.

◆ setTimePenalty()

void Vehicle::setTimePenalty ( int  time)

Set the time penalty of the vehicle.

Parameters
timeThe time penalty of the vehicle, i.e. a positive integrer.
Exceptions
std::invalid_argumentif the time is negative.

◆ setVelocity()

void Vehicle::setVelocity ( double  vel)

Set the velocity of the vehicle.

Parameters
velThe velocity of the vehicle.
Exceptions
std::invalid_argumentif the velocity is negative.

The documentation for this class was generated from the following files: