TAO_EC_Conjunction_Filter Class Reference

The conjunction filter. More...

#include <EC_Conjunction_Filter.h>

Inheritance diagram for TAO_EC_Conjunction_Filter:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_Conjunction_Filter:

Collaboration graph
[legend]
List of all members.

Public Types

typedef unsigned int Word

Public Member Functions

 TAO_EC_Conjunction_Filter (TAO_EC_Filter *children[], size_t n)
virtual ~TAO_EC_Conjunction_Filter (void)
 Destructor.

virtual ChildrenIterator begin (void) const
virtual ChildrenIterator end (void) const
virtual int size (void) const
virtual int filter (const RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info)
virtual int filter_nocopy (RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info)
virtual void push (const RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info)
virtual void push_nocopy (RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info)
virtual void clear (void)
virtual CORBA::ULong max_event_size (void) const
 Returns the maximum size of the events pushed by this filter.

virtual int can_match (const RtecEventComm::EventHeader &header) const
virtual int add_dependencies (const RtecEventComm::EventHeader &header, const TAO_EC_QOS_Info &qos_info)

Private Member Functions

int all_received (void) const
 Determine if all the children have received their events.

 TAO_EC_Conjunction_Filter (const TAO_EC_Conjunction_Filter &)
TAO_EC_Conjunction_Filteroperator= (const TAO_EC_Conjunction_Filter &)

Private Attributes

TAO_EC_Filter ** children_
 The children.

size_t n_
 The number of children.

RtecEventComm::EventSet event_
 The event we send up (once all the children have pushed theirs).

size_t nwords_
Wordbitvec_
ChildrenIterator current_child_
 The current child in the iteration, used in the push() method...


Detailed Description

The conjunction filter.

This filter waits until each one of its children has accepted at least one event. Only in that case it accepts and publishes the sequence formed by all the children events.

Memory Management

It assumes ownership of the children.

Definition at line 41 of file EC_Conjunction_Filter.h.


Member Typedef Documentation

typedef unsigned int TAO_EC_Conjunction_Filter::Word
 

Definition at line 71 of file EC_Conjunction_Filter.h.

Referenced by all_received(), clear(), and TAO_EC_Conjunction_Filter().


Constructor & Destructor Documentation

TAO_EC_Conjunction_Filter::TAO_EC_Conjunction_Filter TAO_EC_Filter children[],
size_t  n
 

Constructor. It assumes ownership of both the array and the children.

Definition at line 12 of file EC_Conjunction_Filter.cpp.

References ACE_NEW, TAO_EC_Filter::adopt_child(), begin(), bits_per_word, clear(), end(), nwords_, and Word.

00014   :  children_ (children),
00015      n_ (n)
00016 {
00017   ChildrenIterator end = this->end ();
00018   for (ChildrenIterator i = this->begin ();
00019        i != end;
00020        ++i)
00021     {
00022       this->adopt_child (*i);
00023     }
00024 
00025   this->nwords_ = this->n_ / bits_per_word + 1;
00026   ACE_NEW (this->bitvec_, Word[this->nwords_]);
00027 
00028   this->clear ();
00029 }

TAO_EC_Conjunction_Filter::~TAO_EC_Conjunction_Filter void   )  [virtual]
 

Destructor.

Definition at line 31 of file EC_Conjunction_Filter.cpp.

References bitvec_.

00032 {
00033   TAO_EC_Filter** end = this->children_ + this->n_;
00034   for (TAO_EC_Filter** i = this->children_;
00035        i != end;
00036        ++i)
00037     {
00038       delete *i;
00039       *i = 0;
00040     }
00041   delete[] this->children_;
00042   this->children_ = 0;
00043   this->n_ = 0;
00044 
00045   delete[] this->bitvec_;
00046   this->bitvec_ = 0;
00047 }

TAO_EC_Conjunction_Filter::TAO_EC_Conjunction_Filter const TAO_EC_Conjunction_Filter  )  [private]
 


Member Function Documentation

int TAO_EC_Conjunction_Filter::add_dependencies const RtecEventComm::EventHeader header,
const TAO_EC_QOS_Info qos_info
[virtual]
 

This is used for computing the scheduling dependencies:

Leaf filters check if the header could be matched, similar to the can_match() method; if it does they return 1, and 0 otherwise. Intermediate nodes always return 0.

This is used to build precise dependencies between the suppliers and the leaf of the filters that accept that event. Notice that only the nodes doing scheduling recurse through the list, so in configurations that do no require scheduling the recursion stops fairly soon.

Implements TAO_EC_Filter.

Definition at line 195 of file EC_Conjunction_Filter.cpp.

00198 {
00199   return 0;
00200 }

int TAO_EC_Conjunction_Filter::all_received void   )  const [private]
 

Determine if all the children have received their events.

Definition at line 50 of file EC_Conjunction_Filter.cpp.

References bitvec_, nwords_, and Word.

Referenced by push().

00051 {
00052   Word* i = this->bitvec_;
00053   for (;
00054        i != this->bitvec_ + this->nwords_;
00055        ++i)
00056     {
00057       if (*i != static_cast<Word> (~0))
00058         return 0;
00059     }
00060   return 1;
00061 }

TAO_EC_Filter::ChildrenIterator TAO_EC_Conjunction_Filter::begin void   )  const [virtual]
 

STL-like iterators Filters follow the Composite pattern. All filters expose the same interface as if they all had children, but for simple filters the iterators return an empty range.

Reimplemented from TAO_EC_Filter.

Definition at line 64 of file EC_Conjunction_Filter.cpp.

Referenced by can_match(), clear(), filter(), filter_nocopy(), max_event_size(), push(), and TAO_EC_Conjunction_Filter().

00065 {
00066   return this->children_;
00067 }

int TAO_EC_Conjunction_Filter::can_match const RtecEventComm::EventHeader header  )  const [virtual]
 

Returns 0 if an event with that header could never be accepted. This can used by the suppliers to filter out consumers that couldn't possibly be interested in their events. The rt_info and

Implements TAO_EC_Filter.

Definition at line 180 of file EC_Conjunction_Filter.cpp.

References begin(), and end().

00182 {
00183   ChildrenIterator end = this->end ();
00184   for (ChildrenIterator i = this->begin ();
00185        i != end;
00186        ++i)
00187     {
00188       if ((*i)->can_match (header) != 0)
00189         return 1;
00190     }
00191   return 0;
00192 }

void TAO_EC_Conjunction_Filter::clear void   )  [virtual]
 

Clear any saved state, must reset and assume no events have been received.

Implements TAO_EC_Filter.

Definition at line 142 of file EC_Conjunction_Filter.cpp.

References begin(), bits_per_word, bitvec_, end(), nwords_, and Word.

Referenced by TAO_EC_Conjunction_Filter().

00143 {
00144   ChildrenIterator end = this->end ();
00145   for (ChildrenIterator i = this->begin ();
00146        i != end;
00147        ++i)
00148     {
00149       (*i)->clear ();
00150     }
00151   Word* j = this->bitvec_;
00152   for (;
00153        j != this->bitvec_ + this->nwords_ - 1;
00154        ++j)
00155     {
00156       *j = 0;
00157     }
00158   int b = static_cast<int> (this->n_ % bits_per_word);
00159   Word last = ~0 << b;
00160   *j = last;
00161 
00162   this->event_.length (0);
00163 }

TAO_EC_Filter::ChildrenIterator TAO_EC_Conjunction_Filter::end void   )  const [virtual]
 

Reimplemented from TAO_EC_Filter.

Definition at line 70 of file EC_Conjunction_Filter.cpp.

Referenced by can_match(), clear(), filter(), filter_nocopy(), max_event_size(), and TAO_EC_Conjunction_Filter().

00071 {
00072   return this->children_ + this->n_;
00073 }

int TAO_EC_Conjunction_Filter::filter const RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info
[virtual]
 

Filter this event, returns 1 if the event is accepted, 0 otherwise. Notice that there are two versions of the method, if the event is not const then filter can take ownership of the event.

Attention:
There seems to be a disparity in interfaces: Supplier always push event sets of size 1 to the EC_ProxyPushSupplier, and EC_Filters do not implement handling of sets of more than 1 event. Then, why is this not enforced by the interface by having EC_ProxyPushSupplier take an event rather than a set?

Implements TAO_EC_Filter.

Definition at line 82 of file EC_Conjunction_Filter.cpp.

References begin(), current_child_, end(), and RtecEventComm::EventSet.

00084 {
00085   ChildrenIterator end = this->end ();
00086   for (this->current_child_ = this->begin ();
00087        this->current_child_ != end;
00088        ++this->current_child_)
00089     {
00090       int n = (*this->current_child_)->filter (event, qos_info);
00091       if (n != 0)
00092         return n;
00093     }
00094   return 0;
00095 }

int TAO_EC_Conjunction_Filter::filter_nocopy RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info
[virtual]
 

Implements TAO_EC_Filter.

Definition at line 98 of file EC_Conjunction_Filter.cpp.

References begin(), end(), and RtecEventComm::EventSet.

00100 {
00101   ChildrenIterator end = this->end ();
00102   for (ChildrenIterator i = this->begin ();
00103        i != end;
00104        ++i)
00105     {
00106       int n = (*i)->filter_nocopy (event, qos_info);
00107       if (n != 0)
00108         return n;
00109     }
00110   return 0;
00111 }

CORBA::ULong TAO_EC_Conjunction_Filter::max_event_size void   )  const [virtual]
 

Returns the maximum size of the events pushed by this filter.

Implements TAO_EC_Filter.

Definition at line 166 of file EC_Conjunction_Filter.cpp.

References begin(), and end().

00167 {
00168   CORBA::ULong n = 0;
00169   ChildrenIterator end = this->end ();
00170   for (ChildrenIterator i = this->begin ();
00171        i != end;
00172        ++i)
00173     {
00174       n += (*i)->max_event_size ();
00175     }
00176   return n;
00177 }

TAO_EC_Conjunction_Filter& TAO_EC_Conjunction_Filter::operator= const TAO_EC_Conjunction_Filter  )  [private]
 

void TAO_EC_Conjunction_Filter::push const RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info
[virtual]
 

This is called by the children when they accept an event and which to pass it up. Notice that there are two versions of the method, if the event is not const then filter can take ownership of the event.

Implements TAO_EC_Filter.

Definition at line 114 of file EC_Conjunction_Filter.cpp.

References ACE_BIT_ENABLED, ACE_SET_BITS, all_received(), begin(), bits_per_word, current_child_, RtecEventComm::EventSet, TAO_EC_Filter::parent(), and TAO_EC_Filter::push_nocopy().

Referenced by push_nocopy().

00116 {
00117   CORBA::Long pos = this->current_child_ - this->begin ();
00118   int w = pos / bits_per_word;
00119   int b = pos % bits_per_word;
00120   if (ACE_BIT_ENABLED (this->bitvec_[w], 1<<b))
00121     return;
00122   ACE_SET_BITS (this->bitvec_[w], 1<<b);
00123   CORBA::ULong n = event.length ();
00124   CORBA::ULong l = this->event_.length ();
00125   this->event_.length (l + n);
00126   for (CORBA::ULong i = 0; i != n; ++i)
00127     {
00128       this->event_[l + i] = event[i];
00129     }
00130   if (this->all_received () && this->parent () != 0)
00131     this->parent ()->push_nocopy (this->event_, qos_info);
00132 }

void TAO_EC_Conjunction_Filter::push_nocopy RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info
[virtual]
 

Implements TAO_EC_Filter.

Definition at line 135 of file EC_Conjunction_Filter.cpp.

References RtecEventComm::EventSet, and push().

00137 {
00138   this->push (event, qos_info);
00139 }

int TAO_EC_Conjunction_Filter::size void   )  const [virtual]
 

Reimplemented from TAO_EC_Filter.

Definition at line 76 of file EC_Conjunction_Filter.cpp.

00077 {
00078   return static_cast<int> (this->n_);
00079 }


Member Data Documentation

Word* TAO_EC_Conjunction_Filter::bitvec_ [private]
 

The bit vector to keep track of the children that have received their events.

Definition at line 99 of file EC_Conjunction_Filter.h.

Referenced by all_received(), clear(), and ~TAO_EC_Conjunction_Filter().

TAO_EC_Filter** TAO_EC_Conjunction_Filter::children_ [private]
 

The children.

Definition at line 82 of file EC_Conjunction_Filter.h.

ChildrenIterator TAO_EC_Conjunction_Filter::current_child_ [private]
 

The current child in the iteration, used in the push() method...

Definition at line 102 of file EC_Conjunction_Filter.h.

Referenced by filter(), and push().

RtecEventComm::EventSet TAO_EC_Conjunction_Filter::event_ [private]
 

The event we send up (once all the children have pushed theirs).

Definition at line 88 of file EC_Conjunction_Filter.h.

size_t TAO_EC_Conjunction_Filter::n_ [private]
 

The number of children.

Definition at line 85 of file EC_Conjunction_Filter.h.

size_t TAO_EC_Conjunction_Filter::nwords_ [private]
 

The number of words in the bit vector

Definition at line 93 of file EC_Conjunction_Filter.h.

Referenced by all_received(), clear(), and TAO_EC_Conjunction_Filter().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:42:01 2008 for TAO_RTEvent by doxygen 1.3.6