Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'map/displacement_mode_manager.hpp')
-rw-r--r--map/displacement_mode_manager.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/map/displacement_mode_manager.hpp b/map/displacement_mode_manager.hpp
new file mode 100644
index 0000000000..a86f7846a6
--- /dev/null
+++ b/map/displacement_mode_manager.hpp
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "std/cstdint.hpp"
+#include "std/function.hpp"
+#include "std/mutex.hpp"
+
+// This class should be used as a single point to control whether
+// hotels displacement mode should be activated or not.
+//
+// *NOTE* as the class is thread-safe, the callback should be
+// very-very lightweight and it should be guaranteed that callback or
+// its callees do not call DisplacementModeManager API. Otherwise,
+// deadlock or exception may happen.
+class DisplacementModeManager
+{
+public:
+ using TCallback = function<void(bool show)>;
+
+ enum Slot
+ {
+ SLOT_INTERACTIVE_SEARCH,
+ SLOT_MAP_SELECTION,
+ SLOT_DEBUG,
+ SLOT_COUNT
+ };
+
+ DisplacementModeManager(TCallback && callback);
+
+ void Set(Slot slot, bool show);
+
+private:
+ TCallback m_callback;
+
+ mutex m_mu;
+ uint32_t m_mask;
+
+ static_assert(SLOT_COUNT <= sizeof(m_mask) * CHAR_BIT, "Number of slots is too large");
+};