-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththeme_factory.h
More file actions
97 lines (89 loc) · 2.84 KB
/
theme_factory.h
File metadata and controls
97 lines (89 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* @file ui/core/theme_factory.h
* @brief Abstract factory for creating and serializing CF UI themes.
*
* Defines the ThemeFactory interface for creating ICFTheme instances
* from names or JSON data, and for serializing themes to JSON format.
*
* @author N/A
* @date N/A
* @version N/A
* @since N/A
* @ingroup none
*/
#pragma once
#include "export.h"
#include "theme.h"
#include <QByteArray>
#include <memory>
namespace cf::ui::core {
/**
* @brief Abstract factory for creating and serializing CF UI themes.
*
* ThemeFactory provides an interface for creating ICFTheme instances from
* theme names or JSON data, and for serializing existing themes to JSON.
* Implementations of this interface handle specific theme formats.
*
* @ingroup none
*
* @note None
*
* @warning None
*
* @code
* class MyThemeFactory : public ThemeFactory {
* public:
* std::unique_ptr<ICFTheme> fromName(const char* name) override {
* // Create theme by name
* }
* std::unique_ptr<ICFTheme> fromJson(const QByteArray& json) override {
* // Parse JSON and create theme
* }
* QByteArray toJson(ICFTheme* raw_theme) override {
* // Serialize theme to JSON
* }
* };
* @endcode
*/
class CF_UI_EXPORT ThemeFactory {
public:
/// @brief Virtual destructor.
virtual ~ThemeFactory() = default;
/**
* @brief Creates a theme from its name.
*
* @param[in] name Name identifier of the theme to create.
* @return Unique pointer to the created theme, or nullptr on error.
* @throws May throw exceptions depending on implementation.
* @note Implementation-specific behavior for unknown names.
* @warning None
* @since N/A
* @ingroup none
*/
virtual std::unique_ptr<ICFTheme> fromName(const char* name) = 0;
/**
* @brief Creates a theme from JSON data.
*
* @param[in] json JSON byte array containing theme definition.
* @return Unique pointer to the created theme, or nullptr on error.
* @throws May throw exceptions depending on implementation.
* @note Implementation-specific JSON format validation.
* @warning None
* @since N/A
* @ingroup none
*/
virtual std::unique_ptr<ICFTheme> fromJson(const QByteArray& json) = 0;
/**
* @brief Serializes a theme to JSON format.
*
* @param[in] raw_theme Pointer to the theme to serialize.
* @return JSON byte array representing the theme.
* @throws May throw exceptions depending on implementation.
* @note None
* @warning None
* @since N/A
* @ingroup none
*/
virtual QByteArray toJson(ICFTheme* raw_theme) = 0;
};
} // namespace cf::ui::core