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
3
#include "
BaseComposites/StandardComposites/BaseMainWindow.h
"
4
#include "
Deserializers/Composites/MainWindowDeserializer.h
"
5
6
namespace
gui_framework
7
{
9
class
GUI_FRAMEWORK_API
Recreator
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
}
BaseMainWindow.h
GUI_FRAMEWORK_API
#define GUI_FRAMEWORK_API
Definition
GUIFrameworkConstants.h:103
MainWindowDeserializer.h
gui_framework::Recreator
Used for recreation windowed application from JSON.
Definition
Recreator.h:10
gui_framework::Recreator::Recreator
Recreator(const std::filesystem::path &pathToJSON)
gui_framework::Recreator::deserialize
std::unique_ptr< MainWindowT > deserialize(Args &&... args) const
Definition
Recreator.h:26
gui_framework::Recreator::Recreator
Recreator(const std::string &json)
gui_framework::Recreator::~Recreator
~Recreator()=default
gui_framework::deserializers::MainWindowDeserializer
Deserialize MainWindow from JSON.
Definition
MainWindowDeserializer.h:21
gui_framework::deserializers::MainWindowDeserializer::deserialize
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.
Definition
MainWindowDeserializer.h:36
gui_framework
Definition
BaseComponent.cpp:21
GUIFramework
src
Deserialization
Recreator.h
Generated by
1.12.0