Make functions static and const
- Make controller helper functions static - Make controller functions which do not modify state const
This commit is contained in:
@@ -18,7 +18,7 @@ Date: 19-02-2026
|
||||
#include "inputHelper.h"
|
||||
#include "outputHelper.h"
|
||||
|
||||
bool checkAccess(std::shared_ptr<User> user, const std::string& userWithAccess)
|
||||
static bool checkAccess(std::shared_ptr<User> user, const std::string& userWithAccess)
|
||||
{
|
||||
if (!user || user->getType() != userWithAccess)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ bool checkAccess(std::shared_ptr<User> user, const std::string& userWithAccess)
|
||||
return true;
|
||||
}
|
||||
|
||||
restaurants::iterator pickRestaurantFromRestaurants(RestaurantOwner& restaurantOwner)
|
||||
static restaurants::iterator pickRestaurantFromRestaurants(RestaurantOwner& restaurantOwner)
|
||||
{
|
||||
util::clear();
|
||||
int restaurantIndex = 1, restaurantChoiceIndex;
|
||||
@@ -212,7 +212,7 @@ void FoodDeliveryController::registerUser()
|
||||
}
|
||||
}
|
||||
|
||||
void FoodDeliveryController::listRestaurants()
|
||||
void FoodDeliveryController::listRestaurants() const
|
||||
{
|
||||
util::clear();
|
||||
if (!checkAccess(m_authenticatedUser, "RestaurantOwner"))
|
||||
@@ -258,7 +258,7 @@ void FoodDeliveryController::addNewRestaurant()
|
||||
std::cout << "Restaurant " << restaurant->getName() << " with ID " << restaurant->getId() << " created successfully\n";
|
||||
}
|
||||
|
||||
void FoodDeliveryController::updateRestaurantStatus()
|
||||
void FoodDeliveryController::updateRestaurantStatus() const
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -24,9 +24,9 @@ public:
|
||||
void run();
|
||||
void login();
|
||||
void registerUser();
|
||||
void listRestaurants();
|
||||
void listRestaurants() const;
|
||||
void addNewRestaurant();
|
||||
void updateRestaurantStatus();
|
||||
void updateRestaurantStatus() const;
|
||||
void listRestaurantOrders();
|
||||
void markOrderReady();
|
||||
void listMenuItems();
|
||||
|
||||
Reference in New Issue
Block a user