Public Member Functions

FPValidator Class Reference

This reference page is linked to from the following overview topics: Parameter Validation.


Search for all occurrences

Detailed Description

See also:
Class InterfaceServer, Class FPInterfaceDesc, Class FPValue, Class Interface_ID, Function Publishing System.

Description:
This class is available in release 4.0 and later only.

An interface descriptor may contain validation information for individual parameters, so that clients (such as MAXScript) can validate values given as parameters to FPInterface calls, prior to making the call. The validation information can be in the form of a range of values for int and float types, or more generally, a validator object that is called to the validate a parameter value.

The validation info is specified in the FPInterface descriptor in optional tagged entries following the parameters to be validated. The two possible tags are f_range and f_validator. An instance of this class is used when f_validator is specified.

Here's an example from a possible mixin interface to Cylinder:

static FPInterfaceDesc cylfpi (

CYL_INTERFACE, _M("cylMixin"), 0, &cylinderDesc, FP_MIXIN,

...

cyl_setRadius, _M("setRadius"), 0, TYPE_VOID, 0, 1,

_M("radius"), 0, TYPE_FLOAT,

f_range, 0.0, 10000.0,

cyl_setDirection, _M("setDirection"), 0, TYPE_VOID, 0, 1,

_M("vector"), 0, TYPE_POINT3,

f_validator, &cylValidator,

...

end

);

The "vector" parameter in the above example has a validator object specified. This must be a pointer to an instance of a class derived from the new class, FPValidator, defined in I/MAXSDK/INCLUDE/iFnPub.h. This is a virtual base class, containing a single method, Validate(), that is called to validate a prospective value for a parameter. You would typically subclass FPValidator in your code and provide an implementation of Validate() to do the validation.

#include <ifnpub.h>

Inheritance diagram for FPValidator:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual bool  Validate (FPInterface *fpi, FunctionID fid, int paramNum, FPValue &val, MSTR &msg)=0

Member Function Documentation

virtual bool Validate ( FPInterface fpi,
FunctionID  fid,
int  paramNum,
FPValue val,
MSTR msg 
) [pure virtual]
Remarks:
This method is called to validate the value val passed for the given parameter in the function whose ID is passed in the specified interface passed. If there are many parameters to validate this way, developers can choose to provide a separate subclass for each parameter or a single subclass and switch on the parameter identification supplied.
Parameters:
FPInterface* fpi

Points to the interface the function is a part of.

FunctionID fid

The ID of the function within the interface above.

int paramNum

Identifies which parameter within the function above to validate.

FPValue& val

The value to validate.

MSTR& msg

Update this string with an error message if needed. The user of the Validator can then display this string.
Returns:
Returns true if the value was valid; false if invalid.

FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator
FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator FPValidator