#include <EC_Basic_Filter_Builder.h>
Inheritance diagram for TAO_EC_Basic_Filter_Builder:
Public Member Functions | |
TAO_EC_Basic_Filter_Builder (TAO_EC_Event_Channel_Base *ec) | |
constructor. | |
virtual | ~TAO_EC_Basic_Filter_Builder (void) |
destructor... | |
TAO_EC_Filter * | build (TAO_EC_ProxyPushSupplier *supplier, RtecEventChannelAdmin::ConsumerQOS &qos) const |
Private Member Functions | |
TAO_EC_Filter * | recursive_build (TAO_EC_ProxyPushSupplier *supplier, RtecEventChannelAdmin::ConsumerQOS &qos, CORBA::ULong &pos) const |
Recursively build the filter tree. | |
CORBA::ULong | count_children (RtecEventChannelAdmin::ConsumerQOS &qos, CORBA::ULong pos) const |
Private Attributes | |
TAO_EC_Event_Channel_Base * | event_channel_ |
The event channel. |
The basic filtering mechanisms in the Event channel (source/type based filtering + disjunctions, conjunctions, logical ands, negations, and bitmasks) are constructed using this class.
Definition at line 43 of file EC_Basic_Filter_Builder.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_EC_Basic_Filter_Builder::TAO_EC_Basic_Filter_Builder | ( | TAO_EC_Event_Channel_Base * | ec | ) |
constructor.
Definition at line 9 of file EC_Basic_Filter_Builder.inl.
00010 : event_channel_ (ec) 00011 { 00012 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_Basic_Filter_Builder::~TAO_EC_Basic_Filter_Builder | ( | void | ) | [virtual] |
TAO_EC_Filter * TAO_EC_Basic_Filter_Builder::build | ( | TAO_EC_ProxyPushSupplier * | supplier, | |
RtecEventChannelAdmin::ConsumerQOS & | qos | |||
) | const [virtual] |
Create the filter, the caller must assume ownership of the filter returned.
Implements TAO_EC_Filter_Builder.
Definition at line 28 of file EC_Basic_Filter_Builder.cpp.
References recursive_build().
00031 { 00032 CORBA::ULong pos = 0; 00033 return this->recursive_build (supplier, qos, pos); 00034 }
CORBA::ULong TAO_EC_Basic_Filter_Builder::count_children | ( | RtecEventChannelAdmin::ConsumerQOS & | qos, | |
CORBA::ULong | pos | |||
) | const [private] |
Count the number of children of the current node, i.e. until a conjunction, disjunction, logical and, bitmask, or negation occurs.
Definition at line 158 of file EC_Basic_Filter_Builder.cpp.
References ACE_ES_BITMASK_DESIGNATOR, ACE_ES_CONJUNCTION_DESIGNATOR, ACE_ES_DISJUNCTION_DESIGNATOR, ACE_ES_LOGICAL_AND_DESIGNATOR, ACE_ES_MASKED_TYPE_DESIGNATOR, ACE_ES_NEGATION_DESIGNATOR, and RtecEventChannelAdmin::ConsumerQOS::dependencies.
Referenced by recursive_build().
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 // We won't let these be nested by the basic filter builder. 00171 // Assume these are the end of the group 00172 break; 00173 else if (e.header.type == ACE_ES_BITMASK_DESIGNATOR) 00174 // These take up an extra element 00175 i++; 00176 else if (e.header.type == ACE_ES_MASKED_TYPE_DESIGNATOR) 00177 // These take up two extra elements 00178 i += 2; 00179 else if (e.header.type == ACE_ES_NEGATION_DESIGNATOR) { 00180 // These enclose another filter. 00181 // Lets try to figure out how many elements the enclosed 00182 // filter takes up (but don't count it in the group). 00183 // Only allow basic filter types and bitmasks within 00184 // a negation (when it is nested within a group). 00185 // This is isn't perfect, but its about the best we can 00186 // do without prefixes. 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 }
TAO_EC_Filter * TAO_EC_Basic_Filter_Builder::recursive_build | ( | TAO_EC_ProxyPushSupplier * | supplier, | |
RtecEventChannelAdmin::ConsumerQOS & | qos, | |||
CORBA::ULong & | pos | |||
) | const [private] |
Recursively build the filter tree.
Definition at line 37 of file EC_Basic_Filter_Builder.cpp.
References ACE_ES_BITMASK_DESIGNATOR, ACE_ES_CONJUNCTION_DESIGNATOR, ACE_ES_DISJUNCTION_DESIGNATOR, ACE_ES_EVENT_DEADLINE_TIMEOUT, ACE_ES_EVENT_INTERVAL_TIMEOUT, ACE_ES_EVENT_TIMEOUT, ACE_ES_LOGICAL_AND_DESIGNATOR, ACE_ES_MASKED_TYPE_DESIGNATOR, ACE_ES_NEGATION_DESIGNATOR, ACE_ES_NULL_DESIGNATOR, ACE_NEW_RETURN, count_children(), RtecEventChannelAdmin::ConsumerQOS::dependencies, and RtecEventComm::Event::header.
Referenced by build().
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++; // Consume the designator 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++; // Consume the designator 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++; // Consume the designator 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++; // Consume the designator 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++; // COnsumer the designator 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++; // Consume the designator 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++; // Consume the designator 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++; // Consume the designator 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++; // Consume the event 00153 return new TAO_EC_Type_Filter (e.header); 00154 }