Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c8e5c6c65 | |||
| d6e95abf72 |
+81
-72
@@ -13,9 +13,42 @@ Date: 19-May-2026
|
|||||||
#include "SerializedRecords.h"
|
#include "SerializedRecords.h"
|
||||||
#include "FileHelper.h"
|
#include "FileHelper.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: DataStore
|
||||||
|
Description: Constructs the DataStore singleton and initializes
|
||||||
|
internal handles to their default values.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
DataStore::DataStore() :
|
DataStore::DataStore() :
|
||||||
m_globalMutex(NULL) {}
|
m_globalMutex(NULL) {}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: ~DataStore
|
||||||
|
Description: Destroys the DataStore singleton and releases all
|
||||||
|
cached application objects owned by the datastore.
|
||||||
|
This includes users, notifications, services,
|
||||||
|
combo packages, inventory items, service bookings,
|
||||||
|
job cards, and invoices.
|
||||||
|
Parameters:
|
||||||
|
- None
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
DataStore::~DataStore()
|
||||||
|
{
|
||||||
|
clearCache(m_userCache);
|
||||||
|
clearCache(m_notificationCache);
|
||||||
|
clearCache(m_serviceCache);
|
||||||
|
clearCache(m_comboPackageCache);
|
||||||
|
clearCache(m_inventoryItemCache);
|
||||||
|
clearCache(m_serviceBookingCache);
|
||||||
|
clearCache(m_jobCardCache);
|
||||||
|
clearCache(m_invoiceCache);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: initialize
|
Function: initialize
|
||||||
Description: Initializes the shared-memory datastore.
|
Description: Initializes the shared-memory datastore.
|
||||||
@@ -193,9 +226,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<User>>: Collection of user records
|
- util::Map<std::string, TrackedRecord<User>>: Collection of user records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<User>> DataStore::getUsers()
|
util::Map<std::string, TrackedRecord<User>>& DataStore::getUsers()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<User>>();
|
return m_userCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -206,9 +239,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<Notification>>: Collection of notification records
|
- util::Map<std::string, TrackedRecord<Notification>>: Collection of notification records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<Notification>> DataStore::getNotifications()
|
util::Map<std::string, TrackedRecord<Notification>>& DataStore::getNotifications()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<Notification>>();
|
return m_notificationCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -219,9 +252,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<Service>>: Collection of service records
|
- util::Map<std::string, TrackedRecord<Service>>: Collection of service records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<Service>> DataStore::getServices()
|
util::Map<std::string, TrackedRecord<Service>>& DataStore::getServices()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<Service>>();
|
return m_serviceCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -232,9 +265,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<ComboPackage>>: Collection of combo package records
|
- util::Map<std::string, TrackedRecord<ComboPackage>>: Collection of combo package records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<ComboPackage>> DataStore::getComboPackages()
|
util::Map<std::string, TrackedRecord<ComboPackage>>& DataStore::getComboPackages()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<ComboPackage>>();
|
return m_comboPackageCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -245,9 +278,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<InventoryItem>>: Collection of inventory item records
|
- util::Map<std::string, TrackedRecord<InventoryItem>>: Collection of inventory item records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<InventoryItem>> DataStore::getInventoryItems()
|
util::Map<std::string, TrackedRecord<InventoryItem>>& DataStore::getInventoryItems()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<InventoryItem>>();
|
return m_inventoryItemCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -258,9 +291,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<ServiceBooking>>: Collection of service booking records
|
- util::Map<std::string, TrackedRecord<ServiceBooking>>: Collection of service booking records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<ServiceBooking>> DataStore::getServiceBookings()
|
util::Map<std::string, TrackedRecord<ServiceBooking>>& DataStore::getServiceBookings()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<ServiceBooking>>();
|
return m_serviceBookingCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -271,9 +304,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<JobCard>>: Collection of job card records
|
- util::Map<std::string, TrackedRecord<JobCard>>: Collection of job card records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<JobCard>> DataStore::getJobCards()
|
util::Map<std::string, TrackedRecord<JobCard>>& DataStore::getJobCards()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<JobCard>>();
|
return m_jobCardCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -284,22 +317,9 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<Invoice>>: Collection of invoice records
|
- util::Map<std::string, TrackedRecord<Invoice>>: Collection of invoice records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<Invoice>> DataStore::getInvoices()
|
util::Map<std::string, TrackedRecord<Invoice>>& DataStore::getInvoices()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<Invoice>>();
|
return m_invoiceCache;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getPayments
|
|
||||||
Description: Retrieves all payment records from the datastore.
|
|
||||||
Parameters:
|
|
||||||
- None
|
|
||||||
Returns:
|
|
||||||
- util::Map<std::string, TrackedRecord<Payment>>: Collection of payment records
|
|
||||||
*/
|
|
||||||
util::Map<std::string, TrackedRecord<Payment>> DataStore::getPayments()
|
|
||||||
{
|
|
||||||
return util::Map<std::string, TrackedRecord<Payment>>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -308,11 +328,11 @@ Description: Retrieves all service management observer records from the datastor
|
|||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<std::string>>: Collection of observer records
|
- util::Map<std::string, User*>: Collection of observer records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<std::string>> DataStore::getServiceManagementObservers()
|
util::Map<std::string, User*> DataStore::getServiceManagementObservers()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<std::string>>();
|
return util::Map<std::string, User*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -321,11 +341,11 @@ Description: Retrieves all payment management observer records from the datastor
|
|||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<std::string>>: Collection of observer records
|
- util::Map<std::string, User*>: Collection of observer records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<std::string>> DataStore::getPaymentManagementObservers()
|
util::Map<std::string, User*> DataStore::getPaymentManagementObservers()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<std::string>>();
|
return util::Map<std::string, User*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -334,22 +354,22 @@ Description: Retrieves all inventory management observer records from the datast
|
|||||||
Parameters:
|
Parameters:
|
||||||
- None
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- util::Map<std::string, TrackedRecord<std::string>>: Collection of observer records
|
- util::Map<std::string, User*>: Collection of observer records
|
||||||
*/
|
*/
|
||||||
util::Map<std::string, TrackedRecord<std::string>> DataStore::getInventoryManagementObservers()
|
util::Map<std::string, User*> DataStore::getInventoryManagementObservers()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, TrackedRecord<std::string>>();
|
return util::Map<std::string, User*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: saveUsers
|
Function: saveUsers
|
||||||
Description: Persists all user records to the datastore.
|
Description: Persists all user records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- users: util::Map<std::string, TrackedRecord<User>>&, collection of user records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveUsers(util::Map<std::string, TrackedRecord<User>>& users)
|
void DataStore::saveUsers()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,11 +377,11 @@ void DataStore::saveUsers(util::Map<std::string, TrackedRecord<User>>& users)
|
|||||||
Function: saveNotifications
|
Function: saveNotifications
|
||||||
Description: Persists all notification records to the datastore.
|
Description: Persists all notification records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- notifications: util::Map<std::string, TrackedRecord<Notification>>&, collection of notification records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveNotifications(util::Map<std::string, TrackedRecord<Notification>>& notifications)
|
void DataStore::saveNotifications()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,11 +389,11 @@ void DataStore::saveNotifications(util::Map<std::string, TrackedRecord<Notificat
|
|||||||
Function: saveServices
|
Function: saveServices
|
||||||
Description: Persists all service records to the datastore.
|
Description: Persists all service records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- services: util::Map<std::string, TrackedRecord<Service>>&, collection of service records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveServices(util::Map<std::string, TrackedRecord<Service>>& services)
|
void DataStore::saveServices()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,11 +401,11 @@ void DataStore::saveServices(util::Map<std::string, TrackedRecord<Service>>& ser
|
|||||||
Function: saveComboPackages
|
Function: saveComboPackages
|
||||||
Description: Persists all combo package records to the datastore.
|
Description: Persists all combo package records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- comboPackages: util::Map<std::string, TrackedRecord<ComboPackage>>&, collection of combo package records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveComboPackages(util::Map<std::string, TrackedRecord<ComboPackage>>& comboPackages)
|
void DataStore::saveComboPackages()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,11 +413,11 @@ void DataStore::saveComboPackages(util::Map<std::string, TrackedRecord<ComboPack
|
|||||||
Function: saveInventoryItems
|
Function: saveInventoryItems
|
||||||
Description: Persists all inventory item records to the datastore.
|
Description: Persists all inventory item records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- inventoryItems: util::Map<std::string, TrackedRecord<InventoryItem>>&, collection of inventory item records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveInventoryItems(util::Map<std::string, TrackedRecord<InventoryItem>>& inventoryItems)
|
void DataStore::saveInventoryItems()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,11 +425,11 @@ void DataStore::saveInventoryItems(util::Map<std::string, TrackedRecord<Inventor
|
|||||||
Function: saveServiceBookings
|
Function: saveServiceBookings
|
||||||
Description: Persists all service booking records to the datastore.
|
Description: Persists all service booking records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- bookings: util::Map<std::string, TrackedRecord<ServiceBooking>>&, collection of service booking records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveServiceBookings(util::Map<std::string, TrackedRecord<ServiceBooking>>& bookings)
|
void DataStore::saveServiceBookings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,11 +437,11 @@ void DataStore::saveServiceBookings(util::Map<std::string, TrackedRecord<Service
|
|||||||
Function: saveJobCards
|
Function: saveJobCards
|
||||||
Description: Persists all job card records to the datastore.
|
Description: Persists all job card records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- jobCards: util::Map<std::string, TrackedRecord<JobCard>>&, collection of job card records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveJobCards(util::Map<std::string, TrackedRecord<JobCard>>& jobCards)
|
void DataStore::saveJobCards()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,23 +449,11 @@ void DataStore::saveJobCards(util::Map<std::string, TrackedRecord<JobCard>>& job
|
|||||||
Function: saveInvoices
|
Function: saveInvoices
|
||||||
Description: Persists all invoice records to the datastore.
|
Description: Persists all invoice records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- invoices: util::Map<std::string, TrackedRecord<Invoice>>&, collection of invoice records
|
- None
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveInvoices(util::Map<std::string, TrackedRecord<Invoice>>& invoices)
|
void DataStore::saveInvoices()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +465,7 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveServiceManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers)
|
void DataStore::saveServiceManagementObservers(util::Map<std::string, User*>& observers)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,11 +473,11 @@ void DataStore::saveServiceManagementObservers(util::Map<std::string, TrackedRec
|
|||||||
Function: savePaymentManagementObservers
|
Function: savePaymentManagementObservers
|
||||||
Description: Persists all payment management observer records to the datastore.
|
Description: Persists all payment management observer records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- observers: util::Map<std::string, TrackedRecord<std::string>>&, collection of observer records
|
- observers: util::Map<std::string, User*>&, collection of observer records
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::savePaymentManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers)
|
void DataStore::savePaymentManagementObservers(util::Map<std::string, User*>& observers)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,11 +485,11 @@ void DataStore::savePaymentManagementObservers(util::Map<std::string, TrackedRec
|
|||||||
Function: saveInventoryManagementObservers
|
Function: saveInventoryManagementObservers
|
||||||
Description: Persists all inventory management observer records to the datastore.
|
Description: Persists all inventory management observer records to the datastore.
|
||||||
Parameters:
|
Parameters:
|
||||||
- observers: util::Map<std::string, TrackedRecord<std::string>>&, collection of observer records
|
- observers: util::Map<std::string, User*>&, collection of observer records
|
||||||
Returns:
|
Returns:
|
||||||
- None
|
- None
|
||||||
*/
|
*/
|
||||||
void DataStore::saveInventoryManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers)
|
void DataStore::saveInventoryManagementObservers(util::Map<std::string, User*>& observers)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,4 +561,5 @@ bool DataStore::unlockDataStore()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ReleaseMutex(m_globalMutex) != 0;
|
return ReleaseMutex(m_globalMutex) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ class InventoryItem;
|
|||||||
class ServiceBooking;
|
class ServiceBooking;
|
||||||
class JobCard;
|
class JobCard;
|
||||||
class Invoice;
|
class Invoice;
|
||||||
class Payment;
|
|
||||||
|
|
||||||
class DataStore
|
class DataStore
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
DataStore();
|
DataStore();
|
||||||
|
~DataStore();
|
||||||
DataStore(const DataStore&) = delete;
|
DataStore(const DataStore&) = delete;
|
||||||
DataStore& operator=(const DataStore&) = delete;
|
DataStore& operator=(const DataStore&) = delete;
|
||||||
DataStore(DataStore&&) = delete;
|
DataStore(DataStore&&) = delete;
|
||||||
@@ -43,34 +43,40 @@ private:
|
|||||||
MappingInfo m_serviceManagementObservers;
|
MappingInfo m_serviceManagementObservers;
|
||||||
MappingInfo m_paymentManagementObservers;
|
MappingInfo m_paymentManagementObservers;
|
||||||
MappingInfo m_inventoryManagementObservers;
|
MappingInfo m_inventoryManagementObservers;
|
||||||
|
util::Map<std::string, TrackedRecord<User>> m_userCache;
|
||||||
|
util::Map<std::string, TrackedRecord<Notification>> m_notificationCache;
|
||||||
|
util::Map<std::string, TrackedRecord<Service>> m_serviceCache;
|
||||||
|
util::Map<std::string, TrackedRecord<ComboPackage>> m_comboPackageCache;
|
||||||
|
util::Map<std::string, TrackedRecord<InventoryItem>> m_inventoryItemCache;
|
||||||
|
util::Map<std::string, TrackedRecord<ServiceBooking>> m_serviceBookingCache;
|
||||||
|
util::Map<std::string, TrackedRecord<JobCard>> m_jobCardCache;
|
||||||
|
util::Map<std::string, TrackedRecord<Invoice>> m_invoiceCache;
|
||||||
public:
|
public:
|
||||||
static DataStore& getInstance();
|
static DataStore& getInstance();
|
||||||
bool initialize();
|
bool initialize();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
util::Map<std::string, TrackedRecord<User>> getUsers();
|
util::Map<std::string, TrackedRecord<User>>& getUsers();
|
||||||
util::Map<std::string, TrackedRecord<Notification>> getNotifications();
|
util::Map<std::string, TrackedRecord<Notification>>& getNotifications();
|
||||||
util::Map<std::string, TrackedRecord<Service>> getServices();
|
util::Map<std::string, TrackedRecord<Service>>& getServices();
|
||||||
util::Map<std::string, TrackedRecord<ComboPackage>> getComboPackages();
|
util::Map<std::string, TrackedRecord<ComboPackage>>& getComboPackages();
|
||||||
util::Map<std::string, TrackedRecord<InventoryItem>> getInventoryItems();
|
util::Map<std::string, TrackedRecord<InventoryItem>>& getInventoryItems();
|
||||||
util::Map<std::string, TrackedRecord<ServiceBooking>> getServiceBookings();
|
util::Map<std::string, TrackedRecord<ServiceBooking>>& getServiceBookings();
|
||||||
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, User*> getServiceManagementObservers();
|
||||||
util::Map<std::string, TrackedRecord<std::string>> getServiceManagementObservers();
|
util::Map<std::string, User*> getPaymentManagementObservers();
|
||||||
util::Map<std::string, TrackedRecord<std::string>> getPaymentManagementObservers();
|
util::Map<std::string, User*> getInventoryManagementObservers();
|
||||||
util::Map<std::string, TrackedRecord<std::string>> getInventoryManagementObservers();
|
void saveUsers();
|
||||||
void saveUsers(util::Map<std::string, TrackedRecord<User>>& users);
|
void saveNotifications();
|
||||||
void saveNotifications(util::Map<std::string, TrackedRecord<Notification>>& notifications);
|
void saveServices();
|
||||||
void saveServices(util::Map<std::string, TrackedRecord<Service>>& services);
|
void saveComboPackages();
|
||||||
void saveComboPackages(util::Map<std::string, TrackedRecord<ComboPackage>>& comboPackages);
|
void saveInventoryItems();
|
||||||
void saveInventoryItems(util::Map<std::string, TrackedRecord<InventoryItem>>& inventoryItems);
|
void saveServiceBookings();
|
||||||
void saveServiceBookings(util::Map<std::string, TrackedRecord<ServiceBooking>>& bookings);
|
void saveJobCards();
|
||||||
void saveJobCards(util::Map<std::string, TrackedRecord<JobCard>>& jobCards);
|
void saveInvoices();
|
||||||
void saveInvoices(util::Map<std::string, TrackedRecord<Invoice>>& invoices);
|
void saveServiceManagementObservers(util::Map<std::string, User*>& observers);
|
||||||
void savePayments(util::Map<std::string, TrackedRecord<Payment>>& payments);
|
void savePaymentManagementObservers(util::Map<std::string, User*>& observers);
|
||||||
void saveServiceManagementObservers(util::Map<std::string, TrackedRecord<std::string>>& observers);
|
void saveInventoryManagementObservers(util::Map<std::string, User*>& 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:
|
||||||
@@ -78,6 +84,8 @@ private:
|
|||||||
util::Map<std::string, TrackedRecord<TObject>> loadRecords(MappingInfo& mapping);
|
util::Map<std::string, TrackedRecord<TObject>> loadRecords(MappingInfo& mapping);
|
||||||
template<typename TObject, typename TSerialized>
|
template<typename TObject, typename TSerialized>
|
||||||
void saveRecords(MappingInfo& mapping, util::Map<std::string, TrackedRecord<TObject>>& records);
|
void saveRecords(MappingInfo& mapping, util::Map<std::string, TrackedRecord<TObject>>& records);
|
||||||
|
template<typename TObject> void clearCache(util::Map<std::string, TrackedRecord<TObject>>&cache);
|
||||||
|
template<typename TObject> void refreshCache(util::Map<std::string, TrackedRecord<TObject>>&cache, util::Map<std::string, TrackedRecord<TObject>>&refreshedCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -123,9 +131,7 @@ Description: Persists all modified and newly added records
|
|||||||
shared-memory mapping. Modified records overwrite
|
shared-memory mapping. Modified records overwrite
|
||||||
their existing slots, while new records are
|
their existing slots, while new records are
|
||||||
appended to the end of the mapping. Records marked
|
appended to the end of the mapping. Records marked
|
||||||
as CLEAN are ignored. After persistence, all
|
as CLEAN are ignored.
|
||||||
temporary objects owned by the tracked records are
|
|
||||||
destroyed to release memory.
|
|
||||||
Parameter:
|
Parameter:
|
||||||
- mapping: Reference to the mapping where records are
|
- mapping: Reference to the mapping where records are
|
||||||
stored.
|
stored.
|
||||||
@@ -158,14 +164,50 @@ template<typename TObject, typename TSerialized> void DataStore::saveRecords(Map
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
size_t recordCount = SharedMemory::getRecordCount(mapping);
|
size_t recordCount = SharedMemory::getRecordCount(mapping);
|
||||||
TSerialized* destination = static_cast<TSerialized*>(SharedMemory::getRecordAddress(mapping, recordCount));
|
TSerialized* destination = static_cast<TSerialized*>(SharedMemory::getRecordAddress(mapping,recordCount));
|
||||||
*destination = serialized;
|
*destination = serialized;
|
||||||
SharedMemory::setRecordCount(mapping, recordCount + 1);
|
SharedMemory::setRecordCount(mapping, recordCount + 1);
|
||||||
|
record.slotIndex = recordCount;
|
||||||
}
|
}
|
||||||
|
record.state = RecordState::CLEAN;
|
||||||
}
|
}
|
||||||
for (int index = 0; index < records.getSize(); ++index)
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: clearCache
|
||||||
|
Description: Releases all objects owned by the cache and
|
||||||
|
clears the cache contents.
|
||||||
|
Parameters:
|
||||||
|
- cache: Cache to be cleared.
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
template<typename TObject>
|
||||||
|
void DataStore::clearCache(util::Map<std::string, TrackedRecord<TObject>>&cache)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < cache.getSize(); ++index)
|
||||||
{
|
{
|
||||||
delete records.getValueAt(index).data;
|
delete cache.getValueAt(index).data;
|
||||||
records.getValueAt(index).data = nullptr;
|
cache.getValueAt(index).data = nullptr;
|
||||||
}
|
}
|
||||||
|
cache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: refreshCache
|
||||||
|
Description: Replaces the contents of an existing cache
|
||||||
|
with a newly loaded cache. Existing cached
|
||||||
|
objects are destroyed before ownership of
|
||||||
|
the new cache contents is transferred.
|
||||||
|
Parameters:
|
||||||
|
- cache: Existing cache to refresh.
|
||||||
|
- refreshedCache: Newly loaded cache contents.
|
||||||
|
Returns:
|
||||||
|
- None
|
||||||
|
*/
|
||||||
|
template<typename TObject>
|
||||||
|
void DataStore::refreshCache(util::Map<std::string, TrackedRecord<TObject>>&cache, util::Map<std::string, TrackedRecord<TObject>>&refreshedCache)
|
||||||
|
{
|
||||||
|
clearCache(cache);
|
||||||
|
cache = refreshedCache;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user