RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
workspace.hpp
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah,
4  Will Cornell Medical College This program is free software: you can
5  redistribute it and/or modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, either version 3 of the
7  License, or (at your option) any later version. This program is distributed
8  in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  See the GNU General Public License for more details. You should have received
11  a copy of the GNU General Public License along with this program. If not,
12  see <http://www.gnu.org/licenses/>.
13 */
14 
15 #ifndef WORKSPACE_H
16 #define WORKSPACE_H
17 
18 #include <utility>
19 
20 #include "daq.hpp"
21 #include "dlplugin.hpp"
22 #include "event.hpp"
23 #include "widgets.hpp"
24 
29 namespace Workspace
30 {
31 
32 /*
33  * Returns a set of functions for generating plugin, component, and panel
34  * classes for a core RTXI widgets
35  *
36  */
37 std::optional<Widgets::FactoryMethods> get_core_plugin_factory(
38  const std::string& plugin_name);
39 
43 class Manager : public Event::Handler
44 {
45 public:
46  Manager(const Manager&) = delete;
47  Manager(Manager&&) = delete;
48  Manager& operator=(const Manager&) = delete;
49  Manager& operator=(Manager&&) = delete;
50  explicit Manager(Event::Manager* ev_manager);
51  ~Manager() override;
52 
61  Widgets::Plugin* loadPlugin(const std::string& library);
62 
68  void unloadPlugin(Widgets::Plugin* plugin);
69 
78  void receiveEvent(Event::Object* event) override;
79 
87  bool isRegistered(const Widgets::Plugin* plugin);
88 
103  std::vector<DAQ::Device*> getDevices(const std::string& driver);
104 
110  std::vector<DAQ::Device*> getAllDevices();
111 
117  void saveSettings(const QString& profile_name);
118 
124  void loadSettings(const QString& profile_name);
125 
126 private:
127  using driver_registry_entry = std::pair<std::string, DAQ::Driver*>;
128  QString settings_prefix;
129  void registerDriver(const std::string& driver_location);
130  void unregisterDriver(const std::string& driver_location);
131 
132  [[nodiscard]] Widgets::Plugin* registerWidget(
133  std::unique_ptr<Widgets::Plugin> widget);
134  void unregisterWidget(Widgets::Plugin* plugin);
135 
136  void registerFactories(const std::string& widget_name,
138  void unregisterFactories(const std::string& widget_name);
139  Widgets::Plugin* loadCorePlugin(const std::string& library);
140 
141  std::unordered_map<std::string, std::vector<std::unique_ptr<Widgets::Plugin>>>
142  rtxi_widgets_registry;
143  std::vector<driver_registry_entry> m_driver_registry;
144  std::unordered_map<std::string, Widgets::FactoryMethods>
145  rtxi_factories_registry;
146  Event::Manager* event_manager;
147  std::unique_ptr<DLL::Loader> m_plugin_loader;
148  std::unique_ptr<DLL::Loader> m_driver_loader;
149 
150  std::mutex m_widgets_mut;
151  std::mutex m_drivers_mut;
152 };
153 
154 } // namespace Workspace
155 
156 #endif // WORKSPACE_H
Manager & operator=(const Manager &)=delete
void saveSettings(const QString &profile_name)
Definition: workspace.cpp:144
void loadSettings(const QString &profile_name)
Definition: workspace.cpp:180
Manager & operator=(Manager &&)=delete
void receiveEvent(Event::Object *event) override
Definition: workspace.cpp:383
~Manager() override
Definition: workspace.cpp:67
bool isRegistered(const Widgets::Plugin *plugin)
Definition: workspace.cpp:92
Manager(Manager &&)=delete
Widgets::Plugin * loadPlugin(const std::string &library)
Definition: workspace.cpp:201
std::vector< DAQ::Device * > getAllDevices()
Definition: workspace.cpp:125
Manager(const Manager &)=delete
std::vector< DAQ::Device * > getDevices(const std::string &driver)
Definition: workspace.cpp:112
void unloadPlugin(Widgets::Plugin *plugin)
Definition: workspace.cpp:268
std::optional< Widgets::FactoryMethods > get_core_plugin_factory(const std::string &plugin_name)
Definition: workspace.cpp:29