00001
00002
00003 #include "orbsvcs/Event/EC_Kokyu_Filter.h"
00004 #include "orbsvcs/Event/EC_QOS_Info.h"
00005 #include "ace/Log_Msg.h"
00006
00007 ACE_RCSID(Event, EC_Kokyu_Filter, "$Id: EC_Kokyu_Filter.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00008
00009 TAO_EC_Kokyu_Filter::
00010 TAO_EC_Kokyu_Filter (const char* name,
00011 RtecScheduler::handle_t rt_info,
00012 RtecScheduler::Scheduler_ptr scheduler,
00013 TAO_EC_Filter* body,
00014 RtecScheduler::handle_t body_info,
00015 RtecScheduler::handle_t parent_info,
00016 RtecScheduler::Info_Type_t info_type)
00017
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 }
00033
00034 TAO_EC_Kokyu_Filter::~TAO_EC_Kokyu_Filter (void)
00035 {
00036 delete this->body_;
00037 }
00038
00039 TAO_EC_Filter::ChildrenIterator
00040 TAO_EC_Kokyu_Filter::begin (void) const
00041 {
00042 return this->body_->begin ();
00043 }
00044
00045 TAO_EC_Filter::ChildrenIterator
00046 TAO_EC_Kokyu_Filter::end (void) const
00047 {
00048 return this->body_->end ();
00049 }
00050
00051 int
00052 TAO_EC_Kokyu_Filter::size (void) const
00053 {
00054 return this->body_->size ();
00055 }
00056
00057 int
00058 TAO_EC_Kokyu_Filter::filter (const RtecEventComm::EventSet &event,
00059 TAO_EC_QOS_Info& qos_info)
00060 {
00061 return this->body_->filter (event, qos_info);
00062 }
00063
00064 int
00065 TAO_EC_Kokyu_Filter::filter_nocopy (RtecEventComm::EventSet &event,
00066 TAO_EC_QOS_Info& qos_info)
00067 {
00068 return this->body_->filter_nocopy (event, qos_info);
00069 }
00070
00071
00072 void
00073 TAO_EC_Kokyu_Filter::compute_qos_info (TAO_EC_QOS_Info& qos_info)
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 }
00098
00099 void
00100 TAO_EC_Kokyu_Filter::push (const RtecEventComm::EventSet &event,
00101 TAO_EC_QOS_Info& qos_info)
00102 {
00103 if (this->parent () != 0)
00104 {
00105 this->compute_qos_info (qos_info);
00106
00107 this->parent ()->push (event, qos_info);
00108 }
00109 }
00110
00111 void
00112 TAO_EC_Kokyu_Filter::push_nocopy (RtecEventComm::EventSet &event,
00113 TAO_EC_QOS_Info& qos_info)
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 }
00122
00123 void
00124 TAO_EC_Kokyu_Filter::clear (void)
00125 {
00126 this->body_->clear ();
00127 }
00128
00129 CORBA::ULong
00130 TAO_EC_Kokyu_Filter::max_event_size (void) const
00131 {
00132 return this->body_->max_event_size ();
00133 }
00134
00135 int
00136 TAO_EC_Kokyu_Filter::can_match (const RtecEventComm::EventHeader& header) const
00137 {
00138 return this->body_->can_match (header);
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 int
00168 TAO_EC_Kokyu_Filter::add_dependencies (const RtecEventComm::EventHeader& header,
00169 const TAO_EC_QOS_Info &qos_info)
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
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 }
00222
00223 void
00224 TAO_EC_Kokyu_Filter::get_qos_info (TAO_EC_QOS_Info& qos_info)
00225 {
00226 this->init_rt_info ();
00227
00228 qos_info.rt_info = this->rt_info_;
00229 }
00230
00231 void
00232 TAO_EC_Kokyu_Filter::init_rt_info (void)
00233 {
00234 if (this->rt_info_computed_)
00235 return;
00236
00237 #if 1 //ifdef'ed from 1 to 0 by VS
00238
00239
00240
00241 this->scheduler_->set (this->rt_info_,
00242 RtecScheduler::VERY_LOW_CRITICALITY,
00243 0,
00244 0,
00245 0,
00246 0,
00247 RtecScheduler::VERY_LOW_IMPORTANCE,
00248 0,
00249 0,
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
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
00281
00282 this->rt_info_computed_ = 1;
00283 }