22 #include "cafDataFieldAccessor.h" 25 #include "cafFieldProxyAccessor.h" 26 #include "cafFieldScriptingCapability.h" 27 #include "cafFieldValidator.h" 34 concept DerivesFromFieldHandle = std::is_base_of<FieldHandle, T>::value;
40 template <DerivesFromFieldHandle FieldType>
44 using GetMethod = std::function<typename FieldType::FieldDataType()>;
45 using SetMethod = std::function<void( const typename FieldType::FieldDataType& )>;
49 , m_keyword( keyword )
53 FieldInitHelper& withDefault(
const typename FieldType::FieldDataType& defaultValue )
55 m_field.setDefaultValue( defaultValue );
56 m_field = defaultValue;
60 FieldInitHelper& withScripting(
bool readable =
true,
bool writable =
true )
62 m_field.addCapability( std::make_unique<FieldScriptingCapability>( readable, writable ) );
68 m_field.setAccessor( std::move( accessor ) );
74 auto accessor = std::make_unique<caffa::FieldProxyAccessor<typename FieldType::FieldDataType>>();
75 accessor->registerGetMethod( getMethod );
76 return withAccessor( std::move( accessor ) );
81 auto accessor = std::make_unique<caffa::FieldProxyAccessor<typename FieldType::FieldDataType>>();
82 accessor->registerSetMethod( setMethod );
83 return withAccessor( std::move( accessor ) );
86 FieldInitHelper& withProxyGetSetAccessor( GetMethod getMethod, SetMethod setMethod )
88 auto accessor = std::make_unique<caffa::FieldProxyAccessor<typename FieldType::FieldDataType>>();
89 accessor->registerGetMethod( getMethod );
90 accessor->registerSetMethod( setMethod );
91 return withAccessor( std::move( accessor ) );
96 m_field.addValidator( std::move( validator ) );
102 m_field.setDocumentation( documentation );
108 m_field.markDeprecated();
121 const std::string& m_keyword;
Used to validate the value of data fields Implementations need the the validate method as well as rea...
Definition: cafFieldValidator.h:94
Definition: cafFieldInitHelper.h:41
Abstract but typed data field accessor. Inherit to create different storage mechanisms.
Definition: cafDataFieldAccessor.h:42
Main Caffa namespace.
Definition: cafApplication.h:30