From e4fc6c25e6c8644865cadab24f8e2d90a8d8e316 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 23 Jul 2017 14:10:12 +0200 Subject: [PATCH] Implement class `SignalVector` It's a templated wrapper for std::vector with an overloaded `operator=` which triggers a signal. --- src/signalvector.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/signalvector.hpp diff --git a/src/signalvector.hpp b/src/signalvector.hpp new file mode 100644 index 000000000..9d39867a9 --- /dev/null +++ b/src/signalvector.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include +#include + +namespace chatterino { + +template +class SignalVector +{ +public: + SignalVector &operator=(std::vector &other) + { + this->data = other; + + this->updated.invoke(); + + return *this; + } + + operator std::vector &() + { + return this->data; + } + + pajlada::Signals::NoArgSignal updated; + +private: + std::vector data; +}; + +} // namespace chatterino