TAO_Notify_Constraint_Visitor Class Reference

#include <Notify_Constraint_Visitors.h>

Collaboration diagram for TAO_Notify_Constraint_Visitor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Notify_Constraint_Visitor (void)
 Constructor.

int bind_structured_event (const CosNotification::StructuredEvent &s_event)
 Put the event data into our hash map.

CORBA::Boolean evaluate_constraint (TAO_ETCL_Constraint *root)
int visit_literal (TAO_ETCL_Literal_Constraint *)
int visit_identifier (TAO_ETCL_Identifier *)
int visit_union_value (TAO_ETCL_Union_Value *)
int visit_union_pos (TAO_ETCL_Union_Pos *)
int visit_component_pos (TAO_ETCL_Component_Pos *)
int visit_component_assoc (TAO_ETCL_Component_Assoc *)
int visit_component_array (TAO_ETCL_Component_Array *)
int visit_special (TAO_ETCL_Special *)
int visit_component (TAO_ETCL_Component *)
int visit_dot (TAO_ETCL_Dot *)
int visit_eval (TAO_ETCL_Eval *)
int visit_default (TAO_ETCL_Default *)
int visit_exist (TAO_ETCL_Exist *)
int visit_unary_expr (TAO_ETCL_Unary_Expr *)
int visit_binary_expr (TAO_ETCL_Binary_Expr *)
int visit_preference (TAO_ETCL_Preference *)

Protected Types

enum  structured_event_field {
  FILTERABLE_DATA, HEADER, FIXED_HEADER, EVENT_TYPE,
  DOMAIN_NAME, TYPE_NAME, EVENT_NAME, VARIABLE_HEADER,
  REMAINDER_OF_BODY, EMPTY
}

Protected Member Functions

int visit_or (TAO_ETCL_Binary_Expr *)
int visit_and (TAO_ETCL_Binary_Expr *)
int visit_twiddle (TAO_ETCL_Binary_Expr *)
int visit_in (TAO_ETCL_Binary_Expr *)
int visit_binary_op (TAO_ETCL_Binary_Expr *binary_expr, int op_type)
CORBA::Boolean sequence_does_contain (const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item)
CORBA::Boolean array_does_contain (const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item)
CORBA::Boolean struct_does_contain (const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item)
CORBA::Boolean union_does_contain (const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item)
CORBA::Boolean any_does_contain (const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item)
CORBA::Boolean simple_type_match (int expr_type, CORBA::TCKind tc_kind)

Protected Attributes

structured_event_field implicit_id_
 Storage for the type of implicit id the component has (if any).

ACE_Hash_Map_Manager< ACE_CString,
structured_event_field, ACE_Null_Mutex
implicit_ids_
ACE_Hash_Map_Manager< ACE_CString,
CORBA::Any, ACE_Null_Mutex
filterable_data_
 Used to lookup names and values in the event's 'filterable_data' field.

ACE_Hash_Map_Manager< ACE_CString,
CORBA::Any, ACE_Null_Mutex
variable_header_
 Used to lookup names and values in the event's 'variable_header' field.

CORBA::String_var domain_name_
CORBA::String_var type_name_
CORBA::String_var event_name_
CORBA::Any remainder_of_body_
 Storage for the structured_event's 'remainder_of_body' field.

ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint > queue_
 The result of a non_boolean operation.

CORBA::Any_var current_value_
CORBA::String_var current_name_

Static Protected Attributes

const size_t implicit_ids_size_ = 27
const size_t filterable_data_size_ = 31
const size_t variable_header_size_ = 31

Member Enumeration Documentation

enum TAO_Notify_Constraint_Visitor::structured_event_field [protected]
 

Enumeration values:
FILTERABLE_DATA 
HEADER 
FIXED_HEADER 
EVENT_TYPE 
DOMAIN_NAME 
TYPE_NAME 
EVENT_NAME 
VARIABLE_HEADER 
REMAINDER_OF_BODY 
EMPTY 

Definition at line 99 of file Notify_Constraint_Visitors.h.

00100     {
00101       FILTERABLE_DATA,
00102       HEADER,
00103       FIXED_HEADER,
00104       EVENT_TYPE,
00105       DOMAIN_NAME,
00106       TYPE_NAME,
00107       EVENT_NAME,
00108       VARIABLE_HEADER,
00109       REMAINDER_OF_BODY,
00110       EMPTY
00111     };


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Notify_Constraint_Visitor::TAO_Notify_Constraint_Visitor void   ) 
 

Constructor.

Definition at line 20 of file Notify_Constraint_Visitors.cpp.

References ACE_CString, ACE_Hash_Map_Manager_Ex< ACE_CString, structured_event_field, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::bind(), DOMAIN_NAME, EVENT_NAME, EVENT_TYPE, FILTERABLE_DATA, FIXED_HEADER, HEADER, implicit_ids_, REMAINDER_OF_BODY, TYPE_NAME, and VARIABLE_HEADER.

00021   : implicit_id_ (TAO_Notify_Constraint_Visitor::EMPTY),
00022     implicit_ids_(implicit_ids_size_),
00023     filterable_data_(filterable_data_size_),
00024     variable_header_(variable_header_size_)
00025 {
00026   (void) this->implicit_ids_.bind (ACE_CString ("filterable_data",
00027     0,
00028     false),
00029     FILTERABLE_DATA);
00030   (void) this->implicit_ids_.bind (ACE_CString ("header",
00031     0,
00032     false),
00033     HEADER);
00034   (void) this->implicit_ids_.bind (ACE_CString ("remainder_of_body",
00035     0,
00036     false),
00037     REMAINDER_OF_BODY);
00038   (void) this->implicit_ids_.bind (ACE_CString ("fixed_header",
00039     0,
00040     false),
00041     FIXED_HEADER);
00042   (void) this->implicit_ids_.bind (ACE_CString ("variable_header",
00043     0,
00044     false),
00045     VARIABLE_HEADER);
00046   (void) this->implicit_ids_.bind (ACE_CString ("event_name",
00047     0,
00048     false),
00049     EVENT_NAME);
00050   (void) this->implicit_ids_.bind (ACE_CString ("event_type",
00051     0,
00052     false),
00053     EVENT_TYPE);
00054   (void) this->implicit_ids_.bind (ACE_CString ("domain_name",
00055     0,
00056     false),
00057     DOMAIN_NAME);
00058   (void) this->implicit_ids_.bind (ACE_CString ("type_name",
00059     0,
00060     false),
00061     TYPE_NAME);
00062 }


Member Function Documentation

CORBA::Boolean TAO_Notify_Constraint_Visitor::any_does_contain const CORBA::Any *  any,
TAO_ETCL_Literal_Constraint &  item
[protected]
 

Definition at line 1332 of file Notify_Constraint_Visitors.cpp.

Referenced by visit_in().

01336 {
01337   const CORBA::Any *result = 0;
01338 
01339   *any >>= result;
01340 
01341   TAO_ETCL_Literal_Constraint element (const_cast<CORBA::Any *>(result));
01342   return item == element;
01343 }

CORBA::Boolean TAO_Notify_Constraint_Visitor::array_does_contain const CORBA::Any *  any,
TAO_ETCL_Literal_Constraint &  item
[protected]
 

Definition at line 1213 of file Notify_Constraint_Visitors.cpp.

References simple_type_match().

Referenced by visit_in().

01215 {
01216   try
01217   {
01218     CORBA::TypeCode_var type = any->type ();
01219     CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in ());
01220 
01221     // The literal and the array elements must be
01222     // of the same simple type.
01223     CORBA::Boolean match = this->simple_type_match (item.expr_type (),
01224       kind);
01225 
01226     if (match == 0)
01227       return 0;
01228 
01229     TAO_DynArray_i dyn_array;
01230     dyn_array.init (*any);
01231 
01232     DynamicAny::AnySeq_var any_seq =
01233       dyn_array.get_elements ();
01234 
01235     CORBA::ULong length = any_seq->length ();
01236 
01237     for (CORBA::ULong i = 0; i < length; ++i)
01238     {
01239       TAO_ETCL_Literal_Constraint element (&any_seq[i]);
01240 
01241       if (item == element)
01242         return 1;
01243     }
01244   }
01245   catch (const CORBA::Exception&)
01246   {
01247     return 0;
01248   }
01249 
01250   return 0;
01251 }

int TAO_Notify_Constraint_Visitor::bind_structured_event const CosNotification::StructuredEvent s_event  ) 
 

Put the event data into our hash map.

Definition at line 65 of file Notify_Constraint_Visitors.cpp.

References ACE_CString, domain_name_, event_name_, CosNotification::StructuredEvent::filterable_data, filterable_data_, CosNotification::StructuredEvent::header, CosNotification::StructuredEvent::remainder_of_body, remainder_of_body_, CORBA::string_dup(), type_name_, and variable_header_.

Referenced by TAO_Notify_ETCL_Filter::match_structured().

00066 {
00067   // The two sequences contained in a structured event are
00068   // copied into hash tables so iteration is done only once.
00069 
00070   CORBA::ULong length = s_event.filterable_data.length ();
00071   CORBA::ULong index = 0;
00072 
00073   for (index = 0; index < length; ++index)
00074   {
00075     ACE_CString name_str (s_event.filterable_data[index].name, 0, false);
00076 
00077     int status =
00078       this->filterable_data_.bind (
00079         name_str,
00080         s_event.filterable_data[index].value
00081         );
00082 
00083     if (status != 0)
00084       return -1;
00085   }
00086 
00087   length = s_event.header.variable_header.length ();
00088 
00089   for (index = 0; index < length; ++index)
00090   {
00091     ACE_CString name_str (s_event.header.variable_header[index].name, 0, false);
00092 
00093     int status =
00094       this->variable_header_.bind (
00095         name_str,
00096         s_event.header.variable_header[index].value
00097         );
00098 
00099     if (status != 0)
00100       return -1;
00101   }
00102 
00103   this->domain_name_ =
00104     CORBA::string_dup (s_event.header.fixed_header.event_type.domain_name);
00105 
00106   this->type_name_ =
00107     CORBA::string_dup (s_event.header.fixed_header.event_type.type_name);
00108 
00109   this->event_name_ =
00110     CORBA::string_dup (s_event.header.fixed_header.event_name);
00111 
00112   this->remainder_of_body_ = s_event.remainder_of_body;
00113 
00114   return 0;
00115 }

CORBA::Boolean TAO_Notify_Constraint_Visitor::evaluate_constraint TAO_ETCL_Constraint *  root  ) 
 

Returns 1 if the event satisfies the constraint represented by the the expression tree rooted at , 0 if it doesn't. If an error occurs during the process, the traversal automatically fails.

Definition at line 118 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::is_empty(), and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::reset().

Referenced by TAO_Notify_Constraint_Interpreter::evaluate().

00121 {
00122   CORBA::Boolean result = 0;
00123   this->queue_.reset ();
00124 
00125   // Evaluate the constraint in root_;
00126   if (root != 0)
00127   {
00128     if ((root->accept (this) == 0) &&
00129       (! this->queue_.is_empty ()))
00130     {
00131       TAO_ETCL_Literal_Constraint top;
00132       this->queue_.dequeue_head (top);
00133       result = (CORBA::Boolean) top;
00134     }
00135   }
00136 
00137   // If a property couldn't be evaluated we must return 0.
00138   return result;
00139 }

CORBA::Boolean TAO_Notify_Constraint_Visitor::sequence_does_contain const CORBA::Any *  any,
TAO_ETCL_Literal_Constraint &  item
[protected]
 

Definition at line 1167 of file Notify_Constraint_Visitors.cpp.

References simple_type_match().

Referenced by visit_in().

01169 {
01170   try
01171   {
01172     CORBA::TypeCode_var type = any->type ();
01173     CORBA::TypeCode_var base_type =
01174       TAO_DynAnyFactory::strip_alias (type.in ());
01175     CORBA::TypeCode_var content_type =
01176       base_type->content_type ();
01177     CORBA::TCKind kind =
01178       TAO_DynAnyFactory::unalias (content_type.in());
01179 
01180     // The literal and the array elements must be
01181     // of the same simple type.
01182     CORBA::Boolean match = this->simple_type_match (item.expr_type (),
01183       kind);
01184 
01185     if (match == 0)
01186       return 0;
01187 
01188     TAO_DynSequence_i dyn_seq;
01189     dyn_seq.init (*any);
01190 
01191     DynamicAny::AnySeq_var any_seq =
01192       dyn_seq.get_elements ();
01193 
01194     CORBA::ULong length = any_seq->length ();
01195 
01196     for (CORBA::ULong i = 0; i < length; ++i)
01197     {
01198       TAO_ETCL_Literal_Constraint element (&any_seq[i]);
01199 
01200       if (item == element)
01201         return 1;
01202     }
01203   }
01204   catch (const CORBA::Exception&)
01205   {
01206     return 0;
01207   }
01208 
01209   return 0;
01210 }

CORBA::Boolean TAO_Notify_Constraint_Visitor::simple_type_match int  expr_type,
CORBA::TCKind  tc_kind
[protected]
 

Definition at line 1346 of file Notify_Constraint_Visitors.cpp.

Referenced by array_does_contain(), sequence_does_contain(), struct_does_contain(), and union_does_contain().

01348 {
01349   switch (expr_type)
01350   {
01351   case TAO_ETCL_STRING:
01352     if (tc_kind != CORBA::tk_string)
01353       return 0;
01354     break;
01355   case TAO_ETCL_DOUBLE:
01356     if (tc_kind != CORBA::tk_double
01357       && tc_kind != CORBA::tk_float)
01358       return 0;
01359     break;
01360   case TAO_ETCL_INTEGER:
01361   case TAO_ETCL_SIGNED:
01362     if (tc_kind != CORBA::tk_short
01363       && tc_kind != CORBA::tk_long
01364       && tc_kind != CORBA::tk_longlong)
01365       return 0;
01366     break;
01367   case TAO_ETCL_UNSIGNED:
01368     if (tc_kind != CORBA::tk_ushort
01369       && tc_kind != CORBA::tk_ulong
01370       && tc_kind != CORBA::tk_ulonglong)
01371       return 0;
01372     break;
01373   case TAO_ETCL_BOOLEAN:
01374     if (tc_kind != CORBA::tk_boolean)
01375       return 0;
01376     break;
01377   default:
01378     return 0;
01379   }
01380   return 1;
01381 }

CORBA::Boolean TAO_Notify_Constraint_Visitor::struct_does_contain const CORBA::Any *  any,
TAO_ETCL_Literal_Constraint &  item
[protected]
 

Definition at line 1254 of file Notify_Constraint_Visitors.cpp.

References simple_type_match().

Referenced by visit_in().

01256 {
01257   try
01258   {
01259     TAO_DynStruct_i dyn_struct;
01260     dyn_struct.init (*any);
01261 
01262     DynamicAny::NameValuePairSeq_var members =
01263       dyn_struct.get_members ();
01264 
01265     CORBA::ULong length = members->length ();
01266     CORBA::TypeCode_var tc;
01267     CORBA::TCKind kind;
01268 
01269     for (CORBA::ULong i = 0; i < length; ++i)
01270     {
01271       tc = members[i].value.type ();
01272       kind = TAO_DynAnyFactory::unalias (tc.in ());
01273 
01274       // The literal and the struct member must be
01275       // of the same simple type.
01276       CORBA::Boolean match = this->simple_type_match (item.expr_type (),
01277         kind);
01278 
01279       if (match == 0)
01280         continue;
01281 
01282       TAO_ETCL_Literal_Constraint element (&members[i].value);
01283 
01284       if (item == element)
01285         return 1;
01286     }
01287   }
01288   catch (const CORBA::Exception&)
01289   {
01290     return 0;
01291   }
01292 
01293   return 0;
01294 }

CORBA::Boolean TAO_Notify_Constraint_Visitor::union_does_contain const CORBA::Any *  any,
TAO_ETCL_Literal_Constraint &  item
[protected]
 

Definition at line 1297 of file Notify_Constraint_Visitors.cpp.

References simple_type_match().

Referenced by visit_in().

01299 {
01300   try
01301   {
01302     TAO_DynUnion_i dyn_union;
01303     dyn_union.init (*any);
01304 
01305     DynamicAny::DynAny_var cc =
01306       dyn_union.current_component ();
01307 
01308     CORBA::Any_var member = cc->to_any ();
01309 
01310     CORBA::TypeCode_var tc = member->type ();
01311     CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());
01312 
01313     // The literal and the union member must be
01314     // of the same simple type.
01315     CORBA::Boolean match = this->simple_type_match (item.expr_type (),
01316       kind);
01317 
01318     if (match == 0)
01319       return 0;
01320 
01321     TAO_ETCL_Literal_Constraint element (&member.inout ());
01322 
01323     return (item == element);
01324   }
01325   catch (const CORBA::Exception&)
01326   {
01327     return 0;
01328   }
01329 }

int TAO_Notify_Constraint_Visitor::visit_and TAO_ETCL_Binary_Expr *   )  [protected]
 

Definition at line 951 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

Referenced by visit_binary_expr().

00952 {
00953   int return_value = -1;
00954   CORBA::Boolean result = 0;
00955   TAO_ETCL_Constraint *lhs = binary->lhs ();
00956 
00957   if (lhs->accept (this) == 0)
00958   {
00959     TAO_ETCL_Literal_Constraint lhs_result;
00960     this->queue_.dequeue_head (lhs_result);
00961     result = (CORBA::Boolean) lhs_result;
00962 
00963     // Short-circuiting AND.
00964     if (result == 1)
00965     {
00966       TAO_ETCL_Constraint *rhs = binary->rhs ();
00967 
00968       if (rhs->accept (this) == 0)
00969       {
00970         TAO_ETCL_Literal_Constraint rhs_result;
00971         this->queue_.dequeue_head (rhs_result);
00972         result = (CORBA::Boolean) rhs_result;
00973         return_value = 0;
00974       }
00975     }
00976     else
00977       return_value = 0;
00978   }
00979 
00980   if (return_value == 0)
00981     this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
00982 
00983   return return_value;
00984 }

int TAO_Notify_Constraint_Visitor::visit_binary_expr TAO_ETCL_Binary_Expr *   ) 
 

Definition at line 879 of file Notify_Constraint_Visitors.cpp.

References visit_and(), visit_binary_op(), visit_in(), visit_or(), and visit_twiddle().

00882 {
00883   int bin_op_type = binary_expr->type ();
00884 
00885   switch (bin_op_type)
00886   {
00887   case TAO_ETCL_OR:
00888     return this->visit_or (binary_expr);
00889   case TAO_ETCL_AND:
00890     return this->visit_and (binary_expr);
00891   case TAO_ETCL_LT:
00892   case TAO_ETCL_LE:
00893   case TAO_ETCL_GT:
00894   case TAO_ETCL_GE:
00895   case TAO_ETCL_EQ:
00896   case TAO_ETCL_NE:
00897   case TAO_ETCL_PLUS:
00898   case TAO_ETCL_MINUS:
00899   case TAO_ETCL_MULT:
00900   case TAO_ETCL_DIV:
00901     return this->visit_binary_op (binary_expr,
00902       bin_op_type);
00903   case TAO_ETCL_TWIDDLE:
00904     return this->visit_twiddle (binary_expr);
00905   case TAO_ETCL_IN:
00906     return this->visit_in (binary_expr);
00907   default:
00908     return -1;
00909   }
00910 }

int TAO_Notify_Constraint_Visitor::visit_binary_op TAO_ETCL_Binary_Expr *  binary_expr,
int  op_type
[protected]
 

Definition at line 987 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

Referenced by visit_binary_expr().

00989 {
00990   int return_value = -1;
00991   TAO_ETCL_Constraint *lhs = binary->lhs ();
00992   CORBA::Boolean result = 0;
00993 
00994   // Perform an operation on the results of evaluating the left and
00995   // right branches of this subtree.
00996   if (lhs->accept (this) == 0)
00997   {
00998     TAO_ETCL_Literal_Constraint left_operand;
00999     this->queue_.dequeue_head (left_operand);
01000     TAO_ETCL_Constraint *rhs = binary->rhs ();
01001 
01002     if (rhs->accept (this) == 0)
01003     {
01004       TAO_ETCL_Literal_Constraint right_operand;
01005       this->queue_.dequeue_head (right_operand);
01006       return_value = 0;
01007 
01008       switch (op_type)
01009       {
01010       case TAO_ETCL_LT:
01011         result = left_operand < right_operand;
01012         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01013         break;
01014       case TAO_ETCL_LE:
01015         result = left_operand <= right_operand;
01016         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01017         break;
01018       case TAO_ETCL_GT:
01019         result = left_operand > right_operand;
01020         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01021         break;
01022       case TAO_ETCL_GE:
01023         result = left_operand >= right_operand;
01024         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01025         break;
01026       case TAO_ETCL_EQ:
01027         result = left_operand == right_operand;
01028         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01029         break;
01030       case TAO_ETCL_NE:
01031         result = left_operand != right_operand;
01032         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01033         break;
01034       case TAO_ETCL_PLUS:
01035         this->queue_.enqueue_head (left_operand + right_operand);
01036         break;
01037       case TAO_ETCL_MINUS:
01038         this->queue_.enqueue_head (left_operand - right_operand);
01039         break;
01040       case TAO_ETCL_MULT:
01041         this->queue_.enqueue_head (left_operand * right_operand);
01042         break;
01043       case TAO_ETCL_DIV:
01044         this->queue_.enqueue_head (left_operand / right_operand);
01045         break;
01046       default:
01047         return_value = -1;
01048       }
01049     }
01050   }
01051 
01052   return return_value;
01053 }

int TAO_Notify_Constraint_Visitor::visit_component TAO_ETCL_Component *   ) 
 

Definition at line 624 of file Notify_Constraint_Visitors.cpp.

References ACE_CString, ACE_NEW_RETURN, current_value_, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), DOMAIN_NAME, EMPTY, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), EVENT_NAME, ACE_Hash_Map_Manager_Ex< ACE_CString, structured_event_field, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::find(), implicit_id_, implicit_ids_, REMAINDER_OF_BODY, and TYPE_NAME.

00627 {
00628   TAO_ETCL_Constraint *nested = component->component ();
00629   TAO_ETCL_Identifier *identifier = component->identifier ();
00630   ACE_CString component_name (identifier->value (),
00631     0,
00632     false);
00633   CORBA::Any *any_ptr = 0;
00634 
00635   if (this->implicit_ids_.find (component_name, this->implicit_id_) != 0)
00636     this->implicit_id_ = TAO_Notify_Constraint_Visitor::EMPTY;
00637 
00638   // If this component has no sub-component, only an identifier, then
00639   // we just visit the identifier, which puts a literal on the queue
00640   // to be handled upon returning from this method call.  If there is
00641   // a sub-component, we store the literal's value in our member _var
00642   // for possible examination at a more nested level, and visit the
00643   // sub-component. If the identifier matches one of the nested field
00644   // names in CosNotification::StructuredEvent, we just visit the
00645   // nested component, if any.
00646   if (this->implicit_id_ == TAO_Notify_Constraint_Visitor::EMPTY)
00647   {
00648     if (nested == 0)
00649     {
00650       // If this is the end of the line, we put the component name
00651       // into current_value_ so visit_exist can use it.
00652       ACE_NEW_RETURN (any_ptr,
00653         CORBA::Any,
00654         -1);
00655       (*any_ptr) <<= component_name.c_str ();
00656       this->current_value_ = any_ptr;
00657       return identifier->accept (this);
00658     }
00659     else
00660     {
00661       int result = identifier->accept (this);
00662 
00663       if (result != 0)
00664         return result;
00665 
00666       TAO_ETCL_Literal_Constraint id;
00667       this->queue_.dequeue_head (id);
00668       ACE_NEW_RETURN (any_ptr,
00669         CORBA::Any (),
00670         -1);
00671       any_ptr->replace (id);
00672       any_ptr->impl ()->_add_ref ();
00673       this->current_value_ = any_ptr;
00674     }
00675   }
00676 
00677   if (nested != 0)
00678     return nested->accept (this);
00679   else
00680   {
00681     switch (this->implicit_id_)
00682     {
00683     case TYPE_NAME:
00684       {
00685         TAO_ETCL_Literal_Constraint tn (this->type_name_.in ());
00686         this->queue_.enqueue_head (tn);
00687         return 0;
00688       }
00689     case EVENT_NAME:
00690       {
00691         TAO_ETCL_Literal_Constraint en (this->event_name_.in ());
00692         this->queue_.enqueue_head (en);
00693         return 0;
00694       }
00695     case DOMAIN_NAME:
00696       {
00697         TAO_ETCL_Literal_Constraint dn (this->domain_name_.in ());
00698         this->queue_.enqueue_head (dn);
00699         return 0;
00700       }
00701     case REMAINDER_OF_BODY:
00702       {
00703         TAO_ETCL_Literal_Constraint rob (&this->remainder_of_body_);
00704         this->queue_.enqueue_head (rob);
00705         return 0;
00706       }
00707       // The above cases are the leaves of the
00708       // CosNotification::StructuredEvent "tree". Anything else and we
00709       // should have a nested component. otherwise, it's an error.
00710     default:
00711       return -1;
00712     }
00713   }
00714 }

int TAO_Notify_Constraint_Visitor::visit_component_array TAO_ETCL_Component_Array *   ) 
 

Definition at line 466 of file Notify_Constraint_Visitors.cpp.

References current_value_, and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00467 {
00468   try
00469   {
00470     // If we are here (from visit_component) the Any containing the
00471     // component as found in filterable_data_ will be in
00472     // current_value_.
00473     CORBA::TypeCode_var tc = this->current_value_->type ();
00474     CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());
00475 
00476     DynamicAny::DynAny_var member;
00477     CORBA::Boolean success = 0;
00478     CORBA::ULong slot = (CORBA::ULong) *array->integer ();
00479 
00480     switch (kind)
00481     {
00482     case CORBA::tk_array:
00483       {
00484         TAO_DynEnum_i dyn_array;
00485         dyn_array.init (this->current_value_.in ());
00486 
00487         success = dyn_array.seek (slot);
00488 
00489         if (success == 0)
00490           return -1;
00491 
00492         member = dyn_array.current_component ();
00493 
00494         break;
00495       }
00496     case CORBA::tk_sequence:
00497       {
00498         TAO_DynStruct_i dyn_sequence;
00499         dyn_sequence.init (this->current_value_.in ());
00500 
00501         success = dyn_sequence.seek (slot);
00502 
00503         if (success == 0)
00504           return -1;
00505 
00506         member =
00507           dyn_sequence.current_component ();
00508 
00509         break;
00510       }
00511       // Enums and sequences are the only two cases handled
00512       // by Component_Array.
00513     default:
00514       return -1;
00515     }
00516 
00517     CORBA::Any_var value = member->to_any ();
00518 
00519     TAO_ETCL_Constraint *comp = array->component ();
00520 
00521     if (comp == 0)
00522     {
00523       TAO_ETCL_Literal_Constraint result (value.ptr ());
00524       this->queue_.enqueue_head (result);
00525       return 0;
00526     }
00527     else
00528     {
00529       this->current_value_ = value._retn ();
00530       return comp->accept (this);
00531     }
00532   }
00533   catch (const CORBA::Exception&)
00534   {
00535     return -1;
00536   }
00537 }

int TAO_Notify_Constraint_Visitor::visit_component_assoc TAO_ETCL_Component_Assoc *   ) 
 

Definition at line 410 of file Notify_Constraint_Visitors.cpp.

References ACE_CString, ACE_NEW_RETURN, current_value_, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), FILTERABLE_DATA, filterable_data_, implicit_id_, VARIABLE_HEADER, and variable_header_.

00413 {
00414   CORBA::Any any;
00415   ACE_CString name (assoc->identifier ()->value (),
00416     0,
00417     false);
00418 
00419   switch (this->implicit_id_)
00420   {
00421   case FILTERABLE_DATA:
00422     if (this->filterable_data_.find (name, any) != 0
00423       || any.impl() == 0)
00424       return -1;
00425     break;
00426   case VARIABLE_HEADER:
00427     if (this->variable_header_.find (name, any) != 0
00428       || any.impl() == 0)
00429       return -1;
00430     break;
00431     // Only the sequence members of CosNotification::StructuredEvent
00432     // can be treated as associative arrays.
00433   default:
00434     return -1;
00435   }
00436 
00437   TAO_ETCL_Constraint *comp = assoc->component ();
00438   CORBA::Any *any_ptr = 0;
00439 
00440   if (comp == 0)
00441   {
00442     TAO_ETCL_Literal_Constraint result (&any);
00443     this->queue_.enqueue_head (result);
00444 
00445     // If we're at the end of the line, put the name into
00446     // current_value_ so visit_exist can use it.
00447     ACE_NEW_RETURN (any_ptr,
00448       CORBA::Any,
00449       -1);
00450     (*any_ptr) <<= name.c_str ();
00451     this->current_value_ = any_ptr;
00452 
00453     return 0;
00454   }
00455   else
00456   {
00457     ACE_NEW_RETURN (any_ptr,
00458       CORBA::Any (any),
00459       -1);
00460     this->current_value_ = any_ptr;
00461     return comp->accept (this);
00462   }
00463 }

int TAO_Notify_Constraint_Visitor::visit_component_pos TAO_ETCL_Component_Pos *   ) 
 

Definition at line 333 of file Notify_Constraint_Visitors.cpp.

References current_value_, and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00336 {
00337   try
00338   {
00339     // If we are here (from visit_component) the Any containing the
00340     // component as found in filterable_data_ will be in current_value_.
00341     CORBA::TypeCode_var tc = this->current_value_->type ();
00342     CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());
00343 
00344     DynamicAny::DynAny_var member;
00345     CORBA::Boolean success = 0;
00346     CORBA::ULong slot = (CORBA::ULong) *pos->integer ();
00347 
00348     switch (kind)
00349     {
00350     case CORBA::tk_enum:
00351       {
00352         TAO_DynEnum_i dyn_enum;
00353         dyn_enum.init (this->current_value_.in ());
00354 
00355         success = dyn_enum.seek (slot);
00356 
00357         if (success == 0)
00358           return -1;
00359 
00360         member =
00361           dyn_enum.current_component ();
00362 
00363         break;
00364       }
00365     case CORBA::tk_struct:
00366       {
00367         TAO_DynStruct_i dyn_struct;
00368         dyn_struct.init (this->current_value_.in ());
00369 
00370         success = dyn_struct.seek (slot);
00371 
00372         if (success == 0)
00373           return -1;
00374 
00375         member = dyn_struct.current_component ();
00376 
00377         break;
00378       }
00379       // @@@ (JP) I think enums and structs are the only two cases
00380       // handled by Component_Pos, since arrays and sequences are
00381       // handled by Component_Array, and unions are handled by
00382       // Union_Pos.
00383     default:
00384       return -1;
00385     }
00386 
00387     CORBA::Any_var value = member->to_any ();
00388 
00389     TAO_ETCL_Constraint *comp = pos->component ();
00390 
00391     if (comp == 0)
00392     {
00393       TAO_ETCL_Literal_Constraint result (value.ptr ());
00394       this->queue_.enqueue_head (result);
00395       return 0;
00396     }
00397     else
00398     {
00399       this->current_value_ = value._retn ();
00400       return comp->accept (this);
00401     }
00402   }
00403   catch (const CORBA::Exception&)
00404   {
00405     return -1;
00406   }
00407 }

int TAO_Notify_Constraint_Visitor::visit_default TAO_ETCL_Default *   ) 
 

Definition at line 733 of file Notify_Constraint_Visitors.cpp.

References current_value_, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00734 {
00735   TAO_ETCL_Constraint *comp = def->component ();
00736 
00737   if (comp == 0)
00738     return -1;
00739 
00740   if (comp->accept (this) != 0)
00741     return -1;
00742 
00743   try
00744   {
00745     CORBA::TypeCode_var tc = this->current_value_->type ();
00746 
00747     // If the current member is not a union, this call will throw
00748     // BadKind and the catch block will return -1.
00749     CORBA::Long default_index = tc->default_index ();
00750 
00751     // No default index.
00752     if (default_index == -1)
00753     {
00754       TAO_ETCL_Literal_Constraint result ((CORBA::Boolean) 0);
00755       this->queue_.enqueue_head (result);
00756       return 0;
00757     }
00758 
00759     // Okay, there's a default index, but is it active?
00760 
00761     TAO_ETCL_Literal_Constraint disc;
00762     this->queue_.dequeue_head (disc);
00763     TAO_ETCL_Literal_Constraint default_index_value (default_index);
00764     return (disc == default_index_value);
00765   }
00766   catch (const CORBA::Exception&)
00767   {
00768     return -1;
00769   }
00770 }

int TAO_Notify_Constraint_Visitor::visit_dot TAO_ETCL_Dot *   ) 
 

Definition at line 717 of file Notify_Constraint_Visitors.cpp.

00718 {
00719   // If we are here, we know we're headed for a more nested
00720   // level, so we just visit it, there's nothing else in this
00721   // constraint.
00722   return dot->component ()->accept (this);
00723 }

int TAO_Notify_Constraint_Visitor::visit_eval TAO_ETCL_Eval *   ) 
 

Definition at line 726 of file Notify_Constraint_Visitors.cpp.

00727 {
00728   // Nothing to do but visit the contained component.
00729   return eval->component ()->accept (this);
00730 }

int TAO_Notify_Constraint_Visitor::visit_exist TAO_ETCL_Exist *   ) 
 

Definition at line 773 of file Notify_Constraint_Visitors.cpp.

References ACE_CString, current_value_, DOMAIN_NAME, domain_name_, EMPTY, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), EVENT_NAME, event_name_, FILTERABLE_DATA, filterable_data_, implicit_id_, TYPE_NAME, type_name_, VARIABLE_HEADER, and variable_header_.

00774 {
00775   TAO_ETCL_Constraint *component = exist->component ();
00776 
00777   if (component->accept (this) == 0)
00778   {
00779     const char *value = 0;
00780     CORBA::Boolean result = 0;
00781 
00782     // For the two cases below, we don't want the item at the top of
00783     // the queue, because it's the result of a hash table
00784     // lookup. For an existence test, we want the key value, which
00785     // is stored in the current_value_ member.
00786     if (this->implicit_id_ == FILTERABLE_DATA
00787       || this->implicit_id_ == VARIABLE_HEADER)
00788     {
00789       this->current_value_ >>= value;
00790     }
00791     // If the implicit id is empty, then we must default
00792     // it to the filterable data and set up the value pointer
00793     else if (this->implicit_id_ == EMPTY)
00794       {
00795         TAO_ETCL_Identifier* ident =
00796           dynamic_cast<TAO_ETCL_Identifier*> (component);
00797         if (ident != 0)
00798           {
00799             this->implicit_id_ = FILTERABLE_DATA;
00800             value = ident->value ();
00801         }
00802       }
00803 
00804 
00805     switch (this->implicit_id_)
00806     {
00807     case FILTERABLE_DATA:
00808       result =
00809         (this->filterable_data_.find (ACE_CString (value, 0, false)) == 0);
00810       break;
00811     case VARIABLE_HEADER:
00812       result =
00813         (this->variable_header_.find (ACE_CString (value, 0, false)) == 0);
00814       break;
00815     case TYPE_NAME:
00816       result = (this->type_name_.in () != 0);
00817       break;
00818     case EVENT_NAME:
00819       result = (this->event_name_.in () != 0);
00820       break;
00821     case DOMAIN_NAME:
00822       result = (this->domain_name_.in () != 0);
00823       break;
00824       // Anything other than the above cases is an error.
00825     default:
00826       return -1;
00827     }
00828 
00829     this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
00830 
00831     return 0;
00832   }
00833 
00834   return -1;
00835 }

int TAO_Notify_Constraint_Visitor::visit_identifier TAO_ETCL_Identifier *   ) 
 

Definition at line 151 of file Notify_Constraint_Visitors.cpp.

References ACE_CString, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), and filterable_data_.

00152 {
00153   int return_value = -1;
00154   const char *name = ident->value ();
00155   ACE_CString key (name, 0, false);
00156 
00157   CORBA::Any any;
00158 
00159   if (this->filterable_data_.find (key, any) == 0)
00160   {
00161     if (any.impl() != 0)
00162     {
00163       this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (&any));
00164       return_value = 0;
00165     }
00166   }
00167 
00168   return return_value;
00169 }

int TAO_Notify_Constraint_Visitor::visit_in TAO_ETCL_Binary_Expr *   )  [protected]
 

Definition at line 1084 of file Notify_Constraint_Visitors.cpp.

References any_does_contain(), array_does_contain(), ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), sequence_does_contain(), struct_does_contain(), and union_does_contain().

Referenced by visit_binary_expr().

01085 {
01086   int return_value = -1;
01087   TAO_ETCL_Constraint *lhs = binary->lhs ();
01088 
01089   // Determine if the left operand is contained in the right.
01090   if (lhs->accept (this) == 0)
01091   {
01092     TAO_ETCL_Literal_Constraint left;
01093     this->queue_.dequeue_head (left);
01094 
01095     TAO_ETCL_Constraint *rhs = binary->rhs ();
01096 
01097     if (rhs->accept (this) == 0)
01098     {
01099       TAO_ETCL_Literal_Constraint bag;
01100       this->queue_.dequeue_head (bag);
01101 
01102       if (bag.expr_type () == TAO_ETCL_COMPONENT)
01103       {
01104         CORBA::Any_var component = new CORBA::Any ();
01105         component->replace (bag);
01106         component->impl ()->_add_ref ();
01107         CORBA::TCKind kind = CORBA::tk_null;
01108 
01109         try
01110         {
01111           CORBA::TypeCode_var tc = component->type ();
01112           kind = TAO_DynAnyFactory::unalias (tc.in ());
01113         }
01114         catch (const CORBA::Exception&)
01115         {
01116           return return_value;
01117         }
01118 
01119         CORBA::Boolean result = 0;
01120 
01121         switch (kind)
01122         {
01123         case CORBA::tk_sequence:
01124           result = this->sequence_does_contain (&component.in (),
01125             left);
01126           break;
01127         case CORBA::tk_array:
01128           result = this->array_does_contain (&component.in (),
01129             left);
01130           break;
01131         case CORBA::tk_struct:
01132           result = this->struct_does_contain (&component.in (),
01133             left);
01134           break;
01135         case CORBA::tk_union:
01136           result = this->union_does_contain (&component.in (),
01137             left);
01138           break;
01139         case CORBA::tk_any:
01140           result = this->any_does_contain (&component.in (),
01141             left);
01142           break;
01143         default:
01144           return return_value;
01145         }
01146 
01147         this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01148         return_value = 0;
01149       }
01150     }
01151   }
01152 
01153   return return_value;
01154 }

int TAO_Notify_Constraint_Visitor::visit_literal TAO_ETCL_Literal_Constraint *   ) 
 

Definition at line 142 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00145 {
00146   this->queue_.enqueue_head (*literal);
00147   return 0;
00148 }

int TAO_Notify_Constraint_Visitor::visit_or TAO_ETCL_Binary_Expr *   )  [protected]
 

Definition at line 913 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

Referenced by visit_binary_expr().

00916 {
00917   int return_value = -1;
00918   CORBA::Boolean result = 0;
00919   TAO_ETCL_Constraint *lhs = binary->lhs ();
00920 
00921   if (lhs->accept (this) == 0)
00922   {
00923     TAO_ETCL_Literal_Constraint lhs_result;
00924     this->queue_.dequeue_head (lhs_result);
00925     result = (CORBA::Boolean) lhs_result;
00926 
00927     // Short-circuiting OR.
00928     if (result == 0)
00929     {
00930       TAO_ETCL_Constraint *rhs = binary->rhs ();
00931 
00932       if (rhs->accept (this) == 0)
00933       {
00934         TAO_ETCL_Literal_Constraint rhs_result;
00935         this->queue_.dequeue_head (rhs_result);
00936         result = (CORBA::Boolean) rhs_result;
00937         return_value = 0;
00938       }
00939     }
00940     else
00941       return_value = 0;
00942   }
00943 
00944   if (return_value == 0)
00945     this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
00946 
00947   return return_value;
00948 }

int TAO_Notify_Constraint_Visitor::visit_preference TAO_ETCL_Preference *   ) 
 

Definition at line 1157 of file Notify_Constraint_Visitors.cpp.

01158 {
01159   // According to OMG 00-06-20 section 2.4.1, the Notification Service
01160   // does not use the preference operators. The method must be here
01161   // because it is called by the ETCL node, which may be used by other
01162   // CORBA services that do use the preference operators.
01163   return -1;
01164 }

int TAO_Notify_Constraint_Visitor::visit_special TAO_ETCL_Special *   ) 
 

Definition at line 540 of file Notify_Constraint_Visitors.cpp.

References current_value_, and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00541 {
00542   try
00543   {
00544     CORBA::TypeCode_var tc = this->current_value_->type ();
00545     tc = TAO_DynAnyFactory::strip_alias (tc.in ());
00546 
00547       CORBA::TCKind kind = tc->kind ();
00548 
00549     switch (special->type ())
00550     {
00551     case TAO_ETCL_LENGTH:
00552       {
00553         CORBA::ULong length;
00554 
00555             switch (kind)
00556         {
00557         case CORBA::tk_sequence:
00558           {
00559             TAO_DynSequence_i dyn_seq;
00560             dyn_seq.init (current_value_.in());
00561 
00562             DynamicAny::AnySeq_var any_seq =
00563               dyn_seq.get_elements ();
00564 
00565             length = any_seq->length ();
00566           }
00567           break;
00568         case CORBA::tk_array:
00569           {
00570             length = tc->length ();
00571           }
00572           break;
00573         default:
00574           return -1;
00575         }
00576 
00577         TAO_ETCL_Literal_Constraint lit (length);
00578         this->queue_.enqueue_head (lit);
00579         return 0;
00580       }
00581     case TAO_ETCL_DISCRIMINANT:
00582       {
00583         // If the TCKind is not a union, the call to init() will
00584         // raise an exception, and the catch block will return -1;
00585         TAO_DynUnion_i dyn_union;
00586         dyn_union.init (this->current_value_.in ());
00587 
00588         DynamicAny::DynAny_var disc =
00589           dyn_union.get_discriminator ();
00590 
00591         CORBA::Any_var disc_any = disc->to_any ();
00592 
00593         TAO_ETCL_Literal_Constraint lit (disc_any.ptr ());
00594         this->queue_.enqueue_head (lit);
00595         return 0;
00596       }
00597     case TAO_ETCL_TYPE_ID:
00598       {
00599         const char *name = tc->name ();
00600 
00601         TAO_ETCL_Literal_Constraint lit (name);
00602         this->queue_.enqueue_head (lit);
00603         return 0;
00604       }
00605     case TAO_ETCL_REPOS_ID:
00606       {
00607         const char *id = tc->id ();
00608 
00609         TAO_ETCL_Literal_Constraint lit (id);
00610         this->queue_.enqueue_head (lit);
00611         return 0;
00612       }
00613     default:
00614       return -1;
00615     }
00616   }
00617   catch (const CORBA::Exception&)
00618   {
00619     return -1;
00620   }
00621 }

int TAO_Notify_Constraint_Visitor::visit_twiddle TAO_ETCL_Binary_Expr *   )  [protected]
 

Definition at line 1056 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), and ACE_OS::strstr().

Referenced by visit_binary_expr().

01057 {
01058   int return_value = -1;
01059   TAO_ETCL_Constraint *lhs = binary->lhs ();
01060 
01061   // Determine if the left operand is a substring of the right.
01062   if (lhs->accept (this) == 0)
01063   {
01064     TAO_ETCL_Literal_Constraint left;
01065     this->queue_.dequeue_head (left);
01066     TAO_ETCL_Constraint *rhs = binary->rhs ();
01067 
01068     if (rhs->accept (this) == 0)
01069     {
01070       TAO_ETCL_Literal_Constraint right;
01071       this->queue_.dequeue_head (right);
01072       CORBA::Boolean result =
01073         (ACE_OS::strstr ((const char *) right,
01074         (const char *) left) != 0);
01075       this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
01076       return_value = 0;
01077     }
01078   }
01079 
01080   return return_value;
01081 }

int TAO_Notify_Constraint_Visitor::visit_unary_expr TAO_ETCL_Unary_Expr *   ) 
 

Definition at line 838 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), and ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00841 {
00842   TAO_ETCL_Constraint *subexpr = unary_expr->subexpr ();
00843 
00844   if (subexpr->accept (this) == 0)
00845   {
00846     TAO_ETCL_Literal_Constraint subexpr_result;
00847     CORBA::Boolean result = 0;
00848     int op_type = unary_expr->type ();
00849 
00850     switch (op_type)
00851     {
00852     case TAO_ETCL_NOT:
00853       this->queue_.dequeue_head (subexpr_result);
00854       result = ! (CORBA::Boolean) subexpr_result;
00855       this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
00856       return 0;
00857     case TAO_ETCL_MINUS:
00858       // The leading '-' was parsed separately, so we have to pull
00859       // the literal constraint off the queue, apply the class' own
00860       // unary minus operator, and put it back.
00861       this->queue_.dequeue_head (subexpr_result);
00862       this->queue_.enqueue_head (-subexpr_result);
00863       return 0;
00864     case TAO_ETCL_PLUS:
00865       // Leave the literal constraint on the queue. The leading
00866       // '+' was just syntactic sugar - no action is necessary.
00867       return 0;
00868     default:
00869       // The parser should never construct a TAO_ETCL_Unary_Constraint
00870       // behind any operators except the above three.
00871       return -1;
00872     }
00873   }
00874 
00875   return -1;
00876 }

int TAO_Notify_Constraint_Visitor::visit_union_pos TAO_ETCL_Union_Pos *   ) 
 

Definition at line 195 of file Notify_Constraint_Visitors.cpp.

References ACE_NEW_RETURN, current_value_, ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::dequeue_head(), ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head(), ACE_OS::strcmp(), and ACE_OutputCDR::write_ulong().

00198 {
00199   try
00200   {
00201     if (union_pos->union_value ()->accept (this) == 0)
00202     {
00203       TAO_ETCL_Literal_Constraint disc_val;
00204       this->queue_.dequeue_head (disc_val);
00205 
00206       TAO_DynUnion_i dyn_union;
00207       dyn_union.init (this->current_value_.in ());
00208 
00209       CORBA::TypeCode_var tc = this->current_value_->type ();
00210 
00211       switch (disc_val.expr_type ())
00212       {
00213       case TAO_ETCL_INTEGER:
00214       case TAO_ETCL_SIGNED:
00215       case TAO_ETCL_UNSIGNED:
00216         {
00217           CORBA::Any disc_any;
00218           CORBA::TypeCode_var disc_tc =
00219             tc->discriminator_type ();
00220           CORBA::TCKind disc_kind =
00221             TAO_DynAnyFactory::unalias (disc_tc.in ());
00222 
00223           switch (disc_kind)
00224           {
00225           case CORBA::tk_boolean:
00226             disc_any <<= CORBA::Any::from_boolean ((CORBA::Boolean) disc_val);
00227             break;
00228           case CORBA::tk_short:
00229             disc_any <<= (CORBA::Short) ((CORBA::Long) disc_val);
00230             break;
00231           case CORBA::tk_ushort:
00232             disc_any <<= (CORBA::UShort) ((CORBA::ULong) disc_val);
00233             break;
00234           case CORBA::tk_long:
00235             disc_any <<= (CORBA::Long) disc_val;
00236             break;
00237           case CORBA::tk_ulong:
00238             disc_any <<= (CORBA::ULong) disc_val;
00239             break;
00240           case CORBA::tk_enum:
00241             {
00242               TAO_OutputCDR cdr;
00243               cdr.write_ulong ((CORBA::ULong) disc_val);
00244               TAO_InputCDR in_cdr (cdr);
00245               TAO::Unknown_IDL_Type *unk = 0;
00246               ACE_NEW_RETURN (unk,
00247                 TAO::Unknown_IDL_Type (disc_tc.in (),
00248                 in_cdr),
00249                 -1);
00250 
00251               disc_any.replace (unk);
00252               break;
00253             }
00254             // @@@ (JP) I don't think ETCL handles 64-bit
00255             // integers at this point, and I also think that
00256             // chars and/or wchars will just come out in the
00257             // constraint as (w)strings of length 1.
00258           case CORBA::tk_longlong:
00259           case CORBA::tk_ulonglong:
00260           case CORBA::tk_char:
00261           case CORBA::tk_wchar:
00262           default:
00263             return -1;
00264           }
00265 
00266           DynamicAny::DynAny_var dyn_any =
00267             TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any &> (
00268               disc_tc.in (),
00269               disc_any);
00270           dyn_union.set_discriminator (dyn_any.in ());
00271           DynamicAny::DynAny_var u_member =
00272             dyn_union.member ();
00273           this->current_value_ =
00274             u_member->to_any ();
00275 
00276           break;
00277         }
00278       case TAO_ETCL_STRING:
00279         {
00280           const char *name = (const char *) disc_val;
00281           CORBA::ULong count =
00282             tc->member_count ();
00283 
00284           const char *member_name = 0;
00285           CORBA::ULong i = 0;
00286 
00287           for (i = 0; i < count; ++i)
00288           {
00289             member_name = tc->member_name (i);
00290 
00291             if (ACE_OS::strcmp (name, member_name) == 0)
00292               break;
00293           }
00294 
00295           // If there's no match, member_label will throw
00296           // CORBA::TypeCode::Bounds and the catch block will
00297           // return -1;
00298           this->current_value_ = tc->member_label (i);
00299 
00300           break;
00301         }
00302         // The TAO_ETCL_Union_Value that was put on the queue
00303         // shouldn't have any other type.
00304       default:
00305         return -1;
00306       }
00307 
00308       TAO_ETCL_Constraint *nested = union_pos->component ();
00309 
00310       // If there's no nested component, then we just want the
00311       // union member value on the queue. Otherwise, we want
00312       // the member value in current_value_ while we visit
00313       // the nested component.
00314       if (nested == 0)
00315       {
00316         TAO_ETCL_Literal_Constraint lit (this->current_value_.ptr ());
00317         this->queue_.enqueue_head (lit);
00318         return 0;
00319       }
00320       else
00321         return nested->accept (this);
00322     }
00323     else
00324       return -1;
00325   }
00326   catch (const CORBA::Exception&)
00327   {
00328     return -1;
00329   }
00330 }

int TAO_Notify_Constraint_Visitor::visit_union_value TAO_ETCL_Union_Value *   ) 
 

Definition at line 172 of file Notify_Constraint_Visitors.cpp.

References ACE_Unbounded_Queue< TAO_ETCL_Literal_Constraint >::enqueue_head().

00175 {
00176   switch (union_value->sign ())
00177   {
00178     case 0:
00179       this->queue_.enqueue_head (*union_value->string ());
00180       break;
00181     case -1:
00182       this->queue_.enqueue_head (-(*union_value->integer ()));
00183       break;
00184     case 1:
00185       this->queue_.enqueue_head (*union_value->integer ());
00186       break;
00187     default:
00188       return -1;
00189   }
00190 
00191   return 0;
00192 }


Member Data Documentation

CORBA::String_var TAO_Notify_Constraint_Visitor::current_name_ [protected]
 

Holder for a string name in the event fields fixed_header, variable_header, or filterable_data.

Definition at line 162 of file Notify_Constraint_Visitors.h.

CORBA::Any_var TAO_Notify_Constraint_Visitor::current_value_ [protected]
 

Holder for a value found in the event fields filterable_data, variable_header or remainder_of_body.

Definition at line 158 of file Notify_Constraint_Visitors.h.

Referenced by visit_component(), visit_component_array(), visit_component_assoc(), visit_component_pos(), visit_default(), visit_exist(), visit_special(), and visit_union_pos().

CORBA::String_var TAO_Notify_Constraint_Visitor::domain_name_ [protected]
 

Storage for string names under the structured event's 'fixed_header' field.

Definition at line 146 of file Notify_Constraint_Visitors.h.

Referenced by bind_structured_event(), and visit_exist().

CORBA::String_var TAO_Notify_Constraint_Visitor::event_name_ [protected]
 

Definition at line 148 of file Notify_Constraint_Visitors.h.

Referenced by bind_structured_event(), and visit_exist().

ACE_Hash_Map_Manager<ACE_CString, CORBA::Any, ACE_Null_Mutex> TAO_Notify_Constraint_Visitor::filterable_data_ [protected]
 

Used to lookup names and values in the event's 'filterable_data' field.

Definition at line 134 of file Notify_Constraint_Visitors.h.

Referenced by bind_structured_event(), visit_component_assoc(), visit_exist(), and visit_identifier().

const size_t TAO_Notify_Constraint_Visitor::filterable_data_size_ = 31 [static, protected]
 

Size of filterable_data_ hash map. TODO: define inline once VC6 support is deprecated.

Definition at line 1384 of file Notify_Constraint_Visitors.cpp.

structured_event_field TAO_Notify_Constraint_Visitor::implicit_id_ [protected]
 

Storage for the type of implicit id the component has (if any).

Definition at line 114 of file Notify_Constraint_Visitors.h.

Referenced by visit_component(), visit_component_assoc(), and visit_exist().

ACE_Hash_Map_Manager<ACE_CString, structured_event_field, ACE_Null_Mutex> TAO_Notify_Constraint_Visitor::implicit_ids_ [protected]
 

Lookup table for the implicit ids, to avoid string comparisons in derived visitors.

Definition at line 126 of file Notify_Constraint_Visitors.h.

Referenced by TAO_Notify_Constraint_Visitor(), and visit_component().

const size_t TAO_Notify_Constraint_Visitor::implicit_ids_size_ = 27 [static, protected]
 

Size of implicit_ids_ hash map.

Note:
A fixed set of 9 keys are stored in this map. In the absence of a minimal perfect hash, ACE's default hash_pjw() and a hash size of 27 ensures each element is hashed to a unique bucket. TODO: define inline once VC6 support is deprecated.

Definition at line 1383 of file Notify_Constraint_Visitors.cpp.

ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint> TAO_Notify_Constraint_Visitor::queue_ [protected]
 

The result of a non_boolean operation.

Definition at line 154 of file Notify_Constraint_Visitors.h.

CORBA::Any TAO_Notify_Constraint_Visitor::remainder_of_body_ [protected]
 

Storage for the structured_event's 'remainder_of_body' field.

Definition at line 151 of file Notify_Constraint_Visitors.h.

Referenced by bind_structured_event().

CORBA::String_var TAO_Notify_Constraint_Visitor::type_name_ [protected]
 

Definition at line 147 of file Notify_Constraint_Visitors.h.

Referenced by bind_structured_event(), and visit_exist().

ACE_Hash_Map_Manager<ACE_CString, CORBA::Any, ACE_Null_Mutex> TAO_Notify_Constraint_Visitor::variable_header_ [protected]
 

Used to lookup names and values in the event's 'variable_header' field.

Definition at line 142 of file Notify_Constraint_Visitors.h.

Referenced by bind_structured_event(), visit_component_assoc(), and visit_exist().

const size_t TAO_Notify_Constraint_Visitor::variable_header_size_ = 31 [static, protected]
 

Size of variable_header_ hash map. TODO: define inline once VC6 support is deprecated.

Definition at line 1385 of file Notify_Constraint_Visitors.cpp.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 15:48:44 2008 for TAO_CosNotification by doxygen 1.3.6