SPH
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EntryControl Class Referenceabstract

Helper object, allowing to add units, tooltips and additional properties into the entry created with VirtualSettings::Category::connect. More...

#include <VirtualSettings.h>

Inheritance diagram for EntryControl:
IVirtualEntry Polymorphic Detail::SettingsEntry< TValue, TEnum, TEnabler > Detail::SettingsEntry< Path, TEnum > Detail::SettingsEntry< TValue, TEnum, std::enable_if_t< FlagsTraits< TValue >::isFlags > > Detail::ValueEntry< TValue, typename > Detail::ValueEntry< TValue, std::enable_if_t< FlagsTraits< TValue >::isFlags > >

Public Types

using Enabler = Function< bool()>
 
using Accessor = Function< void(const Value &newValue)>
 
using Validator = Function< bool(const Value &newValue)>
 
- Public Types inherited from IVirtualEntry
enum class  Type {
  BOOL , INT , FLOAT , VECTOR ,
  INTERVAL , STRING , PATH , ENUM ,
  EXTRA , FLAGS
}
 
enum class  PathType { DIRECTORY , INPUT_FILE , OUTPUT_FILE }
 
using Value = Variant< bool, int, Float, Vector, Interval, std::string, Path, EnumWrapper, ExtraEntry >
 

Public Member Functions

EntryControlsetTooltip (const std::string &newTooltip)
 Adds or replaces the previous tooltip associanted with the entry. More...
 
EntryControlsetUnits (const Float newMult)
 Sets units in which the entry is stored. More...
 
EntryControlsetEnabler (const Enabler &newEnabler)
 Adds or replaces the enabler functor of the entry. More...
 
EntryControladdAccessor (const SharedToken &owner, const Accessor &accessor)
 Adds a functor called when the entry changes, i.e. when set function is called. More...
 
EntryControlsetValidator (const Validator &newValidator)
 Adds or replaces the functor called to validate the new value. More...
 
EntryControlsetSideEffect ()
 Specifies that the entry has a side effect, i.e. in changes values of other entries. More...
 
EntryControlsetPathType (const PathType &newType)
 Sets the type of the path. More...
 
EntryControlsetFileFormats (Array< FileFormat > &&formats)
 Sets the allowed file formats. More...
 
- Public Member Functions inherited from IVirtualEntry
virtual Value get () const =0
 Returns the currently stored value. More...
 
virtual Type getType () const =0
 Returns the type of this entry. More...
 
virtual std::string getName () const =0
 Returns a descriptive name of the entry. More...
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 

Protected Member Functions

virtual bool enabled () const override final
 Returns if this entry is currently enabled. More...
 
virtual std::string getTooltip () const override final
 Returns an optional description of the entry. More...
 
virtual bool hasSideEffect () const override final
 Returns true if the entry can modify multiple values simultaneously. More...
 
virtual Optional< PathTypegetPathType () const override final
 Returns the type of the path. More...
 
virtual Array< FileFormatgetFileFormats () const override final
 Returns the allowed file format for this file entry. More...
 
virtual bool isValid (const Value &value) const override final
 Checks if the given value is a valid input for this entry. More...
 
virtual void setImpl (const Value &value)=0
 

Protected Attributes

std::string tooltip
 
Float mult = 1._f
 
Optional< PathTypepathType = NOTHING
 
Array< FileFormatfileFormats
 
Enabler enabler = nullptr
 
CallbackSet< Accessoraccessors
 
Validator validator = nullptr
 
bool sideEffect = false
 

Detailed Description

Helper object, allowing to add units, tooltips and additional properties into the entry created with VirtualSettings::Category::connect.

Each member function returns a reference to the object in order to allow queuing the calls, such as

control.setTooltip("This is a tooltip").setUnits(1.e3f);

It partially implements the IVirtualEntry interface to avoid code duplication.

Definition at line 149 of file VirtualSettings.h.

Member Typedef Documentation

◆ Accessor

using EntryControl::Accessor = Function<void(const Value& newValue)>

Definition at line 152 of file VirtualSettings.h.

◆ Enabler

Definition at line 151 of file VirtualSettings.h.

◆ Validator

using EntryControl::Validator = Function<bool(const Value& newValue)>

Definition at line 153 of file VirtualSettings.h.

Member Function Documentation

◆ addAccessor()

EntryControl & EntryControl::addAccessor ( const SharedToken owner,
const Accessor accessor 
)

Adds a functor called when the entry changes, i.e. when set function is called.

There can be any number of accessors set for each property.

owner Owner that registered the accessor. When expired, the accessor is no longer called.

accessor New functor to be added.

Definition at line 20 of file VirtualSettings.cpp.

◆ enabled()

bool EntryControl::enabled ( ) const
finaloverrideprotectedvirtual

Returns if this entry is currently enabled.

Implementation may return false if the entry does not have any effect for current setup of the job, for example if the entry is associated with a parameter of a solver which is not being used.

Implements IVirtualEntry.

Definition at line 57 of file VirtualSettings.cpp.

◆ getFileFormats()

Array< IVirtualEntry::FileFormat > EntryControl::getFileFormats ( ) const
finaloverrideprotectedvirtual

Returns the allowed file format for this file entry.

Used only for file entry (i.e. getPathType returns INPUT_FILE or OUTPUT_FILE). The returned array contains pairs of the file format description and the corresponding extension (i.e. 'txt').

Reimplemented from IVirtualEntry.

Definition at line 49 of file VirtualSettings.cpp.

◆ getPathType()

Optional< IVirtualEntry::PathType > EntryControl::getPathType ( ) const
finaloverrideprotectedvirtual

Returns the type of the path.

Used only if type of the entry is PATH, otherwise returns NOTHING.

Reimplemented from IVirtualEntry.

Definition at line 45 of file VirtualSettings.cpp.

◆ getTooltip()

std::string EntryControl::getTooltip ( ) const
finaloverrideprotectedvirtual

Returns an optional description of the entry.

Reimplemented from IVirtualEntry.

Definition at line 61 of file VirtualSettings.cpp.

◆ hasSideEffect()

bool EntryControl::hasSideEffect ( ) const
finaloverrideprotectedvirtual

Returns true if the entry can modify multiple values simultaneously.

Usually, there is a 1-1 correspondence between entries and values (stored either in Settings or directly in the job). However, an entry can modify other values as well, in which case it should signal this by returning true from this function.

Reimplemented from IVirtualEntry.

Definition at line 65 of file VirtualSettings.cpp.

◆ isValid()

bool EntryControl::isValid ( const Value value) const
finaloverrideprotectedvirtual

Checks if the given value is a valid input for this entry.

Implements IVirtualEntry.

Definition at line 53 of file VirtualSettings.cpp.

◆ setEnabler()

EntryControl & EntryControl::setEnabler ( const Enabler newEnabler)

Adds or replaces the enabler functor of the entry.

Enabler specifies whether the entry is accessible or not. The user can still call the member function set or get of the entry even if the functor returns false, but it indicates that the entry has no meaning in the context of the current settings. For example, enabler should returns false for entries associated with parameters of the boundary if there are no boundary conditions in the simulations.

Definition at line 15 of file VirtualSettings.cpp.

◆ setFileFormats()

EntryControl & EntryControl::setFileFormats ( Array< FileFormat > &&  formats)

Sets the allowed file formats.

Definition at line 40 of file VirtualSettings.cpp.

◆ setImpl()

virtual void EntryControl::setImpl ( const Value value)
protectedpure virtual

◆ setPathType()

EntryControl & EntryControl::setPathType ( const PathType newType)

Sets the type of the path.

Definition at line 35 of file VirtualSettings.cpp.

◆ setSideEffect()

EntryControl & EntryControl::setSideEffect ( )

Specifies that the entry has a side effect, i.e. in changes values of other entries.

Definition at line 30 of file VirtualSettings.cpp.

◆ setTooltip()

NAMESPACE_SPH_BEGIN EntryControl & EntryControl::setTooltip ( const std::string &  newTooltip)

Adds or replaces the previous tooltip associanted with the entry.

Definition at line 5 of file VirtualSettings.cpp.

◆ setUnits()

EntryControl & EntryControl::setUnits ( const Float  newMult)

Sets units in which the entry is stored.

Note that the units are currently only applied for Float or Vector entries. Other entries ignore the value.

Definition at line 10 of file VirtualSettings.cpp.

◆ setValidator()

EntryControl & EntryControl::setValidator ( const Validator newValidator)

Adds or replaces the functor called to validate the new value.

If the functor returns false, the value is unchanged.

Definition at line 25 of file VirtualSettings.cpp.

Member Data Documentation

◆ accessors

CallbackSet<Accessor> EntryControl::accessors
protected

Definition at line 161 of file VirtualSettings.h.

◆ enabler

Enabler EntryControl::enabler = nullptr
protected

Definition at line 160 of file VirtualSettings.h.

◆ fileFormats

Array<FileFormat> EntryControl::fileFormats
protected

Definition at line 159 of file VirtualSettings.h.

◆ mult

Float EntryControl::mult = 1._f
protected

Definition at line 157 of file VirtualSettings.h.

◆ pathType

Optional<PathType> EntryControl::pathType = NOTHING
protected

Definition at line 158 of file VirtualSettings.h.

◆ sideEffect

bool EntryControl::sideEffect = false
protected

Definition at line 163 of file VirtualSettings.h.

◆ tooltip

std::string EntryControl::tooltip
protected

Definition at line 156 of file VirtualSettings.h.

◆ validator

Validator EntryControl::validator = nullptr
protected

Definition at line 162 of file VirtualSettings.h.


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