ADD: Adds class function to participant to disconnect itself from the event manager. #4

Merged
byterazor merged 1 commits from csander/EventManagementSystem:main into main 2022-12-22 15:09:36 +01:00
2 changed files with 15 additions and 0 deletions

View File

@ -162,6 +162,11 @@
*/
void disconnect(std::shared_ptr<EventManager::Participant> participant);
/**
* @brief disconnect this participant from the event manager
*/
void disconnect();
public:
/**
* @brief Constructor setting the participant up for use

View File

@ -40,6 +40,16 @@ void EventManager::Participant::disconnect(std::shared_ptr<EventManager::Partici
}
void EventManager::Participant::disconnect()
{
if (manager_ == nullptr)
{
throw std::runtime_error("no event manager set yet");
}
manager_->disconnect(shared_from_this());
}
void EventManager::Participant::emit(std::shared_ptr<EventManager::Event> event)
{
{