TAO_EC_And_Filter Class Reference

The 'logical and' filter. More...

#include <EC_And_Filter.h>

Inheritance diagram for TAO_EC_And_Filter:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_And_Filter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_EC_And_Filter (TAO_EC_Filter *children[], size_t n)
virtual ~TAO_EC_And_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

 TAO_EC_And_Filter (const TAO_EC_And_Filter &)
TAO_EC_And_Filteroperator= (const TAO_EC_And_Filter &)

Private Attributes

TAO_EC_Filter ** children_
 The children.
size_t n_
 The number of children.

Detailed Description

The 'logical and' filter.

This filter has a set of children (fixed at creation time), only if all the children accept an event it does so too.

Memory Management

It assumes ownership of the children.

Definition at line 39 of file EC_And_Filter.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_And_Filter::TAO_EC_And_Filter ( TAO_EC_Filter children[],
size_t  n 
)

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

Definition at line 9 of file EC_And_Filter.cpp.

00011   :  children_ (children),
00012      n_ (n)
00013 {
00014   ChildrenIterator end = this->end ();
00015   for (ChildrenIterator i = this->begin ();
00016        i != end;
00017        ++i)
00018     {
00019       this->adopt_child (*i);
00020     }
00021 }

TAO_EC_And_Filter::~TAO_EC_And_Filter ( void   )  [virtual]

Destructor.

Definition at line 23 of file EC_And_Filter.cpp.

References children_, end(), and n_.

00024 {
00025   TAO_EC_Filter** end = this->children_ + this->n_;
00026   for (TAO_EC_Filter** i = this->children_;
00027        i != end;
00028        ++i)
00029     {
00030       delete *i;
00031       *i = 0;
00032     }
00033   delete[] this->children_;
00034   this->children_ = 0;
00035   this->n_ = 0;
00036 }

TAO_EC_And_Filter::TAO_EC_And_Filter ( const TAO_EC_And_Filter  )  [private]


Member Function Documentation

int TAO_EC_And_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 154 of file EC_And_Filter.cpp.

00157 {
00158   return 0;
00159 }

TAO_EC_Filter::ChildrenIterator TAO_EC_And_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 39 of file EC_And_Filter.cpp.

References children_.

00040 {
00041   return this->children_;
00042 }

int TAO_EC_And_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 139 of file EC_And_Filter.cpp.

References end().

00141 {
00142   ChildrenIterator end = this->end ();
00143   for (ChildrenIterator i = this->begin ();
00144        i != end;
00145        ++i)
00146     {
00147       if ((*i)->can_match (header) == 0)
00148         return 0;
00149     }
00150   return 1;
00151 }

void TAO_EC_And_Filter::clear ( void   )  [virtual]

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

Implements TAO_EC_Filter.

Definition at line 111 of file EC_And_Filter.cpp.

References end().

00112 {
00113   ChildrenIterator end = this->end ();
00114   for (ChildrenIterator i = this->begin ();
00115        i != end;
00116        ++i)
00117     {
00118       (*i)->clear ();
00119     }
00120 }

TAO_EC_Filter::ChildrenIterator TAO_EC_And_Filter::end ( void   )  const [virtual]

Reimplemented from TAO_EC_Filter.

Definition at line 45 of file EC_And_Filter.cpp.

References children_, and n_.

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

00046 {
00047   return this->children_ + this->n_;
00048 }

int TAO_EC_And_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 57 of file EC_And_Filter.cpp.

References end().

00059 {
00060   ChildrenIterator end = this->end ();
00061   for (ChildrenIterator i = this->begin (); i != end; ++i)
00062     {
00063       int n = (*i)->filter (event, qos_info);
00064       if (n == 0)
00065         return 0;
00066     }
00067 
00068   // All children accepted the event, push up...
00069   if (this->parent () != 0)
00070     {
00071       this->parent ()->push (event, qos_info);
00072     }
00073 
00074   return 1;
00075 }

int TAO_EC_And_Filter::filter_nocopy ( RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info 
) [virtual]

Implements TAO_EC_Filter.

Definition at line 78 of file EC_And_Filter.cpp.

References end().

00080 {
00081   ChildrenIterator end = this->end ();
00082   for (ChildrenIterator i = this->begin (); i != end; ++i)
00083     {
00084       int n = (*i)->filter_nocopy (event, qos_info);
00085       if (n == 0)
00086         return 0;
00087     }
00088 
00089   // All children accepted the event, push up...
00090   if (this->parent () != 0)
00091     {
00092       this->parent ()->push (event, qos_info);
00093     }
00094 
00095   return 1;
00096 }

CORBA::ULong TAO_EC_And_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 123 of file EC_And_Filter.cpp.

References end().

00124 {
00125   CORBA::ULong n = 0;
00126   ChildrenIterator end = this->end ();
00127   for (ChildrenIterator i = this->begin ();
00128        i != end;
00129        ++i)
00130     {
00131       CORBA::ULong c = (*i)->max_event_size ();
00132       if (n < c)
00133         n = c;
00134     }
00135   return n;
00136 }

TAO_EC_And_Filter& TAO_EC_And_Filter::operator= ( const TAO_EC_And_Filter  )  [private]

void TAO_EC_And_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 99 of file EC_And_Filter.cpp.

00101 {
00102 }

void TAO_EC_And_Filter::push_nocopy ( RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info 
) [virtual]

Implements TAO_EC_Filter.

Definition at line 105 of file EC_And_Filter.cpp.

00107 {
00108 }

int TAO_EC_And_Filter::size ( void   )  const [virtual]

Reimplemented from TAO_EC_Filter.

Definition at line 51 of file EC_And_Filter.cpp.

References n_.

00052 {
00053   return static_cast<CORBA::ULong> (this->n_);
00054 }


Member Data Documentation

TAO_EC_Filter** TAO_EC_And_Filter::children_ [private]

The children.

Definition at line 75 of file EC_And_Filter.h.

Referenced by begin(), end(), and ~TAO_EC_And_Filter().

size_t TAO_EC_And_Filter::n_ [private]

The number of children.

Definition at line 78 of file EC_And_Filter.h.

Referenced by end(), size(), and ~TAO_EC_And_Filter().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:44:26 2010 for TAO_RTEvent by  doxygen 1.4.7