diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-02-03 12:06:50 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-02-09 12:13:24 +0100 |
commit | 195767619e7a7aeeeb33b13420538f687bef0104 (patch) | |
tree | 5701f484f4b8bff13452a192deab76e70ae91196 /logic/state.cpp | |
parent | e5fdc0dad2609d89dc2a1294ea1c232c33e64785 (diff) |
opentrack: move module list to base class
Diffstat (limited to 'logic/state.cpp')
-rw-r--r-- | logic/state.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/logic/state.cpp b/logic/state.cpp new file mode 100644 index 00000000..afdf5b12 --- /dev/null +++ b/logic/state.cpp @@ -0,0 +1,45 @@ +#include "state.hpp" + +#include <iterator> + +using dylib_ptr = Modules::dylib_ptr; +using dylib_list = Modules::dylib_list; + +std::tuple<dylib_ptr, int> State::module_by_name(const QString& name, dylib_list& list) +{ + auto it = std::find_if(list.cbegin(), list.cend(), [&name](const dylib_ptr& lib) { + if (!lib) + return name.isEmpty(); + else + return name == lib->module_name; + }); + + if (it == list.cend()) + return { nullptr, -1 }; + else + return { *it, int(std::distance(list.cbegin(), it)) }; +} + +State::State(const QString& library_path) : + modules(library_path), + ev(modules.extensions()), + pose(s.all_axis_opts) +{} + +dylib_ptr State::current_tracker() +{ + auto [ptr, idx] = module_by_name(m.tracker_dll, modules.trackers()); + return ptr; +} + +dylib_ptr State::current_protocol() +{ + auto [ptr, idx] = module_by_name(m.protocol_dll, modules.protocols()); + return ptr; +} + +dylib_ptr State::current_filter() +{ + auto [ptr, idx] = module_by_name(m.filter_dll, modules.filters()); + return ptr; +} |