mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 04:51:49 +00:00
fix world previews generation
This commit is contained in:
parent
acea4604fe
commit
6bc549dd90
5 changed files with 38 additions and 25 deletions
28
src/util/CallbacksSet.hpp
Normal file
28
src/util/CallbacksSet.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
template<typename... Args>
|
||||
class CallbacksSet {
|
||||
public:
|
||||
using Func = std::function<void(Args...)>;
|
||||
private:
|
||||
std::unique_ptr<std::vector<Func>> callbacks;
|
||||
public:
|
||||
void listen(const Func& callback) {
|
||||
if (callbacks == nullptr) {
|
||||
callbacks = std::make_unique<std::vector<Func>>();
|
||||
}
|
||||
callbacks->push_back(callback);
|
||||
}
|
||||
|
||||
void notify(Args&&... args) {
|
||||
if (callbacks) {
|
||||
for (auto& callback : *callbacks) {
|
||||
callback(std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue