summaryrefslogtreecommitdiffhomepage
path: root/options/connector.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-10-05 15:54:01 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-10-05 14:35:29 +0000
commitf0216a3c53d43918295f1bd81975b391f4e5ed3b (patch)
treeb6311d48559bbdb4b657beed1bd8164d9157b03f /options/connector.hpp
parent39ea3871c1b3f594df846bc0b9a627c9880ecea4 (diff)
options: don't use typeindex w/ lambdas
Rename traits' functions to be more explicit. Most of the changes are pretty old and I can't read them at this time, sorry. Adjust usages. Issue: #825 Reported-by: @DanielKinsman
Diffstat (limited to 'options/connector.hpp')
-rw-r--r--options/connector.hpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/options/connector.hpp b/options/connector.hpp
index 26812e7f..11aa94da 100644
--- a/options/connector.hpp
+++ b/options/connector.hpp
@@ -8,15 +8,13 @@
#pragma once
-#include <map>
+#include <unordered_map>
#include <vector>
-#include <tuple>
-#include <typeinfo>
-#include <typeindex>
-#include <QVariant>
+
#include <QString>
#include <QMutex>
-#include <QMutexLocker>
+
+#include "compat/qhash.hpp"
#include "export.hpp"
@@ -32,13 +30,10 @@ class OTR_OPTIONS_EXPORT connector
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;
@@ -51,20 +46,16 @@ protected:
QMutexLocker l(get_mtx());
for (auto& pair : connected_values)
- for (auto& val : std::get<0>(pair.second))
- fun(pair.first, val);
+ for (auto& val : pair.second)
+ fun(val);
}
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 options::detail