Skip to content

Commit

Permalink
GUIProperty refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dancazarin committed Dec 12, 2024
1 parent c1da760 commit 7422d58
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 216 deletions.
8 changes: 5 additions & 3 deletions include/brisk/core/Binding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ template <typename... Args>
struct Trigger {
using Type = typename Internal::TriggerArgs<Args...>::Type;

constexpr static bool isTrigger = true;

std::optional<Type> arg;

operator Type() const {
Expand Down Expand Up @@ -183,9 +185,9 @@ using ValueArgument = typename Internal::ValueArgumentImpl<T>::Type;
* @tparam T The type to check.
*/
template <typename T>
concept PropertyLike = requires(T t, const T ct, typename T::Type v) {
requires std::copy_constructible<typename T::Type>;
{ ct.get() } -> std::convertible_to<typename T::Type>;
concept PropertyLike = requires(T t, const T ct, typename T::ValueType v) {
requires std::copy_constructible<typename T::ValueType>;
{ ct.get() } -> std::convertible_to<typename T::ValueType>;
t.set(v);
{ ct.address() } -> std::convertible_to<BindingAddress>;
{ t.this_pointer = nullptr };
Expand Down
9 changes: 9 additions & 0 deletions include/brisk/core/Reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ constexpr void forEachField(Fn&& fn) {
reflection);
}

template <HasReflection T, size_t index>
using FieldType =
std::remove_reference_t<decltype(std::declval<T>().*std::get<index>(reflectionOf<T>()).pointerToField)>;

template <size_t index, HasReflection T>
constexpr decltype(auto) accessField(T&& obj) {
return obj.*(std::get<index>(reflectionOf(std::forward<T>(obj))).pointerToField);
}

/**
* @brief Returns the number of enum values based on the last enum value.
*
Expand Down
Loading

0 comments on commit 7422d58

Please sign in to comment.