67ac7f6625
<UserStory> 1954: Implement Service Refactoring </UserStory> UserStory #1954 <Changes> 1. Refactored notification handling to persist notifications directly in the datastore instead of maintaining notification collections within User objects. 2. Removed recipient User pointer dependencies from Notification and retained recipient user identification through recipientUserId. 3. Implemented generic observer persistence support in DataStore with shared helper methods for loading and saving observer subscriptions. 4. Added datastore-backed observer management for ServiceManagementService, PaymentManagementService, and InventoryManagementService. 5. Updated attach() and detach() operations to load, modify, and persist observer subscriptions using shared memory mappings. 6. Refactored sendNotification() implementations to create and persist Notification records directly to the datastore for subscribed observers. 7. Updated UserManagementService notification retrieval and deletion logic to operate on datastore notification records filtered by recipient user ID. 8. Removed notification ownership and observer-specific notification APIs from User and Observer classes. 9. Added configurable shared memory growth factor support and updated mapping expansion logic to use centralized configuration values. 10. Removed obsolete NotificationManagementService implementation and updated project configuration references. 11. Added DataStoreLockGuard integration for observer and notification persistence operations to ensure synchronized datastore access. </Changes> <Test> N/A </Test> <Review> Sreeja Reghukumar, please review </Review>
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
/*
|
|
File: User.h
|
|
Description: Declares the User class which represents system users in the Vehicle Service Management System.
|
|
Each user has a unique ID, credentials, personal details, notifications, role type, and status.
|
|
The User class also implements the Observer interface to handle notifications.
|
|
Author: Trenser
|
|
Date: 19-May-2026
|
|
*/
|
|
|
|
#pragma once
|
|
#include <string>
|
|
#include "Map.h"
|
|
#include "Observer.h"
|
|
#include "Enums.h"
|
|
|
|
class Notification;
|
|
struct SerializedUser;
|
|
|
|
class User : public Observer
|
|
{
|
|
private:
|
|
static int m_uid;
|
|
std::string m_id;
|
|
std::string m_userName;
|
|
std::string m_password;
|
|
std::string m_name;
|
|
std::string m_phone;
|
|
std::string m_email;
|
|
util::UserType m_type;
|
|
util::State m_status;
|
|
public:
|
|
User();
|
|
User(const std::string& userName, const std::string& password, const std::string& name, const std::string& phone, const std::string& email, util::UserType role);
|
|
User(const std::string& userId, const std::string& userName, const std::string& password, const std::string& name, const std::string& phone, const std::string& email, util::UserType role, util::State status);
|
|
~User() = default;
|
|
const std::string& getId() const;
|
|
const std::string& getUserName() const;
|
|
const std::string& getPassword() const;
|
|
const std::string& getName() const;
|
|
const std::string& getPhone() const;
|
|
const std::string& getEmail() const;
|
|
util::UserType getUserType() const;
|
|
util::State getState() const;
|
|
void setId(const std::string& id);
|
|
void setUserName(const std::string& userName);
|
|
void setPassword(const std::string& password);
|
|
void setName(const std::string& name);
|
|
void setPhone(const std::string& phone);
|
|
void setEmail(const std::string& email);
|
|
void setRole(util::UserType role);
|
|
void setState(util::State status);
|
|
SerializedUser serialize() const;
|
|
static User* deserialize(const SerializedUser& serializedUser);
|
|
};
|