Loading...
Searching...
No Matches
Unsubscribable.h
Go to the documentation of this file.
1//
2// Unsubscribable.h
3//
4
5#ifndef UNSUBSCRIBABLE_H
6#define UNSUBSCRIBABLE_H
7
8#pragma once
9
12namespace ml
13{
46 {
47 public:
60 template<typename EnumType>
61 void unsubscribe(EnumType event)
62 {
63 static_assert(std::is_enum_v<EnumType>,
64 "[Malena] unsubscribe — argument must be an enum value.");
65 doUnsubscribe(EnumKey::get(event));
66 }
67
68
79
80 virtual ~Unsubscribable() = default;
81 private:
82 void doUnsubscribe(const std::string& key);
83 };
84
85} // namespace ml
86#include "../../../src/Traits/Unsubscribable.tpp"
87#endif // 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
Definition Component.h:18
static std::string get(EnumType value)
Generate a unique string key for an enum value.
Definition EnumKey.h:63