00001
00002
00003 #include "orbsvcs/Event_Service_Constants.h"
00004 #include "orbsvcs/Event/EC_Basic_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_Basic_Filter_Builder.inl"
00016 #endif
00017
00018 ACE_RCSID(Event, EC_Basic_Filter_Builder, "$Id: EC_Basic_Filter_Builder.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00019
00020
00021 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00022
00023 TAO_EC_Basic_Filter_Builder::~TAO_EC_Basic_Filter_Builder (void)
00024 {
00025 }
00026
00027 TAO_EC_Filter*
00028 TAO_EC_Basic_Filter_Builder::build (
00029 TAO_EC_ProxyPushSupplier *supplier,
00030 RtecEventChannelAdmin::ConsumerQOS& qos) const
00031 {
00032 CORBA::ULong pos = 0;
00033 return this->recursive_build (supplier, qos, pos);
00034 }
00035
00036 TAO_EC_Filter*
00037 TAO_EC_Basic_Filter_Builder:: recursive_build (
00038 TAO_EC_ProxyPushSupplier *supplier,
00039 RtecEventChannelAdmin::ConsumerQOS& qos,
00040 CORBA::ULong& pos) const
00041 {
00042 CORBA::ULong l = qos.dependencies.length ();
00043 if (pos == l)
00044 return 0;
00045
00046 const RtecEventComm::Event& e = qos.dependencies[pos].event;
00047 if (e.header.type == ACE_ES_CONJUNCTION_DESIGNATOR)
00048 {
00049 pos++;
00050 CORBA::ULong n = this->count_children (qos, pos);
00051
00052 TAO_EC_Filter** children;
00053 ACE_NEW_RETURN (children, TAO_EC_Filter*[n], 0);
00054 CORBA::ULong i = 0;
00055 for (; i != n; ++i)
00056 {
00057 children[i] = this->recursive_build (supplier, qos, pos);
00058 }
00059 return new TAO_EC_Conjunction_Filter (children, n);
00060 }
00061 else if (e.header.type == ACE_ES_DISJUNCTION_DESIGNATOR)
00062 {
00063 pos++;
00064 CORBA::ULong n = this->count_children (qos, pos);
00065
00066 TAO_EC_Filter** children;
00067 ACE_NEW_RETURN (children, TAO_EC_Filter*[n], 0);
00068 CORBA::ULong i = 0;
00069 for (; i != n; ++i)
00070 {
00071 children[i] = this->recursive_build (supplier, qos, pos);
00072 }
00073 return new TAO_EC_Disjunction_Filter (children, n);
00074 }
00075 else if (e.header.type == ACE_ES_LOGICAL_AND_DESIGNATOR)
00076 {
00077 pos++;
00078 CORBA::ULong n = this->count_children (qos, pos);
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 else if (e.header.type == ACE_ES_NEGATION_DESIGNATOR)
00090 {
00091 pos++;
00092
00093 TAO_EC_Filter *child =
00094 this->recursive_build (supplier, qos, pos);
00095 return new TAO_EC_Negation_Filter (child);
00096 }
00097 else if (e.header.type == ACE_ES_BITMASK_DESIGNATOR)
00098 {
00099 pos++;
00100
00101 if (pos == qos.dependencies.length ())
00102 return 0;
00103 CORBA::ULong source_mask = qos.dependencies[pos].event.header.source;
00104 CORBA::ULong type_mask = qos.dependencies[pos].event.header.type;
00105 pos++;
00106
00107 TAO_EC_Filter *child =
00108 this->recursive_build (supplier, qos, pos);
00109 return new TAO_EC_Bitmask_Filter (source_mask,
00110 type_mask,
00111 child);
00112 }
00113 else if (e.header.type == ACE_ES_MASKED_TYPE_DESIGNATOR)
00114 {
00115 pos++;
00116
00117 if (pos == qos.dependencies.length ())
00118 return 0;
00119 CORBA::ULong source_mask = qos.dependencies[pos].event.header.source;
00120 CORBA::ULong type_mask = qos.dependencies[pos].event.header.type;
00121 pos++;
00122
00123 if (pos == qos.dependencies.length ())
00124 return 0;
00125 CORBA::ULong source_value = qos.dependencies[pos].event.header.source;
00126 CORBA::ULong type_value = qos.dependencies[pos].event.header.type;
00127 pos++;
00128
00129 return new TAO_EC_Masked_Type_Filter (source_mask,
00130 type_mask,
00131 source_value,
00132 type_value);
00133 }
00134 else if (e.header.type == ACE_ES_NULL_DESIGNATOR)
00135 {
00136 pos++;
00137
00138 return new TAO_EC_Null_Filter ();
00139 }
00140 else if (e.header.type == ACE_ES_EVENT_TIMEOUT
00141 || e.header.type == ACE_ES_EVENT_INTERVAL_TIMEOUT
00142 || e.header.type == ACE_ES_EVENT_DEADLINE_TIMEOUT)
00143 {
00144 pos++;
00145 TAO_EC_QOS_Info qos_info;
00146 return new TAO_EC_Timeout_Filter (this->event_channel_,
00147 supplier,
00148 qos_info,
00149 e.header.type,
00150 e.header.creation_time);
00151 }
00152 pos++;
00153 return new TAO_EC_Type_Filter (e.header);
00154 }
00155
00156 CORBA::ULong
00157 TAO_EC_Basic_Filter_Builder::
00158 count_children (RtecEventChannelAdmin::ConsumerQOS& qos,
00159 CORBA::ULong pos) const
00160 {
00161 CORBA::ULong l = qos.dependencies.length ();
00162 CORBA::ULong i;
00163 int count = 0;
00164 for (i = pos; i != l; ++i)
00165 {
00166 const RtecEventComm::Event& e = qos.dependencies[i].event;
00167 if (e.header.type == ACE_ES_CONJUNCTION_DESIGNATOR
00168 || e.header.type == ACE_ES_DISJUNCTION_DESIGNATOR
00169 || e.header.type == ACE_ES_LOGICAL_AND_DESIGNATOR)
00170
00171
00172 break;
00173 else if (e.header.type == ACE_ES_BITMASK_DESIGNATOR)
00174
00175 i++;
00176 else if (e.header.type == ACE_ES_MASKED_TYPE_DESIGNATOR)
00177
00178 i += 2;
00179 else if (e.header.type == ACE_ES_NEGATION_DESIGNATOR) {
00180
00181
00182
00183
00184
00185
00186
00187 i++;
00188 switch (qos.dependencies[i].event.header.type) {
00189 case ACE_ES_BITMASK_DESIGNATOR:
00190 i++;
00191 break;
00192 case ACE_ES_MASKED_TYPE_DESIGNATOR:
00193 i += 2;
00194 break;
00195 }
00196 }
00197 count++;
00198 }
00199 return count;
00200 }
00201
00202 TAO_END_VERSIONED_NAMESPACE_DECL