TAO_EC_Sched_Filter Class Reference

Decorate a filter with scheduling information. More...

#include <EC_Sched_Filter.h>

Inheritance diagram for TAO_EC_Sched_Filter:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_Sched_Filter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_EC_Sched_Filter (const char *name, RtecScheduler::handle_t rt_info, RtecScheduler::Scheduler_ptr scheduler, TAO_EC_Filter *body, RtecScheduler::handle_t body_info, RtecScheduler::handle_t parent_info, RtecScheduler::Info_Type_t info_type)
virtual ~TAO_EC_Sched_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)
virtual void get_qos_info (TAO_EC_QOS_Info &qos_info)

Private Member Functions

 TAO_EC_Sched_Filter (const TAO_EC_Sched_Filter &)
TAO_EC_Sched_Filteroperator= (const TAO_EC_Sched_Filter &)
void init_rt_info (void)
 Initialize our RT_Info handle and dependencies.
void compute_qos_info (TAO_EC_QOS_Info &qos_info)
 Compute a new qos_info to push up.

Private Attributes

RtecScheduler::handle_t rt_info_
 The RT_Info handle for this object.
int rt_info_computed_
 Has the Scheduler been updated?
ACE_CString name_
 Our operation name.
RtecScheduler::Scheduler_var scheduler_
 The scheduler we are going to use.
TAO_EC_Filterbody_
 The implementation.
RtecScheduler::handle_t body_info_
 The RT_Info handle for the body.
RtecScheduler::handle_t parent_info_
 The RT_Info handle for the parent.
RtecScheduler::Info_Type_t info_type_
 Required for the scheduling service.

Detailed Description

Decorate a filter with scheduling information.

This filter decorates a regular filter with scheduling information. It creates a new RT_Info entry for the filter and it adds the dependencies between the filter and any childrens it may have.

Memory Management

It assumes ownership of the children.

Definition at line 44 of file EC_Sched_Filter.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_Sched_Filter::TAO_EC_Sched_Filter ( const char *  name,
RtecScheduler::handle_t  rt_info,
RtecScheduler::Scheduler_ptr  scheduler,
TAO_EC_Filter body,
RtecScheduler::handle_t  body_info,
RtecScheduler::handle_t  parent_info,
RtecScheduler::Info_Type_t  info_type 
)

Constructor. It assumes ownership of the <body>, makes a copy of the other parameters

Definition at line 12 of file EC_Sched_Filter.cpp.

00020   :  rt_info_ (rt_info),
00021      rt_info_computed_ (0),
00022      name_ (name),
00023      scheduler_ (RtecScheduler::Scheduler::_duplicate (scheduler)),
00024      body_ (body),
00025      body_info_ (body_info),
00026      parent_info_ (parent_info),
00027      info_type_ (info_type)
00028 {
00029   this->adopt_child (this->body_);
00030 }

TAO_EC_Sched_Filter::~TAO_EC_Sched_Filter ( void   )  [virtual]

Destructor.

Definition at line 32 of file EC_Sched_Filter.cpp.

References body_.

00033 {
00034   delete this->body_;
00035 }

TAO_EC_Sched_Filter::TAO_EC_Sched_Filter ( const TAO_EC_Sched_Filter  )  [private]


Member Function Documentation

int TAO_EC_Sched_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 140 of file EC_Sched_Filter.cpp.

References ACE_DEBUG, TAO_EC_Filter::add_dependencies(), body_, end(), init_rt_info(), LM_DEBUG, TAO_EC_Filter::matches(), TAO_EC_QOS_Info::rt_info, scheduler_, and RtecBase::TWO_WAY_CALL.

00142 {
00143   this->init_rt_info ();
00144 
00145   int matches = this->body_->add_dependencies (header,
00146                                                qos_info);
00147 
00148   if (matches != 0)
00149     {
00150       this->scheduler_->add_dependency (this->rt_info_, qos_info.rt_info, 1,
00151                                         RtecBase::TWO_WAY_CALL);
00152 
00153       RtecScheduler::RT_Info_var info =
00154         this->scheduler_->get (qos_info.rt_info);
00155       ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
00156                   this->name_.c_str (),
00157                   info->entry_point.in ()));
00158     }
00159 
00160   ChildrenIterator end = this->end ();
00161   for (ChildrenIterator i = this->begin (); i != end; ++i)
00162     {
00163       (*i)->add_dependencies (header, qos_info);
00164     }
00165   return 0;
00166 }

TAO_EC_Filter::ChildrenIterator TAO_EC_Sched_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 38 of file EC_Sched_Filter.cpp.

References TAO_EC_Filter::begin(), and body_.

00039 {
00040   return this->body_->begin ();
00041 }

int TAO_EC_Sched_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 134 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::can_match().

00135 {
00136   return this->body_->can_match (header);
00137 }

void TAO_EC_Sched_Filter::clear ( void   )  [virtual]

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

Implements TAO_EC_Filter.

Definition at line 122 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::clear().

00123 {
00124   this->body_->clear ();
00125 }

void TAO_EC_Sched_Filter::compute_qos_info ( TAO_EC_QOS_Info qos_info  )  [private]

Compute a new qos_info to push up.

Definition at line 71 of file EC_Sched_Filter.cpp.

References init_rt_info(), TAO_EC_QOS_Info::preemption_priority, TAO_EC_QOS_Info::rt_info, rt_info_, and scheduler_.

00072 {
00073   this->init_rt_info ();
00074 
00075   qos_info.rt_info = this->rt_info_;
00076   switch (this->info_type_)
00077     {
00078     default:
00079     case RtecScheduler::DISJUNCTION:
00080       break;
00081 
00082     case RtecScheduler::CONJUNCTION:
00083     case RtecScheduler::OPERATION:
00084       {
00085         RtecScheduler::OS_Priority os_priority;
00086         RtecScheduler::Preemption_Subpriority_t p_subpriority;
00087         RtecScheduler::Preemption_Priority_t p_priority;
00088         this->scheduler_->priority (this->rt_info_,
00089                                     os_priority,
00090                                     p_subpriority,
00091                                     p_priority);
00092         qos_info.preemption_priority = p_priority;
00093       }
00094     }
00095 }

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

Reimplemented from TAO_EC_Filter.

Definition at line 44 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::end().

Referenced by add_dependencies(), and init_rt_info().

00045 {
00046   return this->body_->end ();
00047 }

int TAO_EC_Sched_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 56 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::filter().

Referenced by init_rt_info().

00058 {
00059   return this->body_->filter (event, qos_info);
00060 }

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

Implements TAO_EC_Filter.

Definition at line 63 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::filter_nocopy().

00065 {
00066   return this->body_->filter_nocopy (event, qos_info);
00067 }

void TAO_EC_Sched_Filter::get_qos_info ( TAO_EC_QOS_Info qos_info  )  [virtual]

Obtain the QOS information for this filter, the default implementation returns an invalid QOS. Only the filters that support scheduling information implement this method.

Returns:
Returns 0 on success and -1 on failure

Reimplemented from TAO_EC_Filter.

Definition at line 169 of file EC_Sched_Filter.cpp.

References init_rt_info(), TAO_EC_QOS_Info::rt_info, and rt_info_.

Referenced by TAO_EC_Sched_Filter_Builder::recursive_build().

00170 {
00171   this->init_rt_info ();
00172 
00173   qos_info.rt_info = this->rt_info_;
00174 }

void TAO_EC_Sched_Filter::init_rt_info ( void   )  [private]

Initialize our RT_Info handle and dependencies.

Definition at line 177 of file EC_Sched_Filter.cpp.

References ACE_DEBUG, ACE_String_Base< CHAR >::c_str(), end(), filter(), LM_DEBUG, name_, TAO_EC_QOS_Info::rt_info, rt_info_computed_, scheduler_, and RtecBase::TWO_WAY_CALL.

Referenced by add_dependencies(), compute_qos_info(), and get_qos_info().

00178 {
00179   if (this->rt_info_computed_)
00180     return;
00181 
00182   // Provide dummy values the scheduler will compute them based on the
00183   // dependencies and the fact that this is a DISJUNCTION.
00184   this->scheduler_->set (this->rt_info_,
00185                          RtecScheduler::VERY_LOW_CRITICALITY,
00186                          0, // worst_cast_execution_time
00187                          0, // typical_cast_execution_time
00188                          0, // cached_cast_execution_time
00189                          0, // period
00190                          RtecScheduler::VERY_LOW_IMPORTANCE,
00191                          0, // quantum
00192                          0, // threads
00193                          this->info_type_);
00194 
00195 #if 0
00196   ChildrenIterator end = this->end ();
00197   for (ChildrenIterator i = this->begin (); i != end; ++i)
00198     {
00199       TAO_EC_Filter* filter = *i;
00200 
00201       TAO_EC_QOS_Info child;
00202       filter->get_qos_info (child);
00203 
00204       this->scheduler_->add_dependency (this->rt_info_,
00205                                         child.rt_info, 1,
00206                                         RtecBase::TWO_WAY_CALL);
00207 
00208       RtecScheduler::RT_Info_var info =
00209         this->scheduler_->get (child.rt_info);
00210       ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
00211                   info->entry_point.in (),
00212                   this->name_.c_str ()));
00213 
00214     }
00215 #endif /* 0 */
00216 
00217 #if 1
00218   if (this->body_info_ != this->rt_info_)
00219     {
00220       this->scheduler_->add_dependency (this->rt_info_,
00221                                         this->body_info_,
00222                                         1,
00223                                         RtecBase::TWO_WAY_CALL);
00224 
00225       RtecScheduler::RT_Info_var info =
00226         this->scheduler_->get (this->body_info_);
00227       ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
00228                   info->entry_point.in (),
00229                   this->name_.c_str ()));
00230     }
00231 #endif /* 0 */
00232 
00233 #if 1
00234   this->scheduler_->add_dependency (this->parent_info_,
00235                                     this->rt_info_,
00236                                     1,
00237                                     RtecBase::TWO_WAY_CALL);
00238 
00239   RtecScheduler::RT_Info_var info =
00240     this->scheduler_->get (this->parent_info_);
00241   ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
00242               this->name_.c_str (),
00243               info->entry_point.in ()));
00244 #endif /* 0 */
00245 
00246   this->rt_info_computed_ = 1;
00247 }

CORBA::ULong TAO_EC_Sched_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 128 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::max_event_size().

00129 {
00130   return this->body_->max_event_size ();
00131 }

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

void TAO_EC_Sched_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 98 of file EC_Sched_Filter.cpp.

References TAO_EC_Filter::parent(), and TAO_EC_Filter::push().

00100 {
00101   if (this->parent () != 0)
00102     {
00103       this->compute_qos_info (qos_info);
00104 
00105       this->parent ()->push (event, qos_info);
00106     }
00107 }

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

Implements TAO_EC_Filter.

Definition at line 110 of file EC_Sched_Filter.cpp.

References TAO_EC_Filter::parent(), and TAO_EC_Filter::push_nocopy().

00112 {
00113   if (this->parent () != 0)
00114     {
00115       this->compute_qos_info (qos_info);
00116 
00117       this->parent ()->push_nocopy (event, qos_info);
00118     }
00119 }

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

Reimplemented from TAO_EC_Filter.

Definition at line 50 of file EC_Sched_Filter.cpp.

References body_, and TAO_EC_Filter::size().

00051 {
00052   return this->body_->size ();
00053 }


Member Data Documentation

TAO_EC_Filter* TAO_EC_Sched_Filter::body_ [private]

The implementation.

Definition at line 107 of file EC_Sched_Filter.h.

Referenced by add_dependencies(), begin(), can_match(), clear(), end(), filter(), filter_nocopy(), max_event_size(), size(), and ~TAO_EC_Sched_Filter().

RtecScheduler::handle_t TAO_EC_Sched_Filter::body_info_ [private]

The RT_Info handle for the body.

Definition at line 110 of file EC_Sched_Filter.h.

RtecScheduler::Info_Type_t TAO_EC_Sched_Filter::info_type_ [private]

Required for the scheduling service.

Definition at line 116 of file EC_Sched_Filter.h.

ACE_CString TAO_EC_Sched_Filter::name_ [private]

Our operation name.

Definition at line 101 of file EC_Sched_Filter.h.

Referenced by init_rt_info().

RtecScheduler::handle_t TAO_EC_Sched_Filter::parent_info_ [private]

The RT_Info handle for the parent.

Definition at line 113 of file EC_Sched_Filter.h.

RtecScheduler::handle_t TAO_EC_Sched_Filter::rt_info_ [private]

The RT_Info handle for this object.

Definition at line 95 of file EC_Sched_Filter.h.

Referenced by compute_qos_info(), and get_qos_info().

int TAO_EC_Sched_Filter::rt_info_computed_ [private]

Has the Scheduler been updated?

Definition at line 98 of file EC_Sched_Filter.h.

Referenced by init_rt_info().

RtecScheduler::Scheduler_var TAO_EC_Sched_Filter::scheduler_ [private]

The scheduler we are going to use.

Definition at line 104 of file EC_Sched_Filter.h.

Referenced by add_dependencies(), compute_qos_info(), and init_rt_info().


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