GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
Recreator.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace gui_framework
7{
10 {
11 private:
12 json::JSONParser windowedApplicationStructure;
13
14 public:
15 Recreator(const std::filesystem::path& pathToJSON);
16
17 Recreator(const std::string& json);
18
19 template<typename MainWindowT, typename... Args> requires (std::is_base_of_v<BaseMainWindow, MainWindowT>)
20 std::unique_ptr<MainWindowT> deserialize(Args&&... args) const;
21
22 ~Recreator() = default;
23 };
24
25 template<typename MainWindowT, typename... Args> requires (std::is_base_of_v<BaseMainWindow, MainWindowT>)
26 std::unique_ptr<MainWindowT> Recreator::deserialize(Args&&... args) const
27 {
28 const auto& [componentName, description] = *windowedApplicationStructure.begin();
29 std::unique_ptr<MainWindowT> mainWindow = std::make_unique<MainWindowT>(std::forward<Args>(args)...);
30
31 deserializers::MainWindowDeserializer().deserialize(componentName, get<json::utility::jsonObject>(description), mainWindow);
32
33 return mainWindow;
34 }
35}
#define GUI_FRAMEWORK_API
Used for recreation windowed application from JSON.
Definition Recreator.h:10
Recreator(const std::filesystem::path &pathToJSON)
std::unique_ptr< MainWindowT > deserialize(Args &&... args) const
Definition Recreator.h:26
Recreator(const std::string &json)
void deserialize(const std::string &componentName, const json::utility::jsonObject &description, std::unique_ptr< MainWindowT > &mainWindow) const
MainWindow has no parent, you must manage the pointer.