From 68790fd7b8c24cf8a7e9132211338d76d2238af5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 24 Oct 2017 11:32:00 +0200 Subject: spline: use default initialization --- spline/axis-opts.cpp | 2 -- spline/axis-opts.hpp | 3 ++- spline/spline.cpp | 15 ++++++--------- spline/spline.hpp | 25 ++++++++++++------------- 4 files changed, 20 insertions(+), 25 deletions(-) (limited to 'spline') diff --git a/spline/axis-opts.cpp b/spline/axis-opts.cpp index 52fe20f5..d7616939 100644 --- a/spline/axis-opts.cpp +++ b/spline/axis-opts.cpp @@ -25,8 +25,6 @@ static max_clamp get_max_y(Axis k) } axis_opts::axis_opts(QString pfx, Axis idx) : - b_settings_window(make_bundle("opentrack-ui")), - b_mapping_window(make_bundle("opentrack-mappings")), zero(b_settings_window, n(pfx, "zero-pos"), 0), src(b_settings_window, n(pfx, "source-index"), idx), invert(b_settings_window, n(pfx, "invert-sign"), false), diff --git a/spline/axis-opts.hpp b/spline/axis-opts.hpp index ad94236c..5581f569 100644 --- a/spline/axis-opts.hpp +++ b/spline/axis-opts.hpp @@ -34,7 +34,8 @@ struct OTR_SPLINE_EXPORT axis_opts final }; // note, these two bundles can be the same value with no issues - bundle b_settings_window, b_mapping_window; + bundle b_settings_window = make_bundle("opentrack-ui"); + bundle b_mapping_window = make_bundle("opentrack-mappings"); value zero; value src; value invert, altp; diff --git a/spline/spline.cpp b/spline/spline.cpp index 2e29997a..e3cd2d6f 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -24,16 +24,13 @@ #include -constexpr int spline::value_count; +using namespace spline_detail; + +constexpr std::size_t spline::value_count; spline::spline(const QString& name, const QString& axis_name, Axis axis) : - s(nullptr), - data(value_count, -16), - _mutex(QMutex::Recursive), ctx(std::make_shared()), - axis(axis), - activep(false), - validp(false) + axis(axis) { set_bundle(options::make_bundle(name), axis_name, axis); } @@ -460,13 +457,13 @@ void spline::ensure_valid(QList& the_points) } // the return value is only safe to use with no spline::set_bundle calls -std::shared_ptr spline::get_settings() +std::shared_ptr spline::get_settings() { QMutexLocker foo(&_mutex); return s; } -std::shared_ptr spline::get_settings() const +std::shared_ptr spline::get_settings() const { QMutexLocker foo(&_mutex); return s; diff --git a/spline/spline.hpp b/spline/spline.hpp index defa80fc..54c53767 100644 --- a/spline/spline.hpp +++ b/spline/spline.hpp @@ -43,7 +43,7 @@ signals: void recomputed() const; }; -} +} // ns spline_detail class OTR_SPLINE_EXPORT spline final { @@ -60,23 +60,20 @@ class OTR_SPLINE_EXPORT spline final std::shared_ptr s; QMetaObject::Connection connection, conn_maxx, conn_maxy; - std::vector data; - using interp_data_t = decltype(data); + static constexpr std::size_t value_count = 4096; - static constexpr int value_count = 4096; + std::vector data = std::vector(value_count, float(-16)); - MyMutex _mutex; + mutex _mutex { mutex::recursive }; QPointF last_input_value; - std::shared_ptr ctx; + std::shared_ptr ctx { std::make_shared() }; - Axis axis; + Axis axis = NonAxis; - bool activep; - bool validp; + bool activep = false; + bool validp = false; public: - using settings = spline_detail::settings; - void invalidate_settings(); void reload(); @@ -108,9 +105,11 @@ public: bundle get_bundle(); void ensure_valid(QList& the_points); - std::shared_ptr get_settings(); - std::shared_ptr get_settings() const; + std::shared_ptr get_settings(); + std::shared_ptr get_settings() const; using points_t = decltype(s->points()); int get_point_count() const; + + using settings = spline_detail::settings; }; -- cgit v1.2.3