changes
This commit is contained in:
+403
-50
@@ -9,6 +9,137 @@ Date: 19-May-2026
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DataStore.h"
|
#include "DataStore.h"
|
||||||
|
#include "Config.h"
|
||||||
|
#include "SerializedRecords.h"
|
||||||
|
|
||||||
|
DataStore::DataStore() :
|
||||||
|
m_globalMutex(NULL) {}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: initialize
|
||||||
|
Description: Initializes the shared-memory datastore.
|
||||||
|
Creates or opens the global datastore mutex,
|
||||||
|
configures all mapping metadata, and creates
|
||||||
|
or opens the file mappings used to persist
|
||||||
|
application data. After successful completion,
|
||||||
|
all datastore files are mapped into memory and
|
||||||
|
ready for use by the application.
|
||||||
|
Parameter: None
|
||||||
|
Return type: bool
|
||||||
|
- true : Initialization completed successfully.
|
||||||
|
- false : Failed to create the mutex or open
|
||||||
|
one or more file mappings.
|
||||||
|
*/
|
||||||
|
bool DataStore::initialize()
|
||||||
|
{
|
||||||
|
m_globalMutex = CreateMutexA(NULL, FALSE, "VehicleServiceSystemMutex");
|
||||||
|
if (m_globalMutex == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_users.fileName = config::file::USER_FILE;
|
||||||
|
m_users.recordSize = sizeof(SerializedUser);
|
||||||
|
m_notifications.fileName = config::file::NOTIFICATION_FILE;
|
||||||
|
m_notifications.recordSize = sizeof(SerializedNotification);
|
||||||
|
m_services.fileName = config::file::SERVICE_FILE;
|
||||||
|
m_services.recordSize = sizeof(SerializedService);
|
||||||
|
m_comboPackages.fileName = config::file::COMBOPACKAGE_FILE;
|
||||||
|
m_comboPackages.recordSize = sizeof(SerializedComboPackage);
|
||||||
|
m_inventoryItems.fileName = config::file::INVENTORYITEM_FILE;
|
||||||
|
m_inventoryItems.recordSize = sizeof(SerializedInventoryItem);
|
||||||
|
m_serviceBookings.fileName = config::file::SERVICEBOOKING_FILE;
|
||||||
|
m_serviceBookings.recordSize = sizeof(SerializedServiceBooking);
|
||||||
|
m_jobCards.fileName = config::file::JOBCARD_FILE;
|
||||||
|
m_jobCards.recordSize = sizeof(SerializedJobCard);
|
||||||
|
m_invoices.fileName = config::file::INVOICE_FILE;
|
||||||
|
m_invoices.recordSize = sizeof(SerializedInvoice);
|
||||||
|
m_serviceManagementObservers.fileName = config::file::SERVICEMANAGEMENTOBSERVERS;
|
||||||
|
m_serviceManagementObservers.recordSize = sizeof(SerializedObserver);
|
||||||
|
m_paymentManagementObservers.fileName = config::file::PAYMENTMANAGEMENTOBSERVERS;
|
||||||
|
m_paymentManagementObservers.recordSize = sizeof(SerializedObserver);
|
||||||
|
m_inventoryManagementObservers.fileName = config::file::INVENTORYMANAGEMENTOBSERVERS;
|
||||||
|
m_inventoryManagementObservers.recordSize = sizeof(SerializedObserver);
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_users))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_notifications))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_services))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_comboPackages))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_inventoryItems))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_serviceBookings))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_jobCards))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_invoices))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_payments))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_serviceManagementObservers))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_paymentManagementObservers))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SharedMemory::createOrOpenMapping(m_inventoryManagementObservers))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: shutdown
|
||||||
|
Description: Releases all shared-memory resources owned by the
|
||||||
|
datastore. Closes every file mapping, unmaps all
|
||||||
|
mapped views, and releases the datastore mutex.
|
||||||
|
After this call, the datastore must be initialized
|
||||||
|
again before use.
|
||||||
|
Parameter: None
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
void DataStore::shutdown()
|
||||||
|
{
|
||||||
|
SharedMemory::closeMapping(m_users);
|
||||||
|
SharedMemory::closeMapping(m_notifications);
|
||||||
|
SharedMemory::closeMapping(m_services);
|
||||||
|
SharedMemory::closeMapping(m_comboPackages);
|
||||||
|
SharedMemory::closeMapping(m_inventoryItems);
|
||||||
|
SharedMemory::closeMapping(m_serviceBookings);
|
||||||
|
SharedMemory::closeMapping(m_jobCards);
|
||||||
|
SharedMemory::closeMapping(m_invoices);
|
||||||
|
SharedMemory::closeMapping(m_payments);
|
||||||
|
SharedMemory::closeMapping(m_serviceManagementObservers);
|
||||||
|
SharedMemory::closeMapping(m_paymentManagementObservers);
|
||||||
|
SharedMemory::closeMapping(m_inventoryManagementObservers);
|
||||||
|
if (m_globalMutex != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_globalMutex);
|
||||||
|
m_globalMutex = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getInstance
|
Function: getInstance
|
||||||
@@ -26,104 +157,326 @@ DataStore& DataStore::getInstance()
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getUsers
|
Function: getUsers
|
||||||
Description: Retrieves the internal map of users.
|
Description: Retrieves all user records from the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- Reference to util::Map<std::string, User*> containing all users.
|
- util::Map<std::string, TrackedRecord<User>>: Collection of user records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, User*>& DataStore::getUsers()
|
util::Map<std::string, TrackedRecord<User>> DataStore::getUsers()
|
||||||
{
|
{
|
||||||
return m_users;
|
return util::Map<std::string, TrackedRecord<User>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getNotifications
|
||||||
|
Description: Retrieves all notification records from the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- util::Map<std::string, TrackedRecord<Notification>>: Collection of notification records
|
||||||
|
*/
|
||||||
|
util::Map<std::string, TrackedRecord<Notification>> DataStore::getNotifications()
|
||||||
|
{
|
||||||
|
return util::Map<std::string, TrackedRecord<Notification>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getServices
|
Function: getServices
|
||||||
Description: Retrieves the internal map of services.
|
Description: Retrieves all service records from the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- Reference to util::Map<std::string, Service*> containing all services.
|
- util::Map<std::string, TrackedRecord<Service>>: Collection of service records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, Service*>& DataStore::getServices()
|
util::Map<std::string, TrackedRecord<Service>> DataStore::getServices()
|
||||||
{
|
{
|
||||||
return m_services;
|
return util::Map<std::string, TrackedRecord<Service>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getComboPackages
|
Function: getComboPackages
|
||||||
Description: Retrieves the internal map of combo packages.
|
Description: Retrieves all combo package records from the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- Reference to util::Map<std::string, ComboPackage*> containing all combo packages.
|
- util::Map<std::string, TrackedRecord<ComboPackage>>: Collection of combo package records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, ComboPackage*>& DataStore::getComboPackages()
|
util::Map<std::string, TrackedRecord<ComboPackage>> DataStore::getComboPackages()
|
||||||
{
|
{
|
||||||
return m_comboPackages;
|
return util::Map<std::string, TrackedRecord<ComboPackage>>();
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getServiceBookings
|
|
||||||
Description: Retrieves the internal map of service bookings.
|
|
||||||
Parameters:
|
|
||||||
- None
|
|
||||||
Returns:
|
|
||||||
- Reference to util::Map<std::string, ServiceBooking*> containing all service bookings.
|
|
||||||
*/
|
|
||||||
util::Map<std::string, ServiceBooking*>& DataStore::getServiceBookings()
|
|
||||||
{
|
|
||||||
return m_serviceBookings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getJobCards
|
|
||||||
Description: Retrieves the internal map of job cards.
|
|
||||||
Parameters:
|
|
||||||
- None
|
|
||||||
Returns:
|
|
||||||
- Reference to util::Map<std::string, JobCard*> containing all job cards.
|
|
||||||
*/
|
|
||||||
util::Map<std::string, JobCard*>& DataStore::getJobCards()
|
|
||||||
{
|
|
||||||
return m_jobCards;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getInventoryItems
|
Function: getInventoryItems
|
||||||
Description: Retrieves the internal map of inventory items.
|
Description: Retrieves all inventory item records from the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- Reference to util::Map<std::string, InventoryItem*> containing all inventory items.
|
- util::Map<std::string, TrackedRecord<InventoryItem>>: Collection of inventory item records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, InventoryItem*>& DataStore::getInventoryItems()
|
util::Map<std::string, TrackedRecord<InventoryItem>> DataStore::getInventoryItems()
|
||||||
{
|
{
|
||||||
return m_inventoryItems;
|
return util::Map<std::string, TrackedRecord<InventoryItem>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getServiceBookings
|
||||||
|
Description: Retrieves all service booking records from the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- util::Map<std::string, TrackedRecord<ServiceBooking>>: Collection of service booking records
|
||||||
|
*/
|
||||||
|
util::Map<std::string, TrackedRecord<ServiceBooking>> DataStore::getServiceBookings()
|
||||||
|
{
|
||||||
|
return util::Map<std::string, TrackedRecord<ServiceBooking>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getJobCards
|
||||||
|
Description: Retrieves all job card records from the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- util::Map<std::string, TrackedRecord<JobCard>>: Collection of job card records
|
||||||
|
*/
|
||||||
|
util::Map<std::string, TrackedRecord<JobCard>> DataStore::getJobCards()
|
||||||
|
{
|
||||||
|
return util::Map<std::string, TrackedRecord<JobCard>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getInvoices
|
Function: getInvoices
|
||||||
Description: Retrieves the internal map of invoices.
|
Description: Retrieves all invoice records from the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- Reference to util::Map<std::string, Invoice*> containing all invoices.
|
- util::Map<std::string, TrackedRecord<Invoice>>: Collection of invoice records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, Invoice*>& DataStore::getInvoices()
|
util::Map<std::string, TrackedRecord<Invoice>> DataStore::getInvoices()
|
||||||
{
|
{
|
||||||
return m_invoices;
|
return util::Map<std::string, TrackedRecord<Invoice>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getPayments
|
Function: getPayments
|
||||||
Description: Retrieves the internal map of payments.
|
Description: Retrieves all payment records from the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- Reference to util::Map<std::string, Payment*> containing all payments.
|
- util::Map<std::string, TrackedRecord<Payment>>: Collection of payment records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, Payment*>& DataStore::getPayments()
|
util::Map<std::string, TrackedRecord<Payment>> DataStore::getPayments()
|
||||||
{
|
{
|
||||||
return m_payments;
|
return util::Map<std::string, TrackedRecord<Payment>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getServiceManagementObservers
|
||||||
|
Description: Retrieves all service management observer records from the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- util::Map<std::string, TrackedRecord<std::string>>: Collection of observer records
|
||||||
|
*/
|
||||||
|
util::Map<std::string, TrackedRecord<std::string>> DataStore::getServiceManagementObservers()
|
||||||
|
{
|
||||||
|
return util::Map<std::string, TrackedRecord<std::string>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getPaymentManagementObservers
|
||||||
|
Description: Retrieves all payment management observer records from the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- util::Map<std::string, TrackedRecord<std::string>>: Collection of observer records
|
||||||
|
*/
|
||||||
|
util::Map<std::string, TrackedRecord<std::string>> DataStore::getPaymentManagementObservers()
|
||||||
|
{
|
||||||
|
return util::Map<std::string, TrackedRecord<std::string>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getInventoryManagementObservers
|
||||||
|
Description: Retrieves all inventory management observer records from the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- util::Map<std::string, TrackedRecord<std::string>>: Collection of observer records
|
||||||
|
*/
|
||||||
|
util::Map<std::string, TrackedRecord<std::string>> DataStore::getInventoryManagementObservers()
|
||||||
|
{
|
||||||
|
return util::Map<std::string, TrackedRecord<std::string>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveUsers
|
||||||
|
Description: Persists all user records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- users: util::Map<std::string, TrackedRecord<User>>&, collection of user records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveUsers(util::Map<std::string, TrackedRecord<User>>& users)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveNotifications
|
||||||
|
Description: Persists all notification records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- notifications: util::Map<std::string, TrackedRecord<Notification>>&, collection of notification records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveNotifications(util::Map<std::string, TrackedRecord<Notification>>& notifications)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveServices
|
||||||
|
Description: Persists all service records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- services: util::Map<std::string, TrackedRecord<Service>>&, collection of service records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveServices(util::Map<std::string, TrackedRecord<Service>>& services)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveComboPackages
|
||||||
|
Description: Persists all combo package records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- comboPackages: util::Map<std::string, TrackedRecord<ComboPackage>>&, collection of combo package records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveComboPackages(util::Map<std::string, TrackedRecord<ComboPackage>>& comboPackages)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveInventoryItems
|
||||||
|
Description: Persists all inventory item records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- inventoryItems: util::Map<std::string, TrackedRecord<InventoryItem>>&, collection of inventory item records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveInventoryItems(util::Map<std::string, TrackedRecord<InventoryItem>>& inventoryItems)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveServiceBookings
|
||||||
|
Description: Persists all service booking records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- bookings: util::Map<std::string, TrackedRecord<ServiceBooking>>&, collection of service booking records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveServiceBookings(util::Map<std::string, TrackedRecord<ServiceBooking>>& bookings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveJobCards
|
||||||
|
Description: Persists all job card records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- jobCards: util::Map<std::string, TrackedRecord<JobCard>>&, collection of job card records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveJobCards(util::Map<std::string, TrackedRecord<JobCard>>& jobCards)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveInvoices
|
||||||
|
Description: Persists all invoice records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- invoices: util::Map<std::string, TrackedRecord<Invoice>>&, collection of invoice records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveInvoices(util::Map<std::string, TrackedRecord<Invoice>>& invoices)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: savePayments
|
||||||
|
Description: Persists all payment records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- payments: util::Map<std::string, TrackedRecord<Payment>>&, collection of payment records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::savePayments(util::Map<std::string, TrackedRecord<Payment>>& payments)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveServiceManagementObservers
|
||||||
|
Description: Persists all service management observer records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- observers: util::Map<std::string, TrackedRecord<std::string>>&, collection of observer records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveServiceManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: savePaymentManagementObservers
|
||||||
|
Description: Persists all payment management observer records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- observers: util::Map<std::string, TrackedRecord<std::string>>&, collection of observer records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::savePaymentManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: saveInventoryManagementObservers
|
||||||
|
Description: Persists all inventory management observer records to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- observers: util::Map<std::string, TrackedRecord<std::string>>&, collection of observer records
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
void DataStore::saveInventoryManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: lockDataStore
|
||||||
|
Description: Acquires exclusive access to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- bool: True if the datastore was successfully locked, otherwise false
|
||||||
|
*/
|
||||||
|
bool DataStore::lockDataStore()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: unlockDataStore
|
||||||
|
Description: Releases exclusive access to the datastore.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- bool: True if the datastore was successfully unlocked, otherwise false
|
||||||
|
*/
|
||||||
|
bool DataStore::unlockDataStore()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,9 @@ private:
|
|||||||
MappingInfo m_jobCards;
|
MappingInfo m_jobCards;
|
||||||
MappingInfo m_invoices;
|
MappingInfo m_invoices;
|
||||||
MappingInfo m_payments;
|
MappingInfo m_payments;
|
||||||
|
MappingInfo m_serviceManagementObservers;
|
||||||
|
MappingInfo m_paymentManagementObservers;
|
||||||
|
MappingInfo m_inventoryManagementObservers;
|
||||||
public:
|
public:
|
||||||
static DataStore& getInstance();
|
static DataStore& getInstance();
|
||||||
bool initialize();
|
bool initialize();
|
||||||
@@ -53,6 +56,9 @@ public:
|
|||||||
util::Map<std::string, TrackedRecord<JobCard>> getJobCards();
|
util::Map<std::string, TrackedRecord<JobCard>> getJobCards();
|
||||||
util::Map<std::string, TrackedRecord<Invoice>> getInvoices();
|
util::Map<std::string, TrackedRecord<Invoice>> getInvoices();
|
||||||
util::Map<std::string, TrackedRecord<Payment>> getPayments();
|
util::Map<std::string, TrackedRecord<Payment>> getPayments();
|
||||||
|
util::Map<std::string, TrackedRecord<std::string>> getServiceManagementObservers();
|
||||||
|
util::Map<std::string, TrackedRecord<std::string>> getPaymentManagementObservers();
|
||||||
|
util::Map<std::string, TrackedRecord<std::string>> getInventoryManagementObservers();
|
||||||
void saveUsers(util::Map<std::string, TrackedRecord<User>>& users);
|
void saveUsers(util::Map<std::string, TrackedRecord<User>>& users);
|
||||||
void saveNotifications(util::Map<std::string, TrackedRecord<Notification>>& notifications);
|
void saveNotifications(util::Map<std::string, TrackedRecord<Notification>>& notifications);
|
||||||
void saveServices(util::Map<std::string, TrackedRecord<Service>>& services);
|
void saveServices(util::Map<std::string, TrackedRecord<Service>>& services);
|
||||||
@@ -62,6 +68,9 @@ public:
|
|||||||
void saveJobCards(util::Map<std::string, TrackedRecord<JobCard>>& jobCards);
|
void saveJobCards(util::Map<std::string, TrackedRecord<JobCard>>& jobCards);
|
||||||
void saveInvoices(util::Map<std::string, TrackedRecord<Invoice>>& invoices);
|
void saveInvoices(util::Map<std::string, TrackedRecord<Invoice>>& invoices);
|
||||||
void savePayments(util::Map<std::string, TrackedRecord<Payment>>& payments);
|
void savePayments(util::Map<std::string, TrackedRecord<Payment>>& payments);
|
||||||
|
void saveServiceManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers);
|
||||||
|
void savePaymentManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers);
|
||||||
|
void saveInventoryManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers);
|
||||||
bool lockDataStore();
|
bool lockDataStore();
|
||||||
bool unlockDataStore();
|
bool unlockDataStore();
|
||||||
private:
|
private:
|
||||||
|
|||||||
+5
@@ -90,3 +90,8 @@ struct SerializedInvoice
|
|||||||
util::PaymentMode paymentMethod;
|
util::PaymentMode paymentMethod;
|
||||||
util::PaymentStatus status;
|
util::PaymentStatus status;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SerializedObserver
|
||||||
|
{
|
||||||
|
char id[64];
|
||||||
|
};
|
||||||
|
|||||||
-18
@@ -167,24 +167,6 @@ void* SharedMemory::getRecordAddress(MappingInfo& mapping, size_t index)
|
|||||||
return reinterpret_cast<char*>(mapping.mappedView) + sizeof(FileHeader) + index * mapping.recordSize;
|
return reinterpret_cast<char*>(mapping.mappedView) + sizeof(FileHeader) + index * mapping.recordSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getRecordAddress
|
|
||||||
Description: Returns the address of a record at the specified index within the mapped memory region.
|
|
||||||
Parameters:
|
|
||||||
- mapping: MappingInfo&, mapping information and handles
|
|
||||||
- index: size_t, record index
|
|
||||||
Returns:
|
|
||||||
- void*: Pointer to the record, or nullptr if the mapping is not valid
|
|
||||||
*/
|
|
||||||
void* SharedMemory::getRecordAddress(MappingInfo& mapping, size_t index)
|
|
||||||
{
|
|
||||||
if (mapping.mappedView == nullptr)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return reinterpret_cast<char*>(mapping.mappedView) + sizeof(FileHeader) + index * mapping.recordSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: getRecordCount
|
Function: getRecordCount
|
||||||
Description: Returns the number of records currently stored in the mapping.
|
Description: Returns the number of records currently stored in the mapping.
|
||||||
|
|||||||
@@ -29,16 +29,16 @@ namespace config
|
|||||||
namespace file
|
namespace file
|
||||||
{
|
{
|
||||||
const size_t INITIAL_CAPACITY = 100;
|
const size_t INITIAL_CAPACITY = 100;
|
||||||
constexpr const char* INVENTORYITEM_FILE = "files/InventoryItem.csv";
|
constexpr const char* INVENTORYITEM_FILE = "files/InventoryItem.dat";
|
||||||
constexpr const char* USER_FILE = "files/User.csv";
|
constexpr const char* USER_FILE = "files/User.dat";
|
||||||
constexpr const char* NOTIFICATION_FILE = "files/Notification.csv";
|
constexpr const char* NOTIFICATION_FILE = "files/Notification.dat";
|
||||||
constexpr const char* SERVICE_FILE = "files/Service.csv";
|
constexpr const char* SERVICE_FILE = "files/Service.dat";
|
||||||
constexpr const char* COMBOPACKAGE_FILE = "files/ComboPackage.csv";
|
constexpr const char* COMBOPACKAGE_FILE = "files/ComboPackage.dat";
|
||||||
constexpr const char* SERVICEBOOKING_FILE = "files/ServiceBooking.csv";
|
constexpr const char* SERVICEBOOKING_FILE = "files/ServiceBooking.dat";
|
||||||
constexpr const char* JOBCARD_FILE = "files/JobCard.csv";
|
constexpr const char* JOBCARD_FILE = "files/JobCard.dat";
|
||||||
constexpr const char* INVOICE_FILE = "files/Invoice.csv";
|
constexpr const char* INVOICE_FILE = "files/Invoice.dat";
|
||||||
constexpr const char* SERVICEMANAGEMENTOBSERVERS = "files/ServiceManagementObservers.csv";
|
constexpr const char* SERVICEMANAGEMENTOBSERVERS = "files/ServiceManagementObservers.dat";
|
||||||
constexpr const char* PAYMENTMANAGEMENTOBSERVERS = "files/PaymentManagementObservers.csv";
|
constexpr const char* PAYMENTMANAGEMENTOBSERVERS = "files/PaymentManagementObservers.dat";
|
||||||
constexpr const char* INVENTORYMANAGEMENTOBSERVERS = "files/InventoryManagementObservers.csv";
|
constexpr const char* INVENTORYMANAGEMENTOBSERVERS = "files/InventoryManagementObservers.dat";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user