From 310ca879118282f25b6cb2ae681627934278607a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Nov 2018 06:48:51 +0100 Subject: fix some mixin stuff, still not done --- main-window/mixin-traits.cpp | 19 ++++++++++--------- main-window/mixin-traits.hpp | 13 ++++--------- main-window/module-mixin.cpp | 35 ++++++++++++++--------------------- main-window/module-mixin.hpp | 22 ++++++++-------------- main-window/tracking-mixin.cpp | 5 ----- main-window/tracking-mixin.hpp | 19 ------------------- 6 files changed, 36 insertions(+), 77 deletions(-) delete mode 100644 main-window/tracking-mixin.cpp delete mode 100644 main-window/tracking-mixin.hpp (limited to 'main-window') diff --git a/main-window/mixin-traits.cpp b/main-window/mixin-traits.cpp index 5dc2efd8..b74a6f7a 100644 --- a/main-window/mixin-traits.cpp +++ b/main-window/mixin-traits.cpp @@ -43,16 +43,17 @@ void test1() struct W : C, A {}; struct Q : virtual W, virtual D {}; -#if 0 - (void)impl(); // W not a mixin - (void)impl(); // A - (void)impl(); // D => C => A - (void)impl(); // D => C => A - (void)impl(); // B +//#define SHOULD_NOT_COMPILE +#ifdef SHOULD_NOT_COMPILE + (void)impl{}; // W not a mixin + (void)impl{}; // A + (void)impl{}; // D => C => A + (void)impl{}; // D => C => A + (void)impl{}; // B #else - (void)impl(); - (void)impl(); - (void)impl(); + (void)impl{}; + (void)impl{}; + (void)impl{}; #endif } diff --git a/main-window/mixin-traits.hpp b/main-window/mixin-traits.hpp index 6a0206fc..45df7fdb 100644 --- a/main-window/mixin-traits.hpp +++ b/main-window/mixin-traits.hpp @@ -13,11 +13,7 @@ namespace mixins::traits_detail { template struct mixin_traits { // implement this! - using depends = tuple<>; - - // unconditional but at instantiation time - static_assert(sizeof(t) < sizeof(char), - "must specialize mixin_traits"); + //using depends = tuple<>; }; template struct check_depends_; @@ -31,7 +27,7 @@ namespace mixins::traits_detail { struct check_depends_ : std::bool_constant< std::is_base_of_v && - lift::depends>>::value && + lift_v::depends>> && check_depends_::value > { @@ -40,8 +36,7 @@ namespace mixins::traits_detail { template struct impl { - static constexpr bool class_must_inherit_dependent_mixins = - lift>::value; - static_assert(class_must_inherit_dependent_mixins); + static_assert(lift>::value, + "class must inherit dependent mixins"); }; } // ns mixins::traits_detail diff --git a/main-window/module-mixin.cpp b/main-window/module-mixin.cpp index 8d36cb0d..18b2867d 100644 --- a/main-window/module-mixin.cpp +++ b/main-window/module-mixin.cpp @@ -62,7 +62,7 @@ static bool mk_dialog(std::unique_ptr& place, const std::shared_ptr& l if (lib && lib->Dialog) return u{ (t*)lib->Dialog() }; else - return nullptr; + return u{}; }); } @@ -84,39 +84,34 @@ dylib_ptr module_mixin::current_filter() return ptr; } -void module_mixin::show_tracker_settings() +void module_mixin::show_tracker_settings_() { -#if 0 - if (mk_dialog(tracker_dialog, current_tracker()) && work && work->libs.pTracker) - tracker_dialog->register_tracker(work->libs.pTracker.get()); + if (mk_dialog(tracker_dialog, current_tracker()) && state.work && state.work->libs.pTracker) + tracker_dialog->register_tracker(state.work->libs.pTracker.get()); if (tracker_dialog) QObject::connect(tracker_dialog.get(), &ITrackerDialog::closing, - this, [this] { tracker_dialog = nullptr; }); -#endif + &fuzz, [this] { tracker_dialog = nullptr; }); } -void module_mixin::show_proto_settings() +void module_mixin::show_proto_settings_() { -#if 0 - if (mk_dialog(proto_dialog, current_protocol()) && work && work->libs.pProtocol) - proto_dialog->register_protocol(work->libs.pProtocol.get()); + if (mk_dialog(proto_dialog, current_protocol()) && state.work && state.work->libs.pProtocol) + proto_dialog->register_protocol(state.work->libs.pProtocol.get()); if (proto_dialog) QObject::connect(proto_dialog.get(), &IProtocolDialog::closing, - this, [this] { proto_dialog = nullptr; }); -#endif + &fuzz, [this] { proto_dialog = nullptr; }); } -void module_mixin::show_filter_settings() +void module_mixin::show_filter_settings_() { -#if 0 - if (mk_dialog(filter_dialog, current_filter()) && work && work->libs.pFilter) - filter_dialog->register_filter(work->libs.pFilter.get()); + if (mk_dialog(filter_dialog, current_filter()) && state.work && state.work->libs.pFilter) + filter_dialog->register_filter(state.work->libs.pFilter.get()); if (filter_dialog) QObject::connect(filter_dialog.get(), &IFilterDialog::closing, - this, [this] { filter_dialog = nullptr; }); -#endif + &fuzz, [this] { filter_dialog = nullptr; }); } +// this template function must go to a separate function like "options_mixin". template static bool mk_window(std::unique_ptr& place, Args&&... params) { @@ -128,6 +123,4 @@ static bool mk_window(std::unique_ptr& place, Args&&... params) module_mixin::module_mixin() = default; module_mixin::~module_mixin() = default; -module_settings::module_settings() = default; - } // ns diff --git a/main-window/module-mixin.hpp b/main-window/module-mixin.hpp index 307d79b8..cde0484c 100644 --- a/main-window/module-mixin.hpp +++ b/main-window/module-mixin.hpp @@ -4,13 +4,13 @@ #include "compat/library-path.hpp" #include "api/plugin-api.hpp" #include "logic/extensions.hpp" -#include "logic/work.hpp" +#include "logic/state.hpp" +#include "logic/main-settings.hpp" #include #include #include -#include namespace OTR_MIXIN_NS(module_mixin) { @@ -19,15 +19,6 @@ using namespace options; using dylib_ptr = Modules::dylib_ptr; using dylib_list = Modules::dylib_list; -struct OTR_MAIN_EXPORT module_settings final -{ - bundle b { make_bundle("modules") }; - value tracker_dll { b, "tracker-dll", "pt" }, - filter_dll { b, "filter-dll", "accela" }, - protocol_dll { b, "protocol-dll", "freetrack" }; - module_settings(); -}; - struct OTR_MAIN_EXPORT module_mixin { module_mixin(); @@ -43,14 +34,17 @@ struct OTR_MAIN_EXPORT module_mixin dylib_ptr current_protocol(); dylib_ptr current_filter(); - void show_tracker_settings(); - void show_proto_settings(); - void show_filter_settings(); + void show_tracker_settings_(); + void show_proto_settings_(); + void show_filter_settings_(); private: Modules modules { OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH }; event_handler ev { modules.extensions() }; module_settings s; + State state { OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH }; + + QObject fuzz; }; } diff --git a/main-window/tracking-mixin.cpp b/main-window/tracking-mixin.cpp deleted file mode 100644 index 1ec6f3d5..00000000 --- a/main-window/tracking-mixin.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "tracking-mixin.hpp" - -using namespace OTR_MIXIN_NS(tracking_mixin); - -has_work::has_work::~has_work() = default; diff --git a/main-window/tracking-mixin.hpp b/main-window/tracking-mixin.hpp deleted file mode 100644 index e48ca630..00000000 --- a/main-window/tracking-mixin.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "mixins.hpp" - -#include "logic/work.hpp" - -#include - -namespace OTR_MIXIN_NS(tracking_mixin) { - -using work_ptr = std::shared_ptr; - -struct OTR_MAIN_EXPORT has_work { - virtual explicit operator work_ptr() = 0; - inline has_work() = default; - virtual ~has_work(); -}; - -} -- cgit v1.2.3