mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Implement class SignalVector
It's a templated wrapper for std::vector with an overloaded `operator=` which triggers a signal.
This commit is contained in:
parent
9ccfff69d9
commit
e4fc6c25e6
34
src/signalvector.hpp
Normal file
34
src/signalvector.hpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
template <typename TValue>
|
||||||
|
class SignalVector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SignalVector &operator=(std::vector<TValue> &other)
|
||||||
|
{
|
||||||
|
this->data = other;
|
||||||
|
|
||||||
|
this->updated.invoke();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator std::vector<TValue> &()
|
||||||
|
{
|
||||||
|
return this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
pajlada::Signals::NoArgSignal updated;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<TValue> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
Loading…
Reference in a new issue