Flip Reference

DocumentValidator Class Reference

Declared in

flip/DocumentValidator.h

template <class T>   class DocumentValidator;

flip::DocumentValidator is the base of document validators.

Template Parameters

T

The root class to validate. T must inherit from flip::Object

Member Functions Synopsys

validate

Receives document validation request notification

Member Functions

validate

virtual void   validate (T & root) = 0;

To receive document change notification, one will inherit from this class and implement this function.

When a validation error is encountered, the function must throw to notify the flip system that validation failed. The macro flip_VALIDATION_FAILED is provided for convenience.

Example:

class MyValidator : public flip::DocumentValidator <MyRootClass>
{
public:
   virtual void   document_changed (MyRootClass & root) override;
};
void  MyValidator::document_changed (MyRootClass & root)
{
   if (root.changed ())
   {
      if (root.tempo < 20.0) flip_VALIDATION_FAILED ("incorrect tempo");
   }
}