Used by openDAQ properties to coerce a value to match the restrictions imposed by the Property. More...
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 | |
virtual ErrCode INTERFACE_FUNC | coerce (IBaseObject *propObj, IBaseObject *value, IBaseObject **result)=0 |
Coerces value to match the coercion restrictions and outputs the result. More... | |
virtual ErrCode INTERFACE_FUNC | getEval (IString **eval)=0 |
Gets the string expression used when creating the coercer. More... | |
![]() | |
virtual ErrCode INTERFACE_FUNC | borrowInterface (const IntfID &intfID, void **obj) const =0 |
Returns another interface which is supported by the object without incrementing the reference count. More... | |
virtual ErrCode INTERFACE_FUNC | dispose ()=0 |
Disposes all references held by the object. More... | |
virtual ErrCode INTERFACE_FUNC | getHashCode (SizeT *hashCode)=0 |
Returns hash code of the object. More... | |
virtual ErrCode INTERFACE_FUNC | equals (IBaseObject *other, Bool *equal) const =0 |
Compares object to another object for equality. More... | |
virtual ErrCode INTERFACE_FUNC | toString (CharPtr *str)=0 |
Returns a string representation of the object. More... | |
![]() | |
virtual ErrCode INTERFACE_FUNC | queryInterface (const IntfID &intfID, void **obj)=0 |
Returns another interface which is supported by the object and increments the reference count. More... | |
virtual int INTERFACE_FUNC | addRef ()=0 |
Increments the reference count for an interface on an object. More... | |
virtual int INTERFACE_FUNC | releaseRef ()=0 |
Decrements the reference count for an interface on an object. More... | |
|
pure virtual |
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. | |
[out] | result | The coercer output containing the modified value . |
OPENDAQ_ERR_COERCE_FAILED | 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. |