openDAQ
Open data acquisition platform
IValidator Struct Referenceabstract

Used by openDAQ properties to validate whether a value fits the value restrictions of the Property. More...

+ Inheritance diagram for IValidator:
+ Collaboration diagram for IValidator:

Detailed Description

Used by openDAQ properties to validate whether a value fits the value restrictions of the Property.

Whenever a value is set to on a Property object, if the corresponding Property has a validator configured, the value will be validated, throwing a validation error, if the value is not compliant with the validation restrictions. For example, a validator can check the written value for lower-than, greater-than, equality, or other number relations.

The validation conditions are configured with an evaluation string when the validator 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 validate function call. For example, validators created with the string "value == 5" would reject any value that is not equal to 5.

Public Member Functions

virtual ErrCode INTERFACE_FUNC validate (IBaseObject *propObj, IBaseObject *value)=0
 Checks whether value adheres to the validity conditions of the validator. More...
 
virtual ErrCode INTERFACE_FUNC getEval (IString **eval)=0
 Gets the string expression used when creating the validator. More...
 
- Public Member Functions inherited from IBaseObject
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...
 
- Public Member Functions inherited from IUnknown
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...
 

Member Function Documentation

◆ getEval()

virtual ErrCode INTERFACE_FUNC getEval ( IString **  eval)
pure virtual

Gets the string expression used when creating the validator.

Parameters
[out]evalThe validation expression.

◆ validate()

virtual ErrCode INTERFACE_FUNC validate ( IBaseObject propObj,
IBaseObject value 
)
pure virtual

Checks whether value adheres to the validity conditions of the validator.

Parameters
propObjOptional property object parameter required if the validation depends on other properties of the Property object.
valueThe value to be checked for whether it is valid or not.
Return values
OPENDAQ_ERR_VALIDATE_FAILEDif value is invalid.
OPENDAQ_SUCCESSif value is valid.