AUI Framework  develop
Cross-platform base for C++ UI apps
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages Concepts
PropertyList.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 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    template<typename T>
   27
   28    struct PropertyList {
   29    public:
   30        template<ValidDeclaration... Declarations>
   31        PropertyList(Declarations&& ... declarations) {
   32            processDeclarations(std::forward<Declarations>(declarations)...);
   33        }
   34
   35        PropertyList() {
   36
   37        }
   38
   39        [[nodiscard]] const AVector<_<ass::prop::IPropertyBase>>& declarations() const noexcept {
   40            return mProperties;
   41        }
   42
   43        void addDeclaration(_<ass::prop::IPropertyBase> declaration) {
   44            mProperties << std::move(declaration);
   45        }
   46
   47    protected:
   48        template<typename Property, typename... Declarations>
   49        void processDeclarations(Property&& declaration, Declarations&& ... declarations) {
   50            processDeclaration(std::forward<Property>(declaration));
   51            if constexpr (sizeof...(Declarations) > 0) {
   52                processDeclarations(std::forward<Declarations>(declarations)...);
   53            }
   54        }
   55
   56        template<typename T>
   57        void processDeclaration(T&& t) {
   58            if constexpr (std::is_same_v<T, PropertyList>) {
   59                mProperties = std::move(t.mProperties);
   60            } else {
   61                using declaration_t = ass::prop::Property<std::decay_t<T>>;
   62                static_assert(aui::is_complete<declaration_t>,
   63                              "ass::prop::Property template specialization is not defined for this declaration");
   64
   65                mProperties << _new<declaration_t>(t);
   66            }
   67        }
   68
   69        AVector<_<ass::prop::IPropertyBase>> mProperties;
   70    };
   71}
A std::vector with AUI extensions.
Definition AVector.h:39
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
Definition PropertyList.h:26
type_of< T > t
Selects views that are of the specified C++ types.
Definition type_of.h:71
constexpr bool is_complete
Determines whether T is complete or not.
Definition types.h:23
Definition IPropertyBase.h:63