Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members

# TAO_Constraint_Validator Class Reference

TAO_Constraint_Validator ensures that in an expression tree passed to it, the operands of each operation match the correct types. More...

`#include <Constraint_Visitors.h>`

Inheritance diagram for TAO_Constraint_Validator:

[legend]
Collaboration diagram for TAO_Constraint_Validator:

[legend]
List of all members.

## Public Methods
| TAO_Constraint_Validator (void)
| Constructor. More...
virtual | ~TAO_Constraint_Validator (void)
| Destructor. More...
int | validate (TAO_Constraint *root)
| Validate returns 1 if the expression tree whose root is <root> makes semantic sense, in that the operands for each operation comply with each other and the types accepted by the operator. More...
virtual int | visit_constraint (TAO_Unary_Constraint *constraint)
virtual int | visit_with (TAO_Unary_Constraint *unary_with)
virtual int | visit_min (TAO_Unary_Constraint *unary_min)
virtual int | visit_max (TAO_Unary_Constraint *unary_max)
virtual int | visit_first (TAO_Noop_Constraint *noop_first)
virtual int | visit_random (TAO_Noop_Constraint *noop_random)
virtual int | visit_and (TAO_Binary_Constraint *boolean_and)
| The two operands must return a boolean value. More...
virtual int | visit_or (TAO_Binary_Constraint *boolean_or)
virtual int | visit_not (TAO_Unary_Constraint *unary_not)
| The operand must return a boolean value. More...
virtual int | visit_exist (TAO_Unary_Constraint *unary_exist)
| The operand must return a valid (i.e., present in the service type description) property name. More...
virtual int | visit_unary_minus (TAO_Unary_Constraint *unary_minus)
| The operand must return a number to be negated. More...
virtual int | visit_add (TAO_Binary_Constraint *boolean_add)
| Both operands must return numeric results. More...
virtual int | visit_sub (TAO_Binary_Constraint *boolean_sub)
virtual int | visit_mult (TAO_Binary_Constraint *boolean_mult)
virtual int | visit_div (TAO_Binary_Constraint *boolean_div)
virtual int | visit_twiddle (TAO_Binary_Constraint *binary_twiddle)
| Both operands must return strings. More...
virtual int | visit_in (TAO_Binary_Constraint *binary_in)
| The right operand must be a sequence of the same simple type as the left operand. More...
virtual int | visit_less_than (TAO_Binary_Constraint *boolean_lt)
| The left and right operands must both be of the same simple type. More...
virtual int | visit_less_than_equal (TAO_Binary_Constraint *boolean_lte)
virtual int | visit_greater_than (TAO_Binary_Constraint *boolean_gt)
virtual int | visit_greater_than_equal (TAO_Binary_Constraint *boolean_gte)
virtual int | visit_equal (TAO_Binary_Constraint *boolean_eq)
virtual int | visit_not_equal (TAO_Binary_Constraint *boolean_neq)
virtual int | visit_literal (TAO_Literal_Constraint *literal)
| The property must be defined in the service type description. More...
virtual int | visit_property (TAO_Property_Constraint *literal)
## Protected Attributes
TAO_Typecode_Table | type_map_
| A map gleaned from the ServiceTypeStruct, which correlates property names with their types. More...
## Private Methods
CORBA::TypeCode * | extract_type (TAO_Constraint *expr_type, TAO_Expression_Type &type)
int | expr_returns_boolean (TAO_Expression_Type expr_type)
| expr_returns_boolean returns 1 if <expr_type>, when evaluated, will return a boolean. More...
int | expr_returns_number (TAO_Expression_Type expr_type)
| expr_returns_boolean returns 1 if <expr_type>, when evaluated, will return a number. More...
int | expr_returns_string (TAO_Expression_Type expr_type)
| expr_returns_boolean returns 1 if <expr_type>, when evaluated, will return a string. More...
| TAO_Constraint_Validator (const TAO_Constraint_Validator &)
TAO_Constraint_Validator & | operator= (const TAO_Constraint_Validator &)

## Detailed Description

TAO_Constraint_Validator ensures that in an expression tree passed to it, the operands of each operation match the correct types.

TAO_Constraint_Validator uses the visitor pattern to traverse all the nodes in an expression tree, checking that for each operator node the operands are of the proper data type it they're literals, or that they exist in the service type definition _and_ have the proper type, if they're property names. The algorithm for type checking is as follows: ensure that operand expression(s) return the correct types using expr_returns* methods. If they (or it) return the correct types, call accept on each operand until all return true or one returns false, at which point we can back out of the traversal and indicate failure.

## Constructor & Destructor Documentation

TAO_Constraint_Validator::TAO_Constraint_Validator | ( | void |  | ) |

| Constructor.

TAO_Constraint_Validator::~TAO_Constraint_Validator | ( | void |  | ) | `[virtual]`

| Destructor.

TAO_Constraint_Validator::TAO_Constraint_Validator | ( | const TAO_Constraint_Validator & |  | ) | `[private]`

## Member Function Documentation

int TAO_Constraint_Validator::expr_returns_boolean | ( | TAO_Expression_Type | expr_type | ) | `[private]`

| expr_returns_boolean returns 1 if <expr_type>, when evaluated, will return a boolean.

int TAO_Constraint_Validator::expr_returns_number | ( | TAO_Expression_Type | expr_type | ) | `[private]`

| expr_returns_boolean returns 1 if <expr_type>, when evaluated, will return a number.

int TAO_Constraint_Validator::expr_returns_string | ( | TAO_Expression_Type | expr_type | ) | `[private]`

| expr_returns_boolean returns 1 if <expr_type>, when evaluated, will return a string.

CORBA::TypeCode * TAO_Constraint_Validator::extract_type | ( | TAO_Constraint * | expr,
|  | TAO_Expression_Type & | type
| ) | `[private]`

TAO_Constraint_Validator& TAO_Constraint_Validator::operator= | ( | const TAO_Constraint_Validator & |  | ) | `[private]`

int TAO_Constraint_Validator::validate | ( | TAO_Constraint * | root | ) |

| Validate returns 1 if the expression tree whose root is <root> makes semantic sense, in that the operands for each operation comply with each other and the types accepted by the operator.

int TAO_Constraint_Validator::visit_add | ( | TAO_Binary_Constraint * | boolean_add | ) | `[virtual]`

| Both operands must return numeric results. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_and | ( | TAO_Binary_Constraint * | boolean_and | ) | `[virtual]`

| The two operands must return a boolean value. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_constraint | ( | TAO_Unary_Constraint * | constraint | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_div | ( | TAO_Binary_Constraint * | boolean_div | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_equal | ( | TAO_Binary_Constraint * | boolean_eq | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_exist | ( | TAO_Unary_Constraint * | unary_exist | ) | `[virtual]`

| The operand must return a valid (i.e., present in the service type description) property name. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_first | ( | TAO_Noop_Constraint * | noop_first | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_greater_than | ( | TAO_Binary_Constraint * | boolean_gt | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_greater_than_equal | ( | TAO_Binary_Constraint * | boolean_gte | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_in | ( | TAO_Binary_Constraint * | binary_in | ) | `[virtual]`

| The right operand must be a sequence of the same simple type as the left operand. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_less_than | ( | TAO_Binary_Constraint * | boolean_lt | ) | `[virtual]`

| The left and right operands must both be of the same simple type. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_less_than_equal | ( | TAO_Binary_Constraint * | boolean_lte | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_literal | ( | TAO_Literal_Constraint * | literal | ) | `[virtual]`

| The property must be defined in the service type description. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_max | ( | TAO_Unary_Constraint * | unary_max | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_min | ( | TAO_Unary_Constraint * | unary_min | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_mult | ( | TAO_Binary_Constraint * | boolean_mult | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_not | ( | TAO_Unary_Constraint * | unary_not | ) | `[virtual]`

| The operand must return a boolean value. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_not_equal | ( | TAO_Binary_Constraint * | boolean_neq | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_or | ( | TAO_Binary_Constraint * | boolean_or | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_property | ( | TAO_Property_Constraint * | literal | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_random | ( | TAO_Noop_Constraint * | noop_random | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_sub | ( | TAO_Binary_Constraint * | boolean_sub | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_twiddle | ( | TAO_Binary_Constraint * | binary_twiddle | ) | `[virtual]`

| Both operands must return strings. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_unary_minus | ( | TAO_Unary_Constraint * | unary_minus | ) | `[virtual]`

| The operand must return a number to be negated. Reimplemented from TAO_Constraint_Visitor.

int TAO_Constraint_Validator::visit_with | ( | TAO_Unary_Constraint * | unary_with | ) | `[virtual]`

| Reimplemented from TAO_Constraint_Visitor.

## Member Data Documentation

TAO_Typecode_Table TAO_Constraint_Validator::type_map_`[protected]`

| A map gleaned from the ServiceTypeStruct, which correlates property names with their types.

The documentation for this class was generated from the following files:

- Constraint_Visitors.h
- Constraint_Visitors.cpp