00001
00002
00003 #include "orbsvcs/Event_Service_Constants.h"
00004 #include "orbsvcs/Event/EC_Prefix_Filter_Builder.h"
00005 #include "orbsvcs/Event/EC_Type_Filter.h"
00006 #include "orbsvcs/Event/EC_Conjunction_Filter.h"
00007 #include "orbsvcs/Event/EC_Disjunction_Filter.h"
00008 #include "orbsvcs/Event/EC_And_Filter.h"
00009 #include "orbsvcs/Event/EC_Negation_Filter.h"
00010 #include "orbsvcs/Event/EC_Bitmask_Filter.h"
00011 #include "orbsvcs/Event/EC_Masked_Type_Filter.h"
00012 #include "orbsvcs/Event/EC_Timeout_Filter.h"
00013
00014 #if ! defined (__ACE_INLINE__)
00015 #include "orbsvcs/Event/EC_Prefix_Filter_Builder.inl"
00016 #endif
00017
00018 ACE_RCSID(Event, EC_Prefix_Filter_Builder, "$Id: EC_Prefix_Filter_Builder.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 TAO_EC_Prefix_Filter_Builder::~TAO_EC_Prefix_Filter_Builder (void)
00023 {
00024 }
00025
00026 TAO_EC_Filter*
00027 TAO_EC_Prefix_Filter_Builder::build (
00028 TAO_EC_ProxyPushSupplier *supplier,
00029 RtecEventChannelAdmin::ConsumerQOS& qos) const
00030 {
00031 CORBA::ULong pos = 0;
00032 return this->recursive_build (supplier, qos, pos);
00033 }
00034
00035 TAO_EC_Filter*
00036 TAO_EC_Prefix_Filter_Builder:: recursive_build (
00037 TAO_EC_ProxyPushSupplier *supplier,
00038 RtecEventChannelAdmin::ConsumerQOS& qos,
00039 CORBA::ULong& pos) const
00040 {
00041 CORBA::ULong l = qos.dependencies.length ();
00042 if (pos == l)
00043 return 0;
00044
00045 const RtecEventComm::Event& e = qos.dependencies[pos].event;
00046 if (e.header.type == ACE_ES_CONJUNCTION_DESIGNATOR)
00047 {
00048 pos++;
00049 CORBA::ULong n = e.header.source;
00050
00051 TAO_EC_Filter** children;
00052 ACE_NEW_RETURN (children, TAO_EC_Filter*[n], 0);
00053 CORBA::ULong i = 0;
00054 for (; i != n; ++i)
00055 {
00056 children[i] = this->recursive_build (supplier, qos, pos);
00057 }
00058 return new TAO_EC_Conjunction_Filter (children, n);
00059 }
00060 else if (e.header.type == ACE_ES_DISJUNCTION_DESIGNATOR)
00061 {
00062 pos++;
00063 CORBA::ULong n = e.header.source;
00064
00065 TAO_EC_Filter** children;
00066 ACE_NEW_RETURN (children, TAO_EC_Filter*[n], 0);
00067 CORBA::ULong i = 0;
00068 for (; i != n; ++i)
00069 {
00070 children[i] = this->recursive_build (supplier, qos, pos);
00071 }
00072 return new TAO_EC_Disjunction_Filter (children, n);
00073 }
00074
00075 else if (e.header.type == ACE_ES_LOGICAL_AND_DESIGNATOR)
00076 {
00077 pos++;
00078 CORBA::ULong n = e.header.source;
00079
00080 TAO_EC_Filter** children;
00081 ACE_NEW_RETURN (children, TAO_EC_Filter*[n], 0);
00082 CORBA::ULong i = 0;
00083 for (; i != n; ++i)
00084 {
00085 children[i] = this->recursive_build (supplier, qos, pos);
00086 }
00087 return new TAO_EC_And_Filter (children, n);
00088 }
00089
00090 else if (e.header.type == ACE_ES_NEGATION_DESIGNATOR)
00091 {
00092 pos++;
00093
00094 TAO_EC_Filter *child =
00095 this->recursive_build (supplier, qos, pos);
00096 return new TAO_EC_Negation_Filter (child);
00097 }
00098 else if (e.header.type == ACE_ES_BITMASK_DESIGNATOR)
00099 {
00100 pos++;
00101
00102 if (pos == qos.dependencies.length ())
00103 return 0;
00104 CORBA::ULong source_mask = qos.dependencies[pos].event.header.source;
00105 CORBA::ULong type_mask = qos.dependencies[pos].event.header.type;
00106 pos++;
00107
00108 TAO_EC_Filter *child =
00109 this->recursive_build (supplier, qos, pos);
00110 return new TAO_EC_Bitmask_Filter (source_mask,
00111 type_mask,
00112 child);
00113 }
00114 else if (e.header.type == ACE_ES_MASKED_TYPE_DESIGNATOR)
00115 {
00116 pos++;
00117
00118 if (pos == qos.dependencies.length ())
00119 return 0;
00120 CORBA::ULong source_mask = qos.dependencies[pos].event.header.source;
00121 CORBA::ULong type_mask = qos.dependencies[pos].event.header.type;
00122 pos++;
00123
00124 if (pos == qos.dependencies.length ())
00125 return 0;
00126 CORBA::ULong source_value = qos.dependencies[pos].event.header.source;
00127 CORBA::ULong type_value = qos.dependencies[pos].event.header.type;
00128 pos++;
00129
00130 return new TAO_EC_Masked_Type_Filter (source_mask,
00131 type_mask,
00132 source_value,
00133 type_value);
00134 }
00135 else if (e.header.type == ACE_ES_NULL_DESIGNATOR)
00136 {
00137 pos++;
00138
00139 return new TAO_EC_Null_Filter ();
00140 }
00141 else if (e.header.type == ACE_ES_EVENT_TIMEOUT
00142 || e.header.type == ACE_ES_EVENT_INTERVAL_TIMEOUT
00143 || e.header.type == ACE_ES_EVENT_DEADLINE_TIMEOUT)
00144 {
00145 pos++;
00146 TAO_EC_QOS_Info qos_info;
00147 return new TAO_EC_Timeout_Filter (this->event_channel_,
00148 supplier,
00149 qos_info,
00150 e.header.type,
00151 e.header.creation_time);
00152 }
00153 pos++;
00154 return new TAO_EC_Type_Filter (e.header);
00155 }
00156
00157 TAO_END_VERSIONED_NAMESPACE_DECL