EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
ActionControllerBase.hpp
Go to the documentation of this file.
1
9
10#ifndef ECHOMAP_ACTIONCONTROLLERBASE_HPP
11#define ECHOMAP_ACTIONCONTROLLERBASE_HPP
12
13#include <sigc++/slot.h>
14
15#include <filesystem>
16
18#include "../utility/Logger.hpp"
20
21namespace echomap
22{
23
28
34
40
60template <typename Derived> class ActionControllerBase
61{
62 using CallbackT = sigc::slot<void(const Notification&)>;
63 static CallbackT callback;
64
65public:
71 static void bind(
72 CallbackT&& bound_callback
73 )
74 {
75 callback = std::move(bound_callback);
76 }
77
83 static void unbind()
84 {
85 callback.disconnect();
86 }
87
93 static void select_project_file()
94 {
95 Derived::select_project_file_impl();
96 }
97
107 const std::size_t project_id,
108 const std::filesystem::path& external
109 )
110 {
111 Derived::register_vfs_mapping_impl(project_id, external);
112 }
113
114protected:
124 template <
125 class NotificationT,
126 class... Args>
128 NotificationT,
130 static void notify(
131 Args&&... args
132 )
133 {
134 if (callback.empty())
136 "Dropping {} due to unbound application instance.", NotificationNames::get<NotificationT>()
137 );
138 else
139 callback(NotificationT(std::forward<Args>(args)...));
140 }
141};
142
143template <typename Derived> ActionControllerBase<Derived>::CallbackT ActionControllerBase<Derived>::callback{};
144
145} // namespace echomap
146
147#endif // ECHOMAP_ACTIONCONTROLLERBASE_HPP
AllNotifications specification.
EchoMap portable logger specification.
#define LOG_F_WARN(msg,...)
Logs a formatted warning-level message using echomap::Logger::log_f.
Definition Logger.hpp:115
VariantHelpers specification.
Provides a platform-independent static mechanism for performing "system actions", such as raising a f...
static void notify(Args &&... args)
Invokes the notification callback.
Constrains a type to be one of the alternatives of a std::variant.
T forward(T... args)
static void unbind()
Disconnect the callback.
static void bind(CallbackT &&bound_callback)
Bind the callback slot.
std::variant< AddChannelMappingNotification, ModifySensorColourNotification, ModifySensorPositionNotification, ProjectSelectionCompleteNotification, ClearErrorNotification, RaiseFileChooserNotification, RegisterVFSMappingNotification, CompleteProjectLoadNotification, CancelProjectLoadNotification > Notification
A Notification is a trivial message sent exclusively to the EchoMap controller.
static void select_project_file()
Invokes the Project File Action.
static void register_vfs_mapping(const std::size_t project_id, const std::filesystem::path &external)
Invokes the Register VFS Mapping.
The main EchoMap outermost namespace for all non-exported symbols.
static constexpr std::string_view get()
Retrieve a human-readable name for the templated Notification.