UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PropertyWithSetterAndGetter.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
8
9
10template <typename PropertyBaseClass>
11class TPropertyWithSetterAndGetter : public PropertyBaseClass
12{
13public:
14 template <typename PropertyCodegenParams>
16 : PropertyBaseClass(InOwner, Prop)
19 {
20 }
21
22#if UE_WITH_CONSTINIT_UOBJECT
23 template<typename... ArgTypes>
24 consteval TPropertyWithSetterAndGetter(SetterFuncPtr InSetterFunc, GetterFuncPtr InGetterFunc, UE::CodeGen::ConstInit::FPropertyParams PropertyParams, ArgTypes&&... InArgs)
25 : PropertyBaseClass(PropertyParams, Forward<ArgTypes>(InArgs)...)
28 {
29 }
30#endif
31
32 virtual bool HasSetter() const override
33 {
34 return !!SetterFunc;
35 }
36
37 virtual bool HasGetter() const override
38 {
39 return !!GetterFunc;
40 }
41
42 virtual bool HasSetterOrGetter() const override
43 {
44 return !!SetterFunc || !!GetterFunc;
45 }
46
47 virtual void CallSetter(void* Container, const void* InValue) const override
48 {
49 checkf(SetterFunc, TEXT("Calling a setter on %s but the property has no setter defined."), *PropertyBaseClass::GetFullName());
51 }
52
53 virtual void CallGetter(const void* Container, void* OutValue) const override
54 {
55 checkf(GetterFunc, TEXT("Calling a getter on %s but the property has no getter defined."), *PropertyBaseClass::GetFullName());
57 }
58
59protected:
60
63};
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void(* GetterFuncPtr)(const void *InContainer, void *OutValue)
Definition UObjectGlobals.h:3595
void(* SetterFuncPtr)(void *InContainer, const void *InValue)
Definition UObjectGlobals.h:3594
Definition Field.h:353
Definition PropertyWithSetterAndGetter.h:12
virtual bool HasSetter() const override
Definition PropertyWithSetterAndGetter.h:32
TPropertyWithSetterAndGetter(FFieldVariant InOwner, const PropertyCodegenParams &Prop)
Definition PropertyWithSetterAndGetter.h:15
virtual bool HasSetterOrGetter() const override
Definition PropertyWithSetterAndGetter.h:42
SetterFuncPtr SetterFunc
Definition PropertyWithSetterAndGetter.h:61
virtual bool HasGetter() const override
Definition PropertyWithSetterAndGetter.h:37
virtual void CallSetter(void *Container, const void *InValue) const override
Definition PropertyWithSetterAndGetter.h:47
GetterFuncPtr GetterFunc
Definition PropertyWithSetterAndGetter.h:62
virtual void CallGetter(const void *Container, void *OutValue) const override
Definition PropertyWithSetterAndGetter.h:53