Encapsulation of delegates

I’m new to unreal engine and c++. I have a class in which I define a delegate with one parameter and a return type:

DECLARE_DELEGATE_RetVal_OneParam(bool, FInteractionValidatorDelegate, APlayerController*)

I’ve added a property containing this delegate:

FInteractionValidatorDelegate Validator;

And in another class I bind the delegate:

SomeComponent->Validator.BindUObject(this, &AInteractable::IsValid)

This all works fine but I don’t want to expose the delegate publicly thus I want to encapsulate it by adding a BindValidator() method to my component. What is the best method of doing this ?

FInteractionValidation& GetValidator() const { return Validator; } is the simplest way.

Issue is, bind could be a number of things, like uobject or lambda.

What would be the best method to encapsulate the bindUObject function ?

As TheKaosSpectrum, the easiest way is just to return the delegate, if you’re just dead set on encapsulating the bind uobject call, then you have to make a method that takes in a function pointer that matches your delegate (or maybe use a TFunction)

void MyClass::BindMyDelegate(UObject& object, bool(*MyFunc)(APlayerController*))
     MyDelegate.BindUObject(object, MyFunc);

I’m open to more solutions but what I don’t want to happen is that other objects can execute the function that is bound to the delegate so I thought that encapsulating the bindUObject function would prevent that from happening since they can’t get the delegate and call execute on it.

I’m trying to achieve something like the input component does where you can call a BindAxis function containing the delegate binding and some additional information.