SupplierAdmin.cpp

Go to the documentation of this file.
00001 // $Id: SupplierAdmin.cpp 81418 2008-04-24 11:11:22Z johnnyw $
00002 
00003 #include "orbsvcs/Notify/SupplierAdmin.h"
00004 
00005 ACE_RCSID (RT_Notify,
00006            TAO_Notify_SupplierAdmin,
00007            "$Id: SupplierAdmin.cpp 81418 2008-04-24 11:11:22Z johnnyw $")
00008 
00009 #include "orbsvcs/Notify/Builder.h"
00010 #include "orbsvcs/Notify/ProxyConsumer.h"
00011 #include "orbsvcs/Notify/EventChannel.h"
00012 #include "orbsvcs/Notify/Subscription_Change_Worker.h"
00013 #include "orbsvcs/Notify/Find_Worker_T.h"
00014 #include "orbsvcs/Notify/Seq_Worker_T.h"
00015 #include "orbsvcs/Notify/Properties.h"
00016 
00017 #include "tao/debug.h"
00018 
00019 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00020 
00021 //#define DEBUG_LEVEL 9
00022 #ifndef DEBUG_LEVEL
00023 # define DEBUG_LEVEL TAO_debug_level
00024 #endif //DEBUG_LEVEL
00025 
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 typedef TAO_Notify_Find_Worker_T<TAO_Notify_Proxy
00029                                  , CosNotifyChannelAdmin::ProxyConsumer
00030                                  , CosNotifyChannelAdmin::ProxyConsumer_ptr
00031                                  , CosNotifyChannelAdmin::ProxyNotFound>
00032 TAO_Notify_ProxyConsumer_Find_Worker;
00033 
00034 typedef TAO_Notify_Seq_Worker_T<TAO_Notify_Proxy> TAO_Notify_Proxy_Seq_Worker;
00035 
00036 TAO_Notify_SupplierAdmin::TAO_Notify_SupplierAdmin (void)
00037   : TAO_Notify_Admin ()
00038 {
00039 }
00040 
00041 const char *
00042 TAO_Notify_SupplierAdmin::get_admin_type_name () const
00043 {
00044   return "supplier_admin";
00045 }
00046 
00047 TAO_Notify_SupplierAdmin::~TAO_Notify_SupplierAdmin ()
00048 {
00049 }
00050 
00051 void
00052 TAO_Notify_SupplierAdmin::init (TAO_Notify_EventChannel *ec)
00053 {
00054   TAO_Notify_Admin::init (ec);
00055 
00056   const CosNotification::QoSProperties &default_sa_qos =
00057     TAO_Notify_PROPERTIES::instance ()->default_supplier_admin_qos_properties ();
00058 
00059   this->set_qos (default_sa_qos);
00060 }
00061 
00062 void
00063 TAO_Notify_SupplierAdmin::_add_ref (void)
00064 {
00065   this->_incr_refcnt ();
00066 }
00067 
00068 void
00069 TAO_Notify_SupplierAdmin::_remove_ref (void)
00070 {
00071   this->_decr_refcnt ();
00072 }
00073 
00074 void
00075 TAO_Notify_SupplierAdmin::release (void)
00076 {
00077   delete this;
00078   //@@ inform factory
00079 }
00080 
00081 void
00082 TAO_Notify_SupplierAdmin::destroy (void)
00083 {
00084   this->shutdown ();
00085   this->ec_->remove (this);
00086   this->proxy_container ().destroy ();
00087 }
00088 
00089 TAO_Notify::Topology_Object*
00090 TAO_Notify_SupplierAdmin::load_child (const ACE_CString &type,
00091   CORBA::Long id, const TAO_Notify::NVPList& attrs)
00092 {
00093   TAO_Notify::Topology_Object* result = this;
00094   if (type == "proxy_push_consumer")
00095   {
00096     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00097       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00098       , static_cast<int> (id)
00099       ));
00100     result = this->load_proxy(id, CosNotifyChannelAdmin::ANY_EVENT, attrs);
00101   }
00102   else if (type == "structured_proxy_push_consumer")
00103   {
00104     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00105       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00106       , static_cast<int> (id)
00107       ));
00108     result = this->load_proxy(id, CosNotifyChannelAdmin::STRUCTURED_EVENT, attrs);
00109   }
00110   else if (type == "sequence_proxy_push_consumer")
00111   {
00112     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00113       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00114       , static_cast<int> (id)
00115       ));
00116     result = this->load_proxy(id, CosNotifyChannelAdmin::SEQUENCE_EVENT, attrs);
00117   }
00118   else
00119   {
00120     result = TAO_Notify_Admin::load_child (type, id, attrs);
00121   }
00122   return result;
00123 }
00124 
00125 TAO_Notify::Topology_Object*
00126 TAO_Notify_SupplierAdmin::load_proxy (
00127   CORBA::Long id,
00128   CosNotifyChannelAdmin::ClientType ctype,
00129   const TAO_Notify::NVPList& attrs)
00130 {
00131   TAO_Notify_Builder* bld = TAO_Notify_PROPERTIES::instance()->builder();
00132   TAO_Notify_ProxyConsumer * proxy =
00133     bld->build_proxy (this
00134                , ctype
00135                , id);
00136   ACE_ASSERT(proxy != 0);
00137   proxy->load_attrs (attrs);
00138   return proxy;
00139 }
00140 
00141 
00142 void
00143 TAO_Notify_SupplierAdmin::set_qos (const CosNotification::QoSProperties & qos)
00144 {
00145   this->TAO_Notify_Object::set_qos (qos);
00146 }
00147 
00148 CosNotification::QoSProperties*
00149 TAO_Notify_SupplierAdmin::get_qos (void)
00150 {
00151   return this->TAO_Notify_Object::get_qos ();
00152 }
00153 
00154 CosNotifyChannelAdmin::ProxyConsumer_ptr
00155 TAO_Notify_SupplierAdmin::obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype
00156                                                          , CosNotifyChannelAdmin::ProxyID_out proxy_id)
00157 
00158 {
00159   CosNotification::QoSProperties initial_qos;
00160 
00161   CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00162     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00163                                                                 , ctype
00164                                                                 , proxy_id
00165                                                                 , initial_qos);
00166   this->self_change ();
00167   return proxy._retn ();
00168 }
00169 
00170 CosNotifyChannelAdmin::ProxyConsumer_ptr
00171 TAO_Notify_SupplierAdmin::obtain_notification_push_consumer_with_qos (CosNotifyChannelAdmin::ClientType ctype,
00172                                                                   CosNotifyChannelAdmin::ProxyID_out proxy_id,
00173                                                                   const CosNotification::QoSProperties & initial_qos)
00174 {
00175   CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00176     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00177                                                                 , ctype
00178                                                                 , proxy_id,
00179                                                                 initial_qos);
00180   this->self_change ();
00181   return proxy._retn ();
00182 }
00183 
00184 
00185 CosEventChannelAdmin::ProxyPushConsumer_ptr
00186 TAO_Notify_SupplierAdmin::obtain_push_consumer (void)
00187 {
00188   CosEventChannelAdmin::ProxyPushConsumer_var proxy =
00189     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this);
00190   this->self_change ();
00191   return proxy._retn ();
00192 }
00193 
00194 CosNotifyChannelAdmin::AdminID
00195 TAO_Notify_SupplierAdmin::MyID (void)
00196 {
00197   return this->id ();
00198 }
00199 
00200 CosNotifyChannelAdmin::EventChannel_ptr
00201 TAO_Notify_SupplierAdmin::MyChannel (void)
00202 {
00203   return this->ec_->_this ();
00204 }
00205 
00206 ::CosNotifyChannelAdmin::InterFilterGroupOperator
00207 TAO_Notify_SupplierAdmin::MyOperator (void)
00208 {
00209   return this->filter_operator_;
00210 }
00211 
00212 CosNotifyChannelAdmin::ProxyIDSeq*
00213 TAO_Notify_SupplierAdmin::push_consumers (void)
00214 {
00215   TAO_Notify_Proxy_Seq_Worker seq_worker;
00216 
00217   return seq_worker.create (this->proxy_container());
00218 }
00219 
00220 CosNotifyChannelAdmin::ProxyConsumer_ptr
00221 TAO_Notify_SupplierAdmin::get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id)
00222 {
00223   TAO_Notify_ProxyConsumer_Find_Worker find_worker;
00224 
00225   return find_worker.resolve (proxy_id, this->proxy_container());
00226 }
00227 
00228 void
00229 TAO_Notify_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & added,
00230                                         const CosNotification::EventTypeSeq & removed)
00231 
00232 {
00233   TAO_Notify_EventTypeSeq seq_added (added);
00234   TAO_Notify_EventTypeSeq seq_removed (removed);
00235 
00236   {
00237     ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00238                         CORBA::INTERNAL ());
00239 
00240     this->subscribed_types_.add_and_remove (seq_added, seq_removed);
00241 
00242     TAO_Notify_Subscription_Change_Worker worker (added, removed);
00243 
00244     this->proxy_container().collection ()->for_each (&worker);
00245   }
00246 }
00247 
00248 CosNotifyFilter::FilterID
00249 TAO_Notify_SupplierAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter)
00250 {
00251   CosNotifyFilter::FilterID fid =
00252     this->filter_admin_.add_filter (new_filter);
00253   this->self_change ();
00254   return fid;
00255 }
00256 
00257 void
00258 TAO_Notify_SupplierAdmin::remove_filter (CosNotifyFilter::FilterID filter)
00259 {
00260   this->filter_admin_.remove_filter (filter);
00261 }
00262 
00263 ::CosNotifyFilter::Filter_ptr
00264 TAO_Notify_SupplierAdmin::get_filter (CosNotifyFilter::FilterID filter)
00265 {
00266   return this->filter_admin_.get_filter (filter);
00267 }
00268 
00269 ::CosNotifyFilter::FilterIDSeq*
00270 TAO_Notify_SupplierAdmin::get_all_filters (void)
00271 {
00272   return this->filter_admin_.get_all_filters ();
00273 }
00274 
00275 void
00276 TAO_Notify_SupplierAdmin::remove_all_filters (void)
00277 {
00278   this->filter_admin_.remove_all_filters ();
00279 }
00280 
00281 TAO_Notify_ProxyConsumer *
00282 TAO_Notify_SupplierAdmin::find_proxy_consumer (
00283     TAO_Notify::IdVec & id_path,
00284     size_t position)
00285 {
00286   TAO_Notify_ProxyConsumer * result = 0;
00287   size_t path_size = id_path.size ();
00288   if (position < path_size)
00289   {
00290     TAO_Notify_ProxyConsumer_Find_Worker find_worker;
00291     TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container());
00292     result = dynamic_cast <TAO_Notify_ProxyConsumer *> (proxy);
00293   }
00294   return result;
00295 }
00296 
00297 /************** UNIMPLEMENTED METHODS ***************/
00298 
00299 CosEventChannelAdmin::ProxyPullConsumer_ptr
00300 TAO_Notify_SupplierAdmin::obtain_pull_consumer (void)
00301 {
00302   throw CORBA::NO_IMPLEMENT ();
00303 }
00304 
00305 CosNotifyChannelAdmin::ProxyIDSeq*
00306 TAO_Notify_SupplierAdmin::pull_consumers (void)
00307 {
00308   throw CORBA::NO_IMPLEMENT ();
00309 }
00310 
00311 
00312 void
00313 TAO_Notify_SupplierAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/,
00314                                     CosNotification::NamedPropertyRangeSeq_out /*available_qos*/)
00315 {
00316   throw CORBA::NO_IMPLEMENT ();
00317 }
00318 
00319 CosNotifyChannelAdmin::ProxyConsumer_ptr
00320 TAO_Notify_SupplierAdmin::obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType /*ctype*/,
00321                                                          CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/)
00322 {
00323   throw CORBA::NO_IMPLEMENT ();
00324 }
00325 
00326 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7