mirror-chatterino2/src/signalvector.hpp
Rasmus Karlsson e4fc6c25e6 Implement class SignalVector
It's a templated wrapper for std::vector with an overloaded `operator=`
which triggers a signal.
2017-07-23 14:10:12 +02:00

34 lines
513 B
C++

#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