Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Core::VariableSet::DynamicVisitor Class Reference

Base class for visitors with configurable per-type callbacks. Visiting will be prepared at running time by dynamically adding visitor operators for each type one want to visit in the container. The visitor accept type based on either the added operators or an external acceptance functor which can be associated/changed at runtime. This functor is only allowed to reduce the number of visited type as only type for which a visitor operator is registered can be visited. The visitor operators should be any callable that accept to be called using f(const std::string&, T&[, std::any&&]) More...

#include <Core/Containers/VariableSet.hpp>

+ Inheritance diagram for Ra::Core::VariableSet::DynamicVisitor:
+ Collaboration diagram for Ra::Core::VariableSet::DynamicVisitor:

Public Member Functions

 ~DynamicVisitor () override=default
 allows the class to be derived
 
void operator() (std::any &&in, std::any &&userParam) const override
 Execute a visiting operator on accepted types.
 
bool accept (const std::type_index &id) const override
 Acceptance function for the visitor.
 
template<typename T , typename F >
bool addOperator (F &&f)
 Add a visiting operator.
 
template<typename T >
bool hasOperator ()
 Test the existence of an operator associated with a type.
 
template<typename T , typename F >
void addOrReplaceOperator (F &&f)
 Add or replace a visiting operator.
 
template<typename T >
bool removeOperator ()
 Remove a visiting operator.
 
- Public Member Functions inherited from Ra::Core::VariableSet::DynamicVisitorBase

Detailed Description

Base class for visitors with configurable per-type callbacks. Visiting will be prepared at running time by dynamically adding visitor operators for each type one want to visit in the container. The visitor accept type based on either the added operators or an external acceptance functor which can be associated/changed at runtime. This functor is only allowed to reduce the number of visited type as only type for which a visitor operator is registered can be visited. The visitor operators should be any callable that accept to be called using f(const std::string&, T&[, std::any&&])

Definition at line 309 of file VariableSet.hpp.

Member Function Documentation

◆ accept()

bool Ra::Core::VariableSet::DynamicVisitor::accept ( const std::type_index & id) const
nodiscardoverridevirtual

Acceptance function for the visitor.

Parameters
idThe type to test
Returns
true if the type is visitable, false if not

Implements Ra::Core::VariableSet::DynamicVisitorBase.

Definition at line 59 of file VariableSet.cpp.

+ Here is the call graph for this function:

◆ addOperator()

template<typename T , typename F >
bool Ra::Core::VariableSet::DynamicVisitor::addOperator ( F && f)

Add a visiting operator.

Template Parameters
TThe accepted type for the visit.
FThe operator type, a callable with profile void(const std::string&, [const ]T[&], std::any&&).
Parameters
fThe operator object.
Returns
true if the operator was added, false if not (e.g. there is already an operator associated with the type T)

Definition at line 852 of file VariableSet.hpp.

+ Here is the call graph for this function:

◆ addOrReplaceOperator()

template<typename T , typename F >
void Ra::Core::VariableSet::DynamicVisitor::addOrReplaceOperator ( F && f)

Add or replace a visiting operator.

Template Parameters
T
F
Parameters
fThis method is similar to DynamicVisitor::addOperator but replace any existing operator previously associated with the type T

Definition at line 863 of file VariableSet.hpp.

◆ hasOperator()

template<typename T >
bool Ra::Core::VariableSet::DynamicVisitor::hasOperator ( )

Test the existence of an operator associated with a type.

Template Parameters
T
Returns

Definition at line 858 of file VariableSet.hpp.

◆ operator()()

void Ra::Core::VariableSet::DynamicVisitor::operator() ( std::any && in,
std::any && userParam ) const
overridevirtual

Execute a visiting operator on accepted types.

Parameters
inThe variable to process
userParamThe optional user define parameter to forward to type associated functor The variable in contains a wrapping of the association name->value whose visit is accepted. Visiting the association is done by calling the visit operator associated with the underlying type of the variable in.

Implements Ra::Core::VariableSet::DynamicVisitorBase.

Definition at line 63 of file VariableSet.cpp.

+ Here is the call graph for this function:

◆ removeOperator()

template<typename T >
bool Ra::Core::VariableSet::DynamicVisitor::removeOperator ( )

Remove a visiting operator.

Template Parameters
T
Returns
Precondition
The type T must be accepted by an operator.

Definition at line 869 of file VariableSet.hpp.


The documentation for this class was generated from the following files: