00001
00002
00003 #include "orbsvcs/Event_Utilities.h"
00004 #include "ace/Log_Msg.h"
00005 #include "ace/OS_NS_stdio.h"
00006 #include "ace/OS_NS_string.h"
00007
00008 #if !defined (__ACE_INLINE__)
00009 #include "orbsvcs/Event_Utilities.i"
00010 #endif
00011
00012 ACE_RCSID (orbsvcs,
00013 Event_Utilities,
00014 "Event_Utilities.cpp,v 1.21 2005/11/10 06:47:22 ossama Exp")
00015
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 ACE_ConsumerQOS_Factory::
00019 ACE_ConsumerQOS_Factory (TAO_EC_Event_Initializer initializer)
00020 : designator_set_ (0),
00021 event_initializer_ (initializer)
00022 {
00023 qos_.is_gateway = 0;
00024 }
00025
00026 ACE_ConsumerQOS_Factory::~ACE_ConsumerQOS_Factory (void)
00027 {
00028 }
00029
00030 int
00031 ACE_ConsumerQOS_Factory::start_conjunction_group (int nchildren)
00032 {
00033 int l = qos_.dependencies.length ();
00034 qos_.dependencies.length (l + 1);
00035 if (this->event_initializer_ != 0)
00036 (*this->event_initializer_) (qos_.dependencies[l].event);
00037 qos_.dependencies[l].event.header.type = ACE_ES_CONJUNCTION_DESIGNATOR;
00038 qos_.dependencies[l].event.header.source = nchildren;
00039 qos_.dependencies[l].rt_info = 0;
00040 this->designator_set_ = 1;
00041 return 0;
00042 }
00043
00044 int
00045 ACE_ConsumerQOS_Factory::start_disjunction_group (int nchildren)
00046 {
00047 int l = qos_.dependencies.length ();
00048 qos_.dependencies.length (l + 1);
00049 if (this->event_initializer_ != 0)
00050 (*this->event_initializer_) (qos_.dependencies[l].event);
00051 qos_.dependencies[l].event.header.type = ACE_ES_DISJUNCTION_DESIGNATOR;
00052 qos_.dependencies[l].event.header.source = nchildren;
00053 qos_.dependencies[l].rt_info = 0;
00054 this->designator_set_ = 1;
00055 return 0;
00056 }
00057
00058 int
00059 ACE_ConsumerQOS_Factory::start_logical_and_group (int nchildren)
00060 {
00061 int l = qos_.dependencies.length ();
00062 qos_.dependencies.length (l + 1);
00063 if (this->event_initializer_ != 0)
00064 (*this->event_initializer_) (qos_.dependencies[l].event);
00065 qos_.dependencies[l].event.header.type = ACE_ES_LOGICAL_AND_DESIGNATOR;
00066 qos_.dependencies[l].event.header.source = nchildren;
00067 qos_.dependencies[l].rt_info = 0;
00068 this->designator_set_ = 1;
00069 return 0;
00070 }
00071
00072 int
00073 ACE_ConsumerQOS_Factory::start_negation (void)
00074 {
00075 int l = qos_.dependencies.length ();
00076 qos_.dependencies.length (l + 1);
00077 if (this->event_initializer_ != 0)
00078 (*this->event_initializer_) (qos_.dependencies[l].event);
00079 qos_.dependencies[l].event.header.type = ACE_ES_NEGATION_DESIGNATOR;
00080 qos_.dependencies[l].rt_info = 0;
00081 this->designator_set_ = 1;
00082 return 0;
00083 }
00084
00085 int
00086 ACE_ConsumerQOS_Factory::start_bitmask (CORBA::ULong source_mask,
00087 CORBA::ULong type_mask)
00088 {
00089 int l = qos_.dependencies.length ();
00090 qos_.dependencies.length (l + 2);
00091 if (this->event_initializer_ != 0)
00092 {
00093 (*this->event_initializer_) (qos_.dependencies[l].event);
00094 (*this->event_initializer_) (qos_.dependencies[l + 1].event);
00095 }
00096 qos_.dependencies[l].event.header.type = ACE_ES_BITMASK_DESIGNATOR;
00097 qos_.dependencies[l].rt_info = 0;
00098
00099 qos_.dependencies[l+1].event.header.source = source_mask;
00100 qos_.dependencies[l+1].event.header.type = type_mask;
00101 qos_.dependencies[l+1].rt_info = 0;
00102
00103 this->designator_set_ = 1;
00104 return 0;
00105 }
00106
00107 int
00108 ACE_ConsumerQOS_Factory::insert (const RtecEventChannelAdmin::Dependency &subscribe)
00109 {
00110
00111 if (designator_set_ == 0)
00112 {
00113 int l = qos_.dependencies.length ();
00114 qos_.dependencies.length (l + 1);
00115 if (this->event_initializer_ != 0)
00116 (*this->event_initializer_) (qos_.dependencies[l].event);
00117 qos_.dependencies[l].rt_info = 0;
00118 qos_.dependencies[l].event.header.type = ACE_ES_GLOBAL_DESIGNATOR;
00119
00120 this->designator_set_ = 1;
00121 }
00122
00123 int l = qos_.dependencies.length ();
00124 qos_.dependencies.length (l + 1);
00125 qos_.dependencies[l] = subscribe;
00126 return 0;
00127 }
00128
00129 void event_debug (const char* p,
00130 const RtecEventComm::Event& event)
00131 {
00132 size_t l = ACE_OS::strlen (p);
00133 ACE_DEBUG ((LM_DEBUG,
00134 "%*.*s - event.source: %d (0x%x)\n"
00135 "%*.*s event.type: %d (0x%x)\n",
00136 l, l, p, event.header.source, event.header.source,
00137 l, l, p, event.header.type, event.header.type));
00138 }
00139
00140 void
00141 ACE_ConsumerQOS_Factory::debug (const RtecEventChannelAdmin::ConsumerQOS& qos)
00142 {
00143 ACE_DEBUG ((LM_DEBUG, "ConsumerQOS { \n"));
00144 ACE_DEBUG ((LM_DEBUG, " is_gateway: %d\n", qos.is_gateway));
00145
00146 for (u_int i = 0; i < qos.dependencies.length (); ++i)
00147 {
00148 char buf[128];
00149 ACE_OS::sprintf (buf, " dep[%d]", i);
00150 event_debug (buf, qos.dependencies[i].event);
00151 ACE_DEBUG ((LM_DEBUG, "%s rt_info: %d\n",
00152 buf, qos.dependencies[i].rt_info));
00153 }
00154 ACE_DEBUG ((LM_DEBUG, "}\n"));
00155 }
00156
00157
00158 ACE_SupplierQOS_Factory::
00159 ACE_SupplierQOS_Factory (TAO_EC_Event_Initializer initializer,
00160 int qos_max_len)
00161 : event_initializer_ (initializer)
00162 {
00163 qos_.is_gateway = 0;
00164
00165
00166 qos_.publications.length (qos_max_len);
00167
00168
00169
00170 qos_.publications.length (0);
00171 }
00172
00173 int
00174 ACE_SupplierQOS_Factory::insert (RtecEventComm::EventSourceID sid,
00175 RtecEventComm::EventType type,
00176 RtecBase::handle_t rt_info,
00177 u_int ncalls)
00178 {
00179 CORBA::ULong l = this->qos_.publications.length ();
00180 if (l >= this->qos_.publications.maximum ())
00181 {
00182
00183
00184 this->qos_.publications.length (l + 1);
00185
00186
00187
00188
00189 }
00190
00191 if (this->event_initializer_ != 0)
00192 (*this->event_initializer_) (qos_.publications[l].event);
00193 this->qos_.publications[l].event.header.source = sid;
00194 this->qos_.publications[l].event.header.type = type;
00195
00196 this->qos_.publications[l].dependency_info.rt_info = rt_info;
00197 this->qos_.publications[l].dependency_info.number_of_calls = ncalls;
00198 return 0;
00199 }
00200
00201 void ACE_SupplierQOS_Factory::debug (const RtecEventChannelAdmin::SupplierQOS& qos)
00202 {
00203 ACE_DEBUG ((LM_DEBUG, "SupplierQOS { \n"));
00204 ACE_DEBUG ((LM_DEBUG, " is_gateway: %d\n", qos.is_gateway));
00205
00206 for (u_int i = 0; i < qos.publications.length (); ++i)
00207 {
00208 char buf[128] = { 0 };
00209 ACE_OS::sprintf (buf, " publications[%d]", i);
00210 event_debug (buf, qos.publications[i].event);
00211 ACE_DEBUG ((LM_DEBUG,
00212 "%s dependency_info.rt_info: %d\n"
00213 "%s dependency_info.number_of_calls: %d\n",
00214 buf, qos.publications[i].dependency_info.rt_info,
00215 buf, qos.publications[i].dependency_info.number_of_calls));
00216 }
00217 ACE_DEBUG ((LM_DEBUG, "}\n"));
00218
00219 }
00220
00221 TAO_END_VERSIONED_NAMESPACE_DECL