Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
MileageManager Class Reference

Class that manages the mileage of a vehicle. QObject. More...

#include <MileageManager.hpp>

Public Slots

void onSpeedUpdated (float speed)
 Handles the speed updated signal.
 
void updateMileage ()
 Updates the mileage.
 
void saveMileage ()
 Saves the mileage to the file.
 

Signals

void mileageUpdated (double mileage)
 

Public Member Functions

 MileageManager (const QString &filePath, IMileageCalculator *calculator=nullptr, IMileageFileHandler *fileHandler=nullptr, QObject *parent=nullptr)
 Constructs a MileageManager object with the specified file path, calculator, and file handler.
 
 ~MileageManager ()
 Destructs the MileageManager object.
 
void initialize ()
 Initializes the MileageManager object.
 
void shutdown ()
 Shuts down the MileageManager object.
 
double getTotalMileage () const
 

Private Attributes

IMileageCalculatorm_calculator
 
IMileageFileHandlerm_fileHandler
 
bool m_ownCalculator
 
bool m_ownFileHandler
 
QTimer m_updateTimer
 
QTimer m_persistenceTimer
 
double m_totalMileage
 

Detailed Description

Class that manages the mileage of a vehicle. QObject.

Definition at line 28 of file MileageManager.hpp.

Constructor & Destructor Documentation

◆ MileageManager()

MileageManager::MileageManager ( const QString & filePath,
IMileageCalculator * calculator = nullptr,
IMileageFileHandler * fileHandler = nullptr,
QObject * parent = nullptr )
explicit

Constructs a MileageManager object with the specified file path, calculator, and file handler.

Parameters
filePathThe path to the mileage file.
calculatorThe mileage calculator to use.
fileHandlerThe file handler to use.
parentThe 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.

Here is the call graph for this function:

Member Function Documentation

◆ getTotalMileage()

double MileageManager::getTotalMileage ( ) const
inline

Definition at line 40 of file MileageManager.hpp.

◆ initialize()

void MileageManager::initialize ( )

Initializes the MileageManager object.

This method initializes the MileageManager object by reading the mileage from the file and starting the update and persistence timers.

Definition at line 71 of file MileageManager.cpp.

Here is the call graph for this function:

◆ mileageUpdated

void MileageManager::mileageUpdated ( double mileage)
signal
Here is the caller graph for this function:

◆ onSpeedUpdated

void MileageManager::onSpeedUpdated ( float speed)
slot

Handles the speed updated signal.

Parameters
speedThe 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.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ m_calculator

IMileageCalculator* MileageManager::m_calculator
private

Definition at line 51 of file MileageManager.hpp.

◆ m_fileHandler

IMileageFileHandler* MileageManager::m_fileHandler
private

Definition at line 52 of file MileageManager.hpp.

◆ m_ownCalculator

bool MileageManager::m_ownCalculator
private

Definition at line 53 of file MileageManager.hpp.

◆ m_ownFileHandler

bool MileageManager::m_ownFileHandler
private

Definition at line 54 of file MileageManager.hpp.

◆ m_persistenceTimer

QTimer MileageManager::m_persistenceTimer
private

Definition at line 56 of file MileageManager.hpp.

◆ m_totalMileage

double MileageManager::m_totalMileage
private

Definition at line 57 of file MileageManager.hpp.

◆ m_updateTimer

QTimer MileageManager::m_updateTimer
private

Definition at line 55 of file MileageManager.hpp.


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