Class that manages the mileage of a vehicle. QObject.
More...
#include <MileageManager.hpp>
Class that manages the mileage of a vehicle. QObject.
Definition at line 28 of file MileageManager.hpp.
◆ MileageManager()
Constructs a MileageManager object with the specified file path, calculator, and file handler.
- Parameters
-
filePath | The path to the mileage file. |
calculator | The mileage calculator to use. |
fileHandler | The file handler to use. |
parent | The parent object. |
This constructor initializes the MileageManager object with the specified file path, calculator, and file handler. It also sets the total mileage to 0.0.
Definition at line 33 of file MileageManager.cpp.
◆ ~MileageManager()
MileageManager::~MileageManager |
( |
| ) |
|
Destructs the MileageManager object.
This destructor calls the shutdown method to stop the timers and saves the mileage to the file. It also deletes the calculator and file handler if they were created internally.
Definition at line 52 of file MileageManager.cpp.
◆ getTotalMileage()
double MileageManager::getTotalMileage |
( |
| ) |
const |
|
inline |
◆ initialize()
void MileageManager::initialize |
( |
| ) |
|
◆ mileageUpdated
void MileageManager::mileageUpdated |
( |
double | mileage | ) |
|
|
signal |
◆ onSpeedUpdated
void MileageManager::onSpeedUpdated |
( |
float | speed | ) |
|
|
slot |
Handles the speed updated signal.
- Parameters
-
speed | The new speed value. |
This method handles the speed updated signal by adding the speed value to the calculator.
Definition at line 125 of file MileageManager.cpp.
◆ saveMileage
void MileageManager::saveMileage |
( |
| ) |
|
|
slot |
Saves the mileage to the file.
This method saves the total mileage to the file using the file handler.
Definition at line 113 of file MileageManager.cpp.
◆ shutdown()
void MileageManager::shutdown |
( |
| ) |
|
Shuts down the MileageManager object.
This method stops the update and persistence timers and saves the mileage to the file.
Definition at line 88 of file MileageManager.cpp.
◆ updateMileage
void MileageManager::updateMileage |
( |
| ) |
|
|
slot |
Updates the mileage.
This method updates the mileage by calculating the distance traveled since the last update and adding it to the total mileage.
Definition at line 101 of file MileageManager.cpp.
◆ m_calculator
◆ m_fileHandler
◆ m_ownCalculator
bool MileageManager::m_ownCalculator |
|
private |
◆ m_ownFileHandler
bool MileageManager::m_ownFileHandler |
|
private |
◆ m_persistenceTimer
QTimer MileageManager::m_persistenceTimer |
|
private |
◆ m_totalMileage
double MileageManager::m_totalMileage |
|
private |
◆ m_updateTimer
QTimer MileageManager::m_updateTimer |
|
private |
The documentation for this class was generated from the following files: