Add documentation headers across system modules

This commit is contained in:
Jissin Mathew
2026-05-22 13:11:11 +05:30
parent 0adb864329
commit 0519690043
5 changed files with 278 additions and 0 deletions
@@ -34,6 +34,14 @@ void Controller::updateUserDetails(const std::string& email, const std::string&
{
}
/*
Function: getServices
Description: Retrieves all available services in read-only form.
Parameters:
- None
Returns:
- util::Map<std::string, const Service*> containing all services
*/
util::Map<std::string, const Service*> Controller::getServices()
{
util::Map<std::string, Service*> currentServices = m_serviceManagementService.getServices();
@@ -77,6 +85,14 @@ void Controller::removeInventoryItem(const std::string& inventoryItemID)
{
}
/*
Function: getServiceBookings
Description: Retrieves all service bookings in read-only form.
Parameters:
- None
Returns:
- util::Map<std::string, const ServiceBooking*> containing service bookings
*/
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
{
auto serviceBookings = m_serviceManagementService.getServiceBookings();
@@ -88,6 +104,14 @@ util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
return readOnlyServiceBookings;
}
/*
Function: getServiceBookingsByUser
Description: Retrieves all service bookings for a specific user.
Parameters:
- userID: std::string, the user ID
Returns:
- util::Map<std::string, const ServiceBooking*> containing bookings for the user
*/
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookingsByUser(const std::string userID)
{
util::Map<std::string, const ServiceBooking*> readOnlyServiceBookingsByUserMap;
@@ -104,6 +128,14 @@ util::Map<std::string, const User*> Controller::getUsers()
return util::Map<std::string, const User*>();
}
/*
Function: getUsers
Description: Retrieves users filtered by user type.
Parameters:
- userType: util::UserType, type of user (CUSTOMER, TECHNICIAN, ADMIN)
Returns:
- util::Map<std::string, const User*> containing users of the specified type
*/
util::Map<std::string, const User*> Controller::getUsers(util::UserType userType)
{
auto userMap = m_userManagementService.getUsers(userType);
@@ -115,21 +147,57 @@ util::Map<std::string, const User*> Controller::getUsers(util::UserType userType
return readOnlyUserMap;
}
/*
Function: createJobCard
Description: Creates a job card for a service booking assigned to a technician.
Parameters:
- bookingID: std::string, ID of the service booking
- technicianID: std::string, ID of the technician
- serviceID: std::string, ID of the service
Returns:
- void
*/
void Controller::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
{
m_serviceManagementService.createJobCard(bookingID, technicianID, serviceID);
}
/*
Function: createService
Description: Creates a new service with associated inventory items and labor cost.
Parameters:
- name: std::string, name of the service
- inventoryItemIDs: Vector of inventory item IDs
- laborCost: double, labor cost
Returns:
- void
*/
void Controller::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
{
m_serviceManagementService.createService(name, inventoryItemIDs, laborCost);
}
/*
Function: removeService
Description: Removes a service from the system by ID.
Parameters:
- serviceID: std::string, ID of the service
Returns:
- void
*/
void Controller::removeService(const std::string& serviceID)
{
m_serviceManagementService.removeService(serviceID);
}
/*
Function: getJobCardsByUser
Description: Retrieves job cards assigned to the authenticated technician.
Parameters:
- None
Returns:
- util::Map<std::string, const JobCard*> containing job cards
*/
util::Map<std::string, const JobCard*> Controller::getJobCardsByUser()
{
const User* currentUser = getAuthenticatedUser();
@@ -143,6 +211,14 @@ util::Map<std::string, const JobCard*> Controller::getJobCardsByUser()
return readOnlyJobCardMap;
}
/*
Function: completeJob
Description: Marks a job card as completed.
Parameters:
- jobID: std::string, ID of the job card
Returns:
- void
*/
void Controller::completeJob(const std::string& jobID)
{
m_serviceManagementService.completeJob(jobID);
@@ -12,11 +12,27 @@
#include "NotificationManagementService.h"
#include "User.h"
/*
Function: getServiceBookings
Description: Retrieves all service bookings from the datastore.
Parameters:
- None
Returns:
- util::Map<std::string, ServiceBooking*> containing all service bookings
*/
util::Map<std::string, ServiceBooking*> ServiceManagementService::getServiceBookings()
{
return m_dataStore.getServiceBookings();
}
/*
Function: getServiceBooking
Description: Retrieves a specific service booking by its ID.
Parameters:
- serviceID: std::string, ID of the service booking
Returns:
- ServiceBooking*: Pointer to the service booking, or nullptr if not found
*/
ServiceBooking* ServiceManagementService::getServiceBooking(const std::string& serviceID)
{
auto currentServiceBookings = getServiceBookings();
@@ -30,6 +46,19 @@ ServiceBooking* ServiceManagementService::getServiceBooking(const std::string& s
return nullptr;
}
/*
Function: createJobCard
Description: Creates a job card for a given service booking, service, and technician.
Validates booking, service, technician, and inventory availability before creation.
Parameters:
- bookingID: std::string, ID of the service booking
- technicianID: std::string, ID of the technician
- serviceID: std::string, ID of the service
Returns:
- void
Throws:
- std::runtime_error if booking, service, technician, or inventory validation fails
*/
void ServiceManagementService::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
{
UserManagementService m_userManagementService;
@@ -74,6 +103,19 @@ void ServiceManagementService::createJobCard(const std::string& bookingID, const
sendNotification(selectedTechnician,title, message);
}
/*
Function: createService
Description: Creates a new service with associated inventory items and labor cost.
Validates inventory items before creation.
Parameters:
- name: std::string, name of the service
- inventoryItemIDs: util::Vector<std::string>, IDs of required inventory items
- laborCost: double, labor cost for the service
Returns:
- void
Throws:
- std::runtime_error if inventory items are not found or service creation fails
*/
void ServiceManagementService::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
{
util::Map<std::string, InventoryItem*> currentServiceInventoryItems;
@@ -110,11 +152,29 @@ void ServiceManagementService::createService(const std::string& name, const util
currentServices.insert(newService->getId(), newService);
}
/*
Function: getServices
Description: Retrieves all services from the datastore.
Parameters:
- None
Returns:
- util::Map<std::string, Service*> containing all services
*/
util::Map<std::string, Service*> ServiceManagementService::getServices()
{
return m_dataStore.getServices();
}
/*
Function: removeService
Description: Marks a service as inactive by its ID.
Parameters:
- serviceID: std::string, ID of the service
Returns:
- void
Throws:
- std::runtime_error if the service is not found
*/
void ServiceManagementService::removeService(const std::string& serviceID)
{
util::Map<std::string, Service*> currentServices = getServices();
@@ -128,6 +188,14 @@ void ServiceManagementService::removeService(const std::string& serviceID)
}
}
/*
Function: getServiceBookings (overloaded)
Description: Retrieves all service bookings for a specific customer.
Parameters:
- customerID: std::string, ID of the customer
Returns:
- util::Map<std::string, ServiceBooking*> containing bookings for the customer
*/
util::Map<std::string, ServiceBooking*> ServiceManagementService::getServiceBookings(const std::string& customerID)
{
util::Map<std::string, ServiceBooking*> currentServiceBookings = getServiceBookings();
@@ -146,6 +214,14 @@ util::Map<std::string, ServiceBooking*> ServiceManagementService::getServiceBook
return currentUserServiceBookings;
}
/*
Function: getJobCards
Description: Retrieves all job cards assigned to a specific technician.
Parameters:
- technicianID: std::string, ID of the technician
Returns:
- util::Map<std::string, JobCard*> containing job cards assigned to the technician
*/
util::Map<std::string, JobCard*> ServiceManagementService::getJobCards(const std::string& technicianID)
{
util::Map<std::string, JobCard*> jobCards = m_dataStore.getJobCards();
@@ -161,6 +237,15 @@ util::Map<std::string, JobCard*> ServiceManagementService::getJobCards(const std
return technicianJobCards;
}
/*
Function: hasAllJobCardsinServiceBookingCompleted (static helper)
Description: Checks if all job cards for a given service booking are completed.
Parameters:
- bookingId: std::string, ID of the service booking
- currentAssignedJobs: util::Map<std::string, JobCard*>&, map of assigned job cards
Returns:
- bool: True if all job cards are completed, False otherwise
*/
static bool hasAllJobCardsinServiceBookingCompleted(std::string bookingId, util::Map<std::string, JobCard*>& currentAssignedJobs)
{
for (int iterator = 0; iterator < currentAssignedJobs.getSize(); iterator++)
@@ -177,6 +262,18 @@ static bool hasAllJobCardsinServiceBookingCompleted(std::string bookingId, util:
return true;
}
/*
Function: completeJob
Description: Marks a job card as completed for the authenticated technician.
If all job cards in the booking are completed, marks the booking as completed
and generates an invoice.
Parameters:
- jobID: std::string, ID of the job card
Returns:
- void
Throws:
- std::runtime_error if technician is not authenticated, job card not found, or job already completed
*/
void ServiceManagementService::completeJob(const std::string& jobID)
{
AuthenticationManagementService authenticationManagementService;
@@ -62,6 +62,16 @@ void AdminMenu::checkStockAvailability()
{
}
/*
Function: listServiceBookings (static helper)
Description: Lists all pending service bookings and maps them to indices for selection.
Parameters:
- currentBookings: util::Map<std::string, const ServiceBooking*>&, current bookings
- bookingsSize: int&, number of bookings
- serviceBookingsMap: util::Map<int, const ServiceBooking*>&, map of indexed bookings
Returns:
- bool: True if pending services exist, False otherwise
*/
static bool listServiceBookings(util::Map<std::string, const ServiceBooking*>& currentBookings, int& bookingsSize, util::Map<int, const ServiceBooking*>& serviceBookingsMap)
{
int currentIndex = 1;
@@ -107,6 +117,14 @@ static bool listServiceBookings(util::Map<std::string, const ServiceBooking*>& c
return true;
}
/*
Function: selectPendingServiceBookings (static helper)
Description: Allows selection of a pending service booking by index.
Parameters:
- serviceBookingsMap: util::Map<int, const ServiceBooking*>&, map of indexed bookings
Returns:
- const ServiceBooking*: Pointer to the selected booking, or nullptr if invalid
*/
static const ServiceBooking* selectPendingServiceBookings(util::Map<int, const ServiceBooking*>& serviceBookingsMap)
{
int userInputIndex;
@@ -123,6 +141,16 @@ static const ServiceBooking* selectPendingServiceBookings(util::Map<int, const S
}
}
/*
Function: listAvailableTechnicians (static helper)
Description: Lists all available technicians and maps them to indices for selection.
Parameters:
- currentAvailableTechnicians: util::Map<std::string, const User*>, available technicians
- numberOfTechnicians: int, number of technicians
- currentAvailableTechniciansMap: util::Map<int, const User*>&, map of indexed technicians
Returns:
- void
*/
static void listAvailableTechnicians( util::Map<std::string, const User*> currentAvailableTechnicians, int numberOfTechnicians, util::Map<int, const User*>& currentAvailableTechniciansMap)
{
bool hasTechnicians = false;
@@ -153,6 +181,14 @@ static void listAvailableTechnicians( util::Map<std::string, const User*> curren
}
}
/*
Function: selectTechnician (static helper)
Description: Allows selection of a technician by index.
Parameters:
- currentAvailableTechniciansMap: util::Map<int, const User*>&, map of indexed technicians
Returns:
- const User*: Pointer to the selected technician, or nullptr if invalid
*/
static const User* selectTechnician(util::Map<int, const User*>& currentAvailableTechniciansMap)
{
int userInputIndex;
@@ -168,6 +204,15 @@ static const User* selectTechnician(util::Map<int, const User*>& currentAvailabl
}
}
/*
Function: assignJob
Description: Allows the admin to assign pending service bookings to available technicians.
Creates job cards for selected services.
Parameters:
- None
Returns:
- void
*/
void AdminMenu::assignJob()
{
util::clear();
@@ -205,6 +250,15 @@ void AdminMenu::assignJob()
}
/*
Function: selectInventoryItems (static helper)
Description: Allows selection of inventory items by index for creating a service.
Parameters:
- currentInventoryItems: util::Map<std::string, const InventoryItem*>&, available inventory items
- selectedInventoryItems: util::Vector<std::string>&, vector to store selected item IDs
Returns:
- void
*/
static void selectInventoryItems(util::Map<std::string, const InventoryItem*>& currentInventoryItems, util::Vector<std::string>& selectedInventoryItems)
{
bool doRun = true, hasInventoryItems = false;
@@ -270,6 +324,14 @@ static void selectInventoryItems(util::Map<std::string, const InventoryItem*>& c
}
}
/*
Function: createService
Description: Allows the admin to create a new service by selecting inventory items and specifying labor cost.
Parameters:
- None
Returns:
- void
*/
void AdminMenu::createService()
{
util::clear();
@@ -286,6 +348,14 @@ void AdminMenu::createService()
std::cout << "Service created sucessfully.\n";
}
/*
Function: selectServicesToRemove (static helper)
Description: Allows selection of a service to remove by index.
Parameters:
- currentServices: util::Map<std::string, const Service*>, available services
Returns:
- std::string: ID of the selected service, or empty string if invalid
*/
static std::string selectServicesToRemove(util::Map<std::string, const Service*> currentServices)
{
util::Map<int, const Service*> currentServicesMap;
@@ -331,6 +401,14 @@ static std::string selectServicesToRemove(util::Map<std::string, const Service*>
}
}
/*
Function: removeService
Description: Allows the admin to remove an existing service by selecting from available services.
Parameters:
- None
Returns:
- void
*/
void AdminMenu::removeService()
{
util::clear();
@@ -55,6 +55,15 @@ void CustomerMenu::selectComboPackage()
{
}
/*
Function: viewServiceHistory
Description: Displays the customers past service bookings in tabular format,
including booking ID, technician, vehicle details, discount percentage, and status.
Parameters:
- None
Returns:
- void
*/
void CustomerMenu::viewServiceHistory()
{
util::clear();
@@ -35,6 +35,15 @@ bool TechnicianMenu::handleOperation(int choice)
return false;
}
/*
Function: selectJobCardToComplete (static helper)
Description: Lists all incomplete job cards assigned to the technician and allows selection by index.
Parameters:
- assignedJobCards: util::Map<std::string, const JobCard*>&, job cards assigned to the technician
- incompleteJobCards: util::Map<int, const JobCard*>&, map of incomplete job cards indexed for selection
Returns:
- std::string: ID of the selected job card, or empty string if none selected
*/
static std::string selectJobCardToComplete(util::Map<std::string, const JobCard*>& assignedJobCards, util::Map<int, const JobCard*>& incompleteJobCards)
{
int currentIndex = 1;
@@ -82,6 +91,15 @@ static std::string selectJobCardToComplete(util::Map<std::string, const JobCard*
}
}
/*
Function: completeJob
Description: Allows the technician to mark a selected job card as completed.
Validates selection and updates job status through the controller.
Parameters:
- None
Returns:
- void
*/
void TechnicianMenu::completeJob()
{
util::Map<std::string, const JobCard*> assignedJobCards = m_controller.getJobCardsByUser();