Debian Codegraph @

include/ui/iuserinterface.h

raw
1 #pragma once
2
3 #include "imodule.h"
4 #include "iusercontrol.h"
5
6 namespace ui
7 {
8
9 /**
10 * @brief Module responsible for creating all dockable UI panels.
11 *
12 * This is a dynamically populated factory object which maintains a map of
13 * IUserControlCreator objects indexed by name, each of which can create a dock widget of a
14 * specific type. Any part of the code (including plugins) can register new control
15 * creators.
16 */
17 class IUserInterfaceModule: public RegisterableModule
18 {
19 public:
20 ~IUserInterfaceModule() override {}
21
22 // Runs the specified action in the UI thread
23 // this happens when the application has a chance to, usually during event processing
24 // This method is safe to be called from any thread.
25 virtual void dispatch(const std::function<void()>& action) = 0;
26
27 /**
28 * @brief Register a new control
29 *
30 * After registration, clients can acquire the control by invoking the findControl()
31 * method.
32 */
33 virtual void registerControl(IUserControlCreator::Ptr control) = 0;
34
35 /**
36 * @brief Lookup a control creator by name
37 *
38 * @param name
39 * The name of the control creator, which was exposed via the
40 * IUserControlCreator::getControlName() method.
41 *
42 * @return IUserControlCreator::Ptr
43 * Pointer to the matching control creator, or null if no control creator with this name
44 * could be found.
45 */
46 virtual IUserControlCreator::Ptr findControl(const std::string& name) = 0;
47
48 /**
49 * Unregisters the named control. Does nothing if the name is not registered.
50 */
51 virtual void unregisterControl(const std::string& controlName) = 0;
52
53 /**
54 * Iterate over all registered control names
55 */
56 virtual void foreachControl(const std::function<void(const std::string&)>& functor) = 0;
57 };
58
59 }
60
61 constexpr const char* const MODULE_USERINTERFACE = "UserInterfaceModule";
62
63 // The accessor function
64 inline ui::IUserInterfaceModule& GlobalUserInterface()
65 {
66 static module::InstanceReference<ui::IUserInterfaceModule> _reference(MODULE_USERINTERFACE);
67 return _reference;
68 }