summaryrefslogtreecommitdiffhomepage
path: root/options/connector.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'options/connector.hpp')
-rw-r--r--options/connector.hpp50
1 files changed, 14 insertions, 36 deletions
diff --git a/options/connector.hpp b/options/connector.hpp
index 5091ae67..025efda2 100644
--- a/options/connector.hpp
+++ b/options/connector.hpp
@@ -8,64 +8,42 @@
#pragma once
-#include <map>
+#include "compat/qhash.hpp"
+
+#include <unordered_map>
#include <vector>
-#include <tuple>
-#include <typeinfo>
-#include <typeindex>
-#include <QVariant>
+
#include <QString>
#include <QMutex>
-#include <QMutexLocker>
#include "export.hpp"
namespace options {
+ class value_;
+}
-class base_value;
-
-namespace detail {
+namespace options::detail {
class OTR_OPTIONS_EXPORT connector
{
- friend class ::options::base_value;
+ friend class ::options::value_;
- using value_type = base_value*;
+ using value_type = value_*;
using value_vec = std::vector<value_type>;
- using comparator = bool(*)(const QVariant&, const QVariant&);
- using tt = std::tuple<value_vec, comparator, std::type_index>;
- std::map<QString, tt> connected_values;
+ std::unordered_map<QString, value_vec> connected_values;
- void on_value_destructed(const QString& name, value_type val);
- void on_value_created(const QString& name, value_type val);
- bool on_value_destructed_impl(const QString& name, value_type val);
+ void on_value_destructed(value_type val);
+ void on_value_created(value_type val);
protected:
void notify_values(const QString& name) const;
void notify_all_values() const;
virtual QMutex* get_mtx() const = 0;
-
- template<typename F>
- void forall(F&& fun)
- {
- QMutexLocker l(get_mtx());
-
- for (auto& pair : connected_values)
- for (auto& val : std::get<0>(pair.second))
- fun(pair.first, val);
- }
+ void set_all_to_default_();
public:
connector();
virtual ~connector();
-
- bool is_equal(const QString& name, const QVariant& val1, const QVariant& val2) const;
-
- connector(const connector&) = default;
- connector& operator=(const connector&) = default;
- connector(connector&&) = default;
- connector& operator=(connector&&) = default;
};
-} // ns detail
-} // ns options
+} // ns options::detail