Loading...
Searching...
No Matches
Unsubscribable.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4//
5// Unsubscribable.h
6//
7
8#ifndef MALENA_UNSUBSCRIBABLE_H
9#define MALENA_UNSUBSCRIBABLE_H
10
11#pragma once
12
13
16namespace ml
17{
50 {
51 public:
64 template<typename EnumType>
65 void unsubscribe(EnumType event)
66 {
67 static_assert(std::is_enum_v<EnumType>,
68 "[Malena] unsubscribe — argument must be an enum value.");
69 doUnsubscribe(EnumKey::get(event));
70 }
71
72
83
84 virtual ~Unsubscribable() = default;
85 private:
86 void doUnsubscribe(const std::string& key);
87 };
88
89} // namespace ml
90
91#endif // MALENA_UNSUBSCRIBABLE_H
Trait that gives components the ability to unsubscribe from events.
void unsubscribe(EnumType event)
Unsubscribe from a single event by enum value.
void unsubscribeAll()
Remove all event subscriptions for this component.
virtual ~Unsubscribable()=default
#define MALENA_API
Definition Component.h:22
static std::string get(EnumType value)
Generate a unique string key for an enum value.
Definition EnumKey.h:67