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:

Inheritance graph
[legend]
Collaboration diagram for TAO_Constraint_Validator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Constraint_Validator (void)
 Constructor.
virtual ~TAO_Constraint_Validator (void)
 Destructor.
int validate (TAO_Constraint *root)
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.
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.
virtual int visit_exist (TAO_Unary_Constraint *unary_exist)
virtual int visit_unary_minus (TAO_Unary_Constraint *unary_minus)
 The operand must return a number to be negated.
virtual int visit_add (TAO_Binary_Constraint *boolean_add)
 Both operands must return numeric results.
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.
virtual int visit_in (TAO_Binary_Constraint *binary_in)
virtual int visit_less_than (TAO_Binary_Constraint *boolean_lt)
 The left and right operands must both be of the same simple type.
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.
virtual int visit_property (TAO_Property_Constraint *literal)

Protected Attributes

TAO_Typecode_Table type_map_

Private Member Functions

CORBA::TypeCode * extract_type (TAO_Constraint *expr_type, TAO_Expression_Type &type)
int expr_returns_boolean (TAO_Expression_Type expr_type)
int expr_returns_number (TAO_Expression_Type expr_type)
int expr_returns_string (TAO_Expression_Type expr_type)
 TAO_Constraint_Validator (const TAO_Constraint_Validator &)
TAO_Constraint_Validatoroperator= (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.

Definition at line 116 of file Constraint_Visitors.h.


Constructor & Destructor Documentation

TAO_Constraint_Validator::TAO_Constraint_Validator ( void   ) 

Constructor.

Definition at line 770 of file Constraint_Visitors.cpp.

00771 {
00772   // No-Op.
00773 }

TAO_Constraint_Validator::~TAO_Constraint_Validator ( void   )  [virtual]

Destructor.

Definition at line 775 of file Constraint_Visitors.cpp.

References CORBA::release().

00776 {
00777   for (TAO_Typecode_Table::iterator type_iter (this->type_map_);
00778        ! type_iter.done ();
00779        type_iter++)
00780     {
00781       CORBA::TypeCode_ptr corba_type = (*type_iter).int_id_;
00782       CORBA::release (corba_type);
00783     }
00784 }

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.

Definition at line 1197 of file Constraint_Visitors.cpp.

References TAO_BOOLEAN.

Referenced by visit_and(), and visit_equal().

01198 {
01199   // If the expression is a boolean operations, a boolean literal, or
01200   // a boolean property, return 1.
01201   int return_value = 0;
01202 
01203   if (expr_type <= TAO_BOOLEAN)
01204     return_value = 1;
01205 
01206   return return_value;
01207 }

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.

Definition at line 1211 of file Constraint_Visitors.cpp.

References TAO_DOUBLE, TAO_NUMBER, TAO_PLUS, and TAO_SIGNED.

Referenced by visit_add(), visit_div(), visit_equal(), and visit_less_than().

01212 {
01213   // If the expression is a number operation, a numeric literal, or a
01214   // numeric property, return 1.
01215   int return_value = 0;
01216 
01217   if ((expr_type >= TAO_PLUS && expr_type <= TAO_NUMBER) ||
01218       (expr_type >= TAO_SIGNED && expr_type <= TAO_DOUBLE))
01219     return_value = 1;
01220 
01221   return return_value;
01222 }

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.

Definition at line 1225 of file Constraint_Visitors.cpp.

References TAO_STRING.

Referenced by visit_equal(), visit_less_than(), and visit_twiddle().

01226 {
01227   // If the expression is an operation with a string return value, a
01228   // string literal, or a property whose type is string, return 1.
01229   int return_value = 0;
01230 
01231   if (expr_type == TAO_STRING)
01232     return_value = 1;
01233 
01234   return return_value;
01235 }

CORBA::TypeCode * TAO_Constraint_Validator::extract_type ( TAO_Constraint expr_type,
TAO_Expression_Type type 
) [private]

Definition at line 1178 of file Constraint_Visitors.cpp.

References TAO_Literal_Constraint::comparable_type(), TAO_Constraint::expr_type(), TAO_Property_Constraint::name(), and TAO_IDENT.

Referenced by visit_add(), visit_and(), visit_constraint(), visit_div(), visit_equal(), visit_in(), visit_less_than(), visit_not(), visit_twiddle(), and visit_unary_minus().

01180 {
01181   CORBA::TypeCode* return_value = 0;
01182 
01183   type = expr->expr_type ();
01184   if (type == TAO_IDENT)
01185     {
01186       TAO_Property_Constraint* prop = (TAO_Property_Constraint*) expr;
01187       CORBA::String_var prop_name (prop->name ());
01188 
01189       if (this->type_map_.find (prop_name, return_value) == 0)
01190         type = TAO_Literal_Constraint::comparable_type (return_value);
01191     }
01192 
01193   return return_value;
01194 }

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.

Definition at line 787 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept().

Referenced by TAO_Constraint_Interpreter::TAO_Constraint_Interpreter(), and TAO_Preference_Interpreter::TAO_Preference_Interpreter().

00788 {
00789   return root->accept(this);
00790 }

int TAO_Constraint_Validator::visit_add ( TAO_Binary_Constraint boolean_add  )  [virtual]

Both operands must return numeric results.

Implements TAO_Constraint_Visitor.

Definition at line 917 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), expr_returns_number(), extract_type(), TAO_Binary_Constraint::left_operand(), and TAO_Binary_Constraint::right_operand().

Referenced by visit_mult(), and visit_sub().

00918 {
00919   // All the mathematical operators require numeric operands.
00920   int return_value = -1;
00921   TAO_Constraint* left = boolean_add->left_operand (),
00922     *right = boolean_add->right_operand ();
00923   TAO_Expression_Type left_type, right_type;
00924   this->extract_type (left, left_type);
00925   this->extract_type (right, right_type);
00926 
00927   if (this->expr_returns_number (left_type) &&
00928       this->expr_returns_number (right_type))
00929     {
00930       if (left->accept (this) == 0 &&
00931           right->accept (this) == 0)
00932         return_value = 0;
00933     }
00934 
00935   return return_value;
00936 }

int TAO_Constraint_Validator::visit_and ( TAO_Binary_Constraint boolean_and  )  [virtual]

The two operands must return a boolean value.

Implements TAO_Constraint_Visitor.

Definition at line 838 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), expr_returns_boolean(), extract_type(), TAO_Binary_Constraint::left_operand(), and TAO_Binary_Constraint::right_operand().

Referenced by visit_or().

00839 {
00840   int return_value = -1;
00841   TAO_Constraint* left = boolean_and->left_operand (),
00842     *right = boolean_and->right_operand ();
00843   TAO_Expression_Type left_type, right_type;
00844   this->extract_type (left, left_type);
00845   this->extract_type (right, right_type);
00846 
00847   // Can only "and" expressions that return a boolean value
00848   if (this->expr_returns_boolean (left_type) &&
00849       this->expr_returns_boolean (right_type))
00850     {
00851       if (left->accept (this) == 0 &&
00852           right->accept (this) == 0)
00853         return_value = 0;
00854     }
00855 
00856   return return_value;
00857 }

int TAO_Constraint_Validator::visit_constraint ( TAO_Unary_Constraint constraint  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 793 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), extract_type(), and TAO_Unary_Constraint::operand().

Referenced by visit_with().

00794 {
00795   int return_value = -1;
00796   TAO_Expression_Type type;
00797   TAO_Constraint* operand = constraint->operand ();
00798   this->extract_type (operand, type);
00799 
00800   if (this->expr_returns_boolean (type))
00801     return_value =  operand->accept (this);
00802 
00803   return return_value;
00804 }

int TAO_Constraint_Validator::visit_div ( TAO_Binary_Constraint boolean_div  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 954 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), expr_returns_number(), extract_type(), TAO_Binary_Constraint::left_operand(), TAO_Binary_Constraint::right_operand(), TAO_DOUBLE, TAO_SIGNED, and TAO_UNSIGNED.

00955 {
00956   // Div not only requires that both of its operands be numeric, but
00957   // also the the demoninator not be zero. However, since the
00958   // denominator can be an expression who's value can only be
00959   // determined while evaulating the constraint expression, this
00960   // method detects only when the demoniator is a literal whose value
00961   // is zero.
00962   int return_value = -1;
00963   TAO_Constraint* left = boolean_div->left_operand (),
00964     *right = boolean_div->right_operand ();
00965   TAO_Expression_Type left_type, right_type;
00966   this->extract_type (left, left_type);
00967   this->extract_type (right, right_type);
00968 
00969   if (this->expr_returns_number (left_type) &&
00970       this->expr_returns_number (right_type))
00971     {
00972       // Prevent division by zero, a no no.
00973       int right_isnt_zero = 1;
00974       switch(right->expr_type ())
00975         {
00976         case TAO_UNSIGNED:
00977           right_isnt_zero =
00978             (static_cast<CORBA::ULongLong>
00979                (*dynamic_cast<TAO_Literal_Constraint*> (right)) != 0);
00980           break;
00981         case TAO_SIGNED:
00982           right_isnt_zero =
00983             (static_cast<CORBA::LongLong>
00984                (*dynamic_cast<TAO_Literal_Constraint*> (right)) != 0);
00985           break;
00986         case TAO_DOUBLE:
00987           right_isnt_zero =
00988             (static_cast<CORBA::Double>
00989                (*dynamic_cast<TAO_Literal_Constraint*> (right)) != 0.0);
00990           break;
00991         }
00992 
00993       if (right_isnt_zero)
00994         {
00995           if (left->accept (this) == 0 &&
00996               right->accept (this) == 0)
00997             return_value = 0;
00998         }
00999     }
01000 
01001   return return_value;
01002 }

int TAO_Constraint_Validator::visit_equal ( TAO_Binary_Constraint boolean_eq  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 1132 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), expr_returns_boolean(), expr_returns_number(), expr_returns_string(), extract_type(), TAO_Binary_Constraint::left_operand(), and TAO_Binary_Constraint::right_operand().

Referenced by visit_not_equal().

01133 {
01134   int return_value = -1;
01135   TAO_Constraint* left = boolean_eq->left_operand (),
01136     *right = boolean_eq->right_operand ();
01137   TAO_Expression_Type left_type, right_type;
01138   this->extract_type (left, left_type);
01139   this->extract_type (right, right_type);
01140 
01141   if ((this->expr_returns_number (left_type) &&
01142        this->expr_returns_number (right_type)) ||
01143       (this->expr_returns_string (left_type) &&
01144        this->expr_returns_string (right_type)) ||
01145       (this->expr_returns_boolean (left_type) &&
01146        this->expr_returns_boolean (right_type)))
01147     {
01148       if (left->accept (this) == 0 &&
01149           right->accept (this) == 0)
01150         return_value = 0;
01151     }
01152 
01153   return return_value;
01154 }

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.

Implements TAO_Constraint_Visitor.

Definition at line 885 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), TAO_Constraint::expr_type(), TAO_Unary_Constraint::operand(), and TAO_IDENT.

00886 {
00887   // Exist simply requires that its operand be a property name
00888   // included in the service type.
00889   int return_value = -1;
00890   TAO_Constraint* operand = unary_exist->operand ();
00891   TAO_Expression_Type type = operand->expr_type ();
00892 
00893   if (type == TAO_IDENT)
00894     return_value = operand->accept (this);
00895 
00896   return return_value;
00897 }

int TAO_Constraint_Validator::visit_first ( TAO_Noop_Constraint noop_first  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 807 of file Constraint_Visitors.cpp.

00808 {
00809   return 0;
00810 }

int TAO_Constraint_Validator::visit_greater_than ( TAO_Binary_Constraint boolean_gt  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 1118 of file Constraint_Visitors.cpp.

References visit_less_than().

01119 {
01120   return this->visit_less_than (boolean_gt);
01121 }

int TAO_Constraint_Validator::visit_greater_than_equal ( TAO_Binary_Constraint boolean_gte  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 1125 of file Constraint_Visitors.cpp.

References visit_less_than().

01126 {
01127   return this->visit_less_than(boolean_gte);
01128 }

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.

Implements TAO_Constraint_Visitor.

Definition at line 1029 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), extract_type(), TAO_Binary_Constraint::left_operand(), TAO_Binary_Constraint::right_operand(), TAO_Sequence_Extracter_Base::sequence_type(), TAO_SEQUENCE, CORBA::tk_boolean, CORBA::tk_double, CORBA::tk_float, CORBA::tk_long, CORBA::tk_longlong, CORBA::tk_short, CORBA::tk_string, CORBA::tk_ulong, CORBA::tk_ulonglong, CORBA::tk_ushort, and CORBA::tk_void.

01030 {
01031   // In requires that the right operand be a sequence of a simple type
01032   // and that its left operand be an expression that evaluates to a
01033   // value of the same simple type.
01034   int return_value = -1;
01035   TAO_Expression_Type left_type, right_type;
01036   TAO_Constraint
01037     *left = binary_in->left_operand (),
01038     *right = binary_in->right_operand ();
01039 
01040   CORBA::TypeCode* prop_type = this->extract_type (right, right_type);
01041   this->extract_type (left, left_type);
01042 
01043   if (right_type == TAO_SEQUENCE)
01044     {
01045       CORBA::Boolean types_match = 0;
01046       CORBA::TCKind seq_type = CORBA::tk_void;
01047       try
01048         {
01049           seq_type =
01050             TAO_Sequence_Extracter_Base::sequence_type (prop_type);
01051         }
01052       catch (const CORBA::Exception&)
01053         {
01054           return return_value;
01055         }
01056 
01057       if (seq_type != CORBA::tk_void)
01058         {
01059           if (this->expr_returns_number (left_type))
01060             {
01061               types_match = (seq_type == CORBA::tk_short ||
01062                              seq_type == CORBA::tk_ushort ||
01063                              seq_type == CORBA::tk_long ||
01064                              seq_type == CORBA::tk_ulong ||
01065                              seq_type == CORBA::tk_longlong ||
01066                              seq_type == CORBA::tk_ulonglong ||
01067                              seq_type == CORBA::tk_float ||
01068                              seq_type == CORBA::tk_double);
01069             }
01070           else if (this->expr_returns_boolean (left_type))
01071             types_match = (seq_type == CORBA::tk_boolean);
01072           else if (this->expr_returns_string (left_type))
01073             types_match = (seq_type == CORBA::tk_string);
01074 
01075           if (types_match)
01076             return_value = left->accept (this);
01077         }
01078     }
01079 
01080   return return_value;
01081 }

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.

Implements TAO_Constraint_Visitor.

Definition at line 1085 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), expr_returns_number(), expr_returns_string(), extract_type(), TAO_Binary_Constraint::left_operand(), and TAO_Binary_Constraint::right_operand().

Referenced by visit_greater_than(), visit_greater_than_equal(), and visit_less_than_equal().

01086 {
01087   // Comparison operations require that both operands be of the same
01088   // simple type.
01089   int return_value = -1;
01090   TAO_Constraint* left = boolean_lt->left_operand (),
01091     *right = boolean_lt->right_operand ();
01092   TAO_Expression_Type left_type, right_type;
01093   this->extract_type (left, left_type);
01094   this->extract_type (right, right_type);
01095 
01096   if ((this->expr_returns_number (left_type) &&
01097        this->expr_returns_number (right_type)) ||
01098       (this->expr_returns_string (left_type) &&
01099        this->expr_returns_string (right_type)))
01100     {
01101       if (left->accept (this) == 0 &&
01102           right->accept (this) == 0)
01103         return_value = 0;
01104     }
01105 
01106   return return_value;
01107 }

int TAO_Constraint_Validator::visit_less_than_equal ( TAO_Binary_Constraint boolean_lte  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 1111 of file Constraint_Visitors.cpp.

References visit_less_than().

01112 {
01113   return this->visit_less_than (boolean_lte);
01114 }

int TAO_Constraint_Validator::visit_literal ( TAO_Literal_Constraint literal  )  [virtual]

The property must be defined in the service type description.

Implements TAO_Constraint_Visitor.

Definition at line 1165 of file Constraint_Visitors.cpp.

01166 {
01167   return 0;
01168 }

int TAO_Constraint_Validator::visit_max ( TAO_Unary_Constraint unary_max  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 831 of file Constraint_Visitors.cpp.

References visit_unary_minus().

00832 {
00833   return this->visit_unary_minus (unary_max);
00834 }

int TAO_Constraint_Validator::visit_min ( TAO_Unary_Constraint unary_min  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 825 of file Constraint_Visitors.cpp.

References visit_unary_minus().

00826 {
00827   return this->visit_unary_minus (unary_min);
00828 }

int TAO_Constraint_Validator::visit_mult ( TAO_Binary_Constraint boolean_mult  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 947 of file Constraint_Visitors.cpp.

References visit_add().

00948 {
00949   return this->visit_add (boolean_mult);
00950 }

int TAO_Constraint_Validator::visit_not ( TAO_Unary_Constraint unary_not  )  [virtual]

The operand must return a boolean value.

Implements TAO_Constraint_Visitor.

Definition at line 869 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), extract_type(), and TAO_Unary_Constraint::operand().

00870 {
00871   int return_value = -1;
00872   // Not can only negate an expression that returns a boolean.
00873   TAO_Expression_Type type;
00874   TAO_Constraint* operand = unary_not->operand ();
00875   this->extract_type (operand, type);
00876 
00877   if (this->expr_returns_boolean (type))
00878     return_value = operand->accept (this);
00879 
00880   return return_value;
00881 }

int TAO_Constraint_Validator::visit_not_equal ( TAO_Binary_Constraint boolean_neq  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 1158 of file Constraint_Visitors.cpp.

References visit_equal().

01159 {
01160   return this->visit_equal (boolean_neq);
01161 }

int TAO_Constraint_Validator::visit_or ( TAO_Binary_Constraint boolean_or  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 861 of file Constraint_Visitors.cpp.

References visit_and().

00862 {
00863   // The types for or are the same as those for and.
00864   return this->visit_and (boolean_or);
00865 }

int TAO_Constraint_Validator::visit_property ( TAO_Property_Constraint literal  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 1172 of file Constraint_Visitors.cpp.

01173 {
01174   return 0;
01175 }

int TAO_Constraint_Validator::visit_random ( TAO_Noop_Constraint noop_random  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 813 of file Constraint_Visitors.cpp.

00814 {
00815   return 0;
00816 }

int TAO_Constraint_Validator::visit_sub ( TAO_Binary_Constraint boolean_sub  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 940 of file Constraint_Visitors.cpp.

References visit_add().

00941 {
00942   return this->visit_add (boolean_sub);
00943 }

int TAO_Constraint_Validator::visit_twiddle ( TAO_Binary_Constraint binary_twiddle  )  [virtual]

Both operands must return strings.

Implements TAO_Constraint_Visitor.

Definition at line 1006 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), expr_returns_string(), extract_type(), TAO_Binary_Constraint::left_operand(), and TAO_Binary_Constraint::right_operand().

01007 {
01008   // Twiddle requires that both of its operand be strings.
01009   int return_value = -1;
01010   TAO_Constraint* left = binary_twiddle->left_operand (),
01011     *right = binary_twiddle->right_operand ();
01012   TAO_Expression_Type left_type, right_type;
01013   this->extract_type (left, left_type);
01014   this->extract_type (right, right_type);
01015 
01016   if  (this->expr_returns_string (left_type) &&
01017       this->expr_returns_string (right_type))
01018     {
01019       if (left->accept (this) == 0 &&
01020           right->accept (this) == 0)
01021         return_value = 0;
01022     }
01023 
01024   return return_value;
01025 }

int TAO_Constraint_Validator::visit_unary_minus ( TAO_Unary_Constraint unary_minus  )  [virtual]

The operand must return a number to be negated.

Implements TAO_Constraint_Visitor.

Definition at line 901 of file Constraint_Visitors.cpp.

References TAO_Constraint::accept(), extract_type(), and TAO_Unary_Constraint::operand().

Referenced by visit_max(), and visit_min().

00902 {
00903   // Unary minus can only negate a numeric operand.
00904   int return_value = -1;
00905   TAO_Expression_Type type;
00906   TAO_Constraint* operand = unary_minus->operand ();
00907   this->extract_type (operand, type);
00908 
00909   if (this->expr_returns_number (type))
00910     return_value = operand->accept (this);
00911 
00912   return return_value;
00913 }

int TAO_Constraint_Validator::visit_with ( TAO_Unary_Constraint unary_with  )  [virtual]

Implements TAO_Constraint_Visitor.

Definition at line 819 of file Constraint_Visitors.cpp.

References visit_constraint().

00820 {
00821   return this->visit_constraint (unary_with);
00822 }


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.

Definition at line 185 of file Constraint_Visitors.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:49:32 2010 for TAO_CosTrader by  doxygen 1.4.7