Notify_Constraint_Visitors.h

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

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7