AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
PropertyList.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12//
13// Created by alex2 on 03.01.2021.
14//
15
16#pragma once
17
18#include "Property/IProperty.h"
19#include <AUI/Common/AObject.h>
20#include <AUI/Traits/types.h>
21
22
23namespace ass {
24
25 struct PropertyList {
26 public:
27 template<typename... Declarations>
28 PropertyList(Declarations&& ... declarations) {
29 processDeclarations(std::forward<Declarations>(declarations)...);
30 }
31
32 PropertyList() {
33
34 }
35
36 [[nodiscard]] const AVector<_<ass::prop::IPropertyBase>>& declarations() const noexcept {
37 return mProperties;
38 }
39
40 void addDeclaration(_<ass::prop::IPropertyBase> declaration) {
41 mProperties << std::move(declaration);
42 }
43
44 protected:
45 template<typename Property, typename... Declarations>
46 void processDeclarations(Property&& declaration, Declarations&& ... declarations) {
47 processDeclaration(std::forward<Property>(declaration));
48 if constexpr (sizeof...(Declarations) > 0) {
49 processDeclarations(std::forward<Declarations>(declarations)...);
50 }
51 }
52
53 template<typename T>
54 void processDeclaration(T&& t) {
55 if constexpr (std::is_same_v<T, PropertyList>) {
56 mProperties = std::move(t.mProperties);
57 } else {
58 using declaration_t = ass::prop::Property<std::decay_t<T>>;
59 static_assert(aui::is_complete<declaration_t>,
60 "ass::prop::Property template specialization is not defined for this declaration");
61
62 mProperties << _new<declaration_t>(t);
63 }
64 }
65
67 };
68}
A std::vector with AUI extensions.
Definition: AVector.h:38
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Definition: PropertyList.h:25
Definition: IProperty.h:19
Definition: type_of.h:44