00001
00002
00003 #include "orbsvcs/Event/EC_Sched_Filter.h"
00004 #include "orbsvcs/Event/EC_QOS_Info.h"
00005 #include "ace/Log_Msg.h"
00006
00007 ACE_RCSID(Event, EC_Sched_Filter, "$Id: EC_Sched_Filter.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00008
00009 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00010
00011 TAO_EC_Sched_Filter::
00012 TAO_EC_Sched_Filter (const char* name,
00013 RtecScheduler::handle_t rt_info,
00014 RtecScheduler::Scheduler_ptr scheduler,
00015 TAO_EC_Filter* body,
00016 RtecScheduler::handle_t body_info,
00017 RtecScheduler::handle_t parent_info,
00018 RtecScheduler::Info_Type_t info_type)
00019
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 }
00031
00032 TAO_EC_Sched_Filter::~TAO_EC_Sched_Filter (void)
00033 {
00034 delete this->body_;
00035 }
00036
00037 TAO_EC_Filter::ChildrenIterator
00038 TAO_EC_Sched_Filter::begin (void) const
00039 {
00040 return this->body_->begin ();
00041 }
00042
00043 TAO_EC_Filter::ChildrenIterator
00044 TAO_EC_Sched_Filter::end (void) const
00045 {
00046 return this->body_->end ();
00047 }
00048
00049 int
00050 TAO_EC_Sched_Filter::size (void) const
00051 {
00052 return this->body_->size ();
00053 }
00054
00055 int
00056 TAO_EC_Sched_Filter::filter (const RtecEventComm::EventSet &event,
00057 TAO_EC_QOS_Info& qos_info)
00058 {
00059 return this->body_->filter (event, qos_info);
00060 }
00061
00062 int
00063 TAO_EC_Sched_Filter::filter_nocopy (RtecEventComm::EventSet &event,
00064 TAO_EC_QOS_Info& qos_info)
00065 {
00066 return this->body_->filter_nocopy (event, qos_info);
00067 }
00068
00069
00070 void
00071 TAO_EC_Sched_Filter::compute_qos_info (TAO_EC_QOS_Info& qos_info)
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 }
00096
00097 void
00098 TAO_EC_Sched_Filter::push (const RtecEventComm::EventSet &event,
00099 TAO_EC_QOS_Info& qos_info)
00100 {
00101 if (this->parent () != 0)
00102 {
00103 this->compute_qos_info (qos_info);
00104
00105 this->parent ()->push (event, qos_info);
00106 }
00107 }
00108
00109 void
00110 TAO_EC_Sched_Filter::push_nocopy (RtecEventComm::EventSet &event,
00111 TAO_EC_QOS_Info& qos_info)
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 }
00120
00121 void
00122 TAO_EC_Sched_Filter::clear (void)
00123 {
00124 this->body_->clear ();
00125 }
00126
00127 CORBA::ULong
00128 TAO_EC_Sched_Filter::max_event_size (void) const
00129 {
00130 return this->body_->max_event_size ();
00131 }
00132
00133 int
00134 TAO_EC_Sched_Filter::can_match (const RtecEventComm::EventHeader& header) const
00135 {
00136 return this->body_->can_match (header);
00137 }
00138
00139 int
00140 TAO_EC_Sched_Filter::add_dependencies (const RtecEventComm::EventHeader& header,
00141 const TAO_EC_QOS_Info &qos_info)
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 }
00167
00168 void
00169 TAO_EC_Sched_Filter::get_qos_info (TAO_EC_QOS_Info& qos_info)
00170 {
00171 this->init_rt_info ();
00172
00173 qos_info.rt_info = this->rt_info_;
00174 }
00175
00176 void
00177 TAO_EC_Sched_Filter::init_rt_info (void)
00178 {
00179 if (this->rt_info_computed_)
00180 return;
00181
00182
00183
00184 this->scheduler_->set (this->rt_info_,
00185 RtecScheduler::VERY_LOW_CRITICALITY,
00186 0,
00187 0,
00188 0,
00189 0,
00190 RtecScheduler::VERY_LOW_IMPORTANCE,
00191 0,
00192 0,
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
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
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
00245
00246 this->rt_info_computed_ = 1;
00247 }
00248
00249 TAO_END_VERSIONED_NAMESPACE_DECL