|
openDAQ
Open data acquisition platform
|
Used by openDAQ properties to coerce a value to match the restrictions imposed by the Property. More...
Inherits ObjectPtr< ICoercer >.
Used by openDAQ properties to coerce a value to match the restrictions imposed by the Property.
Whenever a value is set to on a Property object, if the corresponding Property has a coercer configured, the value will be evaluated and modified to fit the restrictions imposed by the coercer. For example, a coercer can enforce lower-than, greater-than, equality, or other number relations on written values.
The coercion conditions are configured with an evaluation string when the coercer is constructed. The string constructs an Eval value that replaces any instance of the keyword "value" or "val" with the value being set. The result of the Eval value evaluation is the output of the coerce function call. For example, coercers created with the string "if(value > 5, 5, value)" would enforce that the property value is always equal to or lower than 5.
Public Member Functions | |
| daq::BaseObjectPtr | coerce (const daq::BaseObjectPtr &propObj, const daq::BaseObjectPtr &value) const |
Coerces value to match the coercion restrictions and outputs the result. More... | |
| daq::StringPtr | getEval () const |
| Gets the string expression used when creating the coercer. More... | |
|
inline |
Coerces value to match the coercion restrictions and outputs the result.
| propObj | Optional property object parameter required if the coercion depends on other properties of the Property object. |
| value | The value to be coerced to fit the restrictions. |
value. | OpendaqErrException | if value cannot be coerced to fit the restrictions. |
| OPENDAQ_SUCCESS | If the value either already fits the restrictions, or was successfully modified to do so. |
|
inline |
Gets the string expression used when creating the coercer.