TAO_EC_Kokyu_Filter Class Reference

Decorate a filter with scheduling information. More...

#include <EC_Kokyu_Filter.h>

Inheritance diagram for TAO_EC_Kokyu_Filter:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_Kokyu_Filter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_EC_Kokyu_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_Kokyu_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_Kokyu_Filter (const TAO_EC_Kokyu_Filter &)
TAO_EC_Kokyu_Filteroperator= (const TAO_EC_Kokyu_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_Kokyu_Filter.h.


Constructor & Destructor Documentation

TAO_EC_Kokyu_Filter::TAO_EC_Kokyu_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 10 of file EC_Kokyu_Filter.cpp.

00018   :  rt_info_ (rt_info),
00019      rt_info_computed_ (0),
00020      name_ (name),
00021      scheduler_ (RtecScheduler::Scheduler::_duplicate (scheduler)),
00022      body_ (body),
00023      body_info_ (body_info),
00024      parent_info_ (parent_info),
00025      info_type_ (info_type)
00026 {
00027   this->adopt_child (this->body_);
00028 
00029 #if 1 //by VS
00030 this->rt_info_computed_ = 1;
00031 #endif
00032 }

TAO_EC_Kokyu_Filter::~TAO_EC_Kokyu_Filter ( void   )  [virtual]

Destructor.

Definition at line 34 of file EC_Kokyu_Filter.cpp.

References body_.

00035 {
00036   delete this->body_;
00037 }

TAO_EC_Kokyu_Filter::TAO_EC_Kokyu_Filter ( const TAO_EC_Kokyu_Filter  )  [private]


Member Function Documentation

int TAO_EC_Kokyu_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 168 of file EC_Kokyu_Filter.cpp.

References ACE_DEBUG, TAO_EC_Filter::add_dependencies(), body_, end(), init_rt_info(), LM_DEBUG, TAO_EC_Filter::matches(), RtecBase::ONE_WAY_CALL, TAO_EC_QOS_Info::rt_info, rt_info_, scheduler_, and RtecEventComm::EventHeader::type.

00170 {
00171 #ifdef EC_KOKYU_LOGGING
00172   ACE_DEBUG ((LM_DEBUG, "Entering EC_Kokyu_Filter::add_dependencies\n"));
00173 #endif
00174   this->init_rt_info ();
00175 
00176 #ifdef EC_KOKYU_LOGGING
00177   ACE_DEBUG ((LM_DEBUG,
00178               "this->rt_info_ = %d, header.type = %d, qos_info.rt_info = %d\n",
00179               this->rt_info_, header.type, qos_info.rt_info));
00180 #endif
00181 
00182   //this call the add_dependencies() on con/disjunction filter
00183   int matches = this->body_->add_dependencies (header,
00184                                                qos_info);
00185 
00186   if (matches != 0)
00187     {
00188 #ifdef EC_KOKYU_LOGGING
00189       ACE_DEBUG ((LM_DEBUG, "Kokyu_Filter::matches != 0\n"));
00190 #endif
00191       this->scheduler_->add_dependency (this->rt_info_, qos_info.rt_info, 1,
00192                                         RtecBase::ONE_WAY_CALL);
00193 
00194       RtecScheduler::RT_Info_var info =
00195         this->scheduler_->get (qos_info.rt_info);
00196       ACE_DEBUG ((LM_DEBUG, "[%s][%d] ----> [%s][%d]\n",
00197                   this->name_.c_str (),
00198                   this->rt_info_,
00199                   info->entry_point.in (),
00200                   qos_info.rt_info));
00201     }
00202   else
00203     {
00204 #ifdef EC_KOKYU_LOGGING
00205       ACE_DEBUG ((LM_DEBUG, "Kokyu_Filter::matches == 0\n"));
00206 #endif
00207     }
00208 
00209 #ifdef EC_KOKYU_LOGGING
00210   ACE_DEBUG ((LM_DEBUG, "about to iterate thru children\n"));
00211 #endif
00212   ChildrenIterator end = this->end ();
00213   for (ChildrenIterator i = this->begin (); i != end; ++i)
00214     {
00215       (*i)->add_dependencies (header, qos_info);
00216     }
00217 #ifdef EC_KOKYU_LOGGING
00218   ACE_DEBUG ((LM_DEBUG, "Exiting EC_Kokyu_Filter: add_dependencies\n"));
00219 #endif
00220   return 0;
00221 }

TAO_EC_Filter::ChildrenIterator TAO_EC_Kokyu_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 40 of file EC_Kokyu_Filter.cpp.

References TAO_EC_Filter::begin(), and body_.

00041 {
00042   return this->body_->begin ();
00043 }

int TAO_EC_Kokyu_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 136 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::can_match().

00137 {
00138   return this->body_->can_match (header);
00139 }

void TAO_EC_Kokyu_Filter::clear ( void   )  [virtual]

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

Implements TAO_EC_Filter.

Definition at line 124 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::clear().

00125 {
00126   this->body_->clear ();
00127 }

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

Compute a new qos_info to push up.

Definition at line 73 of file EC_Kokyu_Filter.cpp.

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

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

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

Reimplemented from TAO_EC_Filter.

Definition at line 46 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::end().

Referenced by add_dependencies().

00047 {
00048   return this->body_->end ();
00049 }

int TAO_EC_Kokyu_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 58 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::filter().

00060 {
00061   return this->body_->filter (event, qos_info);
00062 }

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

Implements TAO_EC_Filter.

Definition at line 65 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::filter_nocopy().

00067 {
00068   return this->body_->filter_nocopy (event, qos_info);
00069 }

void TAO_EC_Kokyu_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 224 of file EC_Kokyu_Filter.cpp.

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

Referenced by TAO_EC_Kokyu_Filter_Builder::build(), and TAO_EC_Kokyu_Filter_Builder::recursive_build().

00225 {
00226   this->init_rt_info ();
00227 
00228   qos_info.rt_info = this->rt_info_;
00229 }

void TAO_EC_Kokyu_Filter::init_rt_info ( void   )  [private]

Initialize our RT_Info handle and dependencies.

Definition at line 232 of file EC_Kokyu_Filter.cpp.

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

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

00233 {
00234   if (this->rt_info_computed_)
00235     return;
00236 
00237 #if 1 //ifdef'ed from 1 to 0 by VS
00238 
00239   // Provide dummy values the scheduler will compute them based on the
00240   // dependencies and the fact that this is a DISJUNCTION.
00241   this->scheduler_->set (this->rt_info_,
00242                          RtecScheduler::VERY_LOW_CRITICALITY,
00243                          0, // worst_cast_execution_time
00244                          0, // typical_cast_execution_time
00245                          0, // cached_cast_execution_time
00246                          0, // period
00247                          RtecScheduler::VERY_LOW_IMPORTANCE,
00248                          0, // quantum
00249                          0, // threads
00250                          this->info_type_);
00251 #endif  //ifdef'ed by VS
00252 
00253 #if 0 //ifdef changed from 1 to 0 by VS
00254   if (this->body_info_ != this->rt_info_)
00255     {
00256       this->scheduler_->add_dependency (this->rt_info_,
00257                                         this->body_info_,
00258                                         1,
00259                                         RtecBase::TWO_WAY_CALL);
00260 
00261       RtecScheduler::RT_Info_var info =
00262         this->scheduler_->get (this->body_info_);
00263       ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
00264                   info->entry_point.in (),
00265                   this->name_.c_str ()));
00266     }
00267 #endif /* 0 */
00268 
00269 #if 0 //ifdef changed from 1 to 0 by VS
00270   this->scheduler_->add_dependency (this->parent_info_,
00271                                     this->rt_info_,
00272                                     1,
00273                                     RtecBase::TWO_WAY_CALL);
00274 
00275   RtecScheduler::RT_Info_var info =
00276     this->scheduler_->get (this->parent_info_);
00277   ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
00278               this->name_.c_str (),
00279               info->entry_point.in ()));
00280 #endif /* 0 */
00281 
00282   this->rt_info_computed_ = 1;
00283 }

CORBA::ULong TAO_EC_Kokyu_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 130 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::max_event_size().

00131 {
00132   return this->body_->max_event_size ();
00133 }

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

void TAO_EC_Kokyu_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 100 of file EC_Kokyu_Filter.cpp.

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

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

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

Implements TAO_EC_Filter.

Definition at line 112 of file EC_Kokyu_Filter.cpp.

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

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

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

Reimplemented from TAO_EC_Filter.

Definition at line 52 of file EC_Kokyu_Filter.cpp.

References body_, and TAO_EC_Filter::size().

00053 {
00054   return this->body_->size ();
00055 }


Member Data Documentation

TAO_EC_Filter* TAO_EC_Kokyu_Filter::body_ [private]

The implementation.

Definition at line 107 of file EC_Kokyu_Filter.h.

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

RtecScheduler::handle_t TAO_EC_Kokyu_Filter::body_info_ [private]

The RT_Info handle for the body.

Definition at line 110 of file EC_Kokyu_Filter.h.

RtecScheduler::Info_Type_t TAO_EC_Kokyu_Filter::info_type_ [private]

Required for the scheduling service.

Definition at line 116 of file EC_Kokyu_Filter.h.

ACE_CString TAO_EC_Kokyu_Filter::name_ [private]

Our operation name.

Definition at line 101 of file EC_Kokyu_Filter.h.

Referenced by init_rt_info().

RtecScheduler::handle_t TAO_EC_Kokyu_Filter::parent_info_ [private]

The RT_Info handle for the parent.

Definition at line 113 of file EC_Kokyu_Filter.h.

RtecScheduler::handle_t TAO_EC_Kokyu_Filter::rt_info_ [private]

The RT_Info handle for this object.

Definition at line 95 of file EC_Kokyu_Filter.h.

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

int TAO_EC_Kokyu_Filter::rt_info_computed_ [private]

Has the Scheduler been updated?

Definition at line 98 of file EC_Kokyu_Filter.h.

Referenced by init_rt_info().

RtecScheduler::Scheduler_var TAO_EC_Kokyu_Filter::scheduler_ [private]

The scheduler we are going to use.

Definition at line 104 of file EC_Kokyu_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:30 2010 for TAO_RTEvent by  doxygen 1.4.7