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 "inputHelper.h"
|
||||||
#include "outputHelper.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)
|
if (!user || user->getType() != userWithAccess)
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ bool checkAccess(std::shared_ptr<User> user, const std::string& userWithAccess)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
restaurants::iterator pickRestaurantFromRestaurants(RestaurantOwner& restaurantOwner)
|
static restaurants::iterator pickRestaurantFromRestaurants(RestaurantOwner& restaurantOwner)
|
||||||
{
|
{
|
||||||
util::clear();
|
util::clear();
|
||||||
int restaurantIndex = 1, restaurantChoiceIndex;
|
int restaurantIndex = 1, restaurantChoiceIndex;
|
||||||
@@ -212,7 +212,7 @@ void FoodDeliveryController::registerUser()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FoodDeliveryController::listRestaurants()
|
void FoodDeliveryController::listRestaurants() const
|
||||||
{
|
{
|
||||||
util::clear();
|
util::clear();
|
||||||
if (!checkAccess(m_authenticatedUser, "RestaurantOwner"))
|
if (!checkAccess(m_authenticatedUser, "RestaurantOwner"))
|
||||||
@@ -258,7 +258,7 @@ void FoodDeliveryController::addNewRestaurant()
|
|||||||
std::cout << "Restaurant " << restaurant->getName() << " with ID " << restaurant->getId() << " created successfully\n";
|
std::cout << "Restaurant " << restaurant->getName() << " with ID " << restaurant->getId() << " created successfully\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void FoodDeliveryController::updateRestaurantStatus()
|
void FoodDeliveryController::updateRestaurantStatus() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ public:
|
|||||||
void run();
|
void run();
|
||||||
void login();
|
void login();
|
||||||
void registerUser();
|
void registerUser();
|
||||||
void listRestaurants();
|
void listRestaurants() const;
|
||||||
void addNewRestaurant();
|
void addNewRestaurant();
|
||||||
void updateRestaurantStatus();
|
void updateRestaurantStatus() const;
|
||||||
void listRestaurantOrders();
|
void listRestaurantOrders();
|
||||||
void markOrderReady();
|
void markOrderReady();
|
||||||
void listMenuItems();
|
void listMenuItems();
|
||||||
|
|||||||
Reference in New Issue
Block a user