summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-02 08:20:47 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-02 09:34:17 +0200
commitf2faf7acf4445fef2a149ebbdecb569a2d119d94 (patch)
tree6629ba211a70a54a0ab82f6c4f4de08504072951 /options
parent66e75860d0c54baa39ed789442b09b96eeebe2e6 (diff)
nothing important
Diffstat (limited to 'options')
-rw-r--r--options/base-value.cpp4
-rw-r--r--options/bundle.cpp19
-rw-r--r--options/bundle.hpp51
-rw-r--r--options/connector.cpp7
-rw-r--r--options/connector.hpp9
-rw-r--r--options/defs.hpp5
-rw-r--r--options/slider.cpp15
-rw-r--r--options/slider.hpp2
-rw-r--r--options/value-traits.hpp7
9 files changed, 67 insertions, 52 deletions
diff --git a/options/base-value.cpp b/options/base-value.cpp
index dbeabbea..d900ad0f 100644
--- a/options/base-value.cpp
+++ b/options/base-value.cpp
@@ -26,8 +26,7 @@ void value_::store(const QVariant& datum)
b->store_kv(self_name, datum);
}
-namespace options {
-namespace detail {
+namespace options::detail {
void set_base_value_to_default(value_* val)
{
@@ -35,5 +34,4 @@ void set_base_value_to_default(value_* val)
}
} // ns options::detail
-} // ns options
diff --git a/options/bundle.cpp b/options/bundle.cpp
index e0db3fb3..b722338b 100644
--- a/options/bundle.cpp
+++ b/options/bundle.cpp
@@ -14,10 +14,7 @@
using options::value_;
-namespace options
-{
-
-namespace detail {
+namespace options::detail {
bundle::bundle(const QString& group_name)
: mtx(QMutex::Recursive),
@@ -152,7 +149,7 @@ void bundler::after_profile_changed_()
void bundler::refresh_all_bundles()
{
- singleton().after_profile_changed_();
+ bundler_singleton().after_profile_changed_();
}
bundler::bundler() : implsgl_mtx(QMutex::Recursive)
@@ -164,7 +161,7 @@ bundler::~bundler()
//qDebug() << "exit: bundle singleton";
}
-std::shared_ptr<bundler::v> bundler::make_bundle(const bundler::k& key)
+std::shared_ptr<bundler::v> bundler::make_bundle_(const bundler::k& key)
{
QMutexLocker l(&implsgl_mtx);
@@ -193,7 +190,7 @@ std::shared_ptr<bundler::v> bundler::make_bundle(const bundler::k& key)
return shr;
}
-OTR_OPTIONS_EXPORT bundler& singleton()
+bundler& bundler::bundler_singleton()
{
static bundler ret;
return ret;
@@ -201,14 +198,16 @@ OTR_OPTIONS_EXPORT bundler& singleton()
QMutex* bundle::get_mtx() const { return mtx; }
-} // end options::detail
+} // ns options::detail
+
+namespace options {
OTR_OPTIONS_EXPORT std::shared_ptr<bundle_> make_bundle(const QString& name)
{
if (name.size())
- return detail::singleton().make_bundle(name);
+ return detail::bundler::bundler_singleton().make_bundle_(name);
else
return std::make_shared<bundle_>(QString());
}
-} // end options
+} // ns options
diff --git a/options/bundle.hpp b/options/bundle.hpp
index 98e194db..a12a335c 100644
--- a/options/bundle.hpp
+++ b/options/bundle.hpp
@@ -27,11 +27,17 @@
#include "export.hpp"
-namespace options {
+namespace options::detail {
+ class bundle;
+} // ns options::detail
-namespace detail {
+namespace options {
+ using bundle_ = detail::bundle;
+ using bundle = std::shared_ptr<bundle_>;
+ OTR_OPTIONS_EXPORT std::shared_ptr<detail::bundle> make_bundle(const QString& name);
+} // ns options
-void set_base_value_to_default(value_* val);
+namespace options::detail {
struct bundler;
@@ -52,17 +58,18 @@ private:
group saved;
group transient;
+signals:
+ void reloading();
+ void saving() const;
+ void changed() const;
+
+public:
bundle(const bundle&) = delete;
bundle(bundle&&) = delete;
bundle& operator=(bundle&&) = delete;
bundle& operator=(const bundle&) = delete;
QMutex* get_mtx() const override;
-signals:
- void reloading();
- void saving() const;
- void changed() const;
-public:
cc_noinline bundle(const QString& group_name);
cc_noinline ~bundle() override;
QString name() const { return group_name; }
@@ -82,32 +89,34 @@ public slots:
void set_all_to_default();
};
-OTR_OPTIONS_EXPORT bundler& singleton();
-
-struct OTR_OPTIONS_EXPORT bundler
+struct OTR_OPTIONS_EXPORT bundler final
{
-public:
using k = QString;
using v = bundle;
using weak = std::weak_ptr<v>;
using shared = std::shared_ptr<v>;
+
private:
QMutex implsgl_mtx;
std::map<k, weak> implsgl_data;
void after_profile_changed_();
+
public:
+ static void refresh_all_bundles();
+
+private:
+ friend OTR_OPTIONS_EXPORT
+ std::shared_ptr<v> options::make_bundle(const QString& name);
+
+ std::shared_ptr<v> make_bundle_(const k& key);
+
+ static bundler& bundler_singleton();
+
bundler();
~bundler();
- std::shared_ptr<v> make_bundle(const k& key);
- static void refresh_all_bundles();
};
-OTR_OPTIONS_EXPORT bundler& singleton();
-} // ns options::detail
-
-using bundle_ = detail::bundle;
-using bundle = std::shared_ptr<bundle_>;
+void set_base_value_to_default(value_* val);
-OTR_OPTIONS_EXPORT std::shared_ptr<bundle_> make_bundle(const QString& name);
+} // ns options::detail
-} // ns options
diff --git a/options/connector.cpp b/options/connector.cpp
index 2d039ccf..0efac8f1 100644
--- a/options/connector.cpp
+++ b/options/connector.cpp
@@ -11,8 +11,7 @@
#include <utility>
-namespace options {
-namespace detail {
+namespace options::detail {
static bool generic_is_equal(const QVariant& val1, const QVariant& val2)
{
@@ -129,6 +128,4 @@ connector::connector()
{
}
-}
-
-}
+} // ns options::detail
diff --git a/options/connector.hpp b/options/connector.hpp
index 68e86096..26812e7f 100644
--- a/options/connector.hpp
+++ b/options/connector.hpp
@@ -21,10 +21,10 @@
#include "export.hpp"
namespace options {
+ class value_;
+}
-class value_;
-
-namespace detail {
+namespace options::detail {
class OTR_OPTIONS_EXPORT connector
{
@@ -67,5 +67,4 @@ public:
connector& operator=(connector&&) = default;
};
-} // ns detail
-} // ns options
+} // ns options::detail
diff --git a/options/defs.hpp b/options/defs.hpp
index 58846cc3..2467a7a0 100644
--- a/options/defs.hpp
+++ b/options/defs.hpp
@@ -24,8 +24,7 @@
#define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_DEFINE_METATYPE2(t, __COUNTER__)
-namespace options {
-namespace detail {
+namespace options::detail {
struct custom_type_initializer final
{
@@ -39,4 +38,4 @@ struct custom_type_initializer final
};
} // ns options::detail
-} // ns options
+
diff --git a/options/slider.cpp b/options/slider.cpp
index 4f4124c6..56d9ba16 100644
--- a/options/slider.cpp
+++ b/options/slider.cpp
@@ -24,8 +24,21 @@ slider_value::slider_value(double cur, double min, double max) :
cur_ = min_;
}
-slider_value::slider_value(const slider_value& v) : slider_value(v.cur(), v.min(), v.max())
+slider_value& slider_value::operator=(const slider_value& v)
{
+ if (this != &v)
+ {
+ cur_ = v.cur();
+ min_ = v.min();
+ max_ = v.max();
+ }
+
+ return *this;
+}
+
+slider_value::slider_value(const slider_value& v)
+{
+ *this = v;
}
slider_value::slider_value() : slider_value(0, 0, 0)
diff --git a/options/slider.hpp b/options/slider.hpp
index 6c9c5a23..360c85b8 100644
--- a/options/slider.hpp
+++ b/options/slider.hpp
@@ -40,6 +40,8 @@ namespace options
return t(cur_);
}
+ slider_value& operator=(const slider_value& v);
+
slider_value(const slider_value& v);
slider_value();
bool operator==(const slider_value& v) const;
diff --git a/options/value-traits.hpp b/options/value-traits.hpp
index 0b30248e..b507874c 100644
--- a/options/value-traits.hpp
+++ b/options/value-traits.hpp
@@ -8,8 +8,7 @@
#include <type_traits>
-namespace options {
-namespace detail {
+namespace options::detail {
template<typename t, typename u = t, typename Enable = void>
struct default_value_traits
@@ -49,5 +48,5 @@ struct value_traits<float> : public default_value_traits<float, double, void>
{
};
-} // ns detail
-} // ns options
+} // ns options::detail
+