Implement Model Refactoring
<UserStory> 1955: Model Refactoring</UserStory> UserStory #1955 <Changes> 1. Replaced CSV-based serialization and deserialization in ComboPackage, JobCard, Service, and ServiceBooking models with fixed-size SerializedRecord structures for shared memory storage. 2. Implemented serialize() methods to convert objects into SerializedComboPackage, SerializedJobCard, SerializedService, and SerializedServiceBooking records. 3. Implemented deserialize() methods to reconstruct objects directly from SerializedRecord types instead of parsing CSV strings. 4. Updated model class interfaces to use SerializedRecord types, removing legacy CSV serialization APIs and header generation functions. 5. Added SerializedRecords.h dependencies and forward declarations for Serialized structures across affected models. </Changes> <Test> N/A </Test> <Review> Sreeja Reghukumar, please review </Review>
This commit is contained in:
@@ -9,6 +9,7 @@ Date: 19-May-2026
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include "SerializedRecords.h"
|
||||
#include "ComboPackage.h"
|
||||
#include "Service.h"
|
||||
#include "Factory.h"
|
||||
@@ -28,7 +29,8 @@ Returns:
|
||||
ComboPackage::ComboPackage()
|
||||
: m_id("CMP" + std::to_string(++m_uid)),
|
||||
m_status(util::State::ACTIVE),
|
||||
m_discountPercentage(0.0) {}
|
||||
m_discountPercentage(0.0) {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: ComboPackage
|
||||
@@ -270,72 +272,38 @@ static util::Vector<std::string> getServiceIDsAsVector(const std::string& servic
|
||||
|
||||
/*
|
||||
Function: serialize
|
||||
Description: Serializes the combo package into a CSV-formatted string.
|
||||
Description: Serializes the ComboPackage object into a SerializedComboPackage record.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Serialized combo package record
|
||||
- SerializedComboPackage: Serialized representation of the combo package
|
||||
*/
|
||||
std::string ComboPackage::serialize() const
|
||||
SerializedComboPackage ComboPackage::serialize() const
|
||||
{
|
||||
std::ostringstream serializedComboPackage;
|
||||
serializedComboPackage << m_id << ','
|
||||
<< m_packageName << ','
|
||||
<< m_discountPercentage << ','
|
||||
<< getServiceIDsAsString(m_serviceIDs) << ','
|
||||
<< util::getStateString(m_status);
|
||||
return serializedComboPackage.str();
|
||||
SerializedComboPackage serialized = {};
|
||||
strcpy_s(serialized.id, sizeof(serialized.id), m_id.c_str());
|
||||
strcpy_s(serialized.packageName, sizeof(serialized.packageName), m_packageName.c_str());
|
||||
strcpy_s(serialized.serviceIDs, sizeof(serialized.serviceIDs), getServiceIDsAsString(m_serviceIDs).c_str());
|
||||
serialized.discountPercentage = m_discountPercentage;
|
||||
serialized.status = m_status;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: deserialize
|
||||
Description: Deserializes a CSV-formatted string into a ComboPackage object.
|
||||
Description: Deserializes a SerializedComboPackage record into a ComboPackage object.
|
||||
Parameters:
|
||||
- record: const std::string&, serialized combo package record
|
||||
- serializedComboPackage: const SerializedComboPackage&, serialized combo package record
|
||||
Returns:
|
||||
- ComboPackage*: Pointer to the deserialized ComboPackage object
|
||||
Throws:
|
||||
- std::runtime_error if data is invalid
|
||||
*/
|
||||
ComboPackage* ComboPackage::deserialize(const std::string& record)
|
||||
ComboPackage* ComboPackage::deserialize(const SerializedComboPackage& serializedComboPackage)
|
||||
{
|
||||
std::string id, packageName;
|
||||
std::string discountPercentageString, serviceIDsString, statusString;
|
||||
double discountPercentage;
|
||||
std::istringstream serializedComboPackage(record);
|
||||
getline(serializedComboPackage, id, ',');
|
||||
getline(serializedComboPackage, packageName, ',');
|
||||
getline(serializedComboPackage, discountPercentageString, ',');
|
||||
getline(serializedComboPackage, serviceIDsString, ',');
|
||||
getline(serializedComboPackage, statusString, ',');
|
||||
try
|
||||
{
|
||||
discountPercentage = std::stod(discountPercentageString);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw std::runtime_error("Invalid combo package data");
|
||||
}
|
||||
util::Vector<std::string> serviceIDs = getServiceIDsAsVector(serviceIDsString);
|
||||
util::State status = util::getState(statusString);
|
||||
util::Vector<std::string> serviceIDs = getServiceIDsAsVector(serializedComboPackage.serviceIDs);
|
||||
return Factory::getObject<ComboPackage>(
|
||||
id,
|
||||
packageName,
|
||||
discountPercentage,
|
||||
serializedComboPackage.id,
|
||||
serializedComboPackage.packageName,
|
||||
serializedComboPackage.discountPercentage,
|
||||
serviceIDs,
|
||||
status
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getHeaders
|
||||
Description: Retrieves the CSV headers for combo package serialization.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Header string ("ID,PackageName,DiscountPercentage,ServiceIDs,Status")
|
||||
*/
|
||||
std::string ComboPackage::getHeaders()
|
||||
{
|
||||
return "ID,PackageName,DiscountPercentage,ServiceIDs,Status";
|
||||
serializedComboPackage.status);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ Date: 19-May-2026
|
||||
#include "Enums.h"
|
||||
|
||||
class Service;
|
||||
class SerializedComboPackage;
|
||||
|
||||
class ComboPackage
|
||||
{
|
||||
@@ -38,7 +39,6 @@ public:
|
||||
void setDiscountPercentage(double discountPercentage);
|
||||
void setServices(const util::Map<std::string, Service*>& services);
|
||||
void setState(util::State status);
|
||||
std::string serialize() const;
|
||||
static ComboPackage* deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
SerializedComboPackage serialize() const;
|
||||
static ComboPackage* deserialize(const SerializedComboPackage&);
|
||||
};
|
||||
@@ -9,6 +9,7 @@ Date:19-May-2026
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include "SerializedRecords.h"
|
||||
#include "JobCard.h"
|
||||
#include "Factory.h"
|
||||
#include "StringHelper.h"
|
||||
@@ -28,7 +29,8 @@ JobCard::JobCard()
|
||||
m_booking(nullptr),
|
||||
m_service(nullptr),
|
||||
m_technician(nullptr),
|
||||
m_status(util::ServiceJobStatus()) {}
|
||||
m_status(util::ServiceJobStatus()) {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: JobCard
|
||||
@@ -65,7 +67,8 @@ JobCard::JobCard(const std::string& bookingId,
|
||||
m_technician(technician),
|
||||
m_assignedDate(assignedDate),
|
||||
m_status(status),
|
||||
m_completionDate(completionDate) {}
|
||||
m_completionDate(completionDate) {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: JobCard (parameterized constructor with ID)
|
||||
@@ -351,79 +354,41 @@ void JobCard::setCompletionDate(const util::Timestamp& completionDate)
|
||||
|
||||
/*
|
||||
Function: serialize
|
||||
Description: Serializes the job card into a CSV-formatted string.
|
||||
Description: Serializes the JobCard object into a SerializedJobCard record.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Serialized job card record
|
||||
- SerializedJobCard: Serialized representation of the job card
|
||||
*/
|
||||
std::string JobCard::serialize() const
|
||||
SerializedJobCard JobCard::serialize() const
|
||||
{
|
||||
std::ostringstream serializedJobCard;
|
||||
serializedJobCard << m_id << ','
|
||||
<< m_bookingId << ','
|
||||
<< m_serviceId << ','
|
||||
<< m_technicianId << ','
|
||||
<< m_assignedDate.toString() << ','
|
||||
<< util::getServiceJobStatusString(m_status) << ','
|
||||
<< m_completionDate.toString();
|
||||
return serializedJobCard.str();
|
||||
SerializedJobCard serialized = {};
|
||||
strcpy_s(serialized.id, sizeof(serialized.id), m_id.c_str());
|
||||
strcpy_s(serialized.bookingId, sizeof(serialized.bookingId), m_bookingId.c_str());
|
||||
strcpy_s(serialized.serviceId, sizeof(serialized.serviceId), m_serviceId.c_str());
|
||||
strcpy_s(serialized.technicianId, sizeof(serialized.technicianId), m_technicianId.c_str());
|
||||
serialized.assignedDate = m_assignedDate;
|
||||
serialized.status = m_status;
|
||||
serialized.completionDate = m_completionDate;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: deserialize
|
||||
Description: Deserializes a CSV-formatted string into a JobCard object.
|
||||
Description: Deserializes a SerializedJobCard record into a JobCard object.
|
||||
Parameters:
|
||||
- record: const std::string&, serialized job card record
|
||||
- serializedJobCard: const SerializedJobCard&, serialized job card record
|
||||
Returns:
|
||||
- JobCard*: Pointer to the deserialized JobCard object
|
||||
Throws:
|
||||
- std::runtime_error if timestamp parsing fails
|
||||
*/
|
||||
JobCard* JobCard::deserialize(const std::string& record)
|
||||
JobCard* JobCard::deserialize(const SerializedJobCard& serializedJobCard)
|
||||
{
|
||||
std::string id, bookingId, serviceId, technicianId;
|
||||
std::string assignedDateString, statusString, completionDateString;
|
||||
std::istringstream serializedJobCard(record);
|
||||
getline(serializedJobCard, id, ',');
|
||||
getline(serializedJobCard, bookingId, ',');
|
||||
getline(serializedJobCard, serviceId, ',');
|
||||
getline(serializedJobCard, technicianId, ',');
|
||||
getline(serializedJobCard, assignedDateString, ',');
|
||||
getline(serializedJobCard, statusString, ',');
|
||||
getline(serializedJobCard, completionDateString, ',');
|
||||
util::Timestamp assignedDate;
|
||||
util::Timestamp completionDate;
|
||||
try
|
||||
{
|
||||
assignedDate = util::Timestamp::fromString(assignedDateString);
|
||||
completionDate = util::Timestamp::fromString(completionDateString);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw std::runtime_error("Invalid timestamp");
|
||||
}
|
||||
util::ServiceJobStatus status = util::getServiceJobStatus(statusString);
|
||||
return Factory::getObject<JobCard>(
|
||||
id,
|
||||
bookingId,
|
||||
serviceId,
|
||||
technicianId,
|
||||
assignedDate,
|
||||
status,
|
||||
completionDate
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getHeaders
|
||||
Description: Retrieves the CSV headers for job card serialization.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Header string ("ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate")
|
||||
*/
|
||||
std::string JobCard::getHeaders()
|
||||
{
|
||||
return "ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate";
|
||||
serializedJobCard.id,
|
||||
serializedJobCard.bookingId,
|
||||
serializedJobCard.serviceId,
|
||||
serializedJobCard.technicianId,
|
||||
serializedJobCard.assignedDate,
|
||||
serializedJobCard.status,
|
||||
serializedJobCard.completionDate);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ Date:19-May-2026
|
||||
class ServiceBooking;
|
||||
class Service;
|
||||
class User;
|
||||
struct SerializedJobCard;
|
||||
|
||||
class JobCard
|
||||
{
|
||||
@@ -70,7 +71,6 @@ public:
|
||||
void setAssignedDate(const util::Timestamp& assignedDate);
|
||||
void setStatus(util::ServiceJobStatus status);
|
||||
void setCompletionDate(const util::Timestamp& completionDate);
|
||||
std::string serialize() const;
|
||||
static JobCard* deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
SerializedJobCard serialize() const;
|
||||
static JobCard* deserialize(const SerializedJobCard&);
|
||||
};
|
||||
@@ -8,6 +8,7 @@ Date: 19-May-2026
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include "SerializedRecords.h"
|
||||
#include "Service.h"
|
||||
#include "InventoryItem.h"
|
||||
#include "StringHelper.h"
|
||||
@@ -27,7 +28,8 @@ Returns:
|
||||
Service::Service()
|
||||
: m_id("SRV" + std::to_string(++m_uid)),
|
||||
m_status(util::State::ACTIVE),
|
||||
m_laborCost(0.0) {}
|
||||
m_laborCost(0.0) {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: Service
|
||||
@@ -266,72 +268,38 @@ static util::Vector<std::string> getInventoryItemIDsAsVector(const std::string&
|
||||
|
||||
/*
|
||||
Function: serialize
|
||||
Description: Serializes the service into a CSV-formatted string.
|
||||
Description: Serializes the Service object into a SerializedService record.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Serialized service record
|
||||
- SerializedService: Serialized representation of the service
|
||||
*/
|
||||
std::string Service::serialize() const
|
||||
SerializedService Service::serialize() const
|
||||
{
|
||||
std::ostringstream serializedService;
|
||||
serializedService << m_id << ','
|
||||
<< m_name << ','
|
||||
<< getInventoryItemIDsAsString(m_requiredInventoryItemIDs) << ','
|
||||
<< m_laborCost << ','
|
||||
<< util::getStateString(m_status);
|
||||
return serializedService.str();
|
||||
SerializedService serialized = {};
|
||||
strcpy_s(serialized.id, sizeof(serialized.id), m_id.c_str());
|
||||
strcpy_s(serialized.name, sizeof(serialized.name), m_name.c_str());
|
||||
strcpy_s(serialized.inventoryItemIDs, sizeof(serialized.inventoryItemIDs), getInventoryItemIDsAsString(m_requiredInventoryItemIDs).c_str());
|
||||
serialized.laborCost = m_laborCost;
|
||||
serialized.status = m_status;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: deserialize
|
||||
Description: Deserializes a CSV-formatted string into a Service object.
|
||||
Description: Deserializes a SerializedService record into a Service object.
|
||||
Parameters:
|
||||
- record: const std::string&, serialized service record
|
||||
- serializedService: const SerializedService&, serialized service record
|
||||
Returns:
|
||||
- Service*: Pointer to the deserialized Service object
|
||||
Throws:
|
||||
- std::runtime_error if labor cost parsing fails
|
||||
*/
|
||||
Service* Service::deserialize(const std::string& record)
|
||||
Service* Service::deserialize(const SerializedService& serializedService)
|
||||
{
|
||||
std::string id, name;
|
||||
std::string inventoryItemIDsString, laborCostString, statusString;
|
||||
double laborCost;
|
||||
std::istringstream serializedService(record);
|
||||
getline(serializedService, id, ',');
|
||||
getline(serializedService, name, ',');
|
||||
getline(serializedService, inventoryItemIDsString, ',');
|
||||
getline(serializedService, laborCostString, ',');
|
||||
getline(serializedService, statusString, ',');
|
||||
util::Vector<std::string> inventoryItemIDs = getInventoryItemIDsAsVector(inventoryItemIDsString);
|
||||
try
|
||||
{
|
||||
laborCost = std::stod(laborCostString);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw std::runtime_error("Invalid labor cost");
|
||||
}
|
||||
util::State status = util::getState(statusString);
|
||||
util::Vector<std::string> inventoryItemIDs = getInventoryItemIDsAsVector(serializedService.inventoryItemIDs);
|
||||
return Factory::getObject<Service>(
|
||||
id,
|
||||
name,
|
||||
serializedService.id,
|
||||
serializedService.name,
|
||||
inventoryItemIDs,
|
||||
laborCost,
|
||||
status
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getHeaders
|
||||
Description: Retrieves the CSV headers for service serialization.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Header string ("ID,Name,InventoryIDs,LaborCost,Status")
|
||||
*/
|
||||
std::string Service::getHeaders()
|
||||
{
|
||||
return "ID,Name,InventoryIDs,LaborCost,Status";
|
||||
serializedService.laborCost,
|
||||
serializedService.status);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ Author: Trenser
|
||||
Date: 19-May-2026
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "Map.h"
|
||||
@@ -14,6 +13,7 @@ Date: 19-May-2026
|
||||
#include "Enums.h"
|
||||
|
||||
class InventoryItem;
|
||||
struct SerializedService;
|
||||
|
||||
class Service
|
||||
{
|
||||
@@ -40,7 +40,6 @@ public:
|
||||
void setRequiredInventoryItems(const util::Map<std::string, InventoryItem*>& requiredInventoryItems);
|
||||
void setLaborCost(double laborCost);
|
||||
void setState(util::State status);
|
||||
std::string serialize() const;
|
||||
static Service* deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
SerializedService serialize() const;
|
||||
static Service* deserialize(const SerializedService&);
|
||||
};
|
||||
+30
-65
@@ -6,8 +6,10 @@ Description: Implementation file containing the method definitions of the
|
||||
Author: Trenser
|
||||
Date:19-May-2026
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include "SerializedRecords.h"
|
||||
#include "ServiceBooking.h"
|
||||
#include "Service.h"
|
||||
#include "Enums.h"
|
||||
@@ -28,7 +30,8 @@ ServiceBooking::ServiceBooking()
|
||||
m_customer(nullptr),
|
||||
m_assignedTechnician(nullptr),
|
||||
m_status(util::ServiceJobStatus::PENDING),
|
||||
m_discountPercentage(0.0) {}
|
||||
m_discountPercentage(0.0) {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: ServiceBooking
|
||||
@@ -437,84 +440,46 @@ static util::Vector<std::string> getServiceIDsAsVector(const std::string& servic
|
||||
|
||||
/*
|
||||
Function: serialize
|
||||
Description: Serializes the service booking into a CSV-formatted string.
|
||||
Description: Serializes the ServiceBooking object into a SerializedServiceBooking record.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Serialized booking record
|
||||
- SerializedServiceBooking: Serialized representation of the service booking
|
||||
*/
|
||||
std::string ServiceBooking::serialize() const
|
||||
SerializedServiceBooking ServiceBooking::serialize() const
|
||||
{
|
||||
std::ostringstream serializedBooking;
|
||||
serializedBooking << m_id << ','
|
||||
<< util::getServiceJobStatusString(m_status) << ','
|
||||
<< getServiceIDsAsString(m_serviceIDs) << ','
|
||||
<< m_customerId << ','
|
||||
<< m_vehicleNumber << ','
|
||||
<< m_vehicleBrand << ','
|
||||
<< m_vehicleModel << ','
|
||||
<< m_assignedTechnicianId << ','
|
||||
<< m_discountPercentage << ',';
|
||||
return serializedBooking.str();
|
||||
SerializedServiceBooking serialized = {};
|
||||
strcpy_s(serialized.id, sizeof(serialized.id), m_id.c_str());
|
||||
strcpy_s(serialized.serviceIDs, sizeof(serialized.serviceIDs), getServiceIDsAsString(m_serviceIDs).c_str());
|
||||
strcpy_s(serialized.customerId, sizeof(serialized.customerId), m_customerId.c_str());
|
||||
strcpy_s(serialized.vehicleNumber, sizeof(serialized.vehicleNumber), m_vehicleNumber.c_str());
|
||||
strcpy_s(serialized.vehicleBrand, sizeof(serialized.vehicleBrand), m_vehicleBrand.c_str());
|
||||
strcpy_s(serialized.vehicleModel, sizeof(serialized.vehicleModel), m_vehicleModel.c_str());
|
||||
strcpy_s(serialized.assignedTechnicianId, sizeof(serialized.assignedTechnicianId), m_assignedTechnicianId.c_str());
|
||||
serialized.status = m_status;
|
||||
serialized.discountPercentage = m_discountPercentage;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: deserialize
|
||||
Description: Deserializes a CSV-formatted string into a ServiceBooking object.
|
||||
Description: Deserializes a SerializedServiceBooking record into a ServiceBooking object.
|
||||
Parameters:
|
||||
- record: const std::string&, serialized booking record
|
||||
- serializedServiceBooking: const SerializedServiceBooking&, serialized service booking record
|
||||
Returns:
|
||||
- ServiceBooking*: Pointer to the deserialized ServiceBooking object
|
||||
Throws:
|
||||
- std::runtime_error if discount percentage parsing fails
|
||||
*/
|
||||
ServiceBooking* ServiceBooking::deserialize(const std::string& record)
|
||||
ServiceBooking* ServiceBooking::deserialize(const SerializedServiceBooking& serializedServiceBooking)
|
||||
{
|
||||
std::string id, customerId, vehicleNumber, vehicleBrand, vehicleModel, assignedTechnicianId;
|
||||
std::string serviceJobStatusString, serviceIDsString, discountPercentageString;
|
||||
double discountPercentage;
|
||||
std::istringstream serializedBooking(record);
|
||||
getline(serializedBooking, id, ',');
|
||||
getline(serializedBooking, serviceJobStatusString, ',');
|
||||
getline(serializedBooking, serviceIDsString, ',');
|
||||
getline(serializedBooking, customerId, ',');
|
||||
getline(serializedBooking, vehicleNumber, ',');
|
||||
getline(serializedBooking, vehicleBrand, ',');
|
||||
getline(serializedBooking, vehicleModel, ',');
|
||||
getline(serializedBooking, assignedTechnicianId, ',');
|
||||
getline(serializedBooking, discountPercentageString, ',');
|
||||
util::Vector<std::string> serviceIDs = getServiceIDsAsVector(serviceIDsString);
|
||||
try
|
||||
{
|
||||
discountPercentage = std::stod(discountPercentageString);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw std::runtime_error("Invalid discount percentage");
|
||||
}
|
||||
util::ServiceJobStatus status = util::getServiceJobStatus(serviceJobStatusString);
|
||||
util::Vector<std::string> serviceIDs = getServiceIDsAsVector(serializedServiceBooking.serviceIDs);
|
||||
return Factory::getObject<ServiceBooking>(
|
||||
id,
|
||||
status,
|
||||
serializedServiceBooking.id,
|
||||
serializedServiceBooking.status,
|
||||
serviceIDs,
|
||||
customerId,
|
||||
vehicleNumber,
|
||||
vehicleBrand,
|
||||
vehicleModel,
|
||||
assignedTechnicianId,
|
||||
discountPercentage
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: getHeaders
|
||||
Description: Retrieves the CSV headers for service booking serialization.
|
||||
Parameters:
|
||||
- None
|
||||
Returns:
|
||||
- std::string: Header string ("ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage")
|
||||
*/
|
||||
std::string ServiceBooking::getHeaders()
|
||||
{
|
||||
return "ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage";
|
||||
serializedServiceBooking.customerId,
|
||||
serializedServiceBooking.vehicleNumber,
|
||||
serializedServiceBooking.vehicleBrand,
|
||||
serializedServiceBooking.vehicleModel,
|
||||
serializedServiceBooking.assignedTechnicianId,
|
||||
serializedServiceBooking.discountPercentage);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ Description: Header file declaring the ServiceBooking class, which represents
|
||||
Author: Trenser
|
||||
Date:19-May-2026
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "Map.h"
|
||||
@@ -14,6 +15,7 @@ Date:19-May-2026
|
||||
|
||||
class Service;
|
||||
class User;
|
||||
struct SerializedServiceBooking;
|
||||
|
||||
class ServiceBooking
|
||||
{
|
||||
@@ -78,7 +80,6 @@ public:
|
||||
void setAssignedTechnicianId(const std::string& assignedTechnicianId);
|
||||
void setAssignedTechnician(User* assignedTechnician);
|
||||
void setDiscountPercentage(double discountPercentage);
|
||||
std::string serialize() const;
|
||||
static ServiceBooking* deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
SerializedServiceBooking serialize() const;
|
||||
static ServiceBooking* deserialize(const SerializedServiceBooking&);
|
||||
};
|
||||
Reference in New Issue
Block a user