5
* EC_Filter.h,v 1.22 2003/10/28 18:34:18 bala Exp
7
* @author Carlos O'Ryan (coryan@cs.wustl.edu)
9
* Based on previous work by Tim Harrison (harrison@cs.wustl.edu) and
10
* other members of the DOC group. More details can be found in:
12
* http://doc.ece.uci.edu/~coryan/EC/index.html
15
#ifndef TAO_EC_FILTER_H
16
#define TAO_EC_FILTER_H
18
#include /**/ "ace/pre.h"
20
#include "orbsvcs/RtecEventCommC.h"
22
#include /**/ "event_export.h"
24
#if !defined (ACE_LACKS_PRAGMA_ONCE)
26
#endif /* ACE_LACKS_PRAGMA_ONCE */
28
class TAO_EC_QOS_Info;
31
* @class TAO_EC_Filter
33
* @brief Abstract base class for the filter hierarchy.
35
* The per-consumer filtering mechanisms.
36
* The EC needs to filter data passed to the consumers, so it can
37
* correctly satisfy its subscription requirements.
38
* This filtering can include correlations, sequences, timeouts,
39
* etc. each consumer can request different filtering criteria.
40
* Different filtering objects are associated with each consumer,
41
* the filters are organized in a hierarchical structure,
42
* corresponding to the subscription "expression" that the events
44
* The hierarchy is constructed using the "Builder" pattern.
46
* <H2>Memory Management</H2>
47
* It does *not* assume ownership of its parent.
49
class TAO_RTEvent_Export TAO_EC_Filter
56
virtual ~TAO_EC_Filter (void);
58
/// Obtain the parent of this filter.
59
TAO_EC_Filter* parent (void) const;
61
/// Become the parent of @a child.
62
void adopt_child (TAO_EC_Filter* child);
64
/// Matches two event headers.
65
/// @todo Should we strategize the algorithm used to match headers?
66
static int matches (const RtecEventComm::EventHeader& rhs,
67
const RtecEventComm::EventHeader& lhs);
69
typedef TAO_EC_Filter* value_type;
70
typedef TAO_EC_Filter* const const_value_type;
71
typedef const_value_type* ChildrenIterator;
75
* Filters follow the Composite pattern. All filters expose the same
76
* interface as if they all had children, but for simple filters the
77
* iterators return an empty range.
79
virtual ChildrenIterator begin (void) const;
80
virtual ChildrenIterator end (void) const;
81
virtual int size (void) const;
84
* Filter this event, returns 1 if the event is accepted, 0
86
* Notice that there are two versions of the method, if the event is
87
* not const then filter can take ownership of the event.
89
* @attention There seems to be a disparity in interfaces: Supplier
90
* always push event sets of size 1 to the EC_ProxyPushSupplier, and
91
* EC_Filters do not implement handling of sets of more than 1
92
* event. Then, why is this not enforced by the interface by having
93
* EC_ProxyPushSupplier take an event rather than a set?
95
virtual int filter (const RtecEventComm::EventSet& event,
96
TAO_EC_QOS_Info& qos_info
97
ACE_ENV_ARG_DECL) = 0;
98
virtual int filter_nocopy (RtecEventComm::EventSet& event,
99
TAO_EC_QOS_Info& qos_info
100
ACE_ENV_ARG_DECL) = 0;
103
* This is called by the children when they accept an event and
104
* which to pass it up.
105
* Notice that there are two versions of the method, if the event is
106
* not const then filter can take ownership of the event.
108
virtual void push (const RtecEventComm::EventSet& event,
109
TAO_EC_QOS_Info& qos_info
110
ACE_ENV_ARG_DECL) = 0;
111
virtual void push_nocopy (RtecEventComm::EventSet& event,
112
TAO_EC_QOS_Info& qos_info
113
ACE_ENV_ARG_DECL) = 0;
115
/// Clear any saved state, must reset and assume no events have been
117
virtual void clear (void) = 0;
119
/// Returns the maximum size of the events pushed by this filter.
120
virtual CORBA::ULong max_event_size (void) const = 0;
123
* Returns 0 if an event with that header could never be accepted.
124
* This can used by the suppliers to filter out consumers that
125
* couldn't possibly be interested in their events.
128
virtual int can_match (const RtecEventComm::EventHeader& header) const = 0;
131
* This is used for computing the scheduling dependencies:
133
* Leaf filters check if the header could be matched, similar to the
134
* can_match() method; if it does they return 1, and 0 otherwise.
135
* Intermediate nodes always return 0.
137
* This is used to build precise dependencies between the suppliers
138
* and the leaf of the filters that accept that event. Notice that
139
* only the nodes doing scheduling recurse through the list, so in
140
* configurations that do no require scheduling the recursion stops
143
virtual int add_dependencies (const RtecEventComm::EventHeader& header,
144
const TAO_EC_QOS_Info& qos_info
145
ACE_ENV_ARG_DECL) = 0;
148
* Obtain the QOS information for this filter, the default
149
* implementation returns an invalid QOS. Only the filters that
150
* support scheduling information implement this method.
151
* @return Returns 0 on success and -1 on failure
153
virtual void get_qos_info (TAO_EC_QOS_Info& qos_info
158
TAO_EC_Filter* parent_;
161
// ****************************************************************
164
* @class TAO_EC_Null_Filter
166
* @brief A null filter
168
* This filter accepts any kind of event, it is useful for the
170
* a) Consumers that accept all events
171
* b) Consumers that trust the filtering done at the Supplier
173
* c) Event Channels that don't do filtering (such as CosEC
176
class TAO_RTEvent_Export TAO_EC_Null_Filter : public TAO_EC_Filter
180
TAO_EC_Null_Filter (void);
182
// = The TAO_EC_Filter methods, please check the documentation in
184
virtual int filter (const RtecEventComm::EventSet& event,
185
TAO_EC_QOS_Info& qos_info
187
virtual int filter_nocopy (RtecEventComm::EventSet& event,
188
TAO_EC_QOS_Info& qos_info
190
virtual void push (const RtecEventComm::EventSet& event,
191
TAO_EC_QOS_Info& qos_info
193
virtual void push_nocopy (RtecEventComm::EventSet& event,
194
TAO_EC_QOS_Info& qos_info
196
virtual void clear (void);
197
virtual CORBA::ULong max_event_size (void) const;
198
virtual int can_match (const RtecEventComm::EventHeader& header) const;
199
virtual int add_dependencies (const RtecEventComm::EventHeader& header,
200
const TAO_EC_QOS_Info &qos_info
204
// ****************************************************************
206
// @@ Add more types of filters like:
207
// - Events in a sequence.
208
// - Events in a sequence with timeouts.
209
// - Conjunction with timeout [as opposed to disjunction of
210
// conjunction and a timeout]
213
// ****************************************************************
215
#if defined (__ACE_INLINE__)
216
#include "EC_Filter.i"
217
#endif /* __ACE_INLINE__ */
219
#include /**/ "ace/post.h"
221
#endif /* TAO_EC_FILTER_H */