Compare commits

..

6 Commits

Author SHA1 Message Date
joelthomastrenser dbc9abae6c notification works 2026-06-16 03:37:29 +05:30
joelthomastrenser 9752a76cb2 Modularize 2026-06-16 03:20:49 +05:30
joelthomastrenser 505753cc77 disable working 2026-06-16 03:07:21 +05:30
joelthomastrenser 384a9b05b1 Somewhat working 2026-06-16 02:52:55 +05:30
joelthomastrenser e054076175 events 2026-06-16 01:54:17 +05:30
joelthomastrenser 329fc6e23f Move sharedmemory/ to core/ 2026-06-15 23:51:21 +05:30
11 changed files with 9 additions and 110 deletions
@@ -153,12 +153,9 @@
<ClCompile Include="core\sharedmemory\SharedMemory.cpp">
<Filter>Source Files\Core\SharedMemory</Filter>
</ClCompile>
<ClCompile Include="core\events\EventManager.cpp">
<ClCompile Include="EventManager.cpp">
<Filter>Source Files\Core\Events</Filter>
</ClCompile>
<ClCompile Include="views\Menu.cpp">
<Filter>Source Files\Views</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="utilities\InputHelper.h">
@@ -290,8 +287,5 @@
<ClInclude Include="core\events\EventManager.h">
<Filter>Header Files\Core\Events</Filter>
</ClInclude>
<ClInclude Include="views\Menu.h">
<Filter>Header Files\Views</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -623,14 +623,6 @@ void Controller::shutdown()
dataStore.shutdown();
}
/*
Function: registerEvents
Description: Registers menu event handles with the authentication
service.
Parameter: HANDLE accountDisabledEvent - account disabled event handle
HANDLE notificationAvailableEvent - notification event handle
Return type: void
*/
void Controller::registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent)
{
m_authenticationManagementService.registerEvents(accountDisabledEvent, notificationAvailableEvent);
@@ -8,6 +8,7 @@ Date:19-May-2026
*/
#include <stdexcept>
#include <iostream>
#include "AuthenticationManagementService.h"
#include "User.h"
#include "Utility.h"
@@ -51,6 +52,7 @@ bool AuthenticationManagementService::login(const std::string& username, const s
},
[]()
{
HANDLE eventHandle = OpenEventA(EVENT_MODIFY_STATE, FALSE, "VehicleServiceSystem_NotificationAvailable");
if (m_notificationsAvailableEvent)
{
SetEvent(m_notificationsAvailableEvent);
@@ -115,16 +117,8 @@ void AuthenticationManagementService::changePassword(const std::string& newPassw
m_dataStore.saveUsers();
}
/*
Function: registerEvents
Description: Registers menu event handles used to notify the active
menu of account disable and notification events.
Parameter: HANDLE accountDisabledEvent - account disabled event handle
HANDLE notificationAvailableEvent - notification event handle
Return type: void
*/
void AuthenticationManagementService::registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent)
void AuthenticationManagementService::registerEvents(HANDLE accountDisabledEvent, HANDLE notifictionAvailableEvent)
{
m_accountDisabledEvent = accountDisabledEvent;
m_notificationsAvailableEvent = notificationAvailableEvent;
m_notificationsAvailableEvent = notifictionAvailableEvent;
}
@@ -153,13 +153,6 @@ bool AdminMenu::handleOperation(int choice)
return true;
}
/*
Function: handleNotificationEvent
Description: Retrieves and displays the latest notification for the
currently logged in admin.
Parameter: None
Return type: void
*/
void AdminMenu::handleNotificationEvent()
{
auto notifications = m_controller.getNotifications();
@@ -11,7 +11,7 @@ Date:19-May-2026
#include "Controller.h"
#include "Menu.h"
class AdminMenu : public Menu
class AdminMenu : Menu
{
private:
bool handleOperation(int choice);
@@ -124,13 +124,6 @@ bool CustomerMenu::handleOperation(int choice)
return true;
}
/*
Function: handleNotificationEvent
Description: Retrieves and displays the latest notification for the
currently logged in admin.
Parameter: None
Return type: void
*/
void CustomerMenu::handleNotificationEvent()
{
auto notifications = m_controller.getNotifications();
@@ -12,7 +12,7 @@ Date:19-May-2026
#include "Menu.h"
#include "Controller.h"
class CustomerMenu : public Menu
class CustomerMenu : Menu
{
private:
bool handleOperation(int choice);
@@ -1,21 +1,5 @@
/*
File: Menu.cpp
Description: Implementation file containing common menu event listener
functionality, account disable handling, and notification
event dispatching for all menu types.
Author: Trenser
Date:16-Jun-2026
*/
#include "Menu.h"
/*
Function: Menu
Description: Constructs a Menu object and initializes event handles
and menu state.
Parameter: None
Return type: None
*/
Menu::Menu()
:
m_isMenuActive(false),
@@ -23,26 +7,11 @@ Menu::Menu()
m_notificationAvailableEvent(NULL),
m_shutdownEvent(NULL) {}
/*
Function: ~Menu
Description: Destroys the Menu object and performs event listener
cleanup.
Parameter: None
Return type: None
*/
Menu::~Menu()
{
stopEventListener();
}
/*
Function: startEventListener
Description: Creates menu event handles, registers them with the
authentication service, and starts the event listener
thread.
Parameter: None
Return type: void
*/
void Menu::startEventListener()
{
if (m_isMenuActive.load())
@@ -57,14 +26,6 @@ void Menu::startEventListener()
m_eventListenerThread = std::thread(&Menu::eventListenerLoop, this);
}
/*
Function: eventListenerLoop
Description: Waits for account disabled, notification available,
and shutdown events and dispatches them to the
appropriate handlers.
Parameter: None
Return type: void
*/
void Menu::eventListenerLoop()
{
HANDLE handles[3];
@@ -88,13 +49,6 @@ void Menu::eventListenerLoop()
}
}
/*
Function: stopEventListener
Description: Stops the event listener thread and releases all
associated event handles.
Parameter: None
Return type: void
*/
void Menu::stopEventListener()
{
m_isMenuActive.store(false);
@@ -123,13 +77,6 @@ void Menu::stopEventListener()
m_shutdownEvent = NULL;
}
/*
Function: handleAccountDisabledEvent
Description: Handles an account disabled event by marking the menu
inactive and notifying the user.
Parameter: None
Return type: void
*/
void Menu::handleAccountDisabledEvent()
{
m_isMenuActive.store(false);
@@ -1409,14 +1409,6 @@ inline std::string selectComboPackage(util::Map<std::string, const ComboPackage*
}
}
/*
Function: displayNewNotification
Description: Displays the most recent notification from the supplied
notification collection.
Parameter: util::Vector<const Notification*> notifications -
collection of notifications
Return type: void
*/
inline void displayNewNotification(util::Vector<const Notification*> notifications)
{
const Notification* notification = nullptr;
@@ -51,6 +51,7 @@ void TechnicianMenu::showMenu()
{
break;
}
stopEventListener();
}
catch (const std::exception& e)
{
@@ -98,13 +99,6 @@ bool TechnicianMenu::handleOperation(int choice)
return true;
}
/*
Function: handleNotificationEvent
Description: Retrieves and displays the latest notification for the
currently logged in admin.
Parameter: None
Return type: void
*/
void TechnicianMenu::handleNotificationEvent()
{
auto notifications = m_controller.getNotifications();
@@ -11,7 +11,7 @@ Date:19-May-2026
#include "Controller.h"
#include "Menu.h"
class TechnicianMenu : public Menu
class TechnicianMenu : Menu
{
private:
bool handleOperation(int choice);