diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs')
124 files changed, 6006 insertions, 1110 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp index 312841ff9ed..1ceae887444 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp @@ -4,6 +4,7 @@ #include "EventChannel.h" #include "Proxy.h" #include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "orbsvcs/CosNotifyChannelAdminC.h" #if ! defined (__ACE_INLINE__) #include "Admin.inl" @@ -12,10 +13,24 @@ ACE_RCSID(RT_Notify, TAO_NS_Admin, "$Id$") TAO_NS_Admin::TAO_NS_Admin (void) + :filter_operator_ (CosNotifyChannelAdmin::OR_OP) { + // Initialize all Admin objects to initially be subscribed for all events. + // This is a reasonable default and is ewquired to allow Cos Event consumers/suppliers to send/receive events, + this->subscribed_types_.insert (TAO_NS_EventType::special ()); } TAO_NS_Admin::~TAO_NS_Admin () { } +void +TAO_NS_Admin::subscribed_types (TAO_NS_EventTypeSeq& subscribed_types) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // copy + subscribed_types = this->subscribed_types_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.h b/TAO/orbsvcs/orbsvcs/Notify/Admin.h index a168871fee8..8514026776b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Admin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.h @@ -19,9 +19,9 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ - #include "Container_T.h" -//#include "Proxy.h" +#include "FilterAdmin.h" +#include "EventTypeSeq.h" class TAO_NS_Proxy; class TAO_NS_EventChannel; @@ -29,7 +29,7 @@ class TAO_NS_EventChannel; /** * @class TAO_NS_Admin * - * @brief Base class for Admin interface implementations. + * @brief * */ class TAO_Notify_Export TAO_NS_Admin : public TAO_NS_Container_T <TAO_NS_Proxy, TAO_NS_Admin, TAO_NS_EventChannel> @@ -39,13 +39,33 @@ public: TAO_NS_Admin (void); /// Destructor - ~TAO_NS_Admin (); + ~TAO_NS_Admin (); + + /// Access Admin FilterAdmin. + TAO_NS_FilterAdmin& filter_admin (void); + + /// Set Filter operator + void filter_operator (CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator); + + /// Access Filter operator + CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator (void); + + /// Obtain the Admin's subscribed types. + void subscribed_types (TAO_NS_EventTypeSeq& subscribed_types); protected: typedef TAO_NS_Container_T <TAO_NS_Proxy, TAO_NS_Admin, TAO_NS_EventChannel> inherited; /// = Data Members + /// The types that we've subscribed our proxy objects with the event manager. + TAO_NS_EventTypeSeq subscribed_types_; + + /// Filter Administration + TAO_NS_FilterAdmin filter_admin_; + + /// Filter operator + CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.inl b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl index dae2727000d..6b3949f1076 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Admin.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl @@ -1,3 +1,21 @@ // $Id$ #include "Admin.h" + +ACE_INLINE TAO_NS_FilterAdmin& +TAO_NS_Admin::filter_admin (void) +{ + return this->filter_admin_; +} + +ACE_INLINE void +TAO_NS_Admin::filter_operator (CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator) +{ + this->filter_operator_ = filter_operator; +} + +ACE_INLINE CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_Admin::filter_operator (void) +{ + return this->filter_operator_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp index 6a3925a3f93..33367514fc1 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp @@ -23,6 +23,19 @@ ACE_RCSID(RT_Notify, TAO_NS_Builder, "$Id$") #include "Worker_Task.h" #include "Reactive_Task.h" #include "ThreadPool_Task.h" +#include "FilterFactory.h" +#include "ace/Dynamic_Service.h" + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_Builder::build_filter_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_FilterFactory* ff = ACE_Dynamic_Service<TAO_NS_FilterFactory>::instance ("TAO_NS_FilterFactory"); + + if (ff == 0) + return CosNotifyFilter::FilterFactory::_nil (); + else + return ff->create (ACE_ENV_SINGLE_ARG_PARAMETER); +} CosNotifyChannelAdmin::EventChannelFactory_ptr TAO_NS_Builder::build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) @@ -34,33 +47,35 @@ TAO_NS_Builder::build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV TAO_NS_POA_Helper* object_poa = 0; // Bootstrap initial Object POA ACE_NEW_THROW_EX (object_poa, - TAO_NS_POA_Helper (), - CORBA::NO_MEMORY ()); + TAO_NS_POA_Helper (), + CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (ecf_ret._retn ()); - + auto_ptr<TAO_NS_POA_Helper> auto_object_poa (object_poa); - object_poa->init (poa ACE_ENV_ARG_PARAMETER); + object_poa->init (poa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); - + // Create ECF TAO_NS_EventChannelFactory* ecf = 0; - factory->create (ecf ACE_ENV_ARG_PARAMETER); + factory->create (ecf ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); - + + ecf->TAO_NS_EventChannelFactory::init (ACE_ENV_ARG_PARAMETER); + ecf->destroy_callback (ecf); PortableServer::ServantBase_var servant_var (ecf); - ecf->init (object_poa, 0, object_poa, object_poa ACE_ENV_ARG_PARAMETER); + ecf->TAO_NS_Container_T <TAO_NS_EventChannel, TAO_NS_EventChannelFactory>::init (object_poa, 0, object_poa, object_poa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); - ecf->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + ecf->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); - // Give ownership of object_poa + // Give ownership of object_poa ecf->object_poa (object_poa); - + CORBA::Object_var obj = ecf->activate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); @@ -69,7 +84,7 @@ TAO_NS_Builder::build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV ecf_ret = CosNotifyChannelAdmin::EventChannelFactory::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); - + return (ecf_ret._retn ()); } @@ -86,9 +101,9 @@ TAO_NS_Builder::build_event_channel (TAO_NS_EventChannelFactory* ecf, const CosN TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); TAO_NS_EventChannel* ec = 0; - factory->create (ec ACE_ENV_ARG_PARAMETER); + factory->create (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); - + ec->destroy_callback (ec); PortableServer::ServantBase_var servant_var (ec); @@ -96,7 +111,7 @@ TAO_NS_Builder::build_event_channel (TAO_NS_EventChannelFactory* ecf, const CosN // set the parent - ec->parent_ = ecf; - ec->init (ecf->object_poa(), 0, ecf->object_poa(), ecf->object_poa() ACE_ENV_ARG_PARAMETER); + ec->init (ecf->object_poa(), 0, ecf->object_poa(), ecf->object_poa() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); // Create the default worker task. @@ -104,26 +119,26 @@ TAO_NS_Builder::build_event_channel (TAO_NS_EventChannelFactory* ecf, const CosN ec->worker_task_own (worker_task); // proxy poa is set next. - ec->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + ec->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); // insert ec in ecf container. ecf->insert (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); - + // create the event manager. @@ use factory ACE_NEW_THROW_EX (ec->event_manager_, - TAO_NS_Event_Manager (), - CORBA::NO_MEMORY ()); + TAO_NS_Event_Manager (), + CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (ec_ret._retn ()); ec->event_manager_->init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); - - ec->set_qos (initial_qos ACE_ENV_ARG_PARAMETER); + + ec->set_qos (initial_qos ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); - - ec->set_admin (initial_admin ACE_ENV_ARG_PARAMETER); + + ec->set_admin (initial_admin ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); CORBA::Object_var obj = ec->activate (ACE_ENV_SINGLE_ARG_PARAMETER); @@ -148,20 +163,21 @@ TAO_NS_Builder::build_consumer_admin (TAO_NS_EventChannel* ec, CosNotifyChannelA TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); TAO_NS_ConsumerAdmin* ca = 0; - factory->create (ca ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (ca_ret._retn ()); + factory->create (ca ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); ca->destroy_callback (ca); + ca->filter_operator (op); ca->parent_ = ec; ca->event_manager_ = ec->event_manager_; PortableServer::ServantBase_var servant_var (ca); - ca->init (ec->object_poa (), ec->worker_task (), ec->object_poa (), ec->proxy_poa () ACE_ENV_ARG_PARAMETER); + ca->init (ec->object_poa (), ec->worker_task (), ec->object_poa (), ec->proxy_poa () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ca_ret._retn ()); - - ca->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + + ca->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ca_ret._retn ()); // insert admin in ec container. @@ -172,9 +188,9 @@ TAO_NS_Builder::build_consumer_admin (TAO_NS_EventChannel* ec, CosNotifyChannelA id = ca->id (); - ca_ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ca_ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ca_ret._retn ()); - + return ca_ret._retn (); } @@ -189,20 +205,21 @@ TAO_NS_Builder::build_supplier_admin (TAO_NS_EventChannel* ec, CosNotifyChannelA TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); TAO_NS_SupplierAdmin* sa = 0; - factory->create (sa ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (sa_ret._retn ()); + factory->create (sa ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); sa->destroy_callback (sa); + sa->filter_operator (op); sa->parent_ = ec; sa->event_manager_ = ec->event_manager_; - + PortableServer::ServantBase_var servant_var (sa); - sa->init (ec->object_poa (), ec->worker_task (), ec->object_poa (), ec->proxy_poa () ACE_ENV_ARG_PARAMETER); + sa->init (ec->object_poa (), ec->worker_task (), ec->object_poa (), ec->proxy_poa () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (sa_ret._retn ()); - - sa->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + + sa->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (sa_ret._retn ()); // insert admin in ec container. @@ -213,9 +230,9 @@ TAO_NS_Builder::build_supplier_admin (TAO_NS_EventChannel* ec, CosNotifyChannelA id = sa->id (); - sa_ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + sa_ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (sa_ret._retn ()); - + return sa_ret._retn (); } @@ -225,7 +242,7 @@ TAO_NS_Builder::build_notification_push_consumer (TAO_NS_SupplierAdmin* sa, CosN CORBA::SystemException , CosNotifyChannelAdmin::AdminLimitExceeded )) - + { CosNotifyChannelAdmin::ProxyConsumer_var proxy_ret; @@ -245,26 +262,26 @@ TAO_NS_Builder::build_notification_push_consumer (TAO_NS_SupplierAdmin* sa, CosN factory->create (pc ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (proxy_ret._retn ()); - pc->destroy_callback (pc); + pc->destroy_callback (pc); PortableServer::ServantBase_var servantbase_var (pc); - pc->event_manager_ = sa->event_manager_; - pc->parent_ = sa; - - pc->init (sa->proxy_poa (), sa->worker_task () ACE_ENV_ARG_PARAMETER); + pc->event_manager_ = sa->event_manager_; + pc->parent_ = sa; + + pc->init (sa->proxy_poa (), sa->worker_task () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (proxy_ret._retn ()); - - // insert proxy in admin container. - sa->insert (pc ACE_ENV_ARG_PARAMETER); - + + // insert proxy in admin container. + sa->insert (pc ACE_ENV_ARG_PARAMETER); + CORBA::Object_var obj = pc->activate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (proxy_ret._retn ()); proxy_id = pc->id (); proxy_ret = CosNotifyChannelAdmin::ProxyConsumer::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (proxy_ret._retn ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); } case CosNotifyChannelAdmin::SEQUENCE_EVENT: @@ -276,7 +293,7 @@ TAO_NS_Builder::build_notification_push_consumer (TAO_NS_SupplierAdmin* sa, CosN ACE_THROW_RETURN (CORBA::BAD_PARAM (), CosNotifyChannelAdmin::ProxyConsumer::_nil ()); } - + return proxy_ret._retn (); } @@ -308,24 +325,24 @@ TAO_NS_Builder::build_notification_push_supplier (TAO_NS_ConsumerAdmin* ca, CosN PortableServer::ServantBase_var servant (ps->servant ()); - ps->event_manager_ = ca->event_manager_; - ps->parent_ = ca; - - ps->init (ca->proxy_poa (), ca->worker_task () ACE_ENV_ARG_PARAMETER); + ps->event_manager_ = ca->event_manager_; + ps->parent_ = ca; + + ps->init (ca->proxy_poa (), ca->worker_task () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (proxy_ret._retn ()); - - // insert proxy in admin container. - ca->insert (ps ACE_ENV_ARG_PARAMETER); + + // insert proxy in admin container. + ca->insert (ps ACE_ENV_ARG_PARAMETER); CORBA::Object_var obj = ps->activate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (proxy_ret._retn ()); proxy_id = ps->id (); - ps->init_ps (ACE_ENV_SINGLE_ARG_PARAMETER); + ps->init_ps (ACE_ENV_SINGLE_ARG_PARAMETER); proxy_ret = CosNotifyChannelAdmin::ProxySupplier::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (proxy_ret._retn ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); } case CosNotifyChannelAdmin::SEQUENCE_EVENT: @@ -337,6 +354,6 @@ TAO_NS_Builder::build_notification_push_supplier (TAO_NS_ConsumerAdmin* ca, CosN ACE_THROW_RETURN (CORBA::BAD_PARAM (), CosNotifyChannelAdmin::ProxySupplier::_nil ()); } - + return proxy_ret._retn (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.h b/TAO/orbsvcs/orbsvcs/Notify/Builder.h index a046f401c8a..45691bc6e64 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Builder.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.h @@ -26,6 +26,8 @@ class TAO_NS_EventChannelFactory; class TAO_NS_EventChannel; class TAO_NS_SupplierAdmin; class TAO_NS_ConsumerAdmin; +class TAO_NS_FilterFactory; +//class TAO_NS_Filter; /** * @class TAO_NS_Builder @@ -54,7 +56,7 @@ public: ACE_THROW_SPEC (( CORBA::SystemException )); - + CosNotifyChannelAdmin::ProxyConsumer_ptr build_notification_push_consumer (TAO_NS_SupplierAdmin* sa, CosNotifyChannelAdmin::ClientType ctype, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException @@ -66,6 +68,8 @@ public: CORBA::SystemException , CosNotifyChannelAdmin::AdminLimitExceeded )); + + CosNotifyFilter::FilterFactory_ptr build_filter_factory (ACE_ENV_SINGLE_ARG_DECL); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.cpp b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.cpp new file mode 100644 index 00000000000..8cb1eac6dd0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "Constraint_Interpreter.h" +#include "Constraint_Visitors.h" + +ACE_RCSID(Notify, NS_Constraint_Interpreter, "$Id$") + +TAO_NS_Constraint_Interpreter::TAO_NS_Constraint_Interpreter (void) +{ +} + +TAO_NS_Constraint_Interpreter::~TAO_NS_Constraint_Interpreter (void) +{ +} + +void +TAO_NS_Constraint_Interpreter::build_tree ( + const char *constraints + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CosNotifyFilter::InvalidConstraint, + CORBA::NO_MEMORY)) +{ + if (TAO_ETCL_Interpreter::is_empty_string (constraints)) + { + // Root is deleted in the TAO_Interpreter's destructor. + ACE_NEW_THROW_EX (this->root_, + TAO_ETCL_Literal_Constraint ((CORBA::Boolean) 1), + CORBA::NO_MEMORY ()); + ACE_CHECK; + } + else + { + // root_ is set in this base class call. + if (TAO_ETCL_Interpreter::build_tree (constraints) != 0) + ACE_THROW (CosNotifyFilter::InvalidConstraint ()); + } +} + +CORBA::Boolean +TAO_NS_Constraint_Interpreter::evaluate (TAO_NS_Constraint_Visitor &evaluator) +{ + CORBA::Boolean retval = evaluator.evaluate_constraint (this->root_); + + return retval; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.h b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.h new file mode 100644 index 00000000000..b98724728c7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file NS_Constraint_Interpreter.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore <pradeep@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef TAO_NOTIFY_CONSTRAINT_INTERPRETER_H +#define TAO_NOTIFY_CONSTRAINT_INTERPRETER_H + +#include "ace/pre.h" +#include "orbsvcs/ETCL/ETCL_Interpreter.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ETCL/ETCL_Constraint.h" +#include "orbsvcs/CosNotifyFilterC.h" +#include "etcl_notify_filtering_export.h" + +class TAO_NS_Constraint_Visitor; + +/** + * @class TAO_NS_Constraint_Interpreter + * + * @brief "ETCL" Interpreter for the Notify queries. + */ +class ETCL_Notify_Filtering_Export TAO_NS_Constraint_Interpreter : public TAO_ETCL_Interpreter +{ +public: + // = Initialization and termination methods. + TAO_NS_Constraint_Interpreter (void); + + /// Destructor + ~TAO_NS_Constraint_Interpreter (void); + + /** + * This method builds an expression tree representing the + * constraint specified in <constraints>, and throws an Illegal + * Constraint exception if the constraint given has syntax errors or + * semantic errors, such as mismatched types. + */ + void build_tree (const char* constraints + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CosNotifyFilter::InvalidConstraint, + CORBA::NO_MEMORY)); + + /// Returns true if the constraint is evaluated successfully by + /// the evaluator. + CORBA::Boolean evaluate (TAO_NS_Constraint_Visitor &evaluator); +}; +#include "ace/post.h" +#endif /* TAO_NOTIFY_CONSTRAINT_INTERPRETER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.cpp b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.cpp new file mode 100644 index 00000000000..809c52bb05e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.cpp @@ -0,0 +1,1564 @@ +/* -*- C++ -*- */ +/* $Id$ */ + +#include "Constraint_Visitors.h" +#include "orbsvcs/ETCL/ETCL_Constraint.h" +#include "orbsvcs/ETCL/ETCL_y.h" +#include "tao/DynamicAny/DynArray_i.h" +#include "tao/DynamicAny/DynSequence_i.h" +#include "tao/DynamicAny/DynStruct_i.h" +#include "tao/DynamicAny/DynUnion_i.h" +#include "tao/DynamicAny/DynEnum_i.h" +#include "tao/DynamicAny/DynAnyFactory.h" + +TAO_NS_Constraint_Visitor::TAO_NS_Constraint_Visitor (void) + : implicit_id_ (NONE) +{ + (void) this->implicit_ids_.bind (ACE_CString ("filterable_data", + 0, + 0), + FILTERABLE_DATA); + (void) this->implicit_ids_.bind (ACE_CString ("header", + 0, + 0), + HEADER); + (void) this->implicit_ids_.bind (ACE_CString ("remainder_of_body", + 0, + 0), + REMAINDER_OF_BODY); + (void) this->implicit_ids_.bind (ACE_CString ("fixed_header", + 0, + 0), + FIXED_HEADER); + (void) this->implicit_ids_.bind (ACE_CString ("variable_header", + 0, + 0), + VARIABLE_HEADER); + (void) this->implicit_ids_.bind (ACE_CString ("event_name", + 0, + 0), + EVENT_NAME); + (void) this->implicit_ids_.bind (ACE_CString ("event_type", + 0, + 0), + EVENT_TYPE); + (void) this->implicit_ids_.bind (ACE_CString ("domain_name", + 0, + 0), + DOMAIN_NAME); + (void) this->implicit_ids_.bind (ACE_CString ("type_name", + 0, + 0), + TYPE_NAME); +} + +int +TAO_NS_Constraint_Visitor::bind_structured_event ( + const CosNotification::StructuredEvent &s_event + ) +{ + // The two sequences contained in a structured event are + // copied into hash tables so iteration is done only once. + + CORBA::ULong length = s_event.filterable_data.length (); + CORBA::ULong index = 0; + + for (index = 0; index < length; ++index) + { + ACE_CString name_str (s_event.filterable_data[index].name, 0, 0); + + int status = + this->filterable_data_.bind ( + name_str, + ACE_const_cast (CORBA::Any *, + &s_event.filterable_data[index].value) + ); + + if (status != 0) + { + return -1; + } + } + + length = s_event.header.variable_header.length (); + + for (index = 0; index < length; ++index) + { + ACE_CString name_str (s_event.header.variable_header[index].name, 0, 0); + + int status = + this->variable_header_.bind ( + name_str, + ACE_const_cast (CORBA::Any *, + &s_event.header.variable_header[index].value) + ); + + if (status != 0) + { + return -1; + } + } + + this->domain_name_ = + CORBA::string_dup (s_event.header.fixed_header.event_type.domain_name); + + this->type_name_ = + CORBA::string_dup (s_event.header.fixed_header.event_type.type_name); + + this->event_name_ = + CORBA::string_dup (s_event.header.fixed_header.event_name); + + this->remainder_of_body_ = s_event.remainder_of_body; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::evaluate_constraint ( + TAO_ETCL_Constraint* root + ) +{ + CORBA::Boolean result = 0; + this->queue_.reset (); + + // Evaluate the constraint in root_; + if (root != 0) + { + if ((root->accept (this) == 0) && + (! this->queue_.is_empty ())) + { + TAO_ETCL_Literal_Constraint top; + this->queue_.dequeue_head (top); + result = (CORBA::Boolean) top; + } + } + + // If a property couldn't be evaluated we must return 0. + return result; +} + +int +TAO_NS_Constraint_Visitor::visit_literal ( + TAO_ETCL_Literal_Constraint *literal + ) +{ + this->queue_.enqueue_head (*literal); + return 0; +} + +int +TAO_NS_Constraint_Visitor::visit_identifier (TAO_ETCL_Identifier *ident) +{ + int return_value = -1; + const char *name = ident->value (); + ACE_CString key (name, 0, 0); + + CORBA::Any *any = 0; + + if (this->filterable_data_.find (key, any) == 0) + { + if (any != 0) + { + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (any)); + return_value = 0; + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_union_value ( + TAO_ETCL_Union_Value *union_value + ) +{ + switch (union_value->sign ()) + { + case 0: + this->queue_.enqueue_head (*union_value->string ()); + break; + case -1: + this->queue_.enqueue_head (-(*union_value->integer ())); + break; + case 1: + this->queue_.enqueue_head (*union_value->integer ()); + break; + default: + return -1; + } + + return 0; +} + +int +TAO_NS_Constraint_Visitor::visit_union_pos ( + TAO_ETCL_Union_Pos *union_pos + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + if (union_pos->union_value ()->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint disc_val; + this->queue_.dequeue_head (disc_val); + + TAO_DynUnion_i dyn_union; + dyn_union.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tc = this->current_value_->type (); + + switch (disc_val.expr_type ()) + { + case TAO_ETCL_INTEGER: + case TAO_ETCL_SIGNED: + case TAO_ETCL_UNSIGNED: + { + CORBA::Any disc_any; + CORBA::TypeCode_var disc_tc = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + CORBA::TCKind disc_kind = + TAO_DynAnyFactory::unalias (disc_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + switch (disc_kind) + { + case CORBA::tk_boolean: + disc_any <<= CORBA::Any::from_boolean ((CORBA::Boolean) disc_val); + break; + case CORBA::tk_short: + disc_any <<= (CORBA::Short) ((CORBA::Long) disc_val); + break; + case CORBA::tk_ushort: + disc_any <<= (CORBA::UShort) ((CORBA::ULong) disc_val); + break; + case CORBA::tk_long: + disc_any <<= (CORBA::Long) disc_val; + break; + case CORBA::tk_ulong: + disc_any <<= (CORBA::ULong) disc_val; + break; + case CORBA::tk_enum: + { + TAO_OutputCDR cdr; + cdr.write_ulong ((CORBA::ULong) disc_val); + disc_any._tao_replace (disc_tc.in (), + TAO_ENCAP_BYTE_ORDER, + cdr.begin ()); + break; + } + // @@@ (JP) I don't think ETCL handles 64-bit + // integers at this point, and I also think that + // chars and/or wchars will just come out in the + // constraint as (w)strings of length 1. + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_char: + case CORBA::tk_wchar: + default: + return -1; + } + + DynamicAny::DynAny_var dyn_any = + TAO_DynAnyFactory::make_dyn_any (disc_any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + dyn_union.set_discriminator (dyn_any.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + DynamicAny::DynAny_var u_member = + dyn_union.member (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + this->current_value_ = + u_member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + case TAO_ETCL_STRING: + { + const char *name = (const char *) disc_val; + CORBA::ULong count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + const char *member_name = 0; + CORBA::ULong i = 0; + + for (i = 0; i < count; ++i) + { + member_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ACE_OS::strcmp (name, member_name) == 0) + { + break; + } + } + + // If there's no match, member_label will throw + // CORBA::TypeCode::Bounds and the catch block will + // return -1; + this->current_value_ = tc->member_label (i + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + // The TAO_ETCL_Union_Value that was put on the queue + // shouldn't have any other type. + default: + return -1; + } + + TAO_ETCL_Constraint *nested = union_pos->component (); + + // If there's no nested component, then we just want the + // union member value on the queue. Otherwise, we want + // the member value in current_value_ while we visit + // the nested component. + if (nested == 0) + { + TAO_ETCL_Literal_Constraint lit (this->current_value_); + this->queue_.enqueue_head (lit); + return 0; + } + else + { + return nested->accept (this); + } + } + else + { + return -1; + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_component_pos ( + TAO_ETCL_Component_Pos *pos + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + // If we are here (from visit_component) the Any containing the + // component as found in filterable_data_ will be in current_value_. + CORBA::TypeCode_var tc = this->current_value_->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var member; + CORBA::Boolean success = 0; + CORBA::ULong slot = (CORBA::ULong) *pos->integer (); + + switch (kind) + { + case CORBA::tk_enum: + { + TAO_DynEnum_i dyn_enum; + dyn_enum.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_enum.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = + dyn_enum.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + case CORBA::tk_struct: + { + TAO_DynStruct_i dyn_struct; + dyn_struct.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_struct.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = dyn_struct.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + // @@@ (JP) I think enums and structs are the only two cases handled + // by Component_Pos, since arrays and sequences are handled by + // Component_Array, and unions are handled by Union_Pos. + default: + return -1; + } + + CORBA::Any_var value = member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Constraint *comp = pos->component (); + + if (comp == 0) + { + TAO_ETCL_Literal_Constraint result (value); + this->queue_.enqueue_head (result); + return 0; + } + else + { + this->current_value_ = value._retn (); + return comp->accept (this); + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_component_assoc ( + TAO_ETCL_Component_Assoc *assoc + ) +{ + CORBA::Any *any = 0; + ACE_CString name (assoc->identifier ()->value (), + 0, + 0); + + switch (this->implicit_id_) + { + case FILTERABLE_DATA: + if (this->filterable_data_.find (name, any) != 0 + || any == 0) + { + return -1; + } + + break; + case VARIABLE_HEADER: + if (this->variable_header_.find (name, any) != 0 + || any == 0) + { + return -1; + } + + break; + // Only the sequence members of CosNotification::StructuredEvent can be + // treated as associative arrays. + default: + return -1; + } + + TAO_ETCL_Constraint *comp = assoc->component (); + CORBA::Any *any_ptr = 0; + + if (comp == 0) + { + TAO_ETCL_Literal_Constraint result (any); + this->queue_.enqueue_head (result); + + // If we're at the end of the line, put the name into + // current_value_ so visit_exist can use it. + ACE_NEW_RETURN (any_ptr, + CORBA::Any, + -1); + (*any_ptr) <<= name.c_str (); + this->current_value_ = any_ptr; + + return 0; + } + else + { + ACE_NEW_RETURN (any_ptr, + CORBA::Any (*any), + -1); + this->current_value_ = any_ptr; + return comp->accept (this); + } +} + +int +TAO_NS_Constraint_Visitor::visit_component_array ( + TAO_ETCL_Component_Array *array + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + // If we are here (from visit_component) the Any containing the + // component as found in filterable_data_ will be in current_value_. + CORBA::TypeCode_var tc = this->current_value_->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var member; + CORBA::Boolean success = 0; + CORBA::ULong slot = (CORBA::ULong) *array->integer (); + + switch (kind) + { + case CORBA::tk_array: + { + TAO_DynEnum_i dyn_array; + dyn_array.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_array.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = dyn_array.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + case CORBA::tk_sequence: + { + TAO_DynStruct_i dyn_sequence; + dyn_sequence.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_sequence.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = + dyn_sequence.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + // Enums and sequences are the only two cases handled + // by Component_Array. + default: + return -1; + } + + CORBA::Any_var value = member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Constraint *comp = array->component (); + + if (comp == 0) + { + TAO_ETCL_Literal_Constraint result (value); + this->queue_.enqueue_head (result); + return 0; + } + else + { + this->current_value_ = value._retn (); + return comp->accept (this); + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_special (TAO_ETCL_Special *special) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var tc = this->current_value_->type (); + + switch (special->type ()) + { + case TAO_ETCL_LENGTH: + { + // If the TCKind is not a sequence or an array, the + // call to length() will raise an exception, and the + // catch block will return -1; + CORBA::ULong length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (length); + this->queue_.enqueue_head (lit); + return 0; + } + case TAO_ETCL_DISCRIMINANT: + { + // If the TCKind is not a union, the + // call to init() will raise an exception, and the + // catch block will return -1; + TAO_DynUnion_i dyn_union; + dyn_union.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var disc = + dyn_union.get_discriminator (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Any_var disc_any = disc->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (disc_any); + this->queue_.enqueue_head (lit); + return 0; + } + case TAO_ETCL_TYPE_ID: + { + const char *name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (name); + this->queue_.enqueue_head (lit); + return 0; + } + case TAO_ETCL_REPOS_ID: + { + const char *id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (id); + this->queue_.enqueue_head (lit); + return 0; + } + default: + return -1; + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_component ( + TAO_ETCL_Component *component + ) +{ + TAO_ETCL_Constraint *nested = component->component (); + TAO_ETCL_Identifier *identifier = component->identifier (); + ACE_CString component_name (identifier->value (), + 0, + 0); + CORBA::Any *any_ptr = 0; + + if (this->implicit_ids_.find (component_name, this->implicit_id_) != 0) + { + this->implicit_id_ = NONE; + } + + // If this component has no sub-component, only an identifier, + // then we just visit the identifier, which puts a literal on + // the queue to be handled upon returning from this method call. + // If there is a sub-component, we store the literal's value + // in our member _var for possible examination at a more + // nested level, and visit the sub-component. If the identifier + // matches one of the nested field names in + // CosNotification::StructuredEvent, we just visit the nested + // component, if any. + if (this->implicit_id_ == NONE) + { + if (nested == 0) + { + // If this is the end of the line, we put the component name + // into current_value_ so visit_exist can use it. + ACE_NEW_RETURN (any_ptr, + CORBA::Any, + -1); + (*any_ptr) <<= component_name.c_str (); + this->current_value_ = any_ptr; + return identifier->accept (this); + } + else + { + int result = identifier->accept (this); + + if (result != 0) + { + return result; + } + + TAO_ETCL_Literal_Constraint id; + this->queue_.dequeue_head (id); + ACE_NEW_RETURN (any_ptr, + CORBA::Any (*(const CORBA::Any *) id), + -1); + this->current_value_ = any_ptr; + } + } + + if (nested != 0) + { + return nested->accept (this); + } + else + { + switch (this->implicit_id_) + { + case TYPE_NAME: + { + TAO_ETCL_Literal_Constraint tn (this->type_name_.in ()); + this->queue_.enqueue_head (tn); + return 0; + } + case EVENT_NAME: + { + TAO_ETCL_Literal_Constraint en (this->event_name_.in ()); + this->queue_.enqueue_head (en); + return 0; + } + case DOMAIN_NAME: + { + TAO_ETCL_Literal_Constraint dn (this->domain_name_.in ()); + this->queue_.enqueue_head (dn); + return 0; + } + case REMAINDER_OF_BODY: + { + TAO_ETCL_Literal_Constraint rob (&this->remainder_of_body_); + this->queue_.enqueue_head (rob); + return 0; + } + // The above cases are the leaves of the + // CosNotification::StructuredEvent "tree". Anything else and we + // should have a nested component. otherwise, it's an error. + default: + return -1; + } + } +} + +int +TAO_NS_Constraint_Visitor::visit_dot (TAO_ETCL_Dot *dot) +{ + // If we are here, we know we're headed for a more nested + // level, so we just visit it, there's nothing else in this + // constraint. + return dot->component ()->accept (this); +} + +int +TAO_NS_Constraint_Visitor::visit_eval (TAO_ETCL_Eval *eval) +{ + // Nothing to do but visit the contained component. + return eval->component ()->accept (this); +} + +int +TAO_NS_Constraint_Visitor::visit_default (TAO_ETCL_Default *def) +{ + TAO_ETCL_Constraint *comp = def->component (); + + if (comp == 0) + { + return -1; + } + + if (comp->accept (this) != 0) + { + return -1; + } + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var tc = this->current_value_->type (); + + // If the current member is not a union, this call will + // throw BadKind and the catch block will return -1. + CORBA::Long default_index = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // No default index. + if (default_index == -1) + { + TAO_ETCL_Literal_Constraint result ((CORBA::Boolean) 0); + this->queue_.enqueue_head (result); + return 0; + } + + // Okay, there's a default index, but is it active? + + TAO_ETCL_Literal_Constraint disc; + this->queue_.dequeue_head (disc); + TAO_ETCL_Literal_Constraint default_index_value (default_index); + return (disc == default_index_value); + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_exist (TAO_ETCL_Exist *exist) +{ + TAO_ETCL_Constraint *component = exist->component (); + + if (component->accept (this) == 0) + { + const char *value = 0; + CORBA::Boolean result = 0; + + // For the two cases below, we don't want the item at the top of + // the queue, because it's the result of a hash table lookup. For + // an existence test, we want the key value, which is stored in + // the current_value_ member. + if (this->implicit_id_ == FILTERABLE_DATA + || this->implicit_id_ == VARIABLE_HEADER) + { + TAO_ETCL_Literal_Constraint current ( + &this->current_value_.inout () + ); + value = CORBA::string_dup ((const char *) current); + } + + switch (this->implicit_id_) + { + case FILTERABLE_DATA: + result = + (this->filterable_data_.find (ACE_CString (value, 0, 0)) == 0); + break; + case VARIABLE_HEADER: + result = + (this->variable_header_.find (ACE_CString (value, 0, 0)) == 0); + break; + case TYPE_NAME: + result = (this->type_name_.in () != 0); + break; + case EVENT_NAME: + result = (this->event_name_.in () != 0); + break; + case DOMAIN_NAME: + result = (this->domain_name_.in () != 0); + break; + // Anything other than the above cases is an error. + default: + return -1; + } + + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + + return 0; + } + + return -1; +} + +int +TAO_NS_Constraint_Visitor::visit_unary_expr ( + TAO_ETCL_Unary_Expr *unary_expr + ) +{ + TAO_ETCL_Constraint *subexpr = unary_expr->subexpr (); + + if (subexpr->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint subexpr_result; + CORBA::Boolean result = 0; + int op_type = unary_expr->type (); + + switch (op_type) + { + case TAO_ETCL_NOT: + this->queue_.dequeue_head (subexpr_result); + result = ! (CORBA::Boolean) subexpr_result; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + return 0; + case TAO_ETCL_MINUS: + // The leading '-' was parsed separately, so we have to pull + // the literal constraint off the queue, apply the class' own + // unary minus operator, and put it back. + this->queue_.dequeue_head (subexpr_result); + this->queue_.enqueue_head (-subexpr_result); + return 0; + case TAO_ETCL_PLUS: + // Leave the literal constraint on the queue. The leading + // '+' was just syntactic sugar - no action is necessary. + return 0; + default: + // The parser should never construct a TAO_ETCL_Unary_Constraint + // behind any operators except the above three. + return -1; + } + } + + return -1; +} + +int +TAO_NS_Constraint_Visitor::visit_binary_expr ( + TAO_ETCL_Binary_Expr *binary_expr + ) +{ + int bin_op_type = binary_expr->type (); + + switch (bin_op_type) + { + case TAO_ETCL_OR: + return this->visit_or (binary_expr); + case TAO_ETCL_AND: + return this->visit_and (binary_expr); + case TAO_ETCL_LT: + case TAO_ETCL_LE: + case TAO_ETCL_GT: + case TAO_ETCL_GE: + case TAO_ETCL_EQ: + case TAO_ETCL_NE: + case TAO_ETCL_PLUS: + case TAO_ETCL_MINUS: + case TAO_ETCL_MULT: + case TAO_ETCL_DIV: + return this->visit_binary_op (binary_expr, + bin_op_type); + case TAO_ETCL_TWIDDLE: + return this->visit_twiddle (binary_expr); + case TAO_ETCL_IN: + return this->visit_in (binary_expr); + default: + return -1; + } +} + +int +TAO_NS_Constraint_Visitor::visit_or ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + CORBA::Boolean result = 0; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint lhs_result; + this->queue_.dequeue_head (lhs_result); + result = (CORBA::Boolean) lhs_result; + + // Short-circuiting OR. + if (result == 0) + { + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint rhs_result; + this->queue_.dequeue_head (rhs_result); + result = (CORBA::Boolean) rhs_result; + return_value = 0; + } + } + else + { + return_value = 0; + } + } + + if (return_value == 0) + { + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_and ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + CORBA::Boolean result = 0; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint lhs_result; + this->queue_.dequeue_head (lhs_result); + result = (CORBA::Boolean) lhs_result; + + // Short-circuiting AND. + if (result == 1) + { + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint rhs_result; + this->queue_.dequeue_head (rhs_result); + result = (CORBA::Boolean) rhs_result; + return_value = 0; + } + } + else + { + return_value = 0; + } + } + + if (return_value == 0) + { + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_binary_op ( + TAO_ETCL_Binary_Expr *binary, + int op_type + ) +{ + int return_value = -1; + TAO_ETCL_Constraint *lhs = binary->lhs (); + CORBA::Boolean result = 0; + + // Perform an operation on the results of evaluating the left and + // right branches of this subtree. + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint left_operand; + this->queue_.dequeue_head (left_operand); + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint right_operand; + this->queue_.dequeue_head (right_operand); + return_value = 0; + + switch (op_type) + { + case TAO_ETCL_LT: + result = left_operand < right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_LE: + result = left_operand <= right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_GT: + result = left_operand > right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_GE: + result = left_operand >= right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_EQ: + result = left_operand == right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_NE: + result = left_operand != right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_PLUS: + this->queue_.enqueue_head (left_operand + right_operand); + break; + case TAO_ETCL_MINUS: + this->queue_.enqueue_head (left_operand - right_operand); + break; + case TAO_ETCL_MULT: + this->queue_.enqueue_head (left_operand * right_operand); + break; + case TAO_ETCL_DIV: + this->queue_.enqueue_head (left_operand / right_operand); + break; + default: + return_value = -1; + } + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_twiddle ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + // Determine if the left operand is a substring of the right. + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint left; + this->queue_.dequeue_head (left); + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint right; + this->queue_.dequeue_head (right); + CORBA::Boolean result = + (ACE_OS::strstr ((const char *) right, + (const char *) left) != 0); + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + return_value = 0; + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_in ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + // Determine if the left operand is contained in the right. + + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint left; + this->queue_.dequeue_head (left); + + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint bag; + this->queue_.dequeue_head (bag); + + if (bag.expr_type () == TAO_ETCL_COMPONENT) + { + const CORBA::Any *component = (const CORBA::Any *) bag; + CORBA::TCKind kind = CORBA::tk_null; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var tc = component->type (); + kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return return_value; + } + ACE_ENDTRY; + + CORBA::Boolean result = 0; + + switch (kind) + { + case CORBA::tk_sequence: + result = this->sequence_does_contain (component, + left); + break; + case CORBA::tk_array: + result = this->array_does_contain (component, + left); + break; + case CORBA::tk_struct: + result = this->struct_does_contain (component, + left); + break; + case CORBA::tk_union: + result = this->union_does_contain (component, + left); + break; + case CORBA::tk_any: + result = this->any_does_contain (component, + left); + break; + default: + return return_value; + } + + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + return_value = 0; + } + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_preference ( + TAO_ETCL_Preference * + ) +{ + // According to OMG 00-06-20 section 2.4.1, the Notification Service + // does not use the preference operators. The method must be here + // because it is called by the ETCL node, which may be used by other + // CORBA services that do use the preference operators. + return -1; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::sequence_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var type = any->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the array elements must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + return 0; + } + + TAO_DynSequence_i dyn_seq; + dyn_seq.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::AnySeq_var any_seq = + dyn_seq.get_elements (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = any_seq->length (); + + for (CORBA::ULong i = 0; i < length; ++i) + { + TAO_ETCL_Literal_Constraint element (&any_seq[i]); + + if (item == element) + { + return 1; + } + } + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::array_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var type = any->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the array elements must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + return 0; + } + + TAO_DynArray_i dyn_array; + dyn_array.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::AnySeq_var any_seq = + dyn_array.get_elements (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = any_seq->length (); + + for (CORBA::ULong i = 0; i < length; ++i) + { + TAO_ETCL_Literal_Constraint element (&any_seq[i]); + + if (item == element) + { + return 1; + } + } + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::struct_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + TAO_DynStruct_i dyn_struct; + dyn_struct.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::NameValuePairSeq_var members = + dyn_struct.get_members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = members->length (); + CORBA::TypeCode_var tc; + CORBA::TCKind kind; + + for (CORBA::ULong i = 0; i < length; ++i) + { + tc = members[i].value.type (); + kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the struct member must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + continue; + } + + TAO_ETCL_Literal_Constraint element (&members[i].value); + + if (item == element) + { + return 1; + } + } + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::union_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + TAO_DynUnion_i dyn_union; + dyn_union.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var cc = + dyn_union.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Any_var member = cc->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tc = member->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the union member must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + return 0; + } + + TAO_ETCL_Literal_Constraint element (&member.inout ()); + + return (item == element); + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::any_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + const CORBA::Any *result = 0; + + *any >>= result; + + TAO_ETCL_Literal_Constraint element (ACE_const_cast (CORBA::Any *, + result)); + + return (item == element); +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::simple_type_match (int expr_type, + CORBA::TCKind tc_kind) +{ + switch (expr_type) + { + case TAO_ETCL_STRING: + if (tc_kind != CORBA::tk_string) + { + return 0; + } + case TAO_ETCL_DOUBLE: + if (tc_kind != CORBA::tk_double + && tc_kind != CORBA::tk_float) + { + return 0; + } + case TAO_ETCL_INTEGER: + case TAO_ETCL_SIGNED: + if (tc_kind != CORBA::tk_short + && tc_kind != CORBA::tk_long + && tc_kind != CORBA::tk_longlong) + { + return 0; + } + case TAO_ETCL_UNSIGNED: + if (tc_kind != CORBA::tk_ushort + && tc_kind != CORBA::tk_ulong + && tc_kind != CORBA::tk_ulonglong) + { + return 0; + } + case TAO_ETCL_BOOLEAN: + if (tc_kind != CORBA::tk_boolean) + { + return 0; + } + default: + return 0; + } +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Hash_Map_Manager<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Entry <ACE_CString, CORBA::Any*>; +template class ACE_Hash_Map_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Node<TAO_ETCL_Literal_Constraint>; +template class ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint>; +template class ACE_Unbounded_Queue_Iterator<TAO_ETCL_Literal_Constraint>; + + +template class ACE_Hash_Map_Manager<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Entry <ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field>; +template class ACE_Hash_Map_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Entry <ACE_CString, CORBA::Any*> +#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Node<TAO_ETCL_Literal_Constraint> +#pragma instantiate ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint> +#pragma instantiate ACE_Unbounded_Queue_Iterator<TAO_ETCL_Literal_Constraint> + +#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Entry <ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field> +#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.h b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.h new file mode 100644 index 00000000000..e81821cc81c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.h @@ -0,0 +1,149 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file NS_Constraint_Visitors.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore <pradeep@cs.wustl.edu> + * @author Jeff Parsons <parsons@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef NOTIFY_CONSTRAINT_VISITORS_H +#define NOTIFY_CONSTRAINT_VISITORS_H + +#include "ace/pre.h" +#include "ace/Hash_Map_Manager.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ETCL/ETCL_Constraint_Visitor.h" +#include "orbsvcs/CosNotificationC.h" +#include "etcl_notify_filtering_export.h" + +class TAO_ETCL_Constraint; +class TAO_ETCL_Literal_Constraint; +class TAO_Notify_Property_Constraint; + +class ETCL_Notify_Filtering_Export TAO_NS_Constraint_Visitor + : public TAO_ETCL_Constraint_Visitor +{ +public: + /// Constructor. + TAO_NS_Constraint_Visitor (void); + + /// Put the event data into our hash map. + int bind_structured_event (const CosNotification::StructuredEvent &s_event); + + /** + * Returns 1 if the event satisfies the constraint + * represented by the the expression tree rooted at <root>, 0 if it + * doesn't. If an error occurs during the process, the traversal + * automatically fails. + */ + CORBA::Boolean evaluate_constraint (TAO_ETCL_Constraint *root); + + // The overridden methods. + int visit_literal (TAO_ETCL_Literal_Constraint *); + int visit_identifier (TAO_ETCL_Identifier *); + int visit_union_value (TAO_ETCL_Union_Value *); + int visit_union_pos (TAO_ETCL_Union_Pos *); + int visit_component_pos (TAO_ETCL_Component_Pos *); + int visit_component_assoc (TAO_ETCL_Component_Assoc *); + int visit_component_array (TAO_ETCL_Component_Array *); + int visit_special (TAO_ETCL_Special *); + int visit_component (TAO_ETCL_Component *); + int visit_dot (TAO_ETCL_Dot *); + int visit_eval (TAO_ETCL_Eval *); + int visit_default (TAO_ETCL_Default *); + int visit_exist (TAO_ETCL_Exist *); + int visit_unary_expr (TAO_ETCL_Unary_Expr *); + int visit_binary_expr (TAO_ETCL_Binary_Expr *); + int visit_preference (TAO_ETCL_Preference *); + +protected: + // Sub-methods for visit_binary_expr(). + int visit_or (TAO_ETCL_Binary_Expr *); + int visit_and (TAO_ETCL_Binary_Expr *); + int visit_twiddle (TAO_ETCL_Binary_Expr *); + int visit_in (TAO_ETCL_Binary_Expr *); + int visit_binary_op (TAO_ETCL_Binary_Expr *binary_expr, + int op_type); + + // These use dynamic anys to look inside the ETCL component. + CORBA::Boolean sequence_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean array_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean struct_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean union_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean any_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + + // Utility function to compare a TAO_ETCL_Literal_Constraint type + // and a type code. + CORBA::Boolean simple_type_match (int expr_type, + CORBA::TCKind tc_kind); + + enum structured_event_field + { + FILTERABLE_DATA, + HEADER, + FIXED_HEADER, + EVENT_TYPE, + DOMAIN_NAME, + TYPE_NAME, + EVENT_NAME, + VARIABLE_HEADER, + REMAINDER_OF_BODY, + NONE + }; + + /// Storage for the type of implicit id the component has (if any). + structured_event_field implicit_id_; + + /// Lookup table for the implicit ids, to avoid string comparisons in + /// derived visitors. + ACE_Hash_Map_Manager <ACE_CString, structured_event_field, TAO_SYNCH_MUTEX> + implicit_ids_; + + /// Used to lookup names and values in the event's 'filterable_data' field. + ACE_Hash_Map_Manager <ACE_CString, CORBA::Any *, TAO_SYNCH_MUTEX> + filterable_data_; + + /// Used to lookup names and values in the event's 'variable_header' field. + ACE_Hash_Map_Manager <ACE_CString, CORBA::Any *, TAO_SYNCH_MUTEX> + variable_header_; + + /// Storage for string names under the structured event's + /// 'fixed_header' field. + CORBA::String_var domain_name_; + CORBA::String_var type_name_; + CORBA::String_var event_name_; + + /// Storage for the structured_event's 'remainder_of_body' field. + CORBA::Any remainder_of_body_; + + /// The result of a non_boolean operation. + ACE_Unbounded_Queue <TAO_ETCL_Literal_Constraint> queue_; + + /// Holder for a value found in the event fields filterable_data, + /// variable_header or remainder_of_body. + CORBA::Any_var current_value_; + + /// Holder for a string name in the event fields fixed_header, + /// variable_header, or filterable_data. + CORBA::String_var current_name_; +}; + +#include "ace/post.h" +#endif /* NOTIFY_CONSTRAINT_VISITORS_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp index 523d9e4ca4a..2c0e9bb5efd 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp @@ -8,10 +8,85 @@ ACE_RCSID(RT_Notify, TAO_NS_Consumer, "$Id$") -TAO_NS_Consumer::TAO_NS_Consumer (void) +#include "ace/Refcounted_Auto_Ptr.h" +#include "tao/debug.h" +#include "ProxySupplier.h" +#include "Dispatch_Observer_T.h" + +TAO_NS_Consumer::TAO_NS_Consumer (TAO_NS_ProxySupplier* proxy) + :proxy_ (proxy), event_dispatch_observer_ (0) { } TAO_NS_Consumer::~TAO_NS_Consumer () { } + +TAO_NS_Proxy* +TAO_NS_Consumer::proxy (void) +{ + return this->proxy_supplier (); +} + +void +TAO_NS_Consumer::push (const TAO_NS_Event_var &event ACE_ENV_ARG_DECL) +{ + ACE_TRY + { + this->push_i (event ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->event_dispatch_observer_ != 0) + { + this->event_dispatch_observer_->dispatch_success (this ACE_ENV_ARG_PARAMETER); + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + this->retry_count_ = 0; + } + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_NS_Consumer::push: error sending event. informing dispatch observer\n "); + } + //ACE_RE_THROW; + + if (this->event_dispatch_observer_ != 0) + { + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + + ++this->retry_count_; + this->event_collection_.enqueue_head (event); + } + + this->event_dispatch_observer_->dispatch_failure (this, this->retry_count_ ACE_ENV_ARG_PARAMETER); + } + } + ACE_ENDTRY; +} + +void +TAO_NS_Consumer::dispatch_pending (void) +{ + TAO_NS_Event_Collection event_collection_copy; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + event_collection_copy = this->event_collection_; // Payload is never copied, this is a collections of _vars. + this->event_collection_.reset (); + } + + TAO_NS_ProxySupplier* proxy_supplier = this->proxy_supplier (); + + TAO_NS_Event_var event; + + while (!event_collection_copy.is_empty ()) + { + if (event_collection_copy.dequeue_head (event) == 0) + { + proxy_supplier->push_no_filtering (event); + } + } +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.h b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h index 86b6388fb60..1fb9ae776fe 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Consumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h @@ -19,8 +19,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "orbsvcs/CosNotificationC.h" -#include "Refcountable.h" +#include "ace/Unbounded_Queue.h" +#include "Peer.h" #include "Types.h" /** @@ -29,17 +29,46 @@ * @brief Astract Base class for wrapping consumer objects that connect to the EventChannel * */ -class TAO_Notify_Export TAO_NS_Consumer : public TAO_NS_Refcountable +class TAO_Notify_Export TAO_NS_Consumer : public TAO_NS_Peer { public: /// Constuctor - TAO_NS_Consumer (void); + TAO_NS_Consumer (TAO_NS_ProxySupplier* proxy); /// Destructor - virtual ~TAO_NS_Consumer (); + virtual ~TAO_NS_Consumer (); + + /// Access Specific Proxy. + TAO_NS_ProxySupplier* proxy_supplier (void); + + /// Access Base Proxy. + virtual TAO_NS_Proxy* proxy (void); + + /// Push <event> to this consumer. + void push (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); /// Push <event> to this consumer. - virtual void push (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) = 0; + virtual void push (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) = 0; + + /// Set Observer. + void event_dispatch_observer (TAO_NS_Event_Dispatch_Observer* event_dispatch_observer); + + /// Dispatch the pending events + void dispatch_pending (void); + +protected: + + /// Push Implementation. + virtual void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL) = 0; + + /// The Proxy that we associate with. + TAO_NS_ProxySupplier* proxy_; + + /// Observer + TAO_NS_Event_Dispatch_Observer* event_dispatch_observer_; + + /// Events pending to be delivered. + TAO_NS_Event_Collection event_collection_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl index 882affd00ff..b2d9cde26c9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl @@ -1,3 +1,17 @@ // $Id$ #include "Consumer.h" + +ACE_INLINE +TAO_NS_ProxySupplier* +TAO_NS_Consumer::proxy_supplier (void) +{ + return this->proxy_; +} + +ACE_INLINE void +TAO_NS_Consumer::event_dispatch_observer (TAO_NS_Event_Dispatch_Observer* event_dispatch_observer) +{ + this->event_dispatch_observer_ = event_dispatch_observer; +} + diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp index ba8db23085b..a968c21be71 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp @@ -6,6 +6,7 @@ #include "Proxy.h" #include "orbsvcs/ESF/ESF_Proxy_Collection.h" #include "QoSAdmin.h" +#include "Subscription_Change_Worker.h" #if ! defined (__ACE_INLINE__) #include "ConsumerAdmin.inl" @@ -47,11 +48,6 @@ TAO_NS_ConsumerAdmin::release (void) } void -TAO_NS_ConsumerAdmin::set (CosNotifyChannelAdmin::InterFilterGroupOperator op ACE_ENV_ARG_DECL) -{ -} - -void TAO_NS_ConsumerAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException @@ -61,299 +57,279 @@ TAO_NS_ConsumerAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) } -::CosNotifyChannelAdmin::ProxySupplier_ptr TAO_NS_ConsumerAdmin::obtain_notification_push_supplier ( - CosNotifyChannelAdmin::ClientType ctype, - CosNotifyChannelAdmin::ProxyID_out proxy_id - ) +::CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyChannelAdmin::AdminLimitExceeded - )) + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + return TAO_NS_PROPERTIES::instance()->builder ()->build_notification_push_supplier (this, + ctype, + proxy_id ACE_ENV_ARG_PARAMETER); +} - { - return TAO_NS_PROPERTIES::instance()->builder ()->build_notification_push_supplier (this, - ctype, - proxy_id ACE_ENV_ARG_PARAMETER); - } - CosNotifyChannelAdmin::AdminID TAO_NS_ConsumerAdmin::MyID ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + return this->id (); +} - { - return this->id (); - } - ::CosNotifyChannelAdmin::EventChannel_ptr TAO_NS_ConsumerAdmin::MyChannel ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) - { - //Add your implementation here - return 0; - } - -::CosNotifyChannelAdmin::InterFilterGroupOperator TAO_NS_ConsumerAdmin::MyOperator ( - - ) +{ + //Add your implementation here + return 0; +} + +::CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_ConsumerAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) +{ + return this->filter_operator_; +} - { - //Add your implementation here - return ::CosNotifyChannelAdmin::OR_OP; - } - ::CosNotifyFilter::MappingFilter_ptr TAO_NS_ConsumerAdmin::priority_filter ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) - { - //Add your implementation here - return 0; - } - -void TAO_NS_ConsumerAdmin::priority_filter ( - CosNotifyFilter::MappingFilter_ptr priority_filter - ) +{ + //Add your implementation here + return 0; +} + +void +TAO_NS_ConsumerAdmin::priority_filter (CosNotifyFilter::MappingFilter_ptr priority_filter) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + //Add your implementation here +} - { - //Add your implementation here - } - ::CosNotifyFilter::MappingFilter_ptr TAO_NS_ConsumerAdmin::lifetime_filter ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) - { - //Add your implementation here - return 0; - } - -void TAO_NS_ConsumerAdmin::lifetime_filter ( - CosNotifyFilter::MappingFilter_ptr lifetime_filter - ) +{ + //Add your implementation here + return 0; +} + +void +TAO_NS_ConsumerAdmin::lifetime_filter (CosNotifyFilter::MappingFilter_ptr lifetime_filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + //Add your implementation here +} - { - //Add your implementation here - } - ::CosNotifyChannelAdmin::ProxyIDSeq * TAO_NS_ConsumerAdmin::pull_suppliers ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + //Add your implementation here + return 0; +} - { - //Add your implementation here - return 0; - } - ::CosNotifyChannelAdmin::ProxyIDSeq * TAO_NS_ConsumerAdmin::push_suppliers ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + //Add your implementation here + return 0; +} - { - //Add your implementation here - return 0; - } - ::CosNotifyChannelAdmin::ProxySupplier_ptr TAO_NS_ConsumerAdmin::get_proxy_supplier ( - CosNotifyChannelAdmin::ProxyID proxy_id - ) + CosNotifyChannelAdmin::ProxyID proxy_id + ) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyChannelAdmin::ProxyNotFound - )) + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )) + +{ + //Add your implementation here + return 0; +} - { - //Add your implementation here - return 0; - } - ::CosNotifyChannelAdmin::ProxySupplier_ptr TAO_NS_ConsumerAdmin::obtain_notification_pull_supplier ( - CosNotifyChannelAdmin::ClientType ctype, - CosNotifyChannelAdmin::ProxyID_out proxy_id - ) + CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyChannelAdmin::AdminLimitExceeded - )) + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + //Add your implementation here + return 0; +} - { - //Add your implementation here - return 0; - } - ::CosNotification::QoSProperties * TAO_NS_ConsumerAdmin::get_qos ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + //Add your implementation here + return 0; +} - { - //Add your implementation here - return 0; - } - void TAO_NS_ConsumerAdmin::set_qos ( - const CosNotification::QoSProperties & qos - ) + const CosNotification::QoSProperties & qos + ) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotification::UnsupportedQoS - )) - { - for (CORBA::ULong index = 0; index < qos.length (); ++index) - { - ACE_CString property_name (qos[index].name); - - if (property_name.compare (NotifyExt::ThreadPool) == 0) - { - // check if ThreadPool is required. - NotifyExt::ThreadPoolParams* tp_params = 0; - - qos[index].value >>= tp_params; - - this->qos_admin_->apply_threadpool_qos (this, tp_params ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - break; - } - } + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->qos_admin_->apply_qos (this, qos ACE_ENV_ARG_PARAMETER); } - -void TAO_NS_ConsumerAdmin::validate_qos ( - const CosNotification::QoSProperties & required_qos, - CosNotification::NamedPropertyRangeSeq_out available_qos - ) + +void TAO_NS_ConsumerAdmin::validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL + ) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotification::UnsupportedQoS - )) + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) - { - //Add your implementation here - } - -void TAO_NS_ConsumerAdmin::subscription_change ( - const CosNotification::EventTypeSeq & added, - const CosNotification::EventTypeSeq & removed - ) +{ + //Add your implementation here +} + +void +TAO_NS_ConsumerAdmin::subscription_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyComm::InvalidEventType - )) + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )) +{ + TAO_NS_EventTypeSeq seq_added (added); + TAO_NS_EventTypeSeq seq_removed (removed); { - //Add your implementation here + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->subscribed_types_.init (seq_added, seq_removed); } - -CosNotifyFilter::FilterID TAO_NS_ConsumerAdmin::add_filter ( - CosNotifyFilter::Filter_ptr new_filter - ) + + TAO_NS_Subscription_Change_Worker worker (added, removed); + + this->collection_->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +CosNotifyFilter::FilterID +TAO_NS_ConsumerAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) +{ + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} - { - //Add your implementation here - return 0; - } - -void TAO_NS_ConsumerAdmin::remove_filter ( - CosNotifyFilter::FilterID filter - ) +void +TAO_NS_ConsumerAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyFilter::FilterNotFound - )) + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} - { - //Add your implementation here - } - -::CosNotifyFilter::Filter_ptr TAO_NS_ConsumerAdmin::get_filter ( - CosNotifyFilter::FilterID filter - ) +::CosNotifyFilter::Filter_ptr +TAO_NS_ConsumerAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyFilter::FilterNotFound - )) + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} - { - //Add your implementation here - return 0; - } - -::CosNotifyFilter::FilterIDSeq * TAO_NS_ConsumerAdmin::get_all_filters ( - - ) +::CosNotifyFilter::FilterIDSeq* +TAO_NS_ConsumerAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) +{ + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} - { - //Add your implementation here - return 0; - } - -void TAO_NS_ConsumerAdmin::remove_all_filters ( - - ) +void +TAO_NS_ConsumerAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) +{ + this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} - { - //Add your implementation here - } - ::CosEventChannelAdmin::ProxyPushSupplier_ptr TAO_NS_ConsumerAdmin::obtain_push_supplier ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) + +{ + //Add your implementation here + return 0; +} - { - //Add your implementation here - return 0; - } - ::CosEventChannelAdmin::ProxyPullSupplier_ptr TAO_NS_ConsumerAdmin::obtain_pull_supplier ( - + ) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) - { - //Add your implementation here - return 0; - } +{ + //Add your implementation here + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h index c9d280703e6..0096fddd78d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h @@ -38,10 +38,7 @@ public: TAO_NS_ConsumerAdmin (void); /// Destructor - ~TAO_NS_ConsumerAdmin (); - - /// Init this object. - void set (CosNotifyChannelAdmin::InterFilterGroupOperator op ACE_ENV_ARG_DECL); + ~TAO_NS_ConsumerAdmin (); /// Return servant virtual PortableServer::Servant servant (void); @@ -54,187 +51,185 @@ public: virtual void release (void); protected: - /// = CosNotifyChannelAdmin::ConsumerAdmin methods + /// = CosNotifyChannelAdmin::ConsumerAdmin methods -virtual CosNotifyChannelAdmin::AdminID MyID ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual CosNotifyChannelAdmin::AdminID MyID ( -virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel ( - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel ( -virtual ::CosNotifyFilter::MappingFilter_ptr priority_filter ( - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual void priority_filter ( - CosNotifyFilter::MappingFilter_ptr priority_filter - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual ::CosNotifyFilter::MappingFilter_ptr lifetime_filter ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotifyFilter::MappingFilter_ptr priority_filter ( -virtual void lifetime_filter ( - CosNotifyFilter::MappingFilter_ptr lifetime_filter ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_suppliers ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual void priority_filter ( + CosNotifyFilter::MappingFilter_ptr priority_filter + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_suppliers ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotifyFilter::MappingFilter_ptr lifetime_filter ( -virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr get_proxy_supplier ( - CosNotifyChannelAdmin::ProxyID proxy_id - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyChannelAdmin::ProxyNotFound - )); - -virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr obtain_notification_pull_supplier ( - CosNotifyChannelAdmin::ClientType ctype, - CosNotifyChannelAdmin::ProxyID_out proxy_id - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyChannelAdmin::AdminLimitExceeded - )); - -virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr obtain_notification_push_supplier ( - CosNotifyChannelAdmin::ClientType ctype, - CosNotifyChannelAdmin::ProxyID_out proxy_id ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyChannelAdmin::AdminLimitExceeded - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual void destroy ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual void lifetime_filter ( + CosNotifyFilter::MappingFilter_ptr lifetime_filter + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_suppliers ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual ::CosNotification::QoSProperties * get_qos ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_suppliers ( -virtual void set_qos ( - const CosNotification::QoSProperties & qos - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotification::UnsupportedQoS - )); - -virtual void validate_qos ( - const CosNotification::QoSProperties & required_qos, - CosNotification::NamedPropertyRangeSeq_out available_qos ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotification::UnsupportedQoS - )); - -virtual void subscription_change ( - const CosNotification::EventTypeSeq & added, - const CosNotification::EventTypeSeq & removed - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyComm::InvalidEventType - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual CosNotifyFilter::FilterID add_filter ( - CosNotifyFilter::Filter_ptr new_filter - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr get_proxy_supplier ( + CosNotifyChannelAdmin::ProxyID proxy_id + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )); -virtual void remove_filter ( - CosNotifyFilter::FilterID filter - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyFilter::FilterNotFound - )); + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr obtain_notification_pull_supplier ( + CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); -virtual ::CosNotifyFilter::Filter_ptr get_filter ( - CosNotifyFilter::FilterID filter - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotifyFilter::FilterNotFound - )); + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr obtain_notification_push_supplier ( + CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); -virtual ::CosNotifyFilter::FilterIDSeq * get_all_filters ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual void destroy ( -virtual void remove_all_filters ( - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); -virtual ::CosEventChannelAdmin::ProxyPushSupplier_ptr obtain_push_supplier ( - - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + virtual ::CosNotification::QoSProperties * get_qos ( -virtual ::CosEventChannelAdmin::ProxyPullSupplier_ptr obtain_pull_supplier ( - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos ( + const CosNotification::QoSProperties & qos + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos ( + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void subscription_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )); + + virtual CosNotifyFilter::FilterID add_filter ( + CosNotifyFilter::Filter_ptr new_filter + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_filter ( + CosNotifyFilter::FilterID filter + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )); + + virtual ::CosNotifyFilter::Filter_ptr get_filter ( + CosNotifyFilter::FilterID filter + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )); + + virtual ::CosNotifyFilter::FilterIDSeq * get_all_filters ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_filters ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPushSupplier_ptr obtain_push_supplier ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPullSupplier_ptr obtain_pull_supplier ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container.cpp b/TAO/orbsvcs/orbsvcs/Notify/Container.cpp index bc1cb91ea02..62d20c6490a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Container.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Container.cpp @@ -35,7 +35,7 @@ TAO_NS_Container::cleanup (ACE_ENV_SINGLE_ARG_DECL) if (delete_object_poa_ == 1) { object_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - delete object_poa_; + delete object_poa_; } if (delete_proxy_poa_ == 1) @@ -70,6 +70,3 @@ TAO_NS_Container::proxy_poa (void) { return this->proxy_poa_; } - - - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp index 92e6bf89dc7..dce3ccb625c 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp @@ -55,13 +55,13 @@ TAO_NS_Container_T<TYPE, OBJECT, PARENT>::remove (TYPE* type ACE_ENV_ARG_DECL) { this->collection_->disconnected (type ACE_ENV_ARG_PARAMETER); } - + template<class TYPE, class OBJECT, class PARENT> void TAO_NS_Container_T<TYPE, OBJECT, PARENT>::init_collection (ACE_ENV_SINGLE_ARG_DECL) { // get the factory TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); - + // Init variables factory->create (this->collection_ ACE_ENV_SINGLE_ARG_PARAMETER); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.cpp new file mode 100644 index 00000000000..8d3dc2e3ff4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.cpp @@ -0,0 +1,68 @@ +// $Id$ + +#include "Dispatch_Observer_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Dispatch_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Dispatch_Observer_T, "$id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Peer.h" +#include "Proxy.h" +#include "Properties.h" +#include "Factory.h" + +template <class PEER> +TAO_NS_Dispatch_Observer_T<PEER>::TAO_NS_Dispatch_Observer_T (void) +: max_retry_attempts_ (1) +{ +} + +template <class PEER> +TAO_NS_Dispatch_Observer_T<PEER>::~TAO_NS_Dispatch_Observer_T () +{ + delete this->peer_collection_; +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::init (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + factory->create (this->peer_collection_ ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::enqueue (PEER* peer ACE_ENV_ARG_DECL) +{ + this->peer_collection_->connected (peer ACE_ENV_ARG_DECL); + ACE_CHECK; +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::dispatch_failure (PEER* peer, int retry_count ACE_ENV_ARG_DECL) +{ + if (retry_count > this->max_retry_attempts_) + { + this->peer_collection_->disconnected (peer ACE_ENV_ARG_DECL); + ACE_CHECK; + + peer->proxy ()->destroy (ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else if (retry_count == 1) // failed for the 1st time. + { + this->peer_collection_->connected (peer ACE_ENV_ARG_DECL); + ACE_CHECK; + } +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::dispatch_success (PEER* peer ACE_ENV_ARG_DECL) +{ + this->peer_collection_->disconnected (peer ACE_ENV_ARG_DECL); + ACE_CHECK; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.h b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.h new file mode 100644 index 00000000000..74ef4adadb3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.h @@ -0,0 +1,83 @@ +/* -*- C++ -*- */ +/** + * @file Dispatch_Observer_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_DISPATCH_OBSERVER_T_H +#define TAO_NS_DISPATCH_OBSERVER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "types.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" + +/** + * @class TAO_NS_Dispatch_Observer_T + * + * @brief An observer class that is notified of the success or failure of event/update diapatches. + * If a dispatch fails, the PEER is added to a pending list. This list is obtained by the Pending Worker to retry delivery of + * Events/Updates. When the max_retries are reached, the observer destroys the proxy. + * + */ +template <class PEER> +class TAO_Notify_Export TAO_NS_Dispatch_Observer_T +{ +public: + typedef TAO_ESF_Proxy_Collection<PEER> PEER_COLLECTION; + + /// Constuctor + TAO_NS_Dispatch_Observer_T (void); + + /// Destructor + ~TAO_NS_Dispatch_Observer_T (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + void max_retry_attempts (CORBA::ULong max_retry_attempts); + + /// Enqueue this peer. + void enqueue (PEER* peer); + + /// Dispatch failure notice. + void dispatch_failure (PEER* peer, int retry_count ACE_ENV_ARG_DECL); + + /// Dispatch success notice. + void dispatch_success (PEER* peer ACE_ENV_ARG_DECL); + + /// Get peer collection. + PEER_COLLECTION* peer_collection (void); + +protected: + /// Max retry attempts. + CORBA::ULong max_retry_attempts_; + + /// Pending list. + PEER_COLLECTION* peer_collection_; +}; + +#if defined (__ACE_INLINE__) +#include "Dispatch_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Dispatch_Observer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Dispatch_Observer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_DISPATCH_OBSERVER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.inl new file mode 100644 index 00000000000..995a33dbfb6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.inl @@ -0,0 +1,9 @@ +// $Id$ + +#include "Dispatch_Observer_T.h" + +template <class PEER> ACE_INLINE TAO_NS_Dispatch_Observer_T<PEER>::PEER_COLLECTION* +TAO_NS_Dispatch_Observer_T<PEER>::peer_collection (void) +{ + return this->peer_collection_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp new file mode 100644 index 00000000000..562a6f9d6a0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp @@ -0,0 +1,465 @@ +// $Id$ + +#include "ETCL_Filter.h" + +#if ! defined (__ACE_INLINE__) +#include "ETCL_Filter.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_ETCL_Filter, "$id$") + +#include "ace/Auto_Ptr.h" +#include "tao/debug.h" +#include "Constraint_Visitors.h" + +TAO_NS_ETCL_Filter::TAO_NS_ETCL_Filter (void) +{ +} + +TAO_NS_ETCL_Filter::~TAO_NS_ETCL_Filter () +{ + ACE_DECLARE_NEW_CORBA_ENV; + this->remove_all_constraints (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "Filter Destroyed\n")); + } +} + +char* +TAO_NS_ETCL_Filter::constraint_grammar (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CORBA::string_dup ("ETCL"); +} + +void +TAO_NS_ETCL_Filter::add_constraints_i (const CosNotifyFilter::ConstraintInfoSeq& constraint_info_seq + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )) +{ + for (CORBA::ULong index = 0; + index < constraint_info_seq.length (); + ++index) + { + TAO_NS_Constraint_Expr* notify_constr_expr; + + ACE_TRY + { + ACE_NEW_THROW_EX (notify_constr_expr, + TAO_NS_Constraint_Expr (), + CORBA::NO_MEMORY ()); + + const CosNotifyFilter::ConstraintExp& expr = + constraint_info_seq[index].constraint_expression; + + notify_constr_expr->interpreter.build_tree ( + expr.constraint_expr.in () + ACE_ENV_ARG_PARAMETER + ); + ACE_TRY_CHECK; + + notify_constr_expr->constr_expr = expr; + + CosNotifyFilter::ConstraintID cnstr_id = ++constraint_expr_ids_; + + if (this->constraint_expr_list_.bind (cnstr_id, notify_constr_expr) + == -1) + { + ACE_THROW (CORBA::NO_RESOURCES ()); + } + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Added constraint to filter %x\n", this, expr.constraint_expr.in ())); + } + ACE_CATCHANY + { + // Delete the one that failed us. + delete notify_constr_expr; + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } +} + +CosNotifyFilter::ConstraintInfoSeq* +TAO_NS_ETCL_Filter::add_constraints (const CosNotifyFilter::ConstraintExpSeq& constraint_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )) +{ + CORBA::ULong constraint_length = constraint_list.length (); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "constraint_length = %d\n", + constraint_length)); + } + + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq; + ACE_NEW_THROW_EX (infoseq, + CosNotifyFilter::ConstraintInfoSeq (constraint_length), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + infoseq->length (constraint_length); + + auto_ptr<CosNotifyFilter::ConstraintInfoSeq> auto_infoseq (infoseq); + + // Populate infoseq. + for (CORBA::ULong pop_index = 0; pop_index < constraint_length; ++pop_index) + { + (*infoseq)[pop_index].constraint_expression = + constraint_list [pop_index]; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Adding constraint %d, %s\n", + pop_index, + constraint_list [pop_index].constraint_expr.in ())); + } + } + + this->add_constraints_i (*infoseq + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + auto_infoseq.release (); + + return infoseq; +} + +void +TAO_NS_ETCL_Filter::modify_constraints (const CosNotifyFilter::ConstraintIDSeq & del_list, + const CosNotifyFilter::ConstraintInfoSeq & modify_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint, + CosNotifyFilter::ConstraintNotFound + )) +{ + // First check if all the ids are valid. + u_int index; + + for (index = 0; index < del_list.length (); ++index) + { + if (this->constraint_expr_list_.find (del_list [index]) == -1) + { + ACE_THROW (CosNotifyFilter::ConstraintNotFound (del_list [index])); + } + } + + for (index = 0; index < modify_list.length (); ++index) + { + if (this->constraint_expr_list_.find (modify_list [index].constraint_id) == -1) + { + ACE_THROW (CosNotifyFilter::ConstraintNotFound (modify_list [index].constraint_id)); + } + } + + // Remove previous entries and save them in case we need to reinstate them. + ACE_Array<TAO_NS_Constraint_Expr*> constr_saved (modify_list.length ()); + TAO_NS_Constraint_Expr* constr_expr = 0; + + for (index = 0; index < modify_list.length (); ++index) + { + CosNotifyFilter::ConstraintID cnstr_id = + modify_list [index].constraint_id; + + if (this->constraint_expr_list_.unbind (cnstr_id, constr_expr) != -1) + { + constr_saved[index] = constr_expr; + } + } + + // Now add the new entries. + // Keep a list of ids generated in this session. + ACE_TRY + { + this->add_constraints_i (modify_list + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Restore, + for (index = 0; index < modify_list.length (); ++index) + { + CosNotifyFilter::ConstraintID cnstr_id = ++this->constraint_expr_ids_; + + if (constraint_expr_list_.bind (cnstr_id, constr_saved[index]) == -1) + ACE_THROW (CORBA::NO_RESOURCES ()); + } + + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + + // Now go around deleting... + // for the del_list. + for (index = 0; index < del_list.length (); ++index) + { + if (this->constraint_expr_list_.unbind (del_list [index], constr_expr) != -1) + { + delete constr_expr; + } + } + + // Delete the old constraints. + for (index = 0; index < constr_saved.max_size (); ++index) + { + delete constr_saved[index]; + } +} + +CosNotifyFilter::ConstraintInfoSeq * +TAO_NS_ETCL_Filter::get_constraints (const CosNotifyFilter::ConstraintIDSeq & id_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::ConstraintNotFound)) +{ + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq; + ACE_NEW_THROW_EX (infoseq, + CosNotifyFilter::ConstraintInfoSeq (id_list.length ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + auto_ptr<CosNotifyFilter::ConstraintInfoSeq> auto_infoseq (infoseq); + + TAO_NS_Constraint_Expr *notify_constr_expr = 0; + + for (u_int index = 0; index < id_list.length (); ++index) + { + if (this->constraint_expr_list_.find (id_list[index], + notify_constr_expr) == -1) + ACE_THROW_RETURN (CosNotifyFilter::ConstraintNotFound (id_list[index]), + 0); + + (*infoseq)[index].constraint_expression = + notify_constr_expr->constr_expr; + + // Get an id. + (*infoseq)[index].constraint_id = id_list[index]; + } + + auto_infoseq.release (); + return infoseq; +} + +CosNotifyFilter::ConstraintInfoSeq * +TAO_NS_ETCL_Filter::get_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + size_t current_size = this->constraint_expr_list_.current_size (); + + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq; + ACE_NEW_THROW_EX (infoseq, + CosNotifyFilter::ConstraintInfoSeq (current_size), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + infoseq->length (current_size); + CONSTRAINT_EXPR_LIST_ITER iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_ENTRY *entry; + + for (u_int index = 0; iter.done () == 0; iter.advance (), ++index) + { + if (iter.next (entry) != 0) + { + // Why do we cast to a const object? + // We want to force the TAO_String_Manager to make a + // copy of the string. It wouldn't unless we coax it to use + // the correct assignment operator. + (*infoseq)[index].constraint_expression = + ACE_static_cast (const CosNotifyFilter::ConstraintExp, + entry->int_id_->constr_expr); + + (*infoseq)[index].constraint_id = entry->ext_id_; + } + } + + return infoseq; +} + +void +TAO_NS_ETCL_Filter::remove_all_constraints (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CONSTRAINT_EXPR_LIST_ITER iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_ENTRY *entry; + + u_int index; + + for (index = 0; iter.done () == 0; iter.advance (), ++index) + { + if (iter.next (entry) != 0) + { + delete entry->int_id_; + } + } + + this->constraint_expr_list_.unbind_all (); +} + +void +TAO_NS_ETCL_Filter::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->remove_all_constraints (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::POA_var my_POA = _default_POA (); + + PortableServer::ObjectId_var refTemp = my_POA->servant_to_id (this); + + my_POA->deactivate_object (refTemp.in ()); +} + +CORBA::Boolean +TAO_NS_ETCL_Filter::match (const CORBA::Any & /*filterable_data */ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +CORBA::Boolean +TAO_NS_ETCL_Filter::match_structured (const CosNotification::StructuredEvent & filterable_data + ACE_ENV_ARG_DECL_NOT_USED + ) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData)) +{ + // We want to return true if at least one constraint matches. + CONSTRAINT_EXPR_LIST_ITER iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_ENTRY *entry; + + TAO_NS_Constraint_Visitor visitor; + + if (visitor.bind_structured_event (filterable_data) != 0) + { + // Maybe throw some kind of exception here, or lower down, + return 0; + } + + for (; iter.done () == 0; iter.advance ()) + { + if (iter.next (entry) != 0) + { + if (entry->int_id_->interpreter.evaluate (visitor) == 1) + { + return 1; + } + } + } + + return 0; +} + +CORBA::Boolean +TAO_NS_ETCL_Filter::match_typed ( + const CosNotification::PropertySeq & /* filterable_data */ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +CosNotifyFilter::CallbackID +TAO_NS_ETCL_Filter::attach_callback ( + CosNotifyComm::NotifySubscribe_ptr /* callback */ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +void +TAO_NS_ETCL_Filter::detach_callback ( + CosNotifyFilter::CallbackID /* callback */ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::CallbackNotFound)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosNotifyFilter::CallbackIDSeq * +TAO_NS_ETCL_Filter::get_callbacks (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Hash_Map_Entry<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr *>; +template class ACE_Hash_Map_Manager<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; + +#if !defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION) +template class ACE_Equal_To<CosNotifyFilter::ConstraintID>; +#endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ + +template class ACE_Array<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*>; +template class ACE_Array_Base<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*>; + +template class auto_ptr<CosNotifyFilter::ConstraintInfoSeq>; +template class ACE_Auto_Basic_Ptr<CosNotifyFilter::ConstraintInfoSeq>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Entry<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*> +#pragma instantiate ACE_Hash_Map_Manager<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> + +#if !defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION) +#pragma instantiate ACE_Equal_To<CosNotifyFilter::ConstraintID> +#endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ + +#pragma instantiate ACE_Array<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*> +#pragma instantiate ACE_Array_Base<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*> + +#pragma instantiate auto_ptr<CosNotifyFilter::ConstraintInfoSeq> +#pragma instantiate ACE_Auto_Basic_Ptr<CosNotifyFilter::ConstraintInfoSeq> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h new file mode 100644 index 00000000000..91163631b38 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h @@ -0,0 +1,175 @@ +/* -*- C++ -*- */ +/** + * @file ETCL_Filter.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ETCL_FILTER_H +#define TAO_NS_ETCL_FILTER_H +#include "ace/pre.h" + +#include "etcl_notify_filtering_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Containers_T.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/Atomic_Op.h" +#include "orbsvcs/CosNotifyFilterS.h" +#include "Constraint_Interpreter.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_ETCL_Filter + * + * @brief + * + */ +class ETCL_Notify_Filtering_Export TAO_NS_ETCL_Filter : public POA_CosNotifyFilter::Filter, public PortableServer::RefCountServantBase +{ +public: + /// Constuctor + TAO_NS_ETCL_Filter (void); + + /// Destructor + ~TAO_NS_ETCL_Filter (); + +protected: + virtual char * constraint_grammar (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotifyFilter::ConstraintInfoSeq * add_constraints (const CosNotifyFilter::ConstraintExpSeq & constraint_list ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )); + + virtual void modify_constraints (const CosNotifyFilter::ConstraintIDSeq & del_list, + const CosNotifyFilter::ConstraintInfoSeq & modify_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint, + CosNotifyFilter::ConstraintNotFound + )); + + virtual CosNotifyFilter::ConstraintInfoSeq * get_constraints (const CosNotifyFilter::ConstraintIDSeq & id_list ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::ConstraintNotFound + )); + + virtual CosNotifyFilter::ConstraintInfoSeq * get_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CORBA::Boolean match (const CORBA::Any & filterable_data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CORBA::Boolean match_structured (const CosNotification::StructuredEvent & filterable_data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CORBA::Boolean match_typed (const CosNotification::PropertySeq & filterable_data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CosNotifyFilter::CallbackID attach_callback (CosNotifyComm::NotifySubscribe_ptr callback ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void detach_callback (CosNotifyFilter::CallbackID callback ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::CallbackNotFound + )); + + virtual CosNotifyFilter::CallbackIDSeq * get_callbacks (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +private: + void add_constraints_i (const CosNotifyFilter::ConstraintInfoSeq& constraint_info_seq ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )); + + struct TAO_NS_Constraint_Expr + { + // = DESCRIPTION + // Structure for associating ConstraintInfo with an interpreter. + // + CosNotifyFilter::ConstraintExp constr_expr; + // Constraint Expression. + + TAO_NS_Constraint_Interpreter interpreter; + // Constraint Interpreter. + }; + + /// Id generator for ConstraintInfo's. + ACE_Atomic_Op <TAO_SYNCH_MUTEX, CORBA::Long> constraint_expr_ids_; + + /// A list of the constraints stored in this filter. + ACE_Hash_Map_Manager <CosNotifyFilter::ConstraintID, + ACE_NESTED_CLASS (TAO_NS_ETCL_Filter, TAO_NS_Constraint_Expr*), + TAO_SYNCH_MUTEX> + constraint_expr_list_; + + typedef ACE_Hash_Map_Iterator <CosNotifyFilter::ConstraintID, + ACE_NESTED_CLASS (TAO_NS_ETCL_Filter, TAO_NS_Constraint_Expr*), + TAO_SYNCH_MUTEX> + CONSTRAINT_EXPR_LIST_ITER; + + typedef ACE_Hash_Map_Entry <CosNotifyFilter::ConstraintID, + ACE_NESTED_CLASS (TAO_NS_ETCL_Filter, + TAO_NS_Constraint_Expr*)> + CONSTRAINT_EXPR_ENTRY; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "ETCL_Filter.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_ETCL_FILTER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl new file mode 100644 index 00000000000..0d107de49d5 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "ETCL_Filter.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp new file mode 100644 index 00000000000..6177bc0c7ed --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp @@ -0,0 +1,78 @@ +// $Id$ + +#include "ETCL_FilterFactory.h" + +#if ! defined (__ACE_INLINE__) +#include "ETCL_FilterFactory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_ETCL_FilterFactory, "$id$") + +#include "ETCL_Filter.h" + +TAO_NS_ETCL_FilterFactory::TAO_NS_ETCL_FilterFactory (void) +{ +} + +TAO_NS_ETCL_FilterFactory::~TAO_NS_ETCL_FilterFactory () +{ +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_ETCL_FilterFactory::create (ACE_ENV_SINGLE_ARG_DECL) +{ + return _this (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyFilter::Filter_ptr +TAO_NS_ETCL_FilterFactory::create_filter (const char *constraint_grammar ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )) +{ + // @@: change to "ExTCL" later. + if (ACE_OS::strcmp (constraint_grammar, "TCL") != 0 && + ACE_OS::strcmp (constraint_grammar, "ETCL") != 0) + ACE_THROW_RETURN (CosNotifyFilter::InvalidGrammar (), 0); + + + // Create the RefCounted servant. + TAO_NS_ETCL_Filter* filter = 0; + + ACE_NEW_THROW_EX (filter, + TAO_NS_ETCL_Filter (), + CORBA::NO_MEMORY ()); + + PortableServer::POA_var my_POA = _default_POA (); + + PortableServer::ServantBase_var filter_var (filter); + + PortableServer::ObjectId_var oid = + my_POA->activate_object (filter + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + CORBA::Object_var obj = + my_POA->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + return CosNotifyFilter::Filter::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); +} + +CosNotifyFilter::MappingFilter_ptr +TAO_NS_ETCL_FilterFactory::create_mapping_filter (const char * /*constraint_grammar*/, + const CORBA::Any & /*default_value*/ + ACE_ENV_ARG_DECL_NOT_USED //ACE_ENV_SINGLE_ARG_PARAMETER + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )) +{ + ACE_THROW ((CORBA::NO_IMPLEMENT ())); +} + +ACE_FACTORY_DEFINE (ETCL_Notify_Filtering, TAO_NS_ETCL_FilterFactory) diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h new file mode 100644 index 00000000000..cdfb7bdb500 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +/** + * @file ETCL_FilterFactory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ETCL_FILTERFACTORY_H +#define TAO_NS_ETCL_FILTERFACTORY_H +#include "ace/pre.h" + +#include "etcl_notify_filtering_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/orbsvcs/CosNotifyFilterS.h" +#include "FilterFactory.h" + +/** + * @class TAO_NS_ETCL_FilterFactory + * + * @brief + * + */ +class ETCL_Notify_Filtering_Export TAO_NS_ETCL_FilterFactory : public POA_CosNotifyFilter::FilterFactory, public TAO_NS_FilterFactory +{ +public: + /// Constuctor + TAO_NS_ETCL_FilterFactory (void); + + /// Destructor + ~TAO_NS_ETCL_FilterFactory (); + + ///= TAO_NS_FilterFactory methods. + + virtual CosNotifyFilter::FilterFactory_ptr create (ACE_ENV_SINGLE_ARG_DECL); + + ///= CosNotifyFilter::FilterFactory methods + + virtual CosNotifyFilter::Filter_ptr create_filter (const char * constraint_grammar + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )); + + virtual CosNotifyFilter::MappingFilter_ptr create_mapping_filter (const char * constraint_grammar, + const CORBA::Any & default_value + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )); +}; + +ACE_FACTORY_DECLARE (ETCL_Notify_Filtering, TAO_NS_ETCL_FilterFactory) + +#if defined (__ACE_INLINE__) +#include "ETCL_FilterFactory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ETCL_FILTERFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl new file mode 100644 index 00000000000..9b048ecde54 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "ETCL_FilterFactory.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp index 2ae1254ae80..d73d06bcbc6 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp @@ -17,7 +17,6 @@ TAO_NS_Event::TAO_NS_Event (void) TAO_NS_Event::~TAO_NS_Event () { - if (TAO_debug_level > 0) + if (TAO_debug_level > 1) ACE_DEBUG ((LM_DEBUG,"event:%x destroyed\n", this )); } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.h b/TAO/orbsvcs/orbsvcs/Notify/Event.h index 52b554cfb33..ce76ee569d0 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.h @@ -21,6 +21,7 @@ #include "ace/Copy_Disabled.h" #include "orbsvcs/Event_ForwarderS.h" +#include "orbsvcs/CosNotifyFilterC.h" class TAO_NS_EventType; class TAO_NS_Consumer; @@ -38,16 +39,22 @@ public: TAO_NS_Event (void); /// Destructor - virtual ~TAO_NS_Event (); + virtual ~TAO_NS_Event (); /// Get the event type. virtual const TAO_NS_EventType& type (void) const = 0; + /// Returns true if the filter matches. + virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL) = 0; + /// Push event to consumer virtual void push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const = 0; /// Push event to the Event_Forwarder interface virtual void push (Notify_Internal::Event_Forwarder_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Notify_Internal::Event_Forwarder_ptr forwarder ACE_ENV_ARG_DECL) = 0; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp index 4c1a9a45252..36a3e8205da 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp @@ -57,6 +57,7 @@ TAO_NS_EventChannel::destroy (ACE_ENV_SINGLE_ARG_DECL) )) { this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); + this->event_manager_->shutdown (); } void @@ -66,24 +67,7 @@ TAO_NS_EventChannel::set_qos (const CosNotification::QoSProperties & qos ACE_ENV , CosNotification::UnsupportedQoS )) { - for (CORBA::ULong index = 0; index < qos.length (); ++index) - { - ACE_CString property_name (qos[index].name); - - if (property_name.compare (NotifyExt::ThreadPool) == 0) - { - // check if ThreadPool is required. - NotifyExt::ThreadPoolParams* tp_params = 0; - - qos[index].value >>= tp_params; - - this->qos_admin_->apply_threadpool_qos (this, tp_params ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - break; - } - } - + this->qos_admin_->apply_qos (this, qos ACE_ENV_ARG_PARAMETER); } ::CosNotifyChannelAdmin::EventChannelFactory_ptr @@ -96,9 +80,9 @@ TAO_NS_EventChannel::MyFactory () //Add your implementation here return 0; } - + ::CosNotifyChannelAdmin::ConsumerAdmin_ptr TAO_NS_EventChannel::default_consumer_admin ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -108,9 +92,9 @@ TAO_NS_EventChannel::MyFactory () //Add your implementation here return 0; } - + ::CosNotifyChannelAdmin::SupplierAdmin_ptr TAO_NS_EventChannel::default_supplier_admin ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -120,19 +104,15 @@ TAO_NS_EventChannel::MyFactory () //Add your implementation here return 0; } - -::CosNotifyFilter::FilterFactory_ptr TAO_NS_EventChannel::default_filter_factory ( - - ) + +::CosNotifyFilter::FilterFactory_ptr TAO_NS_EventChannel::default_filter_factory (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException )) - { - //Add your implementation here - return 0; + return this->parent_->get_default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); } - + ::CosNotifyChannelAdmin::ConsumerAdmin_ptr TAO_NS_EventChannel::new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id @@ -140,12 +120,12 @@ TAO_NS_EventChannel::new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupO ACE_THROW_SPEC (( CORBA::SystemException )) - + { /// Builder for ConsumerAdmins return TAO_NS_PROPERTIES::instance()->builder ()->build_consumer_admin (this, op, id); } - + ::CosNotifyChannelAdmin::SupplierAdmin_ptr TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id @@ -159,10 +139,10 @@ TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupO /// Builder for SupplierAdmins return TAO_NS_PROPERTIES::instance()->builder ()->build_supplier_admin (this, op, id); } - + ::CosNotifyChannelAdmin::ConsumerAdmin_ptr TAO_NS_EventChannel::get_consumeradmin ( - CosNotifyChannelAdmin::AdminID id - ) + CosNotifyChannelAdmin::AdminID id + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyChannelAdmin::AdminNotFound @@ -172,10 +152,10 @@ TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupO //Add your implementation here return 0; } - + ::CosNotifyChannelAdmin::SupplierAdmin_ptr TAO_NS_EventChannel::get_supplieradmin ( - CosNotifyChannelAdmin::AdminID id - ) + CosNotifyChannelAdmin::AdminID id + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyChannelAdmin::AdminNotFound @@ -185,9 +165,9 @@ TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupO //Add your implementation here return 0; } - + ::CosNotifyChannelAdmin::AdminIDSeq * TAO_NS_EventChannel::get_all_consumeradmins ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -197,9 +177,9 @@ TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupO //Add your implementation here return 0; } - + ::CosNotifyChannelAdmin::AdminIDSeq * TAO_NS_EventChannel::get_all_supplieradmins ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -209,9 +189,9 @@ TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupO //Add your implementation here return 0; } - + ::CosNotification::QoSProperties * TAO_NS_EventChannel::get_qos ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -221,11 +201,11 @@ TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupO //Add your implementation here return 0; } - + void TAO_NS_EventChannel::validate_qos ( - const CosNotification::QoSProperties & required_qos, - CosNotification::NamedPropertyRangeSeq_out available_qos - ) + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotification::UnsupportedQoS @@ -234,9 +214,9 @@ void TAO_NS_EventChannel::validate_qos ( { //Add your implementation here } - + ::CosNotification::AdminProperties * TAO_NS_EventChannel::get_admin ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -246,10 +226,10 @@ void TAO_NS_EventChannel::validate_qos ( //Add your implementation here return 0; } - + void TAO_NS_EventChannel::set_admin ( - const CosNotification::AdminProperties & admin - ) + const CosNotification::AdminProperties & admin + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotification::UnsupportedAdmin @@ -258,9 +238,9 @@ void TAO_NS_EventChannel::set_admin ( { //Add your implementation here } - + ::CosEventChannelAdmin::ConsumerAdmin_ptr TAO_NS_EventChannel::for_consumers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -270,9 +250,9 @@ void TAO_NS_EventChannel::set_admin ( //Add your implementation here return 0; } - + ::CosEventChannelAdmin::SupplierAdmin_ptr TAO_NS_EventChannel::for_suppliers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -282,4 +262,3 @@ void TAO_NS_EventChannel::set_admin ( //Add your implementation here return 0; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h index b7d83b5bb9f..030da306008 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h @@ -32,7 +32,7 @@ class TAO_NS_EventChannelFactory; /** * @class TAO_NS_EventChannel * - * @brief Implementation of CosNotifyChannelAdmin::EventChannel + * @brief Implementation of CosNotifyChannelAdmin::EventChannel * */ class TAO_Notify_Export TAO_NS_EventChannel : public POA_CosNotifyChannelAdmin::EventChannel, public TAO_NS_Container_T <TAO_NS_Admin, TAO_NS_EventChannel, TAO_NS_EventChannelFactory>, public TAO_NS_Destroy_Callback @@ -45,7 +45,7 @@ public: TAO_NS_EventChannel (void); /// Destructor - ~TAO_NS_EventChannel (); + ~TAO_NS_EventChannel (); /// Return servant virtual PortableServer::Servant servant (void); @@ -68,29 +68,27 @@ protected: CORBA::SystemException )); - virtual ::CosNotifyChannelAdmin::EventChannelFactory_ptr MyFactory ( + virtual ::CosNotifyChannelAdmin::EventChannelFactory_ptr MyFactory ( ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr default_consumer_admin ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr default_supplier_admin ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); - virtual ::CosNotifyFilter::FilterFactory_ptr default_filter_factory ( - - ) + virtual ::CosNotifyFilter::FilterFactory_ptr default_filter_factory (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException )); @@ -129,21 +127,21 @@ protected: )); virtual ::CosNotifyChannelAdmin::AdminIDSeq * get_all_consumeradmins ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::AdminIDSeq * get_all_supplieradmins ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotification::QoSProperties * get_qos ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -167,7 +165,7 @@ protected: )); virtual ::CosNotification::AdminProperties * get_admin ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -182,14 +180,14 @@ protected: )); virtual ::CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp index a9b5e782232..cd10b67bddd 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp @@ -22,6 +22,12 @@ TAO_NS_EventChannelFactory::~TAO_NS_EventChannelFactory () { } +void +TAO_NS_EventChannelFactory::init (ACE_ENV_SINGLE_ARG_DECL) +{ + this->default_filter_factory_ = TAO_NS_PROPERTIES::instance()->builder ()->build_filter_factory (ACE_ENV_ARG_PARAMETER); +} + PortableServer::Servant TAO_NS_EventChannelFactory::servant (void) { @@ -47,6 +53,12 @@ TAO_NS_EventChannelFactory::release (void) //@@ inform factory } +CosNotifyFilter::FilterFactory_ptr +TAO_NS_EventChannelFactory::get_default_filter_factory (void) +{ + return CosNotifyFilter::FilterFactory::_duplicate (this->default_filter_factory_.in ()); +} + ::CosNotifyChannelAdmin::EventChannel_ptr TAO_NS_EventChannelFactory::create_channel ( const CosNotification::QoSProperties & initial_qos, const CosNotification::AdminProperties & initial_admin, @@ -60,9 +72,9 @@ TAO_NS_EventChannelFactory::release (void) { return TAO_NS_PROPERTIES::instance()->builder ()->build_event_channel (this, initial_qos, initial_admin, id ACE_ENV_ARG_PARAMETER); } - + ::CosNotifyChannelAdmin::ChannelIDSeq *TAO_NS_EventChannelFactory::get_all_channels ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -72,7 +84,7 @@ TAO_NS_EventChannelFactory::release (void) return 0; //Add your implementation here } - + ::CosNotifyChannelAdmin::EventChannel_ptr TAO_NS_EventChannelFactory::get_event_channel ( CosNotifyChannelAdmin::ChannelID id ) @@ -83,6 +95,5 @@ TAO_NS_EventChannelFactory::release (void) { //Add your implementation here - return 0; + return 0; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h index 5f93bb7b506..3c875b4198b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h @@ -39,12 +39,15 @@ public: /// Constuctor TAO_NS_EventChannelFactory (void); + /// Init the factory + void init (ACE_ENV_SINGLE_ARG_DECL); + /// Destructor - virtual ~TAO_NS_EventChannelFactory (); + virtual ~TAO_NS_EventChannelFactory (); /// Return servant virtual PortableServer::Servant servant (void); - + /// = ServantBase Methods virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); @@ -52,10 +55,17 @@ public: /// TAO_NS_Destroy_Callback methods virtual void release (void); + /// Accesor for the default filter factory shared by all EC's. + virtual CosNotifyFilter::FilterFactory_ptr get_default_filter_factory (ACE_ENV_SINGLE_ARG_DECL); + protected: /// = Data Members + /// The default filter factory. + CosNotifyFilter::FilterFactory_var default_filter_factory_; + /// = CosNotifyChannelAdmin Methods + virtual ::CosNotifyChannelAdmin::EventChannel_ptr create_channel ( const CosNotification::QoSProperties & initial_qos, const CosNotification::AdminProperties & initial_admin, @@ -68,7 +78,7 @@ public: )); virtual ::CosNotifyChannelAdmin::ChannelIDSeq * get_all_channels ( - + ) ACE_THROW_SPEC (( CORBA::SystemException diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl index 13066cdc8f8..0db217ba45b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl @@ -1,4 +1,3 @@ - // $Id$ #include "EventChannelFactory.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp index d6e41458ec2..ccee7778d4f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp @@ -27,7 +27,7 @@ TAO_NS_EventType::init_i (const char* domain_name, const char* type_name) if (this->is_special () == 1) { this->event_type_.domain_name = (const char* )"*"; - this->event_type_.type_name = (const char* )"%ALL"; + this->event_type_.type_name = (const char* )"%ALL"; } this->recompute_hash (); @@ -78,7 +78,7 @@ TAO_NS_EventType& TAO_NS_EventType::operator=(const TAO_NS_EventType& event_type) { if (this == &event_type) - return *this; + return *this; this->init_i (event_type.event_type_.domain_name.in (),event_type.event_type_.type_name.in ()); @@ -121,4 +121,3 @@ TAO_NS_EventType::is_special (void) const else return 0; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp index 3f700123ab1..ad1bbe48cc6 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp @@ -18,7 +18,7 @@ TAO_NS_EventTypeSeq::TAO_NS_EventTypeSeq (const CosNotification::EventTypeSeq& e } void -TAO_NS_EventTypeSeq::populate (CosNotification::EventTypeSeq& event_type_seq) +TAO_NS_EventTypeSeq::populate (CosNotification::EventTypeSeq& event_type_seq) const { event_type_seq.length (this->size ()); @@ -76,3 +76,65 @@ TAO_NS_EventTypeSeq::remove_seq (const TAO_NS_EventTypeSeq& event_type_seq) for (iter.first (); iter.next (event_type); iter.advance ()) inherited::remove (*event_type); } + +void +TAO_NS_EventTypeSeq::init (TAO_NS_EventTypeSeq& seq_added, TAO_NS_EventTypeSeq& seq_remove_seq) +{ + const TAO_NS_EventType& special = TAO_NS_EventType::special (); + + if (this->find (special) == 0) + { + if (seq_added.find (special) == 0) + { + seq_added.reset (); + seq_remove_seq.reset (); + } + else + { + this->reset (); + this->insert_seq (seq_added); + + seq_remove_seq.reset (); + seq_remove_seq.insert (special); + } + } + else + { + if (seq_added.find (special) == 0) + { + if (seq_remove_seq.find (special) == 0) + { + seq_added.reset (); + seq_remove_seq.reset (); + } + else + { + seq_remove_seq.reset (); + seq_remove_seq.insert_seq (*this); + + this->reset (); + this->insert (special); + + seq_added.reset (); + seq_added.insert (special); + } + } + else + { + if (seq_remove_seq.find (special) == 0) + { + + seq_remove_seq.reset (); + seq_remove_seq.insert_seq (*this); + + this->reset (); + this->insert_seq (seq_added); + } + else + { + this->insert_seq (seq_added); + this->remove_seq (seq_remove_seq); + } + } + } +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h index a6264246751..cad64ad4596 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h @@ -38,6 +38,9 @@ public: TAO_NS_EventTypeSeq (void); TAO_NS_EventTypeSeq (const CosNotification::EventTypeSeq& event_type_seq); + /// Preprocess the types added and removed. + void init (TAO_NS_EventTypeSeq& added, TAO_NS_EventTypeSeq& removed); + /// insert_seq the contents of <event_type_seq> into this object. void insert_seq (const CosNotification::EventTypeSeq& event_type_seq); @@ -51,7 +54,7 @@ public: void remove_seq (const TAO_NS_EventTypeSeq& event_type_seq); /// Populate <event_type_seq> with the contents of this object. - void populate (CosNotification::EventTypeSeq& event_type_seq); + void populate (CosNotification::EventTypeSeq& event_type_seq) const; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp index dd137a25381..bcf4743dfa8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp @@ -9,13 +9,25 @@ ACE_RCSID(RT_Notify, TAO_NS_Event_Manager, "$Id$") +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" + #include "EventTypeSeq.h" #include "Event.h" +#include "Peer.h" +#include "Consumer.h" +#include "ProxyConsumer.h" +#include "ProxySupplier.h" + #include "Event_Map_T.h" -#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Dispatch_Observer_T.h" +#include "Pending_Worker_T.h" +#include "Event_Map_Observer_T.h" TAO_NS_Event_Manager::TAO_NS_Event_Manager (void) - :consumer_map_ (0), supplier_map_ (0), broadcast_list_ (0) + :consumer_map_ (0), supplier_map_ (0), + consumer_map_observer_ (0), supplier_map_observer_ (0), + event_dispatch_observer_(0), updates_dispatch_observer_ (0), + event_pending_worker_ (0), updates_pending_worker_ (0) { } @@ -23,31 +35,103 @@ TAO_NS_Event_Manager::~TAO_NS_Event_Manager () { if (TAO_debug_level > 0) { - ACE_DEBUG ((LM_DEBUG, "destroying consumer/supplier map count = %d/%d, \n", - this->consumer_map_->count (), this->supplier_map_->count ())); + ACE_DEBUG ((LM_DEBUG, "destroying consumer/supplier map count = %d/%d, \n", + this->consumer_map_->event_type_count (), this->supplier_map_->event_type_count ())); } delete this->consumer_map_; delete this->supplier_map_; + delete this->consumer_map_observer_; + delete this->supplier_map_observer_; + delete this->event_dispatch_observer_; + delete this->updates_dispatch_observer_; + delete this->event_pending_worker_; + delete this->updates_pending_worker_; } void TAO_NS_Event_Manager::init (ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW_THROW_EX (this->consumer_map_, - TAO_NS_Consumer_Map (), - CORBA::NO_MEMORY ()); + TAO_NS_Consumer_Map (), + CORBA::NO_MEMORY ()); ACE_CHECK; - + ACE_NEW_THROW_EX (this->supplier_map_, - TAO_NS_Supplier_Map (), - CORBA::NO_MEMORY ()); + TAO_NS_Supplier_Map (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->consumer_map_observer_, + TAO_NS_Consumer_Map_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + + ACE_NEW_THROW_EX (this->supplier_map_observer_, + TAO_NS_Supplier_Map_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->event_dispatch_observer_, + TAO_NS_Event_Dispatch_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->updates_dispatch_observer_, + TAO_NS_Updates_Dispatch_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->event_pending_worker_, + TAO_NS_Event_Pending_Worker (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->updates_pending_worker_, + TAO_NS_Updates_Pending_Worker (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + this->consumer_map_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->supplier_map_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->event_dispatch_observer_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->updates_dispatch_observer_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->consumer_map_observer_->init (this->supplier_map_, this->updates_dispatch_observer_ ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->supplier_map_observer_->init (this->consumer_map_, this->updates_dispatch_observer_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->consumer_map_->attach_observer (this->consumer_map_observer_); + this->supplier_map_->attach_observer (this->supplier_map_observer_); + + this->event_pending_worker_->init (this->event_dispatch_observer_, TAO_NS_PROPERTIES::instance()->update_period () ACE_ENV_ARG_PARAMETER); ACE_CHECK; - - broadcast_list_ = consumer_map_->create_entry (TAO_NS_EventType::special () ACE_ENV_ARG_PARAMETER); + + if (TAO_NS_PROPERTIES::instance()->updates () == 0) + this->updates_pending_worker_->worker_suspend (); + + this->updates_pending_worker_->init (this->updates_dispatch_observer_, TAO_NS_PROPERTIES::instance()->update_period () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_Event_Manager::shutdown (void) +{ + this->event_pending_worker_->shutdown (); + this->updates_pending_worker_->shutdown (); } -void +void TAO_NS_Event_Manager::subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) { TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); @@ -61,7 +145,7 @@ TAO_NS_Event_Manager::subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO } } -void +void TAO_NS_Event_Manager::un_subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) { TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); @@ -75,21 +159,22 @@ TAO_NS_Event_Manager::un_subscribe (TAO_NS_ProxySupplier* proxy_supplier, const } } -void +void TAO_NS_Event_Manager::publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) { TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); - + TAO_NS_EventType* event_type = 0; for (iter.first (); iter.next (event_type) != 0; iter.advance ()) { supplier_map_->insert (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } } -void +void TAO_NS_Event_Manager::un_publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) { TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h index 7222344e895..eddef6ed5b6 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h @@ -21,12 +21,11 @@ #include "Types.h" -class TAO_NS_EventTypeSeq; /** * @class TAO_NS_Event_Manager * - * @brief A class that manages the Consumer and Supplier maps. + * @brief A class that manages the Consumer and Supplier maps. * */ class TAO_Notify_Export TAO_NS_Event_Manager @@ -36,11 +35,14 @@ public: TAO_NS_Event_Manager (void); /// Destructor - ~TAO_NS_Event_Manager (); + ~TAO_NS_Event_Manager (); /// Init void init (ACE_ENV_SINGLE_ARG_DECL); + /// Init + void shutdown (void); + /// Subscribe <proxy_supplier> to the event type sequence list <seq>. void subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL); @@ -57,6 +59,12 @@ public: TAO_NS_Consumer_Map* consumer_map (void); TAO_NS_Supplier_Map* supplier_map (void); + /// Event Dispatch Observer + TAO_NS_Event_Dispatch_Observer* event_dispatch_observer (void); + + /// Update dispatch observer. + TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer (void); + protected: /// Consumer Map TAO_NS_Consumer_Map* consumer_map_; @@ -64,8 +72,23 @@ protected: /// Supplier Map TAO_NS_Supplier_Map* supplier_map_; - /// Cache the list that always gets events. - TAO_NS_Consumer_Collection* broadcast_list_; + /// Consumer Map Observer + TAO_NS_Consumer_Map_Observer* consumer_map_observer_; + + /// Supplier Map Observer + TAO_NS_Supplier_Map_Observer* supplier_map_observer_; + + /// Event Dispatch Observer. + TAO_NS_Event_Dispatch_Observer* event_dispatch_observer_; + + /// Update dispatch observer. + TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer_; + + /// Worker task that dispatches pending events. + TAO_NS_Event_Pending_Worker* event_pending_worker_; + + /// Worker task that dispatches pending update messges. + TAO_NS_Updates_Pending_Worker* updates_pending_worker_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl index 848d3f4945a..590886dd9e4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl @@ -1,6 +1,7 @@ // $Id$ #include "Event_Manager.h" +#include "Event_Map_T.h" ACE_INLINE TAO_NS_Consumer_Map* TAO_NS_Event_Manager::consumer_map (void) @@ -13,3 +14,16 @@ TAO_NS_Event_Manager::supplier_map (void) { return supplier_map_; } + +ACE_INLINE TAO_NS_Event_Dispatch_Observer* +TAO_NS_Event_Manager::event_dispatch_observer (void) +{ + return this->event_dispatch_observer_; +} + +ACE_INLINE TAO_NS_Updates_Dispatch_Observer* +TAO_NS_Event_Manager::updates_dispatch_observer (void) +{ + return this->updates_dispatch_observer_; +} + diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp new file mode 100644 index 00000000000..5b886cbfa25 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#include "Event_Map_Entry_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Map_Entry_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Event_Map_Entry_T, "$id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Properties.h" +#include "Factory.h" + +template <class PROXY> +TAO_NS_Event_Map_Entry_T<PROXY>::TAO_NS_Event_Map_Entry_T (void) + : collection_ (0), count_ (0) +{ +} + +template <class PROXY> +TAO_NS_Event_Map_Entry_T<PROXY>::~TAO_NS_Event_Map_Entry_T () +{ + delete collection_; +} + +template <class PROXY> void +TAO_NS_Event_Map_Entry_T<PROXY>::init (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + factory->create (collection_ ACE_ENV_ARG_PARAMETER); +} + +template <class PROXY> void +TAO_NS_Event_Map_Entry_T<PROXY>::connected (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->collection_->connected (proxy ACE_ENV_ARG_PARAMETER); + ++count_; +} + +template <class PROXY> void +TAO_NS_Event_Map_Entry_T<PROXY>::disconnected (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->collection_->disconnected (proxy ACE_ENV_ARG_PARAMETER); + --count_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h new file mode 100644 index 00000000000..a5017db05b2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Entry_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_MAP_ENTRY_T_H +#define TAO_NS_EVENT_MAP_ENTRY_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Copy_Disabled.h" +#include "types.h" + +template <class PROXY, class ACE_LOCK> class TAO_NS_Event_Map_T; + +/** + * @class TAO_NS_Event_Map_Entry_T + * + * @brief The entry stored in the event map. + * + */ +template <class PROXY> +class TAO_NS_Event_Map_Entry_T : private ACE_Copy_Disabled +{ +public: + typedef TAO_ESF_Proxy_Collection<PROXY> COLLECTION; + + /// Constructor + TAO_NS_Event_Map_Entry_T (void); + + /// Destructor + ~TAO_NS_Event_Map_Entry_T (void); + + /// Init - Allocates collection + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Connect + void connected (PROXY* proxy ACE_ENV_ARG_DECL); + + /// Disconnect + void disconnected (PROXY* proxy ACE_ENV_ARG_DECL); + + /// Collection accessor + COLLECTION* collection (void); + + /// Count accessor + int count (void); + +protected: + /// The Collection + COLLECTION* collection_; + + /// Count of PROXY's connected in the collection; + int count_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Map_Entry_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Event_Map_Entry_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Map_Entry_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MAP_ENTRY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl new file mode 100644 index 00000000000..5877d0c4799 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl @@ -0,0 +1,15 @@ +// $Id$ + +#include "Event_Map_Entry_T.h" + +template <class PROXY> ACE_INLINE TAO_NS_Event_Map_Entry_T<PROXY>::COLLECTION* +TAO_NS_Event_Map_Entry_T<PROXY>::collection (void) +{ + return collection_; +} + +template <class PROXY> ACE_INLINE int +TAO_NS_Event_Map_Entry_T<PROXY>::count (void) +{ + return this->count_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer.h new file mode 100644 index 00000000000..8b0887560d6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Observer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_MAP_OBSERVER_H +#define TAO_NS_EVENT_MAP_OBSERVER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_NS_Event_Map_Observer + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Event_Map_Observer +{ +public: + /// <event_type> was seen for the first time in the event map. + virtual void type_added (const TAO_NS_EventType& event_type) = 0; + + /// <event_type> does not have any proxy interested in it. + virtual void type_removed (const TAO_NS_EventType& event_type) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MAP_OBSERVER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp new file mode 100644 index 00000000000..255cd09c057 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp @@ -0,0 +1,99 @@ +// $Id$ + +#include "Event_Map_Observer_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Map_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_Event_Map_Observer_T, "$id$") + +#include "Proxy.h" +#include "Peer.h" +#include "Dispatch_Observer_T.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Event_Map_T.h" + +/******************************************************************************************/ + +template <class PROXY> +TAO_NS_Update_Added_Worker<PROXY>::TAO_NS_Update_Added_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer) + :event_type_ (event_type), dispatch_observer_ (dispatch_observer) +{ +} + +template <class PROXY> void +TAO_NS_Update_Added_Worker<PROXY>::work (PROXY* proxy ACE_ENV_ARG_DECL) +{ + proxy->peer()->type_added (this->event_type_); + this->dispatch_observer_->enqueue (proxy->peer()); // Tell the observer that this peer has a update pending. +} + +/******************************************************************************************/ + +template <class PROXY> +TAO_NS_Update_Removed_Worker<PROXY>::TAO_NS_Update_Removed_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer) + :event_type_ (event_type), dispatch_observer_ (dispatch_observer) +{ +} + +template <class PROXY> void +TAO_NS_Update_Removed_Worker<PROXY>::work (PROXY* proxy ACE_ENV_ARG_DECL) +{ + proxy->peer()->type_removed (this->event_type_); + this->dispatch_observer_->enqueue (proxy->peer()); // Tell the observer that this peer has a update pending. +} + +/******************************************************************************************/ + +template <class PROXY> +TAO_NS_Event_Map_Observer_T<PROXY>::TAO_NS_Event_Map_Observer_T (void) + :event_map_ (0), dispatch_observer_ (0) +{ +} + +template <class PROXY> +TAO_NS_Event_Map_Observer_T<PROXY>::~TAO_NS_Event_Map_Observer_T () +{ +} + +template <class PROXY> void +TAO_NS_Event_Map_Observer_T<PROXY>::init (EVENT_MAP* event_map, TAO_NS_Updates_Dispatch_Observer* dispatch_observer) +{ + this->event_map_ = event_map; + this->dispatch_observer_ = dispatch_observer; +} + +template <class PROXY> void +TAO_NS_Event_Map_Observer_T<PROXY>::type_added (const TAO_NS_EventType& event_type) +{ + UPDATE_ADDED_WORKER worker (event_type, this->dispatch_observer_); + + PROXY_COLLECTION* proxys = this->event_map_->find (event_type ACE_ENV_ARG_PARAMETER); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); + + // Get the default broadcast collection. + proxys = this->event_map_->broadcast_collection (); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +template <class PROXY> void +TAO_NS_Event_Map_Observer_T<PROXY>::type_removed (const TAO_NS_EventType& event_type) +{ + UPDATE_REMOVED_WORKER worker (event_type, this->dispatch_observer_); + + PROXY_COLLECTION* proxys = this->event_map_->find (event_type ACE_ENV_ARG_PARAMETER); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); + + // Get the default broadcast collection. + proxys = this->event_map_->broadcast_collection (); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.h new file mode 100644 index 00000000000..4f01f9eaafa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.h @@ -0,0 +1,126 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Observer_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_EVENT_MAP_OBSERVER_T_H +#define TAO_EVENT_MAP_OBSERVER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Types.h" +#include "Event_Map_Observer.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +/** + * @class TAO_NS_Update_Added_Worker_T + * + * @brief Inform Peers of new offered type. + * + */ +template <class PROXY> +class TAO_Notify_Export TAO_NS_Update_Added_Worker : public TAO_ESF_Worker<PROXY> +{ +public: + TAO_NS_Update_Added_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer); + +protected: + ///= TAO_ESF_Worker method + void work (PROXY* proxy ACE_ENV_ARG_DECL); + + const TAO_NS_EventType& event_type_; + + /// Updates Observer. + TAO_NS_Updates_Dispatch_Observer* dispatch_observer_; +}; + +/*******************************************************************************************/ + + +/** + * @class TAO_NS_Update_Removed_Worker_T + * + * @brief Inform Peers of offered type removed. + * + */ +template <class PROXY> +class TAO_Notify_Export TAO_NS_Update_Removed_Worker : public TAO_ESF_Worker<PROXY> +{ +public: + TAO_NS_Update_Removed_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer); + +protected: + ///= TAO_ESF_Worker method + void work (PROXY* proxy ACE_ENV_ARG_DECL); + + const TAO_NS_EventType& event_type_; + + /// Updates Observer. + TAO_NS_Updates_Dispatch_Observer* dispatch_observer_; +}; + +/*******************************************************************************************/ + +/** + * @class TAO_Event_Map_Observer_T + * + * @brief Observe significant changes to the Event Map. + * + */ +template <class PROXY> +class TAO_Notify_Export TAO_NS_Event_Map_Observer_T : public TAO_NS_Event_Map_Observer +{ + typedef TAO_NS_Event_Map_T<PROXY, TAO_SYNCH_RW_MUTEX> EVENT_MAP; + typedef TAO_NS_Update_Added_Worker<PROXY> UPDATE_ADDED_WORKER; + typedef TAO_NS_Update_Removed_Worker<PROXY> UPDATE_REMOVED_WORKER; + typedef TAO_ESF_Proxy_Collection<PROXY> PROXY_COLLECTION; + +public: + /// Constructor + TAO_NS_Event_Map_Observer_T (void); + + /// Destructor + ~TAO_NS_Event_Map_Observer_T (); + + /// Set the inverse event map and the updates dispatch observer. + void init (EVENT_MAP* event_map, TAO_NS_Updates_Dispatch_Observer* dispatch_observer); + + /// <event_type> was seen for the first time in the event map. + virtual void type_added (const TAO_NS_EventType& event_type); + + /// <event_type> does not have any proxy interested in it. + virtual void type_removed (const TAO_NS_EventType& event_type); + +protected: + /// Event Map + EVENT_MAP* event_map_; + + /// Updates Observer. + TAO_NS_Updates_Dispatch_Observer* dispatch_observer_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Map_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Event_Map_Observer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Map_Observer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_EVENT_MAP_OBSERVER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.inl new file mode 100644 index 00000000000..64d00a6df8f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "Event_Map_Observer_T.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp index 9adf05f6298..c48383c378e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp @@ -4,9 +4,11 @@ #define TAO_NS_EVENT_MAP_T_C #include "Event_Map_T.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Event_Map_Entry_T.h" #include "Properties.h" #include "Factory.h" -#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Event_Map_Observer.h" #if ! defined (__ACE_INLINE__) #include "Event_Map_T.inl" @@ -14,45 +16,9 @@ ACE_RCSID(RT_Notify, TAO_NS_Event_Map_T, "$Id$") -template <class PROXY> -TAO_NS_Event_Map_Entry_T<PROXY>::TAO_NS_Event_Map_Entry_T (void) - : collection_ (0), count_ (0) -{ -} - -template <class PROXY> -TAO_NS_Event_Map_Entry_T<PROXY>::~TAO_NS_Event_Map_Entry_T () -{ - delete collection_; -} - -template <class PROXY> void -TAO_NS_Event_Map_Entry_T<PROXY>::init (ACE_ENV_SINGLE_ARG_DECL) -{ - TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); - - factory->create (collection_ ACE_ENV_ARG_PARAMETER); -} - -template <class PROXY> void -TAO_NS_Event_Map_Entry_T<PROXY>::connected (PROXY* proxy ACE_ENV_ARG_DECL) -{ - this->collection_->connected (proxy ACE_ENV_ARG_PARAMETER); - ++count_; -} - -template <class PROXY> void -TAO_NS_Event_Map_Entry_T<PROXY>::disconnected (PROXY* proxy ACE_ENV_ARG_DECL) -{ - this->collection_->disconnected (proxy ACE_ENV_ARG_PARAMETER); - --count_; -} - -/*****************************************************************************/ - template <class PROXY, class ACE_LOCK> TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::TAO_NS_Event_Map_T (void) - :count_ (0) + :event_type_count_ (0), broadcast_collection_ (0), observer_ (0) { } @@ -62,7 +28,14 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::~TAO_NS_Event_Map_T () { } -template <class PROXY, class ACE_LOCK> TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::COLLECTION* +template <class PROXY, class ACE_LOCK> void +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::init (ACE_ENV_SINGLE_ARG_DECL) +{ + broadcast_collection_ = this->create_entry (TAO_NS_EventType::special () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +template <class PROXY, class ACE_LOCK> TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::COLLECTION* TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::create_entry (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) { TAO_NS_Event_Map_Entry_T<PROXY>* entry; @@ -71,15 +44,15 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::create_entry (const TAO_NS_EventType& event { ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0); - + result = this->map_.find (event_type, entry); } if (result == -1) { ACE_NEW_THROW_EX (entry, - ENTRY (), - CORBA::NO_MEMORY ()); + ENTRY (), + CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (0); entry->init (ACE_ENV_SINGLE_ARG_PARAMETER); @@ -88,7 +61,7 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::create_entry (const TAO_NS_EventType& event ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0); if (map_.bind (event_type, entry) == -1) - ACE_THROW_RETURN (CORBA::NO_MEMORY (), 0); + ACE_THROW_RETURN (CORBA::NO_MEMORY (), 0); } return entry->collection (); @@ -110,14 +83,14 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::insert (PROXY* proxy, const TAO_NS_EventTyp if (result == -1) { ACE_NEW_THROW_EX (entry, - ENTRY (), - CORBA::NO_MEMORY ()); + ENTRY (), + CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (-1); entry->init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - entry->connected (proxy ACE_ENV_ARG_PARAMETER); + entry->connected (proxy ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); @@ -125,7 +98,10 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::insert (PROXY* proxy, const TAO_NS_EventTyp if (map_.bind (event_type, entry) == -1) ACE_THROW_RETURN (CORBA::NO_MEMORY (), -1); - return ++count_; + if (this->observer_ != 0) + this->observer_->type_added (event_type); + + return ++event_type_count_; } else { @@ -133,7 +109,7 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::insert (PROXY* proxy, const TAO_NS_EventTyp ACE_CHECK_RETURN (-1); ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - return ++count_; + return ++event_type_count_; } } @@ -154,23 +130,22 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::remove (PROXY* proxy, const TAO_NS_EventTyp entry->disconnected (proxy ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - return --count_; + ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + return --event_type_count_; if (entry->count () == 0) - { - /// @@TODO: Exec a strategy for removing entries. - } + { + if (this->observer_ != 0) + this->observer_->type_removed (event_type); + + /// @@TODO: Exec a strategy for removing entries. + /// Strategy 1: remove_immediately + /// Strategy 2: remove_bunch_after_threshold + /// Strategy 3: use cached allocator + } } return -1; } -template <class PROXY, class ACE_LOCK> int -TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::count (void) -{ - return this->count_; -} - #endif /* TAO_NS_EVENT_MAP_T_C */ - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h index 4b7fd107bcd..22eccd88c42 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h @@ -20,52 +20,11 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Hash_Map_Manager.h" -#include "ace/Copy_Disabled.h" #include "Types.h" #include "EventType.h" +#include "Event_Map_Entry_T.h" -template <class PROXY, class ACE_LOCK> class TAO_NS_Event_Map_T; - -/** - * @class TAO_NS_Event_Map_Entry_T - * - * @brief The entry stored in the event map. - * - */ -template <class PROXY> -class TAO_NS_Event_Map_Entry_T : private ACE_Copy_Disabled -{ -public: - typedef TAO_ESF_Proxy_Collection<PROXY> COLLECTION; - - /// Constructor - TAO_NS_Event_Map_Entry_T (void); - - /// Destructor - ~TAO_NS_Event_Map_Entry_T (void); - - /// Init - Allocates collection - void init (ACE_ENV_SINGLE_ARG_DECL); - - /// Connect - void connected (PROXY* proxy ACE_ENV_ARG_DECL); - - /// Disconnect - void disconnected (PROXY* proxy ACE_ENV_ARG_DECL); - - /// Collection accessor - COLLECTION* collection (void); - - /// Count accessor - int count (void); - -protected: - /// The Collection - COLLECTION* collection_; - - /// Count of PROXY's connected in the collection; - int count_; -}; +class TAO_NS_Event_Map_Observer; /** * @class TAO_NS_Event_Map_T @@ -84,9 +43,15 @@ public: TAO_NS_Event_Map_T (void); /// Destructor - ~TAO_NS_Event_Map_T (); + ~TAO_NS_Event_Map_T (); - /// An entry can be precreated for an event_type. else it is created when required (during insert). + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Attach an Observer. + void attach_observer (TAO_NS_Event_Map_Observer* observer); + + /// An entry can be precreated for an event_type. else it is created when required (during insert). COLLECTION* create_entry (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); /// Associate PROXY and event_type. returns count of PROXYs. @@ -95,11 +60,14 @@ public: /// Remove association of PROXY and event_type. returns count of PROXYs. int remove (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); - /// Find the collection mapped mapped to the <event_type> + /// Find the collection mapped to the <event_type> COLLECTION* find (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); - /// Access count - int count (void); + /// Find the default broadcast list. + COLLECTION* broadcast_collection (void); + + /// Access count, number of different event types in the map. + int event_type_count (void); protected: /// The Map that stores eventtype to entry mapping. @@ -109,7 +77,13 @@ protected: ACE_LOCK lock_; /// Count of items entered in the map. - int count_; + int event_type_count_; + + /// The default broadcast list for EventType::special. + COLLECTION* broadcast_collection_; + + /// Observer attached to us. + TAO_NS_Event_Map_Observer* observer_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl index 9aa02f7707b..c6c4f204b08 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl @@ -2,18 +2,6 @@ #include "Event_Map_T.h" -template <class PROXY> ACE_INLINE TAO_NS_Event_Map_Entry_T<PROXY>::COLLECTION* -TAO_NS_Event_Map_Entry_T<PROXY>::collection (void) -{ - return collection_; -} - -template <class PROXY> ACE_INLINE int -TAO_NS_Event_Map_Entry_T<PROXY>::count (void) -{ - return count_; -} - template <class PROXY, class ACE_LOCK> ACE_INLINE TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::COLLECTION* TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::find (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) { @@ -26,3 +14,21 @@ TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::find (const TAO_NS_EventType& event_type AC else return 0; } + +template <class PROXY, class ACE_LOCK> ACE_INLINE TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::COLLECTION* +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::broadcast_collection (void) +{ + return this->broadcast_collection_; +} + +template <class PROXY, class ACE_LOCK> ACE_INLINE void +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::attach_observer (TAO_NS_Event_Map_Observer* observer) +{ + this->observer_ = observer; +} + +template <class PROXY, class ACE_LOCK> ACE_INLINE int +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::event_type_count (void) +{ + return this->event_type_count_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp index cb5af284a7f..3a4eecdde33 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp @@ -20,7 +20,7 @@ ACE_RCSID(RN_Notify, TAO_NS_Factory, "$Id$") - + TAO_NS_Factory::TAO_NS_Factory (void) { } @@ -46,47 +46,69 @@ TAO_NS_Factory::create (TAO_NS_QoSAdmin*& qos_admin ACE_ENV_SINGLE_ARG_DECL) } void -TAO_NS_Factory::create (TAO_NS_Supplier_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) +TAO_NS_Factory::create (TAO_NS_Peer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Peer>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Peer, TAO_ESF_Proxy_List<TAO_NS_Peer>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_ProxyConsumer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) { typedef TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>::Iterator ProxyIterator; - typedef TAO_ESF_Copy_On_Write<TAO_NS_ProxyConsumer, TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>,ProxyIterator, ACE_SYNCH> ProxyType; - + typedef TAO_ESF_Copy_On_Write<TAO_NS_ProxyConsumer, TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>,ProxyIterator, ACE_SYNCH> ProxyType; + ACE_NEW_THROW_EX (collection, - ProxyType (), - CORBA::NO_MEMORY ()); + ProxyType (), + CORBA::NO_MEMORY ()); } void -TAO_NS_Factory::create (TAO_NS_Consumer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) +TAO_NS_Factory::create (TAO_NS_ProxySupplier_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) { typedef TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>::Iterator ProxyIterator; - typedef TAO_ESF_Copy_On_Write<TAO_NS_ProxySupplier, TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>,ProxyIterator, ACE_SYNCH> ProxyType; - + typedef TAO_ESF_Copy_On_Write<TAO_NS_ProxySupplier, TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_Consumer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Consumer>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Consumer, TAO_ESF_Proxy_List<TAO_NS_Consumer>,ProxyIterator, ACE_SYNCH> ProxyType; + ACE_NEW_THROW_EX (collection, - ProxyType (), - CORBA::NO_MEMORY ()); + ProxyType (), + CORBA::NO_MEMORY ()); } void TAO_NS_Factory::create (TAO_NS_EventChannel_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) { typedef TAO_ESF_Proxy_List<TAO_NS_EventChannel>::Iterator ProxyIterator; - typedef TAO_ESF_Copy_On_Write<TAO_NS_EventChannel, TAO_ESF_Proxy_List<TAO_NS_EventChannel>,ProxyIterator, ACE_SYNCH> ProxyType; - + typedef TAO_ESF_Copy_On_Write<TAO_NS_EventChannel, TAO_ESF_Proxy_List<TAO_NS_EventChannel>,ProxyIterator, ACE_SYNCH> ProxyType; + ACE_NEW_THROW_EX (collection, - ProxyType (), - CORBA::NO_MEMORY ()); + ProxyType (), + CORBA::NO_MEMORY ()); } void TAO_NS_Factory::create (TAO_NS_Admin_Collection*& collection ACE_ENV_SINGLE_ARG_DECL) { typedef TAO_ESF_Proxy_List<TAO_NS_Admin>::Iterator ProxyIterator; - typedef TAO_ESF_Copy_On_Write<TAO_NS_Admin, TAO_ESF_Proxy_List<TAO_NS_Admin>,ProxyIterator, ACE_SYNCH> ProxyType; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Admin, TAO_ESF_Proxy_List<TAO_NS_Admin>,ProxyIterator, ACE_SYNCH> ProxyType; ACE_NEW_THROW_EX (collection, - ProxyType (), - CORBA::NO_MEMORY ()); + ProxyType (), + CORBA::NO_MEMORY ()); } void @@ -96,11 +118,11 @@ TAO_NS_Factory::create (TAO_NS_Proxy_Collection*& collection ACE_ENV_SINGLE_ARG_ typedef TAO_ESF_Copy_On_Write<TAO_NS_Proxy,TAO_ESF_Proxy_List<TAO_NS_Proxy>,ProxyIterator,ACE_SYNCH> ProxyType; ACE_NEW_THROW_EX (collection, - ProxyType (), - CORBA::NO_MEMORY ()); + ProxyType (), + CORBA::NO_MEMORY ()); } -void +void TAO_NS_Factory::create (TAO_NS_EventChannelFactory*& factory ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW_THROW_EX (factory, diff --git a/TAO/orbsvcs/orbsvcs/Notify/Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Factory.h index 0e80465d7fd..a3c7dd6ec47 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Factory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Factory.h @@ -46,7 +46,7 @@ public: TAO_NS_Factory (void); /// Destructor - virtual ~TAO_NS_Factory (); + virtual ~TAO_NS_Factory (); /// Create Object Lock. virtual ACE_Lock* create_object_lock (ACE_ENV_SINGLE_ARG_DECL); @@ -55,19 +55,22 @@ public: virtual void create (TAO_NS_QoSAdmin*& qos_admin ACE_ENV_SINGLE_ARG_DECL); /// Create Collection - virtual void create (TAO_NS_Supplier_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); - virtual void create (TAO_NS_Consumer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_ProxySupplier_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_ProxyConsumer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); virtual void create (TAO_NS_EventChannel_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); virtual void create (TAO_NS_Admin_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); virtual void create (TAO_NS_Proxy_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_Peer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_Consumer_Collection*& collection ACE_ENV_SINGLE_ARG_DECL); + /// Create EventChannelFactory virtual void create (TAO_NS_EventChannelFactory*& channel_factory ACE_ENV_SINGLE_ARG_DECL); - + /// Create EventChannel virtual void create (TAO_NS_EventChannel*& channel ACE_ENV_SINGLE_ARG_DECL); - + /// Create SupplierAdmin virtual void create (TAO_NS_SupplierAdmin*& admin ACE_ENV_SINGLE_ARG_DECL); @@ -75,10 +78,10 @@ public: virtual void create (TAO_NS_ConsumerAdmin*& admin ACE_ENV_SINGLE_ARG_DECL); /// Create StructuredProxyPushConsumer - virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_SINGLE_ARG_DECL); - + virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_SINGLE_ARG_DECL); + /// Create StructuredProxyPushSupplier - virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_SINGLE_ARG_DECL); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp new file mode 100644 index 00000000000..9a93765627a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp @@ -0,0 +1,158 @@ +/* -*- C++ -*- $Id$ */ +#include "FilterAdmin.h" +#include "ace/Refcounted_Auto_Ptr.h" + +ACE_RCSID(Notify, FilterAdmin, "$Id$") + +// Implementation skeleton constructor +TAO_NS_FilterAdmin::TAO_NS_FilterAdmin (void) +{ +} + +// Implementation skeleton destructor +TAO_NS_FilterAdmin::~TAO_NS_FilterAdmin (void) +{ +} + +CORBA::Boolean +TAO_NS_FilterAdmin::match (TAO_NS_Event_var &event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )) +{ + // If no filter is active, treat it as a '*' i.e, let all events pass. + // or if its the special type, let it pass. + if (this->filter_list_.current_size () == 0) // || event.is_special_event_type ()) + return 1; + + // We want to return true if atleast one constraint matches. + FILTER_LIST::ITERATOR iter (this->filter_list_); + FILTER_LIST::ENTRY *entry; + CORBA::Boolean ret_val = 0; + + for (; iter.next (entry); iter.advance ()) + { + ret_val = event->do_match (entry->int_id_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (ret_val == 1) + return 1; + } + + return 0; +} + +CosNotifyFilter::FilterID +TAO_NS_FilterAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (new_filter)) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + CosNotifyFilter::FilterID new_id = this->filter_ids_.id (); + + CosNotifyFilter::Filter_var new_filter_var = + CosNotifyFilter::Filter::_duplicate (new_filter); + + if (this->filter_list_.bind (new_id, new_filter_var) == -1) + ACE_THROW_RETURN (CORBA::INTERNAL (), + 0); + else + { + return new_id; + } +} + +void TAO_NS_FilterAdmin::remove_filter (CosNotifyFilter::FilterID filter_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + if (this->filter_list_.unbind (filter_id) == -1) + ACE_THROW (CosNotifyFilter::FilterNotFound ()); +} + +CosNotifyFilter::Filter_ptr +TAO_NS_FilterAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + CosNotifyFilter::Filter_var filter_var; + + if (this->filter_list_.find (filter, + filter_var) == -1) + ACE_THROW_RETURN (CosNotifyFilter::FilterNotFound (), + 0); + + return CosNotifyFilter::Filter::_duplicate (filter_var.in ()); +} + +CosNotifyFilter::FilterIDSeq* +TAO_NS_FilterAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + // Figure out the length of the list. + size_t len = this->filter_list_.current_size (); + + CosNotifyFilter::FilterIDSeq* list = 0; + + // Allocate the list of <len> length. + ACE_NEW_THROW_EX (list, + CosNotifyFilter::FilterIDSeq (len), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + list->length (len); + + FILTER_LIST_ITER iter (this->filter_list_); + FILTER_LIST_ENTRY *entry; + + u_int index; + + for (index = 0; iter.done () == 0; iter.advance (), ++index) + { + if (iter.next (entry) != 0) + { + list[index] = entry->ext_id_; + } + } + + return list; +} + +void +TAO_NS_FilterAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->filter_list_.unbind_all (); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Hash_Map_Entry<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var>; +template class ACE_Hash_Map_Manager<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class TAO_Notify_ID_Pool_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::FilterIDSeq>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Hash_Map_Entry<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var> +#pragma instantiate ACE_Hash_Map_Manager<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate TAO_Notify_ID_Pool_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::FilterIDSeq> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h new file mode 100644 index 00000000000..0f56bea1704 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h @@ -0,0 +1,88 @@ +//============================================================================= +/** + * @file FilterAdmin.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore <pradeep@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef NOTIFY_FILTERADMIN_H +#define NOTIFY_FILTERADMIN_H +#include "ace/pre.h" + +#include "orbsvcs/CosNotifyFilterS.h" +#include "ace/Hash_Map_Manager.h" +#include "ID_Factory.h" +#include "Event.h" +#include "notify_export.h" +#include "Types.h" + +/** + * @class TAO_NS_FilterAdmin + * + * @brief FilterAdmin interface methods implementation. + * + */ +class TAO_Notify_Export TAO_NS_FilterAdmin +{ + + public: + /// Constructor + TAO_NS_FilterAdmin (void); + + /// Destructor + virtual ~TAO_NS_FilterAdmin (void); + + // = match operation on all the filters + /// See if any of the filters match. + CORBA::Boolean match (TAO_NS_Event_var &event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CosNotifyFilter::FilterID add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )); + + virtual CosNotifyFilter::Filter_ptr get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )); + + virtual CosNotifyFilter::FilterIDSeq * get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + private: + typedef ACE_Hash_Map_Manager <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var, TAO_SYNCH_MUTEX> FILTER_LIST; + typedef ACE_Hash_Map_Iterator <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var, TAO_SYNCH_MUTEX> FILTER_LIST_ITER; + typedef ACE_Hash_Map_Entry <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var> FILTER_LIST_ENTRY; + + /// List of filters + FILTER_LIST filter_list_; + + /// Id generator for proxy suppliers + TAO_NS_ID_Factory filter_ids_; +}; + +#include "ace/post.h" +#endif /* NOTIFY_FILTERADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h new file mode 100644 index 00000000000..0f6b520589b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +/** + * @file FilterFactory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_FILTERFACTORY_H +#define TAO_NS_FILTERFACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Object.h" + +/** + * @class TAO_NS_FilterFactory + * + * @brief Service Object to obtain a CosNotifyFilter::FilterFactory reference. + * + */ +class /*TAO_Notify_Export*/ TAO_NS_FilterFactory : public ACE_Service_Object +{ +public: + /// Factory method to create a FilterFactory reference + /// The Factory is activated in the default POA. + virtual CosNotifyFilter::FilterFactory_ptr create (ACE_ENV_SINGLE_ARG_DECL) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_FILTERFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp index 60e7331d9f3..68ccfaec69b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp @@ -16,4 +16,3 @@ TAO_NS_Method_Request::TAO_NS_Method_Request (TAO_NS_Event_var& event) TAO_NS_Method_Request::~TAO_NS_Method_Request () { } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp index a03c637d0ca..b101ede6ac8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp @@ -3,6 +3,7 @@ #include "Method_Request_Dispatch.h" #include "ProxySupplier.h" #include "Consumer.h" +#include "tao/debug.h" #if ! defined (__ACE_INLINE__) #include "Method_Request_Dispatch.inl" @@ -29,10 +30,35 @@ TAO_NS_Method_Request_Dispatch::copy (void) int TAO_NS_Method_Request_Dispatch::call (void) { - ACE_DECLARE_NEW_CORBA_ENV; + ACE_DECLARE_NEW_CORBA_ENV; - this->event_->push (this->proxy_supplier_->consumer () ACE_ENV_ARG_PARAMETER); + CORBA::Boolean val = this->proxy_supplier_->check_filters (this->event_ ACE_ENV_ARG_PARAMETER); + + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG, "Proxysupplier %x filter eval result = %d",this->proxy_supplier_ , val)); + + // Filter failed - do nothing. + if (val == 0) + return 0; + + ACE_TRY + { + this->proxy_supplier_->consumer ()->push (this->event_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::UserException, ue) + { + ACE_PRINT_EXCEPTION (ue, + "TAO_NS_Method_Request_Dispatch::: error sending event. "); + //ACE_RE_THROW; + } + ACE_CATCH (CORBA::SystemException, se) + { + ACE_PRINT_EXCEPTION (se, + "TAO_NS_Method_Request_Dispatch::: error sending event. "); + //ACE_RE_THROW; + } + ACE_ENDTRY; return 0; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp new file mode 100644 index 00000000000..49176d45704 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp @@ -0,0 +1,55 @@ +// $Id$ + +#include "Method_Request_Dispatch_No_Filtering.h" +#include "ProxySupplier.h" +#include "Consumer.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Dispatch_No_Filtering.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Dispatch_No_Filtering, "$Id$") + +TAO_NS_Method_Request_Dispatch_No_Filtering::TAO_NS_Method_Request_Dispatch_No_Filtering (TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier) + : TAO_NS_Method_Request (event), proxy_supplier_ (proxy_supplier) +{ +} + +TAO_NS_Method_Request_Dispatch_No_Filtering::~TAO_NS_Method_Request_Dispatch_No_Filtering () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Dispatch_No_Filtering::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Dispatch_No_Filtering (this->event_, this->proxy_supplier_); +} + +int +TAO_NS_Method_Request_Dispatch_No_Filtering::call (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + this->proxy_supplier_->consumer ()->push (this->event_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::UserException, ue) + { + ACE_PRINT_EXCEPTION (ue, + "TAO_NS_Method_Request_Dispatch_No_Filtering::: error sending event. "); + //ACE_RE_THROW; + } + ACE_CATCH (CORBA::SystemException, se) + { + ACE_PRINT_EXCEPTION (se, + "TAO_NS_Method_Request_Dispatch_No_Filtering::: error sending event. "); + //ACE_RE_THROW; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h new file mode 100644 index 00000000000..a5180890f75 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h @@ -0,0 +1,56 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Dispatch_No_Filtering.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_DISPATCH_METHOD_REQUEST_NO_FILTERING_H +#define TAO_NS_DISPATCH_METHOD_REQUEST_NO_FILTERING_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Method_Request.h" +#include "Types.h" + +/** + * @class TAO_NS_Method_Request_Dispatch_No_Filtering + * + * @brief Dispatchs an event to a proxy supplier but does NOT perform filtering. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Dispatch_No_Filtering : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Dispatch_No_Filtering (TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier); + + /// Destructor + ~TAO_NS_Method_Request_Dispatch_No_Filtering (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute method. + virtual int call (void); + +private: + /// Proxy Supplier that we use. + TAO_NS_ProxySupplier* proxy_supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Dispatch_No_Filtering.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_DISPATCH_METHOD_REQUEST_NO_FILTERING_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl new file mode 100644 index 00000000000..56932a7ab41 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "Method_Request_Dispatch_No_Filtering.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp index b925033ddc3..bd25b092ed5 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp @@ -5,6 +5,7 @@ #include "Event_Map_T.h" #include "ProxySupplier.h" #include "ProxyConsumer.h" +#include "tao/debug.h" #if ! defined (__ACE_INLINE__) #include "Method_Request_Lookup.inl" @@ -31,11 +32,27 @@ TAO_NS_Method_Request_Lookup::copy (void) int TAO_NS_Method_Request_Lookup::call (void) { - ACE_DECLARE_NEW_CORBA_ENV; - - TAO_NS_Consumer_Collection* consumers = map_->find (this->event_->type () ACE_ENV_ARG_PARAMETER); - - consumers->for_each (this ACE_ENV_ARG_PARAMETER); + ACE_DECLARE_NEW_CORBA_ENV; + + CORBA::Boolean val = this->proxy_consumer_->check_filters (this->event_ ACE_ENV_ARG_PARAMETER); + + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG, "Proxyconsumer %x filter eval result = %d",this->proxy_consumer_ , val)); + + // Filter failed - do nothing. + if (val == 0) + return 0; + + TAO_NS_ProxySupplier_Collection* consumers = map_->find (this->event_->type () ACE_ENV_ARG_PARAMETER); + + if (consumers != 0) + consumers->for_each (this ACE_ENV_ARG_PARAMETER); + + // Get the default consumers + consumers = map_->broadcast_collection (); + + if (consumers != 0) + consumers->for_each (this ACE_ENV_ARG_PARAMETER); return 0; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h index 85db7dbba7f..8400c9753af 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h @@ -26,7 +26,7 @@ /** * @class TAO_NS_Method_Request_Lookup * - * @brief Lookup command object looks up the event type of the given event in the consumer map and send the event to each proxysupplier. + * @brief Lookup command object looks up the event type of the given event in the consumer map and send the event to each proxysupplier. * */ class TAO_Notify_Export TAO_NS_Method_Request_Lookup : public TAO_NS_Method_Request, public TAO_ESF_Worker<TAO_NS_ProxySupplier> @@ -36,7 +36,7 @@ public: TAO_NS_Method_Request_Lookup (TAO_NS_Event_var& event, TAO_NS_ProxyConsumer* proxy_consumer, TAO_NS_Consumer_Map* map); /// Destructor - ~TAO_NS_Method_Request_Lookup (); + ~TAO_NS_Method_Request_Lookup (); /// Create a copy of this object. TAO_NS_Method_Request* copy (void); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp index 084ac37bc93..eb11d18ace8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp @@ -18,7 +18,7 @@ TAO_NS_Method_Request_Shutdown::~TAO_NS_Method_Request_Shutdown () { } -int +int TAO_NS_Method_Request_Shutdown::call (void) { // Shut down the scheduler by deactivating the activation queue's @@ -27,4 +27,3 @@ TAO_NS_Method_Request_Shutdown::call (void) this->task_->msg_queue ()->deactivate (); return -1; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h index 9a35cc0b0a7..4d2e43d6eca 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h @@ -36,7 +36,7 @@ public: TAO_NS_Method_Request_Shutdown (TAO_NS_ThreadPool_Task* task); /// Destructor - ~TAO_NS_Method_Request_Shutdown (); + ~TAO_NS_Method_Request_Shutdown (); /// Execute method. virtual int call (void); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp index 17fcc006489..36c7a678205 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp @@ -1,6 +1,9 @@ // $Id$ #include "Notify_Service.h" + +#include "ace/Sched_Params.h" +#include "ace/Arg_Shifter.h" #include "tao/ORB_Core.h" #include "Builder.h" #include "Properties.h" @@ -9,6 +12,7 @@ ACE_RCSID(RT_Notify, TAO_NS_Notify_Service, "$Id$") TAO_NS_Notify_Service::TAO_NS_Notify_Service (void) +:factory_ (0), builder_ (0) { } @@ -18,6 +22,47 @@ TAO_NS_Notify_Service::~TAO_NS_Notify_Service () delete builder_; } +int +TAO_NS_Notify_Service::init (int argc, char *argv[]) +{ + ACE_Arg_Shifter arg_shifter (argc, argv); + + const ACE_TCHAR *current_arg = 0; + + while (arg_shifter.is_anything_left ()) + { + if (arg_shifter.cur_arg_strncasecmp ("-Updates") == 0) // -AsynchUpdates update_period_uS + { + arg_shifter.consume_arg (); + + current_arg = arg_shifter.get_current (); + + if (current_arg != 0) + { + ACE_Time_Value update_period (0, ACE_OS::atoi (current_arg)); + + + TAO_NS_PROPERTIES::instance()->updates (1); + TAO_NS_PROPERTIES::instance()->update_period (update_period); + } + } + else if (arg_shifter.cur_arg_strncasecmp ("-NoUpdates") == 0) // No Updates to begin with. + { + arg_shifter.consume_arg (); + + TAO_NS_PROPERTIES::instance()->updates (0); + } + } + + return 0; +} + +int +TAO_NS_Notify_Service::fini (void) +{ + return 0; +} + void TAO_NS_Notify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { @@ -30,6 +75,10 @@ TAO_NS_Notify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) void TAO_NS_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { + /// first, init the main thread. + //this->init_main_thread (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + // Obtain the Root POA CORBA::Object_var object = orb->resolve_initial_references("RootPOA" @@ -42,14 +91,15 @@ TAO_NS_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) PortableServer::POA_var default_poa = PortableServer::POA::_narrow (object.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; - + /// Set the properties TAO_NS_Properties* properties = TAO_NS_PROPERTIES::instance(); - + properties->default_poa (default_poa.in ()); properties->sched_policy (orb->orb_core ()->orb_params ()->sched_policy ()); properties->scope_policy (orb->orb_core ()->orb_params ()->scope_policy ()); + // Init the factory and builder this->init_factory (ACE_ENV_SINGLE_ARG_PARAMETER); @@ -60,11 +110,75 @@ TAO_NS_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) } void +TAO_NS_Notify_Service::init_main_thread (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + ACE_Sched_Params::Policy sched_policy; + long thr_sched_policy = orb->orb_core ()->orb_params ()->sched_policy (); + + long thr_scope_policy = orb->orb_core ()->orb_params ()->scope_policy (); + + if (thr_sched_policy == THR_SCHED_FIFO) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Sched policy = THR_SCHED_FIFO\n")); + + sched_policy = ACE_SCHED_FIFO; + } + else if (thr_sched_policy == THR_SCHED_RR) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Sched policy = THR_SCHED_RR\n")); + + sched_policy = ACE_SCHED_RR; + } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Sched policy = THR_SCHED_OTHER\n")); + + sched_policy = ACE_SCHED_OTHER; + } + + /// Check sched. + int min_priority = ACE_Sched_Params::priority_min (sched_policy); + int max_priority = ACE_Sched_Params::priority_max (sched_policy); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "max_priority = %d, min_priority = %d\n", + max_priority, min_priority)); + + if (max_priority == min_priority) + { + ACE_DEBUG ((LM_DEBUG,"Detected max_priority == min_priority\n")); + } + } + + // Set the main thread to min priority... + int priority = min_priority; + + if (ACE_OS::sched_params (ACE_Sched_Params (sched_policy , + priority, + ACE_SCOPE_PROCESS)) != 0) + { + if (ACE_OS::last_error () == EPERM) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t): user is not superuser, " + "test runs in time-shared class\n")); + } + else + ACE_ERROR ((LM_ERROR, + "(%P|%t): sched_params failed\n")); + } +} + +void TAO_NS_Notify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW_THROW_EX (this->factory_, - TAO_NS_Factory (), - CORBA::NO_MEMORY ()); + TAO_NS_Factory (), + CORBA::NO_MEMORY ()); ACE_CHECK; TAO_NS_PROPERTIES::instance()->factory (this->factory_); @@ -74,8 +188,8 @@ void TAO_NS_Notify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW_THROW_EX (this->builder_, - TAO_NS_Builder (), - CORBA::NO_MEMORY ()); + TAO_NS_Builder (), + CORBA::NO_MEMORY ()); ACE_CHECK; TAO_NS_PROPERTIES::instance()->builder (this->builder_); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h index 17fc5630ec0..02a51734254 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h @@ -38,11 +38,15 @@ public: TAO_NS_Notify_Service (void); /// Destructor - virtual ~TAO_NS_Notify_Service (); + virtual ~TAO_NS_Notify_Service (); + + /// = Service_Object virtual method overloads. + virtual int init (int argc, char *argv[]); + virtual int fini (void); /// Init virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); - + /// Create the Channel Factory. virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL); @@ -56,6 +60,9 @@ protected: /// Creates the Builder for RT Notify objects. virtual void init_builder (ACE_ENV_SINGLE_ARG_DECL); + /// Apply ORB Schedluling policy to main thread and set its priority to the lowest available. + void init_main_thread (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + /// Service component for object factory operations. TAO_NS_Factory* factory_; @@ -71,4 +78,3 @@ ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_Notify_Service) #include "ace/post.h" #endif /* TAO_NS_COSNOTIFY_SERVICE_H */ - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp index 66ca453d755..58794b6bc6d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp @@ -17,13 +17,13 @@ ACE_RCSID(RT_Notify, TAO_NS_Object, "$Id$") TAO_NS_Object::TAO_NS_Object (void) :event_manager_ (0), qos_admin_ (0), id_ (0), poa_ (0), worker_task_ (0), delete_worker_task_ (0) { - if (TAO_debug_level > 0 ) + if (TAO_debug_level > 1 ) ACE_DEBUG ((LM_DEBUG,"object:%x created\n", this )); } TAO_NS_Object::~TAO_NS_Object () { - if (TAO_debug_level > 0 ) + if (TAO_debug_level > 1 ) ACE_DEBUG ((LM_DEBUG,"object:%x destroyed\n", this )); this->shutdown_worker_task (); @@ -47,7 +47,7 @@ TAO_NS_Object::activate (ACE_ENV_SINGLE_ARG_DECL) return poa_->activate (this->servant (), id_ ACE_ENV_ARG_PARAMETER); } -void +void TAO_NS_Object::deactivate (ACE_ENV_SINGLE_ARG_DECL) { poa_->deactivate (id_ ACE_ENV_ARG_PARAMETER); @@ -95,4 +95,3 @@ TAO_NS_Object::worker_task (TAO_NS_Worker_Task* worker_task) delete_worker_task_ = 0; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.h b/TAO/orbsvcs/orbsvcs/Notify/Object.h index 474627ceb5f..211e10e84fa 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.h @@ -22,11 +22,13 @@ #include "tao/corba.h" #include "tao/PortableServer/Servant_Base.h" #include "Types.h" +#include "PropertySeq.h" class TAO_NS_POA_Helper; class TAO_NS_Worker_Task; class TAO_NS_QoSAdmin; class TAO_NS_Event_Manager; +class TAO_NS_AdminProperties; /** * @class TAO_NS_Object @@ -34,7 +36,7 @@ class TAO_NS_Event_Manager; * @brief Base Object for RT_Notify's CORBA Objects. * */ -class TAO_Notify_Export TAO_NS_Object +class TAO_Notify_Export TAO_NS_Object { public: /// Constuctor @@ -64,6 +66,9 @@ public: /// Get Worker Task. TAO_NS_Worker_Task* worker_task (void); + /// Get the POA assigned to us. + TAO_NS_POA_Helper* poa (void); + /// Set Worker Task. This object assume ownership of the set object. void worker_task_own (TAO_NS_Worker_Task* worker_task); @@ -73,8 +78,8 @@ public: protected: /// Servant which we use. virtual PortableServer::Servant servant (void) = 0; - - /// Shutdown the current worker task and delete it if we own it. + + /// Shutdown the current worker task and delete it if we own it. void shutdown_worker_task (void); ///= Protected data members. @@ -82,12 +87,18 @@ protected: /// The event manager. TAO_NS_Event_Manager* event_manager_; - /// Administer Qos functionality. + /// Administer Qos functionality. TAO_NS_QoSAdmin* qos_admin_; ///=Attributes - /// Id assigned to this object + /// Admin Properties. + TAO_NS_AdminProperties* admin_properties_; + + /// QoS Properties. + TAO_NS_PropertySeq qos_properties_; + + /// Id assigned to this object TAO_NS_Object_Id id_; /// The POA in which the object is activated. @@ -96,7 +107,7 @@ protected: /// Worker Task. TAO_NS_Worker_Task* worker_task_; - /// Ownership flag + /// Ownership flag int delete_worker_task_; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.inl b/TAO/orbsvcs/orbsvcs/Notify/Object.inl index 42e2e280bb6..6e46813987e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.inl @@ -14,3 +14,8 @@ TAO_NS_Object::worker_task (void) return this->worker_task_; } +ACE_INLINE TAO_NS_POA_Helper* +TAO_NS_Object::poa (void) +{ + return this->poa_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp index 316aa64c58a..372773f3af6 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp @@ -30,9 +30,9 @@ TAO_NS_Object_T<TYPE, PARENT>::destroy (TYPE *type ACE_ENV_ARG_DECL) this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - + if (parent_) - parent_->remove (type ACE_ENV_ARG_PARAMETER); + parent_->remove (type ACE_ENV_ARG_PARAMETER); } #endif /* TAO_NS_OBJECT_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object_T.h b/TAO/orbsvcs/orbsvcs/Notify/Object_T.h index fa6b2f67f25..88692b98328 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object_T.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Object_T.h @@ -38,7 +38,7 @@ public: TAO_NS_Object_T (void); /// Destructor - virtual ~TAO_NS_Object_T (); + virtual ~TAO_NS_Object_T (); /// destroy <type> void destroy (TYPE* type ACE_ENV_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp index aafdfaad997..8d475b3cbeb 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp @@ -1,7 +1,6 @@ // $Id$ #include "POA_Helper.h" -#include "tao/debug.h" #if ! defined (__ACE_INLINE__) #include "POA_Helper.inl" @@ -9,32 +8,34 @@ ACE_RCSID(RT_Notify, TAO_NS_POA_Helper, "$Id$") +#include "tao/debug.h" + TAO_NS_POA_Helper::TAO_NS_POA_Helper (void) { } TAO_NS_POA_Helper::~TAO_NS_POA_Helper () { - + } void TAO_NS_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name ACE_ENV_ARG_DECL) { CORBA::PolicyList policy_list (2); - + this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - + this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER); } void TAO_NS_POA_Helper::init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL) { - char child_poa_name[32]; + char child_poa_name[32]; ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10); - + this->init (parent_poa, child_poa_name ACE_ENV_ARG_PARAMETER); } @@ -43,15 +44,15 @@ void TAO_NS_POA_Helper::set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL) { policy_list.length (2); - + policy_list[0] = parent_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID - ACE_ENV_ARG_PARAMETER); + ACE_ENV_ARG_PARAMETER); ACE_CHECK; policy_list[1] = parent_poa->create_id_assignment_policy (PortableServer::USER_ID - ACE_ENV_ARG_PARAMETER); + ACE_ENV_ARG_PARAMETER); ACE_CHECK; } @@ -65,12 +66,14 @@ TAO_NS_POA_Helper::create_i (PortableServer::POA_ptr parent_poa, const char* poa // Create the child POA. this->poa_ = parent_poa->create_POA (poa_name, - manager.in (), - policy_list - ACE_ENV_ARG_PARAMETER); + manager.in (), + policy_list + ACE_ENV_ARG_PARAMETER); ACE_CHECK; - /* + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Created POA : %s\n", this->poa_->the_name ())); + /* // Destroy the policies for (CORBA::ULong index = 0; index < policy_list.length (); ++index) { @@ -115,11 +118,14 @@ TAO_NS_POA_Helper::activate (PortableServer::Servant servant, CORBA::Long& id AC // Generate a new ID. id = this->id_factory_.id (); + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Activating object with id = %d in POA : %s\n", id, this->poa_->the_name ())); + // Convert CORBA::Long to ObjectId PortableServer::ObjectId_var oid = this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - + poa_->activate_object_with_id (oid.in (), servant ACE_ENV_ARG_PARAMETER); @@ -157,7 +163,3 @@ TAO_NS_POA_Helper::destroy (ACE_ENV_SINGLE_ARG_DECL) poa_->destroy (1,0 ACE_ENV_ARG_PARAMETER); // The <wait_for_completion> flag = 0 } - - - - diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h index 21e0ccd65fc..0839ec78897 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h @@ -26,7 +26,7 @@ /** * @class TAO_NS_POA_Helper * - * @brief POA Abstraction. + * @brief POA Abstraction. * */ class TAO_Notify_Export TAO_NS_POA_Helper : private ACE_Copy_Disabled @@ -42,7 +42,7 @@ public: void init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL); /// Destructor - virtual ~TAO_NS_POA_Helper (); + virtual ~TAO_NS_POA_Helper (); /// Get underlying POA PortableServer::POA_ptr poa (void); @@ -68,10 +68,10 @@ protected: /// POA PortableServer::POA_var poa_; - + /// ID Factory TAO_NS_ID_Factory id_factory_; - + /// Convert id to ObjectID PortableServer::ObjectId* long_to_ObjectId (CORBA::Long id ACE_ENV_ARG_DECL) const; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp new file mode 100644 index 00000000000..c091c3289cd --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp @@ -0,0 +1,92 @@ +// $Id$ + +#include "Peer.h" + +#if ! defined (__ACE_INLINE__) +#include "Peer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Peer, "$id$") + +#include "tao/debug.h" +#include "Dispatch_Observer_T.h" + +TAO_NS_Peer::TAO_NS_Peer (void) +{ +} + +TAO_NS_Peer::~TAO_NS_Peer () +{ +} + +void +TAO_NS_Peer::type_added (const TAO_NS_EventType& added) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + this->added_.insert (added); + this->removed_.remove (added); +} + +void +TAO_NS_Peer::type_removed (const TAO_NS_EventType& removed) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + this->removed_.insert (removed); + this->added_.remove (removed); +} + +void +TAO_NS_Peer::dispatch_pending (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->added_.size () == 0 && this->removed_.size () == 0) + return; // Return if nothing to send. + + TAO_NS_EventTypeSeq added_copy; + TAO_NS_EventTypeSeq removed_copy; + TAO_NS_Reverse_Lock unlock (this->lock_); + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + + added_copy = this->added_; + removed_copy = this->removed_; + this->added_.reset (); + this->removed_.reset (); + + ACE_TRY + { + { + ACE_GUARD (TAO_NS_Reverse_Lock, ace_mon, unlock); + + this->dispatch_updates_i (added_copy, removed_copy ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->updates_dispatch_observer_ != 0) + this->updates_dispatch_observer_->dispatch_success (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + this->retry_count_ = 0; + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Peer:dispatch_pending serror sending updates\n "); + } + //ACE_RE_THROW; + + ++this->retry_count_; + + if (this->updates_dispatch_observer_ != 0) + { + /// Restore the lists. + this->added_.insert_seq (added_copy); + this->removed_.insert_seq (removed_copy); + + ACE_GUARD (TAO_NS_Reverse_Lock, ace_mon, unlock); + + this->updates_dispatch_observer_->dispatch_failure (this, this->retry_count_ ACE_ENV_ARG_PARAMETER); + } + } + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.h b/TAO/orbsvcs/orbsvcs/Notify/Peer.h new file mode 100644 index 00000000000..23d1844bf03 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.h @@ -0,0 +1,91 @@ +/* -*- C++ -*- */ +/** + * @file Peer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PEER_H +#define TAO_NS_PEER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" +#include "EventTypeSeq.h" +#include "Types.h" + +/** + * @class TAO_NS_Peer + * + * @brief Base class for Supplier and Consumer classes. + * This object delegates its reference count to its creator proxy object. + * + */ +class TAO_Notify_Export TAO_NS_Peer +{ +public: + /// Constuctor + TAO_NS_Peer (void); + + /// Destructor + ~TAO_NS_Peer (); + + void updates_dispatch_observer (TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer); + + /// Access Proxy. + virtual TAO_NS_Proxy* proxy (void) = 0; + + /// This method sigantures deliberately match the RefCounting methods required for ESF Proxy + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + + ///=Subscription change + + /// Subscription type added + void type_added (const TAO_NS_EventType& added); + + /// Subscription type removed + void type_removed (const TAO_NS_EventType& removed); + + /// Dispatch Pending. + void dispatch_pending (ACE_ENV_SINGLE_ARG_DECL); + +protected: + // Dispatch updates implementation. + virtual void dispatch_updates_i (const TAO_NS_EventTypeSeq & added, + const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL) = 0; + + ///= Data Members + + /// The mutex to serialize access to state variables. + TAO_SYNCH_MUTEX lock_; + + /// Types added. + TAO_NS_EventTypeSeq added_; + + /// Types removed. + TAO_NS_EventTypeSeq removed_; + + // Updates Dispatch Observer + TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer_; + + /// Retry count. How many times have we failed to contact the remote peer? + int retry_count_; +}; + +#if defined (__ACE_INLINE__) +#include "Peer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PEER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.inl b/TAO/orbsvcs/orbsvcs/Notify/Peer.inl new file mode 100644 index 00000000000..fb50a661dda --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.inl @@ -0,0 +1,23 @@ +// $Id$ + +#include "Peer.h" +#include "Proxy.h" + +CORBA::ULong +TAO_NS_Peer::_incr_refcnt (void) +{ + return this->proxy ()->_incr_refcnt (); +} + +CORBA::ULong +TAO_NS_Peer::_decr_refcnt (void) +{ + return this->proxy ()->_decr_refcnt (); +} + + +void +TAO_NS_Peer::updates_dispatch_observer (TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer) +{ + this->updates_dispatch_observer_ = updates_dispatch_observer; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.cpp new file mode 100644 index 00000000000..e2f9c7371ec --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.cpp @@ -0,0 +1,94 @@ +// $Id$ + +#include "Pending_Worker_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Pending_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Pending_Worker_T, "$id$") + +#include "tao/debug.h" +#include "Properties.h" + +/*****************************************************************************************/ + +template <class PEER> void +TAO_NS_Dispatch_Pending_Worker_T<PEER>::work (PEER* peer ACE_ENV_ARG_DECL) +{ + peer->dispatch_pending (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +/*****************************************************************************************/ + +template <class PEER> +TAO_NS_Pending_Worker_T<PEER>::TAO_NS_Pending_Worker_T (void) + :dispatch_observer_ (0), done_ (0), suspended_ (0) +{ +} + +template <class PEER> +TAO_NS_Pending_Worker_T<PEER>::~TAO_NS_Pending_Worker_T () +{ +} + +template <class PEER> void +TAO_NS_Pending_Worker_T<PEER>::init (TAO_NS_Dispatch_Observer_T<PEER>* dispatch_observer, ACE_Time_Value& update_period ACE_ENV_ARG_DECL) +{ + this->dispatch_observer_ = dispatch_observer; + this->update_period_ = update_period; + + long flags = THR_NEW_LWP | THR_JOINABLE; + + flags |= + TAO_NS_PROPERTIES::instance()->scope_policy () | + TAO_NS_PROPERTIES::instance()->sched_policy (); + + // Become an active object. + if (this->ACE_Task <ACE_SYNCH>::activate (flags, + 1, + 0, + ACE_DEFAULT_THREAD_PRIORITY) == -1) + { + if (TAO_debug_level > 0) + { + if (ACE_OS::last_error () == EPERM) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Insufficient privilege.\n"))); + else + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("(%t) task activation at priority %d failed\n") + ACE_TEXT ("exiting!\n%a"), + ACE_DEFAULT_THREAD_PRIORITY)); + } + + ACE_THROW (CORBA::BAD_PARAM ()); + } +} + +template <class PEER> int +TAO_NS_Pending_Worker_T<PEER>::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + while (!this->done_) + { + ACE_OS::sleep (this->update_period_); + + if (this->suspended_ == 1) + continue; + + TAO_NS_Dispatch_Pending_Worker_T<PEER> worker; + + TAO_NS_Dispatch_Observer_T<PEER>::PEER_COLLECTION* peer_collection + = this->dispatch_observer_->peer_collection (); + + if (peer_collection != 0) + peer_collection->for_each (&worker ACE_ENV_ARG_PARAMETER); + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "Exiting TAO_NS_Pending_Worker_T<PEER>::svc \n")); + } + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.h b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.h new file mode 100644 index 00000000000..365b66c0b27 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.h @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ +/** + * @file Pending_Worker_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PENDING_WORKER_T_H +#define TAO_NS_PENDING_WORKER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Types.h" +#include "ace/Task.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +template <class PEER> class TAO_NS_Dispatch_Observer_T; + +/** + * @class TAO_NS_Dispatch_Pending_Worker_T + * + * @brief Ask each PEER to dispatch pending updates. + * + */ +template <class PEER> +class TAO_Notify_Export TAO_NS_Dispatch_Pending_Worker_T : public TAO_ESF_Worker<PEER> +{ +protected: + ///= TAO_ESF_Worker method + void work (PEER* peer ACE_ENV_ARG_DECL); +}; + +/*******************************************************************************************/ + +/** + * @class TAO_NS_Pending_Worker_T + * + * @brief Periodic Task that obtains the list of pending PEER's from the dispatch_observer and dispatches pending events/updates. + * + */ +template <class PEER> +class TAO_Notify_Export TAO_NS_Pending_Worker_T : public ACE_Task<ACE_SYNCH> +{ +public: + /// Constuctor + TAO_NS_Pending_Worker_T (void); + + /// Destructor + ~TAO_NS_Pending_Worker_T (); + + /// Init + void init (TAO_NS_Dispatch_Observer_T<PEER>* dispatch_observer, ACE_Time_Value& update_period ACE_ENV_ARG_DECL); + + /// Shutdown + void shutdown (void); + + /// Suspend + void worker_suspend (void); + + /// Resume + void worker_resume (void); + +protected: + /// task svc + virtual int svc (void); + + /// The observer that logs PEERs that need updates. + TAO_NS_Dispatch_Observer_T<PEER>* dispatch_observer_; + + /// The period at which updates are send. + ACE_Time_Value update_period_; + + /// Flag that we should shutdown. + CORBA::Boolean done_; + + /// Flag that we are suspended. + CORBA::Boolean suspended_; +}; + +#if defined (__ACE_INLINE__) +#include "Pending_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Pending_Worker_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Pending_Worker_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PENDING_WORKER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.inl new file mode 100644 index 00000000000..c937771d04e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.inl @@ -0,0 +1,22 @@ +// $Id$ + +#include "Pending_Worker_T.h" + +ACE_INLINE template <class PEER> void +TAO_NS_Pending_Worker_T<PEER>::shutdown (void) +{ + this->done_ = 1; + this->wait (); +} + +ACE_INLINE template <class PEER> void +TAO_NS_Pending_Worker_T<PEER>::worker_suspend (void) +{ + this->suspended_ = 1; +} + +ACE_INLINE template <class PEER> void +TAO_NS_Pending_Worker_T<PEER>::worker_resume (void) +{ + this->suspended_ = 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp index cdbbb4572cd..f0530087b1a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp @@ -15,69 +15,30 @@ TAO_NS_Proxy::TAO_NS_Proxy (void) this->subscribed_types_.insert (TAO_NS_EventType::special ()); } - TAO_NS_Proxy::~TAO_NS_Proxy () { } -void -TAO_NS_Proxy::preprocess (TAO_NS_EventTypeSeq& seq_added, TAO_NS_EventTypeSeq& seq_remove_seq) +CORBA::Boolean +TAO_NS_Proxy::check_filters (TAO_NS_Event_var &event ACE_ENV_ARG_DECL) { - const TAO_NS_EventType& special = TAO_NS_EventType::special (); + // check if it passes the parent filter. + CORBA::Boolean parent_val = + this->parent_->filter_admin ().match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - if (this->subscribed_types_.find (special) == 0) - { - if (seq_added.find (special) == 0) - { - seq_added.reset (); - seq_remove_seq.reset (); - } - else - { - this->subscribed_types_.reset (); - this->subscribed_types_.insert_seq (seq_added); + CORBA::Boolean val = 0; - seq_remove_seq.reset (); - seq_remove_seq.insert (special); - } + if (this->parent_->filter_operator () == CosNotifyChannelAdmin::AND_OP) + { + val = parent_val && this->filter_admin_.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } else { - if (seq_added.find (special) == 0) - { - if (seq_remove_seq.find (special) == 0) - { - seq_added.reset (); - seq_remove_seq.reset (); - } - else - { - seq_remove_seq.reset (); - seq_remove_seq.insert_seq (this->subscribed_types_); - - this->subscribed_types_.reset (); - this->subscribed_types_.insert (special); - - seq_added.reset (); - seq_added.insert (special); - } - } - else - { - if (seq_remove_seq.find (special) == 0) - { - - seq_remove_seq.reset (); - seq_remove_seq.insert_seq (this->subscribed_types_); - - this->subscribed_types_.reset (); - this->subscribed_types_.insert_seq (seq_added); - } - else - { - this->subscribed_types_.insert_seq (seq_added); - this->subscribed_types_.remove_seq (seq_remove_seq); - } - } + val = parent_val || this->filter_admin_.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } + + return val; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.h b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h index fb6c3d5e083..cbac9a0effe 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Proxy.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h @@ -21,8 +21,10 @@ #include "Object_T.h" #include "EventTypeSeq.h" +#include "FilterAdmin.h" class TAO_NS_Admin; +class TAO_NS_Peer; /** * @class TAO_NS_Proxy @@ -37,16 +39,32 @@ public: TAO_NS_Proxy (void); /// Destructor - ~TAO_NS_Proxy (); + ~TAO_NS_Proxy (); /// Init method. // virtual void init (ACE_ENV_SINGLE_ARG_DECL); + /// Subscribed types. + TAO_NS_EventTypeSeq& subscribed_types (void); + + /// Check if this event passes the admin and proxy filters. + CORBA::Boolean check_filters (TAO_NS_Event_var &event ACE_ENV_ARG_DECL); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) = 0; + + /// Access our Peer. + virtual TAO_NS_Peer* peer (void) = 0; + + /// Notification of subscriptions/offers set at the admin. + virtual void admin_subscription (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) = 0; protected: typedef TAO_NS_Object_T <TAO_NS_Proxy, TAO_NS_Admin> inherited; - /// Preprocess the types added and removed. - void preprocess (TAO_NS_EventTypeSeq& added, TAO_NS_EventTypeSeq& removed); + /// Filter Administration + TAO_NS_FilterAdmin filter_admin_; /// The types that we're subscribed with the event manager. TAO_NS_EventTypeSeq subscribed_types_; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl b/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl index 30483781a8f..773ecde8afd 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl @@ -1,3 +1,9 @@ // $Id$ #include "Proxy.h" + +ACE_INLINE TAO_NS_EventTypeSeq& +TAO_NS_Proxy::subscribed_types (void) +{ + return this->subscribed_types_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp index 33b92c42e46..83ad52cb0f3 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp @@ -2,6 +2,8 @@ #include "ProxyConsumer.h" #include "Supplier.h" +#include "Admin.h" +#include "tao/debug.h" #if ! defined (__ACE_INLINE__) #include "ProxyConsumer.inl" @@ -16,7 +18,12 @@ TAO_NS_ProxyConsumer::TAO_NS_ProxyConsumer (void) TAO_NS_ProxyConsumer::~TAO_NS_ProxyConsumer () { - this->supplier_->_decr_refcnt (); +} + +TAO_NS_Peer* +TAO_NS_ProxyConsumer::peer (void) +{ + return this->supplier (); } void @@ -29,13 +36,17 @@ TAO_NS_ProxyConsumer::connect (TAO_NS_Supplier *supplier ACE_ENV_ARG_DECL) ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); ACE_CHECK; - + if (this->is_connected ()) ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); else { supplier_ = supplier; + supplier->updates_dispatch_observer (this->event_manager_->updates_dispatch_observer ()); + + this->parent_->subscribed_types (this->subscribed_types_); // get the parents subscribed types. + event_manager_->publish (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); } } @@ -44,6 +55,8 @@ void TAO_NS_ProxyConsumer::disconnect (void) { event_manager_->un_publish (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + + this->supplier_->_decr_refcnt (); } void @@ -56,11 +69,10 @@ TAO_NS_ProxyConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL) //@@ inform the supplier that its disconnected? } -void +void TAO_NS_ProxyConsumer::push (TAO_NS_Event_var &event) { TAO_NS_Method_Request_Lookup request (event, this, this->event_manager_->consumer_map ()); this->worker_task ()->exec (request); } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h index c30d800ba86..da157a43385 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h @@ -39,7 +39,7 @@ public: TAO_NS_ProxyConsumer (void); /// Destructor - ~TAO_NS_ProxyConsumer (); + ~TAO_NS_ProxyConsumer (); /// Connect void connect (TAO_NS_Supplier* supplier ACE_ENV_ARG_DECL) @@ -56,6 +56,12 @@ public: virtual void push (TAO_NS_Event_var &event); + /// Access our Peer. + virtual TAO_NS_Peer* peer (void); + + /// Access the Supplier + TAO_NS_Supplier* supplier (void); + protected: /// Return 1 if connected int is_connected (void); diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl index c9074028875..37512888c80 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl @@ -6,8 +6,14 @@ #include "Event_Manager.h" #include "Method_Request_Lookup.h" -ACE_INLINE int +ACE_INLINE int TAO_NS_ProxyConsumer::is_connected (void) { return supplier_ == 0 ? 0 : 1; } + +ACE_INLINE TAO_NS_Supplier* +TAO_NS_ProxyConsumer::supplier (void) +{ + return this->supplier_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp index e964dff0d62..8569a30bdb7 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp @@ -2,6 +2,7 @@ #include "ProxySupplier.h" #include "Event_Manager.h" +#include "Admin.h" #if ! defined (__ACE_INLINE__) #include "ProxySupplier.inl" @@ -9,6 +10,8 @@ ACE_RCSID(RT_Notify, TAO_NS_ProxySupplier, "$Id$") +#include "Method_Request_Dispatch_No_Filtering.h" + TAO_NS_ProxySupplier::TAO_NS_ProxySupplier (void) :consumer_ (0) { @@ -16,7 +19,6 @@ TAO_NS_ProxySupplier::TAO_NS_ProxySupplier (void) TAO_NS_ProxySupplier::~TAO_NS_ProxySupplier () { - this->consumer_->_decr_refcnt (); } void @@ -24,6 +26,12 @@ TAO_NS_ProxySupplier::init_ps (ACE_ENV_SINGLE_ARG_DECL) { } +TAO_NS_Peer* +TAO_NS_ProxySupplier:: peer (void) +{ + return this->consumer (); +} + void TAO_NS_ProxySupplier::connect (TAO_NS_Consumer *consumer ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( @@ -41,6 +49,11 @@ TAO_NS_ProxySupplier::connect (TAO_NS_Consumer *consumer ACE_ENV_ARG_DECL) { consumer_ = consumer; + consumer->event_dispatch_observer (this->event_manager_->event_dispatch_observer ()); + consumer->updates_dispatch_observer (this->event_manager_->updates_dispatch_observer ()); + + this->parent_->subscribed_types (this->subscribed_types_); // get the parents subscribed types. + event_manager_->subscribe (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); } } @@ -49,6 +62,9 @@ void TAO_NS_ProxySupplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) { event_manager_->un_subscribe (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->consumer_->_decr_refcnt (); } void @@ -61,7 +77,7 @@ TAO_NS_ProxySupplier::shutdown (ACE_ENV_SINGLE_ARG_DECL) //@@ inform the consumer that its disconnected? } -void +void TAO_NS_ProxySupplier::push (TAO_NS_Event_var &event) { TAO_NS_Method_Request_Dispatch request (event, this); @@ -69,3 +85,10 @@ TAO_NS_ProxySupplier::push (TAO_NS_Event_var &event) this->worker_task ()->exec (request); } +void +TAO_NS_ProxySupplier::push_no_filtering (TAO_NS_Event_var &event) +{ + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h index f4ac42b09f6..9c476e8ba55 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h @@ -27,7 +27,7 @@ /** * @class TAO_NS_ProxySupplier * - * @brief Base class for all the ProxySuppliers. + * @brief Base class for all the ProxySuppliers. * */ class TAO_Notify_Export TAO_NS_ProxySupplier : public TAO_NS_Proxy @@ -54,18 +54,24 @@ public: /// Dispatch Event to consumer virtual void push (TAO_NS_Event_var &event); + /// Dispatch Event to consumer, no filtering + virtual void push_no_filtering (TAO_NS_Event_var &event); + /// Shutdown (TAO_NS_Container_T method) virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + /// Access our Peer. + virtual TAO_NS_Peer* peer (void); + /// Access the Consumer TAO_NS_Consumer* consumer (void); -protected: +protected: /// Return 1 if connected int is_connected (void); /// The Consumer that we're connect to. - TAO_NS_Consumer* consumer_; + TAO_NS_Consumer* consumer_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl index e2d63d51060..6815967ff6f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl @@ -1,11 +1,10 @@ // $Id$ #include "ProxySupplier.h" -//#include "Properties.h" #include "Method_Request_Dispatch.h" #include "Worker_Task.h" -ACE_INLINE int +ACE_INLINE int TAO_NS_ProxySupplier::is_connected (void) { return consumer_ == 0 ? 0 : 1; diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.cpp index 6734d82d16f..8870699ca0e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.cpp @@ -19,6 +19,35 @@ TAO_NS_QoSAdmin::~TAO_NS_QoSAdmin () } void +TAO_NS_QoSAdmin::apply_qos (TAO_NS_Container* container, const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) +{ + for (CORBA::ULong index = 0; index < qos.length (); ++index) + { + ACE_CString property_name (qos[index].name); + + if (property_name.compare (NotifyExt::ThreadPool) == 0) + { + // check if ThreadPool is required. + NotifyExt::ThreadPoolParams* tp_params = 0; + + qos[index].value >>= tp_params; + + this->apply_threadpool_qos (container, tp_params ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else if (property_name.compare (NotifyExt::ThreadPoolLanes) == 0) + { + NotifyExt::ThreadPoolLanesParams* tpl_params = 0; + + qos[index].value >>= tpl_params; + + this->apply_threadpool_lane_qos (container, tpl_params ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } +} + +void TAO_NS_QoSAdmin::apply_threadpool_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL) { // @@ TODO??: check if number of threads is 0, if so, set as reactive. @@ -36,3 +65,9 @@ TAO_NS_QoSAdmin::apply_threadpool_qos (TAO_NS_Container* container, NotifyExt::T container->worker_task_own (worker_task); } +void +TAO_NS_QoSAdmin::apply_threadpool_lane_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL) +{ + // No lane support + ACE_THROW ((CORBA::NO_IMPLEMENT ())); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.h index d00b6a52b1e..b2d8de83427 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSAdmin.h @@ -19,6 +19,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "orbsvcs/CosNotificationC.h" #include "orbsvcs/NotifyExtC.h" class TAO_NS_Container; @@ -26,7 +27,7 @@ class TAO_NS_Container; /** * @class TAO_NS_QoSAdmin * - * @brief Admin class to manage and apply QoS parameters to the EventChannel, Admin and Proxy classes. + * @brief Admin class to manage and apply QoS parameters to the EventChannel, Admin and Proxy classes. * */ class TAO_Notify_Export TAO_NS_QoSAdmin @@ -36,10 +37,16 @@ public: TAO_NS_QoSAdmin (void); /// Destructor - ~TAO_NS_QoSAdmin (); + ~TAO_NS_QoSAdmin (); + void apply_qos (TAO_NS_Container* container, const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL); + +protected: /// Apply Threadpool QoS virtual void apply_threadpool_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL); + + /// Apply ThreadpoolLanes QoS + virtual void apply_threadpool_lane_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.cpp index 8ed68dd03f1..411dab84434 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.cpp @@ -21,4 +21,3 @@ TAO_NS_RTCORBA_Builder::TAO_NS_RTCORBA_Builder (void) TAO_NS_RTCORBA_Builder::~TAO_NS_RTCORBA_Builder () { } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.h index a70b12af0cc..b037386338b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Builder.h @@ -34,7 +34,7 @@ public: TAO_NS_RTCORBA_Builder (void); /// Destructor - ~TAO_NS_RTCORBA_Builder (); + ~TAO_NS_RTCORBA_Builder (); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.cpp index 53615a959cb..9dbc9bf495b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.cpp @@ -19,4 +19,3 @@ TAO_NS_RTCORBA_EventChannel::TAO_NS_RTCORBA_EventChannel (void) TAO_NS_RTCORBA_EventChannel::~TAO_NS_RTCORBA_EventChannel () { } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.h index c78440decc9..2b6470d3e97 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_EventChannel.h @@ -34,7 +34,7 @@ public: TAO_NS_RTCORBA_EventChannel (void); /// Destructor - ~TAO_NS_RTCORBA_EventChannel (); + ~TAO_NS_RTCORBA_EventChannel (); protected: }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.cpp index 57981b3be9a..6e49fb45af4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.cpp @@ -35,7 +35,7 @@ TAO_NS_RTCORBA_Factory::create (TAO_NS_EventChannel*& channel ACE_ENV_SINGLE_ARG TAO_NS_RTCORBA_EventChannel (), CORBA::NO_MEMORY ()); } - + void TAO_NS_RTCORBA_Factory::create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_SINGLE_ARG_DECL) { @@ -58,5 +58,3 @@ TAO_NS_RTCORBA_Factory::create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_E TAO_NS_RTCORBA_StructuredProxyPushConsumer (), CORBA::NO_MEMORY ()); } - - diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.h index bf59dfaec35..8b8463a5efc 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Factory.h @@ -34,7 +34,7 @@ public: TAO_NS_RTCORBA_Factory (void); /// Destructor - ~TAO_NS_RTCORBA_Factory (); + ~TAO_NS_RTCORBA_Factory (); /// Create QoSAdmin virtual void create (TAO_NS_QoSAdmin*& qos_admin ACE_ENV_SINGLE_ARG_DECL); @@ -43,10 +43,10 @@ public: virtual void create (TAO_NS_EventChannel*& ACE_ENV_SINGLE_ARG_DECL); /// Create StructuredProxyPushSupplier - virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_SINGLE_ARG_DECL); /// Create StructuredProxyPushConsumer - virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_SINGLE_ARG_DECL); + virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_SINGLE_ARG_DECL); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.cpp index 86a137e929b..f21b7de60b3 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.cpp @@ -42,7 +42,7 @@ TAO_NS_RTCORBA_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) // Resolve RTORB CORBA::Object_var object = orb->resolve_initial_references ("RTORB" - ACE_ENV_ARG_PARAMETER); + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); RTCORBA::RTORB_var rt_orb = @@ -53,7 +53,7 @@ TAO_NS_RTCORBA_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) // Resolve RTCurrent object = orb->resolve_initial_references ("RTCurrent" - ACE_ENV_ARG_PARAMETER); + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); RTCORBA::Current_var current = @@ -70,8 +70,8 @@ void TAO_NS_RTCORBA_Notify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW_THROW_EX (this->factory_, - TAO_NS_RTCORBA_Factory (), - CORBA::NO_MEMORY ()); + TAO_NS_RTCORBA_Factory (), + CORBA::NO_MEMORY ()); ACE_CHECK; TAO_NS_PROPERTIES::instance()->factory (this->factory_); @@ -81,8 +81,8 @@ void TAO_NS_RTCORBA_Notify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW_THROW_EX (this->builder_, - TAO_NS_RTCORBA_Builder (), - CORBA::NO_MEMORY ()); + TAO_NS_RTCORBA_Builder (), + CORBA::NO_MEMORY ()); ACE_CHECK; TAO_NS_PROPERTIES::instance()->builder (this->builder_); diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.h index c4f8f9f46e4..b84effb722f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Notify_Service.h @@ -34,7 +34,7 @@ public: TAO_NS_RTCORBA_Notify_Service (void); /// Destructor - ~TAO_NS_RTCORBA_Notify_Service (); + ~TAO_NS_RTCORBA_Notify_Service (); /// Init the service. virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.cpp index 3a24fc69f0e..0464e39e0ad 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.cpp @@ -19,9 +19,9 @@ TAO_NS_RTCORBA_POA_Helper::~TAO_NS_RTCORBA_POA_Helper () void TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL) { - char child_poa_name[32]; + char child_poa_name[32]; ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10); - + this->init (parent_poa, child_poa_name, tp_params ACE_ENV_ARG_PARAMETER); } @@ -32,41 +32,106 @@ TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER); ACE_CHECK; - + RTCORBA::RTORB_var rt_orb = TAO_NS_RTCORBA_PROPERTIES::instance ()->rt_orb (); policy_list.length (3); policy_list[2] = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, - 0 - ACE_ENV_ARG_PARAMETER); + 0 + ACE_ENV_ARG_PARAMETER); ACE_CHECK; - + if (tp_params != 0) - { + { if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, "Creating threadpool: static threads = %d, def. prio = %d\n", tp_params->static_threads, tp_params->default_priority)); - } + { + ACE_DEBUG ((LM_DEBUG, "Creating threadpool: static threads = %d, def. prio = %d\n", tp_params->static_threads, tp_params->default_priority)); + } // Create the thread-pool. RTCORBA::ThreadpoolId threadpool_id = rt_orb->create_threadpool (tp_params->stacksize, - tp_params->static_threads, - tp_params->dynamic_threads, - tp_params->default_priority, - tp_params->allow_request_buffering, - tp_params->max_buffered_requests, - tp_params->max_request_buffer_size - ACE_ENV_ARG_PARAMETER); + tp_params->static_threads, + tp_params->dynamic_threads, + tp_params->default_priority, + tp_params->allow_request_buffering, + tp_params->max_buffered_requests, + tp_params->max_request_buffer_size + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list.length (4); + policy_list[3] = + rt_orb->create_threadpool_policy (threadpool_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL) +{ + char child_poa_name[32]; + ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10); + + this->init (parent_poa, child_poa_name, tpl_params ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL) +{ + CORBA::PolicyList policy_list (4); + + this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + RTCORBA::RTORB_var rt_orb = TAO_NS_RTCORBA_PROPERTIES::instance ()->rt_orb (); + + policy_list.length (3); + policy_list[2] = + rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (tpl_params != 0) + { + // Populate RTCORBA Lanes. + RTCORBA::ThreadpoolLanes lanes (tpl_params->lanes.length ()); + + for (CORBA::ULong index = 0; index < tpl_params->lanes.length (); ++index) + { + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "Creating threadpool lane %d: priority = %d, static threads = %d\n", + index, tpl_params->lanes[index].lane_priority, tpl_params->lanes[index].static_threads)); + } + + lanes[index].lane_priority = tpl_params->lanes[index].lane_priority; + lanes[index].static_threads = tpl_params->lanes[index].static_threads; + lanes[index].dynamic_threads = tpl_params->lanes[index].dynamic_threads; + } + + // Create the thread-pool. + RTCORBA::ThreadpoolId threadpool_id = + rt_orb->create_threadpool_with_lanes (tpl_params->stacksize, + lanes, + tpl_params->allow_borrowing, + tpl_params->allow_request_buffering, + tpl_params->max_buffered_requests, + tpl_params->max_request_buffer_size + ACE_ENV_ARG_PARAMETER); ACE_CHECK; policy_list.length (4); - policy_list[3] = - rt_orb->create_threadpool_policy (threadpool_id - ACE_ENV_ARG_PARAMETER); + policy_list[3] = + rt_orb->create_threadpool_policy (threadpool_id + ACE_ENV_ARG_PARAMETER); ACE_CHECK; } - + this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.h index 4c7d9506ddb..6b4e46d9557 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.h @@ -32,13 +32,19 @@ class TAO_RT_Notify_Export TAO_NS_RTCORBA_POA_Helper : public TAO_NS_POA_Helper { public: /// Destructor - ~TAO_NS_RTCORBA_POA_Helper (); + ~TAO_NS_RTCORBA_POA_Helper (); /// Create a new PortableServer::POA. void init (PortableServer::POA_ptr parent_poa, const char* poa_name, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL); /// Create a new PortableServer::POA. The name is chosen at random. void init (PortableServer::POA_ptr parent_poa, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. + void init (PortableServer::POA_ptr parent_poa, const char* poa_name, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. The name is chosen at random. + void init (PortableServer::POA_ptr parent_poa, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.cpp index 2e065b3565d..b56be4626e8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.cpp @@ -15,4 +15,3 @@ TAO_NS_RTCORBA_Properties::TAO_NS_RTCORBA_Properties (void) TAO_NS_RTCORBA_Properties::~TAO_NS_RTCORBA_Properties () { } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.h index 23f8a952f8a..cc12b60ab9e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_Properties.h @@ -30,14 +30,14 @@ */ class TAO_RT_Notify_Export TAO_NS_RTCORBA_Properties { - friend class ACE_Singleton<TAO_NS_RTCORBA_Properties, TAO_SYNCH_MUTEX>; + friend class ACE_Singleton<TAO_NS_RTCORBA_Properties, TAO_SYNCH_MUTEX>; public: /// Constuctor TAO_NS_RTCORBA_Properties (void); /// Destructor - ~TAO_NS_RTCORBA_Properties (); + ~TAO_NS_RTCORBA_Properties (); RTCORBA::RTORB_ptr rt_orb (void); void rt_orb (RTCORBA::RTORB_ptr rt_orb); @@ -48,7 +48,7 @@ public: protected: /// RT-ORB RTCORBA::RTORB_var rt_orb_; - + /// Current RTCORBA::Current_var current_; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.cpp index 5ff7768a309..94f8c1aa8d9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.cpp @@ -21,18 +21,14 @@ TAO_NS_RTCORBA_ProxyConsumer::~TAO_NS_RTCORBA_ProxyConsumer () { } -void +void TAO_NS_RTCORBA_ProxyConsumer::push (TAO_NS_Event_var &event) { if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "(%x,%P,%t) received event priority %d\n", this, - TAO_NS_RTCORBA_PROPERTIES::instance()->current ()->the_priority ())); - + TAO_NS_RTCORBA_PROPERTIES::instance()->current ()->the_priority ())); + TAO_NS_Method_Request_Lookup request (event, this, this->event_manager_->consumer_map ()); request.call (); } - - - - diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.h index e4fff9b4085..b306afe8a27 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxyConsumer.h @@ -34,9 +34,9 @@ public: TAO_NS_RTCORBA_ProxyConsumer (void); /// Destructor - ~TAO_NS_RTCORBA_ProxyConsumer (); + ~TAO_NS_RTCORBA_ProxyConsumer (); - /// Process + /// Process virtual void push (TAO_NS_Event_var &event); }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.cpp index a83e1404030..ec8a7f337eb 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.cpp @@ -7,6 +7,10 @@ #include "RTCORBA_Properties.h" #include "Event.h" #include "Types.h" +#include "Structured/StructuredEvent.h" +#include "Method_Request_Dispatch.h" +#include "Method_Request_Dispatch_No_Filtering.h" +#include "Worker_Task.h" #if ! defined (__ACE_INLINE__) #include "RTCORBA_ProxySupplier.inl" @@ -38,18 +42,42 @@ TAO_NS_RTCORBA_ProxySupplier::push (TAO_NS_Event_var &event) event->push (this->event_forwarder_.in () ACE_ENV_ARG_PARAMETER); } -void -TAO_NS_RTCORBA_ProxySupplier::forward (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) +void +TAO_NS_RTCORBA_ProxySupplier::push_no_filtering (TAO_NS_Event_var &event) +{ + event->push_no_filtering (this->event_forwarder_.in () ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RTCORBA_ProxySupplier::forward (const CosNotification::StructuredEvent& notification ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )) + CORBA::SystemException + )) { if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "(%x,%P,%t) TAO_NS_RTCORBA_ProxySupplier::forward received event priority %d\n", this, - TAO_NS_RTCORBA_PROPERTIES::instance()->current ()->the_priority ())); + TAO_NS_RTCORBA_PROPERTIES::instance()->current ()->the_priority ())); + + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + TAO_NS_Method_Request_Dispatch request (event, this); - // final dispatch to consumer - this->consumer_->push (event ACE_ENV_ARG_PARAMETER); + this->worker_task ()->exec (request); } +void +TAO_NS_RTCORBA_ProxySupplier::forward_no_filtering (const CosNotification::StructuredEvent& notification ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "(%x,%P,%t) TAO_NS_RTCORBA_ProxySupplier::forward_no_filtering received event priority %d\n", this, + TAO_NS_RTCORBA_PROPERTIES::instance()->current ()->the_priority ())); + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.h index 58eb08e436c..ed97cb2019d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_ProxySupplier.h @@ -42,15 +42,24 @@ public: /// Override TAO_NS_ProxySupplier::push virtual void push (TAO_NS_Event_var &event); + /// Dispatch Event to consumer, no filtering + virtual void push_no_filtering (TAO_NS_Event_var &event); + /// POA_Notify_Internal::Event_Forwarder method virtual void forward (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException - )); + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_no_filtering (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); private: /// Our ref. - Notify_Internal::Event_Forwarder_var event_forwarder_; + Notify_Internal::Event_Forwarder_var event_forwarder_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.cpp index 254b0a08a28..b1582efca56 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.cpp @@ -24,19 +24,44 @@ TAO_NS_RTCORBA_QoSAdmin::apply_threadpool_qos (TAO_NS_Container* container, Noti { TAO_NS_RTCORBA_POA_Helper* proxy_poa = 0; - // Bootstrap EC Proxy POA + // Bootstrap EC Proxy POA ACE_NEW_THROW_EX (proxy_poa, - TAO_NS_RTCORBA_POA_Helper (), - CORBA::NO_MEMORY ()); + TAO_NS_RTCORBA_POA_Helper (), + CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (ec_ret._retn ()); auto_ptr<TAO_NS_POA_Helper> auto_proxy_poa (proxy_poa); - + + PortableServer::POA_var default_poa = TAO_NS_PROPERTIES::instance ()->default_poa (); + + proxy_poa->init (default_poa.in (), tp_params ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Give ownership of proxy_poa + container->proxy_poa (proxy_poa); + + // release auto ref. + auto_proxy_poa.release (); +} + +void +TAO_NS_RTCORBA_QoSAdmin::apply_threadpool_lane_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL) +{ + TAO_NS_RTCORBA_POA_Helper* proxy_poa = 0; + + // Bootstrap EC Proxy POA + ACE_NEW_THROW_EX (proxy_poa, + TAO_NS_RTCORBA_POA_Helper (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (ec_ret._retn ()); + + auto_ptr<TAO_NS_POA_Helper> auto_proxy_poa (proxy_poa); + PortableServer::POA_var default_poa = TAO_NS_PROPERTIES::instance ()->default_poa (); - proxy_poa->init (default_poa.in (), tp_params ACE_ENV_ARG_PARAMETER); + proxy_poa->init (default_poa.in (), tpl_params ACE_ENV_ARG_PARAMETER); ACE_CHECK; - + // Give ownership of proxy_poa container->proxy_poa (proxy_poa); diff --git a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.h index b8f6f5b1099..c5d9add38f8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_QoSAdmin.h @@ -34,10 +34,13 @@ public: TAO_NS_RTCORBA_QoSAdmin (void); /// Destructor - ~TAO_NS_RTCORBA_QoSAdmin (); + ~TAO_NS_RTCORBA_QoSAdmin (); /// Apply Threadpool QoS virtual void apply_threadpool_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL); + + /// Apply ThreadpoolLanes QoS + virtual void apply_threadpool_lane_qos (TAO_NS_Container* container, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h index 9b92292f307..81ca7876efb 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h @@ -34,7 +34,7 @@ public: TAO_NS_Reactive_Task (void); /// Destructor - ~TAO_NS_Reactive_Task (); + ~TAO_NS_Reactive_Task (); /// Exec the request. virtual void exec (TAO_NS_Method_Request& method_request); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp index 2a77a6fc0e1..46178ac6b46 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp @@ -24,6 +24,7 @@ CORBA::ULong TAO_NS_Refcountable::_incr_refcnt (void) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + if (TAO_debug_level > 0 ) ACE_DEBUG ((LM_DEBUG,"object:%x incr refcount = %d\n", this, refcount_+1 )); @@ -56,4 +57,3 @@ TAO_NS_Refcountable::destroy_callback (TAO_NS_Destroy_Callback* destroy_callback { destroy_callback_ = destroy_callback; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp new file mode 100644 index 00000000000..12210af6fc4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp @@ -0,0 +1,18 @@ +// $Id$ + +#include "Subscription_Change_Worker.h" + +#if ! defined (__ACE_INLINE__) +#include "Subscription_Change_Worker.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_Subscription_Change_Worker, "$id$") + +TAO_NS_Subscription_Change_Worker::TAO_NS_Subscription_Change_Worker (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed) +:added_ (added), removed_ (removed) +{ +} + +TAO_NS_Subscription_Change_Worker::~TAO_NS_Subscription_Change_Worker () +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h new file mode 100644 index 00000000000..2baea73b727 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h @@ -0,0 +1,55 @@ +/* -*- C++ -*- */ +/** + * @file Subscription_Change_Worker.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_SUBSCRIPTION_CHANGE_WORKER_H +#define TAO_SUBSCRIPTION_CHANGE_WORKER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +class TAO_NS_Proxy; + +/** + * @class TAO_Subscription_Change_Worker + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Subscription_Change_Worker : public TAO_ESF_Worker<TAO_NS_Proxy> +{ +public: + /// Constuctor + TAO_NS_Subscription_Change_Worker (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed); + + /// Destructor + ~TAO_NS_Subscription_Change_Worker (); + + ///= TAO_ESF_Worker method + void work (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL); + +protected: + const CosNotification::EventTypeSeq & added_; + const CosNotification::EventTypeSeq & removed_; +}; + +#if defined (__ACE_INLINE__) +#include "Subscription_Change_Worker.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_SUBSCRIPTION_CHANGE_WORKER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl new file mode 100644 index 00000000000..afce0cf8cf4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl @@ -0,0 +1,10 @@ +// $Id$ + +#include "Subscription_Change_Worker.h" +#include "Proxy.h" + +void +TAO_NS_Subscription_Change_Worker::work (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + proxy->admin_subscription (this->added_, this->removed_ ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp index b23749d29e8..ecc2ee5279c 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp @@ -8,7 +8,10 @@ ACE_RCSID(RT_Notify, TAO_NS_Supplier, "$Id$") -TAO_NS_Supplier::TAO_NS_Supplier (void) +#include "ProxyConsumer.h" + +TAO_NS_Supplier::TAO_NS_Supplier (TAO_NS_ProxyConsumer* proxy) + :proxy_ (proxy) { } @@ -16,3 +19,8 @@ TAO_NS_Supplier::~TAO_NS_Supplier () { } +TAO_NS_Proxy* +TAO_NS_Supplier::proxy (void) +{ + return this->proxy_consumer (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.h b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h index 2b07529eb5f..fcfe29292ad 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Supplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h @@ -19,7 +19,9 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "Refcountable.h" +#include "Peer.h" + +class TAO_NS_ProxyConsumer; /** * @class TAO_NS_Supplier @@ -27,14 +29,24 @@ * @brief Base Wrappers for Suppliers that connect to the EventChannel. * */ -class TAO_Notify_Export TAO_NS_Supplier : public TAO_NS_Refcountable +class TAO_Notify_Export TAO_NS_Supplier : public TAO_NS_Peer { public: /// Constuctor - TAO_NS_Supplier (void); + TAO_NS_Supplier (TAO_NS_ProxyConsumer* proxy); /// Destructor - ~TAO_NS_Supplier (); + ~TAO_NS_Supplier (); + + /// Access Specific Proxy. + TAO_NS_ProxyConsumer* proxy_consumer (void); + + /// Access Base Proxy. + virtual TAO_NS_Proxy* proxy (void); + +protected: + /// The proxy that we associate with. + TAO_NS_ProxyConsumer* proxy_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl index bdc8354606e..8250f996547 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl @@ -1,3 +1,9 @@ // $Id$ #include "Supplier.h" + +ACE_INLINE TAO_NS_ProxyConsumer* +TAO_NS_Supplier::proxy_consumer (void) +{ + return this->proxy_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp index 5ac0fc97ae3..a7ffa89f53a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp @@ -5,6 +5,8 @@ #include "Proxy.h" #include "EventChannel.h" #include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "QoSAdmin.h" +#include "Subscription_Change_Worker.h" #if ! defined (__ACE_INLINE__) #include "SupplierAdmin.inl" @@ -47,17 +49,22 @@ TAO_NS_SupplierAdmin::release (void) } void -TAO_NS_SupplierAdmin::set (CosNotifyChannelAdmin::InterFilterGroupOperator op ACE_ENV_ARG_DECL) +TAO_NS_SupplierAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) { + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); } -void -TAO_NS_SupplierAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) +void +TAO_NS_SupplierAdmin::set_qos (const CosNotification::QoSProperties & qos) ACE_THROW_SPEC (( CORBA::SystemException + , CosNotification::UnsupportedQoS )) { - this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); + this->qos_admin_->apply_qos (this, qos ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::ProxyConsumer_ptr @@ -66,15 +73,15 @@ TAO_NS_SupplierAdmin::obtain_notification_push_consumer (CosNotifyChannelAdmin:: CORBA::SystemException , CosNotifyChannelAdmin::AdminLimitExceeded )) - + { - return TAO_NS_PROPERTIES::instance()->builder ()->build_notification_push_consumer (this, - ctype, - proxy_id ACE_ENV_ARG_PARAMETER); + return TAO_NS_PROPERTIES::instance()->builder ()->build_notification_push_consumer (this, + ctype, + proxy_id ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -83,9 +90,9 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { return this->id (); } - + ::CosNotifyChannelAdmin::EventChannel_ptr TAO_NS_SupplierAdmin::MyChannel ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -93,24 +100,20 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { //Add your implementation here - return 0; + return 0; } - -::CosNotifyChannelAdmin::InterFilterGroupOperator TAO_NS_SupplierAdmin::MyOperator ( - - ) + +::CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_SupplierAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException )) - { - return ::CosNotifyChannelAdmin::OR_OP; - - //Add your implementation here + return this->filter_operator_; } - + ::CosNotifyChannelAdmin::ProxyIDSeq * TAO_NS_SupplierAdmin::pull_consumers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -118,11 +121,11 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { //Add your implementation here - return 0; + return 0; } - + ::CosNotifyChannelAdmin::ProxyIDSeq * TAO_NS_SupplierAdmin::push_consumers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -130,12 +133,12 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { //Add your implementation here - return 0; + return 0; } - + ::CosNotifyChannelAdmin::ProxyConsumer_ptr TAO_NS_SupplierAdmin::get_proxy_consumer ( - CosNotifyChannelAdmin::ProxyID proxy_id - ) + CosNotifyChannelAdmin::ProxyID proxy_id + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyChannelAdmin::ProxyNotFound @@ -143,13 +146,13 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { //Add your implementation here - return 0; + return 0; } - + ::CosNotifyChannelAdmin::ProxyConsumer_ptr TAO_NS_SupplierAdmin::obtain_notification_pull_consumer ( - CosNotifyChannelAdmin::ClientType ctype, - CosNotifyChannelAdmin::ProxyID_out proxy_id - ) + CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyChannelAdmin::AdminLimitExceeded @@ -157,11 +160,11 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { //Add your implementation here - return 0; + return 0; } - + ::CosNotification::QoSProperties * TAO_NS_SupplierAdmin::get_qos ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -169,25 +172,13 @@ CosNotifyChannelAdmin::AdminID TAO_NS_SupplierAdmin::MyID ( { //Add your implementation here - return 0; + return 0; } - -void TAO_NS_SupplierAdmin::set_qos ( - const CosNotification::QoSProperties & qos - ) - ACE_THROW_SPEC (( - CORBA::SystemException - , CosNotification::UnsupportedQoS - )) -{ - //Add your implementation here -} - void TAO_NS_SupplierAdmin::validate_qos ( - const CosNotification::QoSProperties & required_qos, - CosNotification::NamedPropertyRangeSeq_out available_qos - ) + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotification::UnsupportedQoS @@ -196,82 +187,83 @@ void TAO_NS_SupplierAdmin::validate_qos ( { //Add your implementation here } - -void TAO_NS_SupplierAdmin::offer_change ( - const CosNotification::EventTypeSeq & added, - const CosNotification::EventTypeSeq & removed - ) + +void +TAO_NS_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyComm::InvalidEventType )) { - //Add your implementation here + TAO_NS_EventTypeSeq seq_added (added); + TAO_NS_EventTypeSeq seq_removed (removed); + + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->subscribed_types_.init (seq_added, seq_removed); + } + + TAO_NS_Subscription_Change_Worker worker (added, removed); + + this->collection_->for_each (&worker ACE_ENV_ARG_PARAMETER); } - -CosNotifyFilter::FilterID TAO_NS_SupplierAdmin::add_filter ( - CosNotifyFilter::Filter_ptr new_filter - ) + +CosNotifyFilter::FilterID +TAO_NS_SupplierAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException )) - { - //Add your implementation here - return 0; + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); } - -void TAO_NS_SupplierAdmin::remove_filter ( - CosNotifyFilter::FilterID filter - ) + +void +TAO_NS_SupplierAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyFilter::FilterNotFound )) - { - //Add your implementation here + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); } - -::CosNotifyFilter::Filter_ptr TAO_NS_SupplierAdmin::get_filter ( - CosNotifyFilter::FilterID filter - ) + +::CosNotifyFilter::Filter_ptr +TAO_NS_SupplierAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException , CosNotifyFilter::FilterNotFound )) - { - //Add your implementation here - return 0; + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); } - -::CosNotifyFilter::FilterIDSeq * TAO_NS_SupplierAdmin::get_all_filters ( - - ) + +::CosNotifyFilter::FilterIDSeq* +TAO_NS_SupplierAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException )) - { - //Add your implementation here - return 0; + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); } - -void TAO_NS_SupplierAdmin::remove_all_filters ( - - ) + +void +TAO_NS_SupplierAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException )) - { - //Add your implementation here + this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); } - + ::CosEventChannelAdmin::ProxyPushConsumer_ptr TAO_NS_SupplierAdmin::obtain_push_consumer ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -279,11 +271,11 @@ void TAO_NS_SupplierAdmin::remove_all_filters ( { //Add your implementation here - return 0; + return 0; } - + ::CosEventChannelAdmin::ProxyPullConsumer_ptr TAO_NS_SupplierAdmin::obtain_pull_consumer ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -291,6 +283,5 @@ void TAO_NS_SupplierAdmin::remove_all_filters ( { //Add your implementation here - return 0; + return 0; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h index c1eee20ab10..28d75a6fd28 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h @@ -37,10 +37,7 @@ public: TAO_NS_SupplierAdmin (void); /// Destructor - ~TAO_NS_SupplierAdmin (); - - /// Init this object. - void set (CosNotifyChannelAdmin::InterFilterGroupOperator op ACE_ENV_ARG_DECL); + ~TAO_NS_SupplierAdmin (); /// Return servant virtual PortableServer::Servant servant (void); @@ -53,37 +50,37 @@ public: virtual void release (void); protected: - /// = CosNotifyChannelAdmin::SupplierAdmin methods + /// = CosNotifyChannelAdmin::SupplierAdmin methods virtual CosNotifyChannelAdmin::AdminID MyID ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_consumers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_consumers ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -116,14 +113,14 @@ protected: )); virtual void destroy ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosNotification::QoSProperties * get_qos ( - + ) ACE_THROW_SPEC (( CORBA::SystemException @@ -179,28 +176,28 @@ protected: )); virtual ::CosNotifyFilter::FilterIDSeq * get_all_filters ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual void remove_all_filters ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosEventChannelAdmin::ProxyPushConsumer_ptr obtain_push_consumer ( - + ) ACE_THROW_SPEC (( CORBA::SystemException )); virtual ::CosEventChannelAdmin::ProxyPullConsumer_ptr obtain_pull_consumer ( - + ) ACE_THROW_SPEC (( CORBA::SystemException diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp index b2393adc7e7..726ccb47499 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp @@ -31,22 +31,22 @@ TAO_NS_ThreadPool_Task::init (NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG // Become an active object. if (this->ACE_Task <ACE_SYNCH>::activate (flags, - tp_params->static_threads, - 0, - tp_params->default_priority) == -1) + tp_params->static_threads, + 0, + tp_params->default_priority) == -1) { if (TAO_debug_level > 0) - { - if (ACE_OS::last_error () == EPERM) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Insufficient privilege.\n"))); - else - ACE_DEBUG ((LM_ERROR, - ACE_TEXT ("(%t) task activation at priority %d failed\n") - ACE_TEXT ("exiting!\n%a"), - tp_params->default_priority)); - } - - ACE_THROW (CORBA::BAD_PARAM ()); + { + if (ACE_OS::last_error () == EPERM) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Insufficient privilege.\n"))); + else + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("(%t) task activation at priority %d failed\n") + ACE_TEXT ("exiting!\n%a"), + tp_params->default_priority)); + } + + ACE_THROW (CORBA::BAD_PARAM ()); } } @@ -54,13 +54,13 @@ void TAO_NS_ThreadPool_Task::exec (TAO_NS_Method_Request& method_request) { /// Use Buffering Strategy - + TAO_NS_Method_Request* request_copy = method_request.copy (); - + this->activation_queue_.enqueue (request_copy); } -int +int TAO_NS_ThreadPool_Task::svc (void) { for (;;) @@ -71,9 +71,9 @@ TAO_NS_ThreadPool_Task::svc (void) if (0 == mo_p) { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%t) activation queue shut down\n"))); + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%t) activation queue shut down\n"))); break; } auto_ptr<ACE_Method_Request> mo (mo_p); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Types.cpp b/TAO/orbsvcs/orbsvcs/Notify/Types.cpp index 8a5931d2563..6701d0ca8fa 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Types.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Types.cpp @@ -8,5 +8,3 @@ #endif /* __ACE_INLINE__ */ ACE_RCSID(RT_Notify, TAO_NS_Types, "$Id$") - - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Types.h b/TAO/orbsvcs/orbsvcs/Notify/Types.h index b9c0e9372b8..a5666018741 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Types.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Types.h @@ -20,7 +20,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "tao/corba.h" -#include "tao/orbconf.h" +#include "tao/orbconf.h" /** * Forward declare templates @@ -29,6 +29,13 @@ template <class EVENT, class SYNCH> class ACE_Refcounted_Auto_Ptr; template <class PROXY> class TAO_ESF_Proxy_Collection; template <class TYPE> class TAO_ESF_RefCount_Guard; template <class PROXY, class ACE_LOCK> class TAO_NS_Event_Map_T; +template <class T> class ACE_Unbounded_Queue; +template <class PEER> class TAO_NS_Dispatch_Observer_T; +template <class PROXY> class TAO_NS_Event_Map_Observer_T; +template <class PEER> class TAO_NS_Pending_Worker_T; +template <class LOCK, class TYPE> ACE_Atomic_Op; +template <class LOCK, class TYPE> TAO_NS_Signal_Property; +template <class TYPE> TAO_NS_Property_T; /** * Forward declare classes @@ -42,24 +49,49 @@ class TAO_NS_Proxy; class TAO_NS_Event; class TAO_NS_ProxySupplier; class TAO_NS_ProxyConsumer; +class TAO_NS_Peer; +class TAO_NS_EventType; +class TAO_NS_EventTypeSeq; /** * Define common types */ +typedef ACE_Reverse_Lock<TAO_SYNCH_MUTEX> TAO_NS_Reverse_Lock; + typedef CORBA::Long TAO_NS_Object_Id; typedef ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> TAO_NS_Event_var; -typedef TAO_ESF_Proxy_Collection<TAO_NS_ProxyConsumer> TAO_NS_Supplier_Collection; -typedef TAO_ESF_Proxy_Collection<TAO_NS_ProxySupplier> TAO_NS_Consumer_Collection; +typedef ACE_Unbounded_Queue<TAO_NS_Event_var> TAO_NS_Event_Collection; + +typedef TAO_ESF_Proxy_Collection<TAO_NS_ProxyConsumer> TAO_NS_ProxyConsumer_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_ProxySupplier> TAO_NS_ProxySupplier_Collection; typedef TAO_ESF_Proxy_Collection<TAO_NS_EventChannel> TAO_NS_EventChannel_Collection; typedef TAO_ESF_Proxy_Collection<TAO_NS_Admin> TAO_NS_Admin_Collection; typedef TAO_ESF_Proxy_Collection<TAO_NS_Proxy> TAO_NS_Proxy_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Consumer> TAO_NS_Consumer_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Supplier> TAO_NS_Supplier_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Peer> TAO_NS_Peer_Collection; + typedef TAO_ESF_RefCount_Guard<CORBA::ULong> TAO_NS_Object_RefCount_Guard; typedef TAO_NS_Event_Map_T<TAO_NS_ProxySupplier, TAO_SYNCH_RW_MUTEX> TAO_NS_Consumer_Map; typedef TAO_NS_Event_Map_T<TAO_NS_ProxyConsumer, TAO_SYNCH_RW_MUTEX> TAO_NS_Supplier_Map; +typedef TAO_NS_Event_Map_Observer_T<TAO_NS_ProxyConsumer> TAO_NS_Consumer_Map_Observer; +typedef TAO_NS_Event_Map_Observer_T<TAO_NS_ProxySupplier> TAO_NS_Supplier_Map_Observer; + +typedef TAO_NS_Dispatch_Observer_T<TAO_NS_Peer> TAO_NS_Updates_Dispatch_Observer; +typedef TAO_NS_Dispatch_Observer_T<TAO_NS_Consumer> TAO_NS_Event_Dispatch_Observer; + +typedef TAO_NS_Pending_Worker_T<TAO_NS_Peer> TAO_NS_Updates_Pending_Worker; +typedef TAO_NS_Pending_Worker_T<TAO_NS_Consumer> TAO_NS_Event_Pending_Worker; + +typedef ACE_Atomic_Op <TAO_SYNCH_MUTEX,CORBA::Long> TAO_NS_Property_Atomic_Long; +typedef TAO_NS_Signal_Property <TAO_SYNCH_MUTEX,CORBA::Long> TAO_NS_Signal_Property_Long; + +typedef TAO_NS_Property_T<CORBA::Long> TAO_NS_Property_Long; + #include "ace/post.h" #endif /* TAO_NS_TYPES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp index 53e7db14e55..6abd835bfe5 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp @@ -21,4 +21,3 @@ TAO_NS_Worker_Task::shutdown (void) { return; } - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h index 1c6636f07f1..c10c70d5581 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h @@ -24,7 +24,7 @@ /** * @class TAO_NS_Worker_Task * - * @brief Base Worker Task. + * @brief Base Worker Task. * */ class TAO_Notify_Export TAO_NS_Worker_Task diff --git a/TAO/orbsvcs/orbsvcs/Notify/etcl_notify_filtering_export.h b/TAO/orbsvcs/orbsvcs/Notify/etcl_notify_filtering_export.h new file mode 100644 index 00000000000..51203597ac5 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/etcl_notify_filtering_export.h @@ -0,0 +1,50 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ETCL_Notify_Filtering +// ------------------------------ +#ifndef ETCL_NOTIFY_FILTERING_EXPORT_H +#define ETCL_NOTIFY_FILTERING_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (ETCL_NOTIFY_FILTERING_HAS_DLL) +# define ETCL_NOTIFY_FILTERING_HAS_DLL 1 +#endif /* ! ETCL_NOTIFY_FILTERING_HAS_DLL */ + +#if defined (ETCL_NOTIFY_FILTERING_HAS_DLL) && (ETCL_NOTIFY_FILTERING_HAS_DLL == 1) +# if defined (ETCL_NOTIFY_FILTERING_BUILD_DLL) +# define ETCL_Notify_Filtering_Export ACE_Proper_Export_Flag +# define ETCL_NOTIFY_FILTERING_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define ETCL_NOTIFY_FILTERING_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* ETCL_NOTIFY_FILTERING_BUILD_DLL */ +# define ETCL_Notify_Filtering_Export ACE_Proper_Import_Flag +# define ETCL_NOTIFY_FILTERING_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define ETCL_NOTIFY_FILTERING_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ETCL_NOTIFY_FILTERING_BUILD_DLL */ +#else /* ETCL_NOTIFY_FILTERING_HAS_DLL == 1 */ +# define ETCL_Notify_Filtering_Export +# define ETCL_NOTIFY_FILTERING_SINGLETON_DECLARATION(T) +# define ETCL_NOTIFY_FILTERING_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* ETCL_NOTIFY_FILTERING_HAS_DLL == 1 */ + +// Set ETCL_NOTIFY_FILTERING_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (ETCL_NOTIFY_FILTERING_NTRACE) +# if (ACE_NTRACE == 1) +# define ETCL_NOTIFY_FILTERING_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define ETCL_NOTIFY_FILTERING_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !ETCL_NOTIFY_FILTERING_NTRACE */ + +#if (ETCL_NOTIFY_FILTERING_NTRACE == 1) +# define ETCL_NOTIFY_FILTERING_TRACE(X) +#else /* (ETCL_NOTIFY_FILTERING_NTRACE == 1) */ +# define ETCL_NOTIFY_FILTERING_TRACE(X) ACE_TRACE_IMPL(X) +#endif /* (ETCL_NOTIFY_FILTERING_NTRACE == 1) */ + +#endif /* ETCL_NOTIFY_FILTERING_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/orbsvcs/orbsvcs/Notify/notify_export.h b/TAO/orbsvcs/orbsvcs/Notify/notify_export.h index d17be740d41..35d26b85690 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/notify_export.h +++ b/TAO/orbsvcs/orbsvcs/Notify/notify_export.h @@ -1,4 +1,3 @@ - // -*- C++ -*- // $Id$ // Definition for Win32 Export directives. diff --git a/TAO/orbsvcs/orbsvcs/Notify/notify_stubs_export.h b/TAO/orbsvcs/orbsvcs/Notify/notify_stubs_export.h index 75b83640c83..1092241fe82 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/notify_stubs_export.h +++ b/TAO/orbsvcs/orbsvcs/Notify/notify_stubs_export.h @@ -1,50 +1,49 @@ - // -*- C++ -*- // $Id$ // Definition for Win32 Export directives. -// This file is generated automatically by generate_export_file.pl TAO_NOTIFY_STUBS +// This file is generated automatically by generate_export_file.pl TAO_Notify_Stubs // ------------------------------ -#ifndef TAO_NOTIFY_STUBS_EXPORT_H -#define TAO_NOTIFY_STUBS_EXPORT_H +#ifndef TAO_Notify_Stubs_EXPORT_H +#define TAO_Notify_Stubs_EXPORT_H #include "ace/config-all.h" -#if !defined (TAO_NOTIFY_STUBS_HAS_DLL) -# define TAO_NOTIFY_STUBS_HAS_DLL 1 -#endif /* ! TAO_NOTIFY_STUBS_HAS_DLL */ - -#if defined (TAO_NOTIFY_STUBS_HAS_DLL) && (TAO_NOTIFY_STUBS_HAS_DLL == 1) -# if defined (TAO_NOTIFY_STUBS_BUILD_DLL) -# define TAO_NOTIFY_STUBS_Export ACE_Proper_Export_Flag -# define TAO_NOTIFY_STUBS_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define TAO_NOTIFY_STUBS_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else /* TAO_NOTIFY_STUBS_BUILD_DLL */ -# define TAO_NOTIFY_STUBS_Export ACE_Proper_Import_Flag -# define TAO_NOTIFY_STUBS_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define TAO_NOTIFY_STUBS_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* TAO_NOTIFY_STUBS_BUILD_DLL */ -#else /* TAO_NOTIFY_STUBS_HAS_DLL == 1 */ -# define TAO_NOTIFY_STUBS_Export -# define TAO_NOTIFY_STUBS_SINGLETON_DECLARATION(T) -# define TAO_NOTIFY_STUBS_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* TAO_NOTIFY_STUBS_HAS_DLL == 1 */ - -// Set TAO_NOTIFY_STUBS_NTRACE = 0 to turn on library specific tracing even if +#if !defined (TAO_Notify_Stubs_HAS_DLL) +# define TAO_Notify_Stubs_HAS_DLL 1 +#endif /* ! TAO_Notify_Stubs_HAS_DLL */ + +#if defined (TAO_Notify_Stubs_HAS_DLL) && (TAO_Notify_Stubs_HAS_DLL == 1) +# if defined (TAO_Notify_Stubs_BUILD_DLL) +# define TAO_Notify_Stubs_Export ACE_Proper_Export_Flag +# define TAO_Notify_Stubs_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_Notify_Stubs_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_Notify_Stubs_BUILD_DLL */ +# define TAO_Notify_Stubs_Export ACE_Proper_Import_Flag +# define TAO_Notify_Stubs_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_Notify_Stubs_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_Notify_Stubs_BUILD_DLL */ +#else /* TAO_Notify_Stubs_HAS_DLL == 1 */ +# define TAO_Notify_Stubs_Export +# define TAO_Notify_Stubs_SINGLETON_DECLARATION(T) +# define TAO_Notify_Stubs_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_Notify_Stubs_HAS_DLL == 1 */ + +// Set TAO_Notify_Stubs_NTRACE = 0 to turn on library specific tracing even if // tracing is turned off for ACE. -#if !defined (TAO_NOTIFY_STUBS_NTRACE) +#if !defined (TAO_Notify_Stubs_NTRACE) # if (ACE_NTRACE == 1) -# define TAO_NOTIFY_STUBS_NTRACE 1 +# define TAO_Notify_Stubs_NTRACE 1 # else /* (ACE_NTRACE == 1) */ -# define TAO_NOTIFY_STUBS_NTRACE 0 +# define TAO_Notify_Stubs_NTRACE 0 # endif /* (ACE_NTRACE == 1) */ -#endif /* !TAO_NOTIFY_STUBS_NTRACE */ +#endif /* !TAO_Notify_Stubs_NTRACE */ -#if (TAO_NOTIFY_STUBS_NTRACE == 1) -# define TAO_NOTIFY_STUBS_TRACE(X) -#else /* (TAO_NOTIFY_STUBS_NTRACE == 1) */ -# define TAO_NOTIFY_STUBS_TRACE(X) ACE_TRACE_IMPL(X) -#endif /* (TAO_NOTIFY_STUBS_NTRACE == 1) */ +#if (TAO_Notify_Stubs_NTRACE == 1) +# define TAO_Notify_Stubs_TRACE(X) +#else /* (TAO_Notify_Stubs_NTRACE == 1) */ +# define TAO_Notify_Stubs_TRACE(X) ACE_TRACE_IMPL(X) +#endif /* (TAO_Notify_Stubs_NTRACE == 1) */ -#endif /* TAO_NOTIFY_STUBS_EXPORT_H */ +#endif /* TAO_Notify_Stubs_EXPORT_H */ // End of auto generated file. |