Notify_Constraint_Visitors.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Notify_Constraint_Visitors.h
00006  *
00007  *  Notify_Constraint_Visitors.h,v 1.32 2006/03/14 06:14:34 jtc Exp
00008  *
00009  *  @author Pradeep Gore <pradeep@cs.wustl.edu>
00010  *  @author Jeff Parsons <parsons@cs.wustl.edu>
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef NOTIFY_CONSTRAINT_VISITORS_H
00016 #define NOTIFY_CONSTRAINT_VISITORS_H
00017 
00018 #include /**/ "ace/pre.h"
00019 #include "ace/Hash_Map_Manager.h"
00020 #include "ace/Unbounded_Queue.h"
00021 #include "ace/Null_Mutex.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "orbsvcs/ETCL/ETCL_Constraint_Visitor.h"
00028 #include "orbsvcs/ETCL/ETCL_Constraint.h"
00029 #include "orbsvcs/CosNotificationC.h"
00030 
00031 #include "orbsvcs/Notify/notify_serv_export.h"
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 class TAO_Notify_Property_Constraint;
00036 
00037 class TAO_Notify_Serv_Export TAO_Notify_Constraint_Visitor
00038   : public TAO_ETCL_Constraint_Visitor
00039 {
00040 public:
00041   /// Constructor.
00042   TAO_Notify_Constraint_Visitor (void);
00043 
00044   /// Put the event data into our hash map.
00045   int bind_structured_event (const CosNotification::StructuredEvent &s_event);
00046 
00047   /**
00048    * Returns 1 if the event satisfies the constraint
00049    * represented by the the expression tree rooted at <root>, 0 if it
00050    * doesn't. If an error occurs during the process, the traversal
00051    * automatically fails.
00052    */
00053   CORBA::Boolean evaluate_constraint (TAO_ETCL_Constraint *root);
00054 
00055   // The overridden methods.
00056   int visit_literal (TAO_ETCL_Literal_Constraint *);
00057   int visit_identifier (TAO_ETCL_Identifier *);
00058   int visit_union_value (TAO_ETCL_Union_Value *);
00059   int visit_union_pos (TAO_ETCL_Union_Pos *);
00060   int visit_component_pos (TAO_ETCL_Component_Pos *);
00061   int visit_component_assoc (TAO_ETCL_Component_Assoc *);
00062   int visit_component_array (TAO_ETCL_Component_Array *);
00063   int visit_special (TAO_ETCL_Special *);
00064   int visit_component (TAO_ETCL_Component *);
00065   int visit_dot (TAO_ETCL_Dot *);
00066   int visit_eval (TAO_ETCL_Eval *);
00067   int visit_default (TAO_ETCL_Default *);
00068   int visit_exist (TAO_ETCL_Exist *);
00069   int visit_unary_expr (TAO_ETCL_Unary_Expr *);
00070   int visit_binary_expr (TAO_ETCL_Binary_Expr *);
00071   int visit_preference (TAO_ETCL_Preference *);
00072 
00073 protected:
00074   // Sub-methods for visit_binary_expr().
00075   int visit_or (TAO_ETCL_Binary_Expr *);
00076   int visit_and (TAO_ETCL_Binary_Expr *);
00077   int visit_twiddle (TAO_ETCL_Binary_Expr *);
00078   int visit_in (TAO_ETCL_Binary_Expr *);
00079   int visit_binary_op (TAO_ETCL_Binary_Expr *binary_expr,
00080                        int op_type);
00081 
00082   // These use dynamic anys to look inside the ETCL component.
00083   CORBA::Boolean sequence_does_contain (const CORBA::Any *any,
00084                                         TAO_ETCL_Literal_Constraint &item);
00085   CORBA::Boolean array_does_contain (const CORBA::Any *any,
00086                                      TAO_ETCL_Literal_Constraint &item);
00087   CORBA::Boolean struct_does_contain (const CORBA::Any *any,
00088                                       TAO_ETCL_Literal_Constraint &item);
00089   CORBA::Boolean union_does_contain (const CORBA::Any *any,
00090                                      TAO_ETCL_Literal_Constraint &item);
00091   CORBA::Boolean any_does_contain (const CORBA::Any *any,
00092                                    TAO_ETCL_Literal_Constraint &item);
00093 
00094   // Utility function to compare a TAO_ETCL_Literal_Constraint type
00095   // and a type code.
00096   CORBA::Boolean simple_type_match (int expr_type,
00097                                     CORBA::TCKind tc_kind);
00098 
00099   enum structured_event_field
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     };
00112 
00113   /// Storage for the type of implicit id the component has (if any).
00114   structured_event_field implicit_id_;
00115 
00116   /// Size of implicit_ids_ hash map.
00117   /// @note A fixed set of 9 keys are stored in this map.  In the absence
00118   /// of a minimal perfect hash, ACE's default hash_pjw() and a hash size
00119   /// of 27 ensures each element is hashed to a unique bucket.
00120   /// TODO: define inline once VC6 support is deprecated.
00121   static const size_t implicit_ids_size_;
00122 
00123   /// Lookup table for the implicit ids, to avoid string comparisons in
00124   /// derived visitors.
00125   ACE_Hash_Map_Manager <ACE_CString, structured_event_field, ACE_Null_Mutex>
00126     implicit_ids_;
00127 
00128   /// Size of filterable_data_ hash map.
00129   /// TODO: define inline once VC6 support is deprecated.
00130   static const size_t filterable_data_size_;
00131 
00132   /// Used to lookup names and values in the event's 'filterable_data' field.
00133   ACE_Hash_Map_Manager <ACE_CString, CORBA::Any, ACE_Null_Mutex>
00134     filterable_data_;
00135 
00136   /// Size of variable_header_ hash map.
00137   /// TODO: define inline once VC6 support is deprecated.
00138   static const size_t variable_header_size_;
00139 
00140   /// Used to lookup names and values in the event's 'variable_header' field.
00141   ACE_Hash_Map_Manager <ACE_CString, CORBA::Any, ACE_Null_Mutex>
00142     variable_header_;
00143 
00144   /// Storage for string names under the structured event's
00145   /// 'fixed_header' field.
00146   CORBA::String_var domain_name_;
00147   CORBA::String_var type_name_;
00148   CORBA::String_var event_name_;
00149 
00150   /// Storage for the structured_event's 'remainder_of_body' field.
00151   CORBA::Any remainder_of_body_;
00152 
00153   /// The result of a non_boolean operation.
00154   ACE_Unbounded_Queue <TAO_ETCL_Literal_Constraint> queue_;
00155 
00156   /// Holder for a value found in the event fields filterable_data,
00157   /// variable_header or remainder_of_body.
00158   CORBA::Any_var current_value_;
00159 
00160   /// Holder for a string name in the event fields fixed_header,
00161   /// variable_header, or filterable_data.
00162   CORBA::String_var current_name_;
00163 };
00164 
00165 TAO_END_VERSIONED_NAMESPACE_DECL
00166 
00167 #include /**/ "ace/post.h"
00168 #endif /* NOTIFY_CONSTRAINT_VISITORS_H */

Generated on Thu Nov 9 13:24:12 2006 for TAO_CosNotification by doxygen 1.3.6