summaryrefslogtreecommitdiffhomepage
path: root/logic/tracker.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-12 12:01:59 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-12 12:04:28 +0100
commit359875cf3328fbf8fbfe83fd8c061dd27d836bc2 (patch)
treec6e4ff0afd9a64e9079d857e40ce9191f3aca6b5 /logic/tracker.cpp
parentf3a13f070dee3356f332890a5eeb91c4464fec8d (diff)
logic/tracker: move from header
Diffstat (limited to 'logic/tracker.cpp')
-rw-r--r--logic/tracker.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/logic/tracker.cpp b/logic/tracker.cpp
index 448cb9de..8757e98e 100644
--- a/logic/tracker.cpp
+++ b/logic/tracker.cpp
@@ -30,7 +30,7 @@ using namespace euler;
constexpr double Tracker::r2d;
constexpr double Tracker::d2r;
-Tracker::Tracker(Mappings &m, SelectedLibraries &libs, TrackLogger &logger) :
+Tracker::Tracker(Mappings& m, SelectedLibraries& libs, TrackLogger& logger) :
m(m),
libs(libs),
logger(logger),
@@ -449,3 +449,40 @@ void Tracker::get_raw_and_mapped_poses(double* mapped, double* raw) const
}
}
+
+void bits::set(bits::flags flag_, bool val_)
+{
+ unsigned b_(b);
+ const unsigned flag = unsigned(flag_);
+ const unsigned val = unsigned(!!val_);
+ while (!b.compare_exchange_weak(b_,
+ unsigned((b_ & ~flag) | (flag * val)),
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst))
+ { /* empty */ }
+}
+
+void bits::negate(bits::flags flag_)
+{
+ unsigned b_(b);
+ const unsigned flag = unsigned(flag_);
+ while (!b.compare_exchange_weak(b_,
+ (b_ & ~flag) | (flag & ~b_),
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst))
+ { /* empty */ }
+}
+
+bool bits::get(bits::flags flag)
+{
+ return !!(b & flag);
+}
+
+bits::bits() : b(0u)
+{
+ set(f_center, true);
+ set(f_enabled, true);
+ set(f_zero, false);
+ set(f_tcomp_disabled, false);
+ set(f_should_quit, false);
+}