notif
This commit is contained in:
+1
@@ -22,6 +22,7 @@ struct SerializedNotification
|
|||||||
char title[128];
|
char title[128];
|
||||||
char message[1024];
|
char message[1024];
|
||||||
util::Timestamp createdAt;
|
util::Timestamp createdAt;
|
||||||
|
util::State state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SerializedService
|
struct SerializedService
|
||||||
|
|||||||
-1
@@ -15,5 +15,4 @@ namespace SharedMemory
|
|||||||
void setRecordCount(MappingInfo& mapping, size_t count);
|
void setRecordCount(MappingInfo& mapping, size_t count);
|
||||||
size_t getCapacity(MappingInfo& mapping);
|
size_t getCapacity(MappingInfo& mapping);
|
||||||
bool ensureCapacityForInsert(MappingInfo& mapping);
|
bool ensureCapacityForInsert(MappingInfo& mapping);
|
||||||
bool shrinkIfNeeded(MappingInfo& mapping);
|
|
||||||
};
|
};
|
||||||
@@ -24,7 +24,7 @@ Returns:
|
|||||||
*/
|
*/
|
||||||
Notification::Notification()
|
Notification::Notification()
|
||||||
: m_id("NOT" + std::to_string(++m_uid)),
|
: m_id("NOT" + std::to_string(++m_uid)),
|
||||||
m_recipient(nullptr) {}
|
m_recipient(nullptr), m_state(util::State::ACTIVE) {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: Notification
|
Function: Notification
|
||||||
@@ -44,6 +44,7 @@ Notification::Notification(const std::string& recipientUserId, User* recipient,
|
|||||||
m_recipient(recipient),
|
m_recipient(recipient),
|
||||||
m_title(title),
|
m_title(title),
|
||||||
m_message(message),
|
m_message(message),
|
||||||
|
m_state(util::State::ACTIVE),
|
||||||
m_createdAt(createdAt){}
|
m_createdAt(createdAt){}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -59,13 +60,14 @@ Parameters:
|
|||||||
Returns:
|
Returns:
|
||||||
- A new Notification object
|
- A new Notification object
|
||||||
*/
|
*/
|
||||||
Notification::Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt)
|
Notification::Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt, const util::State& state)
|
||||||
: m_id(id),
|
: m_id(id),
|
||||||
m_recipientUserId(recipientUserId),
|
m_recipientUserId(recipientUserId),
|
||||||
m_recipient(nullptr),
|
m_recipient(nullptr),
|
||||||
m_title(title),
|
m_title(title),
|
||||||
m_message(message),
|
m_message(message),
|
||||||
m_createdAt(createdAt)
|
m_createdAt(createdAt),
|
||||||
|
m_state(state)
|
||||||
{
|
{
|
||||||
int idNumber = util::extractNumber(m_id);
|
int idNumber = util::extractNumber(m_id);
|
||||||
if (idNumber > m_uid)
|
if (idNumber > m_uid)
|
||||||
@@ -234,6 +236,7 @@ SerializedNotification Notification::serialize() const
|
|||||||
strcpy_s(serialized.title, sizeof(serialized.title), m_title.c_str());
|
strcpy_s(serialized.title, sizeof(serialized.title), m_title.c_str());
|
||||||
strcpy_s(serialized.message, sizeof(serialized.message), m_message.c_str());
|
strcpy_s(serialized.message, sizeof(serialized.message), m_message.c_str());
|
||||||
serialized.createdAt = m_createdAt;
|
serialized.createdAt = m_createdAt;
|
||||||
|
serialized.state = m_state;
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,5 +255,6 @@ Notification* Notification::deserialize(const SerializedNotification& serialized
|
|||||||
serializedNotification.recipientUserId,
|
serializedNotification.recipientUserId,
|
||||||
serializedNotification.title,
|
serializedNotification.title,
|
||||||
serializedNotification.message,
|
serializedNotification.message,
|
||||||
serializedNotification.createdAt);
|
serializedNotification.createdAt,
|
||||||
|
serializedNotification.state);
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ Date: 19-May-2026
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
|
#include "Enums.h"
|
||||||
|
|
||||||
class User;
|
class User;
|
||||||
struct SerializedNotification;
|
struct SerializedNotification;
|
||||||
@@ -23,10 +24,11 @@ private:
|
|||||||
std::string m_title;
|
std::string m_title;
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
util::Timestamp m_createdAt;
|
util::Timestamp m_createdAt;
|
||||||
|
util::State m_state;
|
||||||
public:
|
public:
|
||||||
Notification();
|
Notification();
|
||||||
Notification(const std::string& recipientUserId, User* recipient, const std::string& title, const std::string& message, const util::Timestamp& createdAt);
|
Notification(const std::string& recipientUserId, User* recipient, const std::string& title, const std::string& message, const util::Timestamp& createdAt);
|
||||||
Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt);
|
Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt, const util::State& state);
|
||||||
const std::string& getId() const;
|
const std::string& getId() const;
|
||||||
const std::string& getRecipientUserId() const;
|
const std::string& getRecipientUserId() const;
|
||||||
User* getRecipient() const;
|
User* getRecipient() const;
|
||||||
@@ -39,6 +41,8 @@ public:
|
|||||||
void setTitle(const std::string& title);
|
void setTitle(const std::string& title);
|
||||||
void setMessage(const std::string& message);
|
void setMessage(const std::string& message);
|
||||||
void setCreatedAt(const util::Timestamp& createdAt);
|
void setCreatedAt(const util::Timestamp& createdAt);
|
||||||
|
util::State getState();
|
||||||
|
void setState(util::State state);
|
||||||
SerializedNotification serialize() const;
|
SerializedNotification serialize() const;
|
||||||
static Notification* deserialize(const SerializedNotification&);
|
static Notification* deserialize(const SerializedNotification&);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user