From 3cf97dcebf513d925d91e688be0ec5d546ba8e58 Mon Sep 17 00:00:00 2001 From: pradeep Date: Tue, 25 Feb 2003 13:15:26 +0000 Subject: *** empty log message *** --- TAO/orbsvcs/orbsvcs/Notify/Admin.cpp | 97 ++ TAO/orbsvcs/orbsvcs/Notify/Admin.h | 100 ++ TAO/orbsvcs/orbsvcs/Notify/Admin.inl | 19 + TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp | 70 + TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h | 114 ++ TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl | 55 + TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp | 271 ++++ TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h | 137 ++ TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl | 19 + TAO/orbsvcs/orbsvcs/Notify/Builder.cpp | 426 ++++++ TAO/orbsvcs/orbsvcs/Notify/Builder.h | 115 ++ TAO/orbsvcs/orbsvcs/Notify/Builder.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp | 105 ++ TAO/orbsvcs/orbsvcs/Notify/Consumer.h | 102 ++ TAO/orbsvcs/orbsvcs/Notify/Consumer.inl | 27 + TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp | 328 ++++ TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h | 217 +++ TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Consumer_Map.h | 36 + TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp | 62 + TAO/orbsvcs/orbsvcs/Notify/Container_T.h | 76 + TAO/orbsvcs/orbsvcs/Notify/Container_T.inl | 7 + .../orbsvcs/Notify/CosNotify_Initializer.cpp | 13 + TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.h | 38 + TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp | 327 ++++ TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h | 90 ++ TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp | 395 +++++ TAO/orbsvcs/orbsvcs/Notify/Default_Factory.h | 101 ++ TAO/orbsvcs/orbsvcs/Notify/Default_Factory.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp | 488 ++++++ TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h | 175 +++ TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp | 81 + TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h | 88 ++ TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Event.cpp | 46 + TAO/orbsvcs/orbsvcs/Notify/Event.h | 104 ++ TAO/orbsvcs/orbsvcs/Notify/Event.inl | 13 + TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp | 379 +++++ TAO/orbsvcs/orbsvcs/Notify/EventChannel.h | 221 +++ TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp | 192 +++ TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h | 122 ++ TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/EventType.cpp | 129 ++ TAO/orbsvcs/orbsvcs/Notify/EventType.h | 92 ++ TAO/orbsvcs/orbsvcs/Notify/EventType.inl | 13 + TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp | 223 +++ TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h | 74 + TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp | 328 ++++ TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h | 150 ++ TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl | 57 + TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp | 52 + TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h | 93 ++ TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl | 25 + TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp | 164 ++ TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h | 119 ++ TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl | 50 + TAO/orbsvcs/orbsvcs/Notify/Factory.h | 126 ++ TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp | 177 +++ TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h | 88 ++ TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h | 40 + TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.cpp | 47 + TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.h | 72 + TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.inl | 8 + TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp | 17 + TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h | 52 + TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl | 7 + TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp | 70 + TAO/orbsvcs/orbsvcs/Notify/Method_Request.h | 80 + TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl | 1 + .../orbsvcs/Notify/Method_Request_Dispatch.cpp | 71 + .../orbsvcs/Notify/Method_Request_Dispatch.h | 61 + .../orbsvcs/Notify/Method_Request_Dispatch.inl | 1 + .../Method_Request_Dispatch_No_Filtering.cpp | 57 + .../Notify/Method_Request_Dispatch_No_Filtering.h | 61 + .../Method_Request_Dispatch_No_Filtering.inl | 1 + .../orbsvcs/Notify/Method_Request_Lookup.cpp | 84 ++ TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h | 69 + .../orbsvcs/Notify/Method_Request_Lookup.inl | 1 + .../orbsvcs/Notify/Method_Request_Shutdown.cpp | 35 + .../orbsvcs/Notify/Method_Request_Shutdown.h | 57 + .../orbsvcs/Notify/Method_Request_Shutdown.inl | 1 + .../orbsvcs/Notify/Method_Request_Updates.cpp | 55 + .../orbsvcs/Notify/Method_Request_Updates.h | 66 + .../orbsvcs/Notify/Method_Request_Updates.inl | 3 + .../Notify/Notify_Constraint_Interpreter.cpp | 46 + .../orbsvcs/Notify/Notify_Constraint_Interpreter.h | 62 + .../orbsvcs/Notify/Notify_Constraint_Visitors.cpp | 1564 ++++++++++++++++++++ .../orbsvcs/Notify/Notify_Constraint_Visitors.h | 149 ++ .../orbsvcs/Notify/Notify_Default_CO_Factory.cpp | 12 + .../orbsvcs/Notify/Notify_Default_CO_Factory.h | 42 + .../Notify/Notify_Default_Collection_Factory.cpp | 12 + .../Notify/Notify_Default_Collection_Factory.h | 40 + .../orbsvcs/Notify/Notify_Default_EMO_Factory.cpp | 12 + .../orbsvcs/Notify/Notify_Default_EMO_Factory.h | 38 + .../orbsvcs/Notify/Notify_Default_POA_Factory.cpp | 12 + .../orbsvcs/Notify/Notify_Default_POA_Factory.h | 37 + .../Notify/Notify_EventChannelFactory_i.cpp | 47 + .../orbsvcs/Notify/Notify_EventChannelFactory_i.h | 39 + .../orbsvcs/Notify/Notify_EventChannel_i.cpp | 452 ++++++ TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.h | 318 ++++ TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.cpp | 9 + TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.h | 28 + TAO/orbsvcs/orbsvcs/Notify/Object.cpp | 265 ++++ TAO/orbsvcs/orbsvcs/Notify/Object.h | 164 ++ TAO/orbsvcs/orbsvcs/Notify/Object.inl | 37 + TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp | 165 +++ TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h | 84 ++ TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl | 7 + TAO/orbsvcs/orbsvcs/Notify/Peer.cpp | 111 ++ TAO/orbsvcs/orbsvcs/Notify/Peer.h | 81 + TAO/orbsvcs/orbsvcs/Notify/Peer.inl | 15 + TAO/orbsvcs/orbsvcs/Notify/Properties.cpp | 44 + TAO/orbsvcs/orbsvcs/Notify/Properties.h | 149 ++ TAO/orbsvcs/orbsvcs/Notify/Properties.inl | 145 ++ TAO/orbsvcs/orbsvcs/Notify/Property.h | 39 + TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp | 53 + TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h | 62 + TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl | 7 + TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp | 43 + TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h | 81 + TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl | 49 + TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp | 119 ++ TAO/orbsvcs/orbsvcs/Notify/Property_T.h | 161 ++ TAO/orbsvcs/orbsvcs/Notify/Property_T.inl | 78 + TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp | 133 ++ TAO/orbsvcs/orbsvcs/Notify/Proxy.h | 106 ++ TAO/orbsvcs/orbsvcs/Notify/Proxy.inl | 7 + TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp | 152 ++ TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h | 93 ++ TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl | 19 + TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp | 81 + TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h | 84 ++ TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp | 180 +++ TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h | 100 ++ TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl | 19 + TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp | 223 +++ TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h | 162 ++ TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp | 160 ++ TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h | 158 ++ TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp | 138 ++ TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h | 102 ++ TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl | 25 + TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp | 106 ++ TAO/orbsvcs/orbsvcs/Notify/RT_Builder.h | 54 + TAO/orbsvcs/orbsvcs/Notify/RT_Builder.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/RT_Factory.cpp | 29 + TAO/orbsvcs/orbsvcs/Notify/RT_Factory.h | 50 + TAO/orbsvcs/orbsvcs/Notify/RT_Factory.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp | 96 ++ TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h | 60 + TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.cpp | 153 ++ TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.h | 64 + TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/RT_Properties.cpp | 17 + TAO/orbsvcs/orbsvcs/Notify/RT_Properties.h | 65 + TAO/orbsvcs/orbsvcs/Notify/RT_Properties.inl | 27 + TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.cpp | 48 + TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.h | 64 + TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp | 54 + TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h | 71 + TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl | 7 + TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp | 51 + TAO/orbsvcs/orbsvcs/Notify/Refcountable.h | 81 + TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl | 14 + TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.cpp | 37 + TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.h | 68 + TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.inl | 9 + TAO/orbsvcs/orbsvcs/Notify/Service.h | 59 + .../Structured/RT_StructuredProxyPushSupplier.cpp | 44 + .../Structured/RT_StructuredProxyPushSupplier.h | 58 + .../Structured/RT_StructuredProxyPushSupplier.inl | 3 + .../orbsvcs/Notify/Structured/StructuredEvent.cpp | 93 ++ .../orbsvcs/Notify/Structured/StructuredEvent.h | 77 + .../orbsvcs/Notify/Structured/StructuredEvent.inl | 4 + .../Structured/StructuredProxyPushConsumer.cpp | 107 ++ .../Structured/StructuredProxyPushConsumer.h | 98 ++ .../Structured/StructuredProxyPushConsumer.inl | 3 + .../Structured/StructuredProxyPushSupplier.cpp | 82 + .../Structured/StructuredProxyPushSupplier.h | 98 ++ .../Structured/StructuredProxyPushSupplier.inl | 3 + .../Notify/Structured/StructuredPushConsumer.cpp | 57 + .../Notify/Structured/StructuredPushConsumer.h | 67 + .../Notify/Structured/StructuredPushConsumer.inl | 3 + .../Notify/Structured/StructuredPushSupplier.cpp | 33 + .../Notify/Structured/StructuredPushSupplier.h | 58 + .../Notify/Structured/StructuredPushSupplier.inl | 3 + .../orbsvcs/Notify/Subscription_Change_Worker.cpp | 18 + .../orbsvcs/Notify/Subscription_Change_Worker.h | 55 + .../orbsvcs/Notify/Subscription_Change_Worker.inl | 9 + TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp | 35 + TAO/orbsvcs/orbsvcs/Notify/Supplier.h | 66 + TAO/orbsvcs/orbsvcs/Notify/Supplier.inl | 7 + TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp | 300 ++++ TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h | 189 +++ TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/Supplier_Map.h | 35 + TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp | 180 +++ TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h | 95 ++ TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl | 15 + TAO/orbsvcs/orbsvcs/Notify/Timer.h | 49 + TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.cpp | 47 + TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h | 66 + TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.cpp | 47 + TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h | 62 + TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.inl | 3 + TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp | 22 + TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h | 70 + TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl | 1 + TAO/orbsvcs/orbsvcs/Notify/notify_export.h | 40 + TAO/orbsvcs/orbsvcs/Notify/rt_notify_export.h | 39 + 220 files changed, 18709 insertions(+) create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Admin.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Admin.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Admin.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Builder.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Builder.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Builder.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Consumer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Consumer.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Consumer_Map.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Container_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Container_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Default_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Default_Factory.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventChannel.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventType.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventType.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventType.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Object.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Object.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Object.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Peer.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Peer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Peer.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Properties.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Properties.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Properties.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Property_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Proxy.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Proxy.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Builder.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Builder.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Factory.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Factory.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Factory.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Properties.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Properties.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_Properties.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Refcountable.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Service.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Supplier.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Supplier.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Supplier_Map.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl create mode 100644 TAO/orbsvcs/orbsvcs/Notify/notify_export.h create mode 100644 TAO/orbsvcs/orbsvcs/Notify/rt_notify_export.h diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp new file mode 100644 index 00000000000..6723aa20d68 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp @@ -0,0 +1,97 @@ +// $Id$ + +#include "Admin.h" + +#if ! defined (__ACE_INLINE__) +#include "Admin.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Admin, "$Id$") + +#include "orbsvcs/CosNotifyChannelAdminC.h" + +#include "Container_T.h" +#include "Proxy.h" +#include "EventChannel.h" + +TAO_NS_Admin::TAO_NS_Admin (void) + : ec_ (0) + , proxy_container_ (0) + , filter_operator_ (CosNotifyChannelAdmin::OR_OP) +{ + // Initialize all Admin objects to initially be subscribed for all events. + // This is a reasonable default and is required to allow Cos Event consumers/suppliers to send/receive events, + this->subscribed_types_.insert (TAO_NS_EventType::special ()); +} + +TAO_NS_Admin::~TAO_NS_Admin () +{ + this->ec_->_decr_refcnt (); +} + +void +TAO_NS_Admin::init (TAO_NS_EventChannel *ec ACE_ENV_ARG_DECL) +{ + this->ec_ = ec; + + this->ec_->_incr_refcnt (); + + this->TAO_NS_Object::init (ec); + + ACE_NEW_THROW_EX (this->proxy_container_, + TAO_NS_Proxy_Container (), + CORBA::INTERNAL ()); + ACE_CHECK; + + this->proxy_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + +} + +void +TAO_NS_Admin::remove (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + this->proxy_container_->remove (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_Admin::subscribed_types (TAO_NS_EventTypeSeq& subscribed_types ACE_ENV_ARG_DECL) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // copy + subscribed_types = this->subscribed_types_; +} + +int +TAO_NS_Admin::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return 1; + + this->proxy_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + delete this->proxy_container_; + + return 0; +} + +void +TAO_NS_Admin::insert (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + this->proxy_container_->insert (proxy ACE_ENV_ARG_PARAMETER); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_Container_T ; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Container_T + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.h b/TAO/orbsvcs/orbsvcs/Notify/Admin.h new file mode 100644 index 00000000000..12228fb5a67 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.h @@ -0,0 +1,100 @@ +/* -*- C++ -*- */ +/** + * @file Admin.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_ADMIN_H +#define TAO_NS_ADMIN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "FilterAdmin.h" +#include "EventTypeSeq.h" +#include "Object.h" + +class TAO_NS_Proxy; +class TAO_NS_EventChannel; +template class TAO_NS_Container_T; + +/** + * @class TAO_NS_Admin + * + * @brief Base class for the ConsumerAdmin and SupplierAdmin. + * + */ + +class TAO_Notify_Export TAO_NS_Admin : public virtual TAO_NS_Object +{ + friend class TAO_NS_Builder; +public: + typedef CosNotifyChannelAdmin::AdminIDSeq SEQ; + typedef CosNotifyChannelAdmin::AdminIDSeq_var SEQ_VAR; + + /// Constuctor + TAO_NS_Admin (void); + + /// Destructor + ~TAO_NS_Admin (); + + /// Init + void init (TAO_NS_EventChannel *ec ACE_ENV_ARG_DECL); + + /// Insert the proxy in the . + void insert (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL); + + /// Remove type from container_ + void remove (TAO_NS_Proxy *proxy ACE_ENV_ARG_DECL); + + /// 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 ACE_ENV_ARG_DECL); + + /// Shutdown + virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); + +protected: + typedef TAO_NS_Container_T TAO_NS_Proxy_Container; + + /// = Data Members + + /// The EventChannel. + TAO_NS_EventChannel *ec_; + + /// The Proxy Container. + TAO_NS_Proxy_Container *proxy_container_;; + + /// 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__) +#include "Admin.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.inl b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl new file mode 100644 index 00000000000..2975697d92a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl @@ -0,0 +1,19 @@ +// $Id$ + +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/AdminProperties.cpp b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp new file mode 100644 index 00000000000..46b3d3c0ec2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp @@ -0,0 +1,70 @@ +// $Id$ + +#include "AdminProperties.h" + +#if ! defined (__ACE_INLINE__) +#include "AdminProperties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_AdminProperties, "$id$") + +#include "orbsvcs/CosNotificationC.h" + +TAO_NS_AdminProperties::TAO_NS_AdminProperties (void) + : max_global_queue_length_ (CosNotification::MaxQueueLength, 0), + max_consumers_ (CosNotification::MaxConsumers, 0), + max_suppliers_ (CosNotification::MaxSuppliers, 0), + reject_new_events_ (CosNotification::RejectNewEvents, 0), + global_queue_length_ (0), + global_queue_not_full_condition_ (global_queue_lock_) +{ +} + +TAO_NS_AdminProperties::~TAO_NS_AdminProperties () +{ +} + +int +TAO_NS_AdminProperties::init (const CosNotification::PropertySeq& prop_seq) +{ + if (TAO_NS_PropertySeq::init (prop_seq) != 0) + return -1; + + this->max_global_queue_length_.set (*this); + this->max_consumers_.set (*this); + this->max_suppliers_.set (*this); + this->reject_new_events_.set (*this); + + //@@ check if unsupported property was set. + // This will happen when number of successfull inits != numbers of items bound in map_. + + return 0; +} + +CORBA::Boolean +TAO_NS_AdminProperties::queue_full (void) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, 1); + + if (this->max_global_queue_length () == 0) + return 0; + else + if (this->global_queue_length_ > this->max_global_queue_length ().value ()) + return 1; + + return 0; +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Atomic_Op; +template class ACE_Atomic_Op_Ex; +template class ACE_Refcounted_Auto_Ptr; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Atomic_Op +#pragma instantiate ACE_Atomic_Op_Ex +#pragma ACE_Refcounted_Auto_Ptr + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h new file mode 100644 index 00000000000..e05e06d2b1c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h @@ -0,0 +1,114 @@ +/* -*- C++ -*- */ +/** + * @file AdminProperties.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_ADMINPROPERTIES_H +#define TAO_NS_ADMINPROPERTIES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Atomic_Op.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "tao/orbconf.h" +#include "PropertySeq.h" +#include "Property_T.h" +#include "Property.h" +#include "Property_Boolean.h" + +/** + * @class TAO_NS_AdminProperties + * + * @brief The AdminProperties per EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_AdminProperties : public TAO_NS_PropertySeq +{ +public: + /// Constuctor + TAO_NS_AdminProperties (void); + + /// Destructor + ~TAO_NS_AdminProperties (); + + // Init + int init (const CosNotification::PropertySeq& prop_seq); + + // = Accessors + const TAO_NS_Property_Long& max_global_queue_length (void) const; + const TAO_NS_Property_Long& max_consumers (void) const; + const TAO_NS_Property_Long& max_suppliers (void) const; + const TAO_NS_Property_Boolean& reject_new_events (void) const; + + CORBA::Long& global_queue_length (void); + TAO_SYNCH_MUTEX& global_queue_lock (void); + TAO_SYNCH_CONDITION& global_queue_not_full_condition (void); + + TAO_NS_Atomic_Property_Long& consumers (void); + TAO_NS_Atomic_Property_Long& suppliers (void); + + // = Helper method + /// Returns true if Queue is full + CORBA::Boolean queue_full (void); + +protected: + // @@ Pradeep can you explain why there is any maximum for these + // values? Should they be configurable by the user so the resource + // requirements can be bounded? + + // = Admin. properties + // for all these properties the default O implies no limit + /** + * The maximum number of events that will be queued by the channel before + * the channel begins discarding events or rejecting new events upon + * receipt of each new event. + */ + TAO_NS_Property_Long max_global_queue_length_; + + /// The maximum number of consumers that can be connected to the channel at + /// any given time. + TAO_NS_Property_Long max_consumers_; + + /// The maximum number of suppliers that can be connected to the channel at + /// any given time. + TAO_NS_Property_Long max_suppliers_; + + /// Reject any new event. + TAO_NS_Property_Boolean reject_new_events_; + + //= Variables + /// This is used to count the queue length across all buffers in the Notify Service + /// to enforce the "MaxQueueLength" property. + CORBA::Long global_queue_length_; + + /// Global queue lock used to serialize access to all queues. + TAO_SYNCH_MUTEX global_queue_lock_; + + /// The condition that the queue_length_ is not at max. + TAO_SYNCH_CONDITION global_queue_not_full_condition_; + + /// These are used to count the number of consumers and suppliers connected to + /// the system. + TAO_NS_Atomic_Property_Long consumers_; + TAO_NS_Atomic_Property_Long suppliers_; +}; + +typedef ACE_Refcounted_Auto_Ptr TAO_NS_AdminProperties_var; + +#if defined (__ACE_INLINE__) +#include "AdminProperties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ADMINPROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl new file mode 100644 index 00000000000..4abdd9b071a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl @@ -0,0 +1,55 @@ +// $Id$ + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_AdminProperties::max_global_queue_length (void) const +{ + return this->max_global_queue_length_; +} + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_AdminProperties::max_consumers (void) const +{ + return this->max_consumers_; +} + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_AdminProperties::max_suppliers (void) const +{ + return this->max_suppliers_; +} + +ACE_INLINE const TAO_NS_Property_Boolean& +TAO_NS_AdminProperties::reject_new_events (void) const +{ + return this->reject_new_events_; +} + +ACE_INLINE CORBA::Long& +TAO_NS_AdminProperties::global_queue_length (void) +{ + return this->global_queue_length_; +} + +ACE_INLINE TAO_SYNCH_MUTEX& +TAO_NS_AdminProperties::global_queue_lock (void) +{ + return this->global_queue_lock_; +} + +ACE_INLINE TAO_SYNCH_CONDITION& +TAO_NS_AdminProperties::global_queue_not_full_condition (void) +{ + return this->global_queue_not_full_condition_; +} + +ACE_INLINE TAO_NS_Atomic_Property_Long& +TAO_NS_AdminProperties::consumers (void) +{ + return this->consumers_; +} + +ACE_INLINE TAO_NS_Atomic_Property_Long& +TAO_NS_AdminProperties::suppliers (void) +{ + return this->suppliers_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp new file mode 100644 index 00000000000..c030592d339 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp @@ -0,0 +1,271 @@ +// $Id$ + +#include "Buffering_Strategy.h" + +#if ! defined (__ACE_INLINE__) +#include "Buffering_Strategy.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Buffering_Strategy, "$id$") + +#include "ace/Message_Queue.h" +#include "orbsvcs/CosNotificationC.h" +#include "Method_Request.h" +#include "Notify_Extensions.h" +#include "QoSProperties.h" +#include "tao/debug.h" + +TAO_NS_Buffering_Strategy::TAO_NS_Buffering_Strategy (TAO_NS_Message_Queue& msg_queue, TAO_NS_AdminProperties_var& admin_properties, CORBA::Long batch_size) + : msg_queue_ (msg_queue), + admin_properties_ (admin_properties), + global_queue_lock_ (admin_properties->global_queue_lock ()), + global_queue_not_full_condition_ (admin_properties->global_queue_not_full_condition ()), + global_queue_length_ (admin_properties->global_queue_length ()), + max_global_queue_length_ (admin_properties->max_global_queue_length ()), + max_local_queue_length_ (0), + order_policy_ (CosNotification::OrderPolicy, CosNotification::AnyOrder), + discard_policy_ (CosNotification::DiscardPolicy, CosNotification::AnyOrder), + use_discarding_ (1), + local_queue_not_full_condition_ (global_queue_lock_), + batch_size_ (batch_size), + batch_size_reached_condition_ (global_queue_lock_), + shutdown_ (0) +{ +} + +TAO_NS_Buffering_Strategy::~TAO_NS_Buffering_Strategy () +{ +} + +void +TAO_NS_Buffering_Strategy::update_qos_properties (const TAO_NS_QoSProperties& qos_properties) +{ + this->order_policy_.set (qos_properties); + + if (this->discard_policy_.set (qos_properties) != -1) + { + this->use_discarding_ = 1; + } + + TAO_NS_Property_Time blocking_timeout (TAO_Notify_Extensions::BlockingPolicy); + + if (blocking_timeout.set (qos_properties) != -1) // if set to a valid time, init the blocking_time_ + { + this->use_discarding_ = 0; + + this->blocking_time_ = +# if defined (ACE_CONFIG_WIN32_H) + ACE_Time_Value (ACE_static_cast (long, blocking_timeout.value ())); +# else + ACE_Time_Value (blocking_timeout.value () / 1); +# endif /* ACE_CONFIG_WIN32_H */ + } +} + +void +TAO_NS_Buffering_Strategy::shutdown (void) +{ + ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_); + + this->shutdown_ = 1; + + this->global_queue_not_full_condition_.broadcast (); + this->local_queue_not_full_condition_.broadcast (); + this->batch_size_reached_condition_.broadcast (); +} + +int +TAO_NS_Buffering_Strategy::enqueue (TAO_NS_Method_Request& method_request) +{ + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); + + // while either local or global max reached + while ((this->max_local_queue_length_ != 0 && + this->msg_queue_.message_count () == this->max_local_queue_length_) + || + (this->max_global_queue_length_.value () != 0 && + this->global_queue_length_ == this->max_global_queue_length_.value ())) + { + if (this->shutdown_ == 1) // if we're shutdown, don't play this silly game. + return -1; + + if (this->use_discarding_ == 1) + { + if (this->global_queue_length_ == this->max_global_queue_length_.value () + && this->msg_queue_.message_count () == 0) // global max. reached but can't discard + { + // block. this is a hack because the real solution is to locate the appropriate queue and dequeue from it. + this->global_queue_not_full_condition_.wait (); + } + else // local max reached or, at global max but non-zero local count. + { + if (this->discard () == -1) + return -1; + + --this->global_queue_length_; + + // ACE_DEBUG ((LM_DEBUG, "Discarded from %x, global_queue_length = %d\n", this, this->global_queue_length_)); + + this->global_queue_not_full_condition_.signal (); + this->local_queue_not_full_condition_.signal (); + } + } + else // block + { + if (this->msg_queue_.message_count () == this->max_local_queue_length_) // local maximum reached + { + if (this->blocking_time_ == ACE_Time_Value::zero) // wait forever if need be. + { + this->local_queue_not_full_condition_.wait (); + } + else // finite blocking time. + { + ACE_Time_Value absolute = ACE_OS::gettimeofday () + this->blocking_time_; + + if (this->local_queue_not_full_condition_.wait (&absolute) == -1) // returns -1 on timeout + return -1; // Note message is discarded if it could not be enqueued in the given time. + } + } + else // global max reached + { + if (this->blocking_time_ == ACE_Time_Value::zero) // wait forever if need be. + { + this->global_queue_not_full_condition_.wait (); + } + else // finite blocking time. + { + ACE_Time_Value absolute = ACE_OS::gettimeofday () + blocking_time_; + + if (this->global_queue_not_full_condition_.wait (&absolute) == -1) // returns -1 on timeout + return -1; + } + } + } // block + } // while + + if (this->queue (method_request) == -1) + { + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "Panic! failed to enqueue event")); + return -1; + } + + ++this->global_queue_length_; + + // ACE_DEBUG ((LM_DEBUG, "Inserted to %x, global_queue_length = %d\n", this, this->global_queue_length_)); + + if (this->msg_queue_.message_count () == this->batch_size_) + batch_size_reached_condition_.signal (); + + return this->msg_queue_.message_count (); +} + +int +TAO_NS_Buffering_Strategy::dequeue (TAO_NS_Method_Request* &method_request, const ACE_Time_Value *abstime) +{ + ACE_Message_Block *mb; + + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); + + while (this->msg_queue_.message_count () < this->batch_size_) // block + { + this->batch_size_reached_condition_.wait (abstime); + + if (this->shutdown_ == 1) // if we're shutdown, don't play this silly game. + return -1; + + if (errno == ETIME) + return 0; + } + + if (this->msg_queue_.dequeue (mb) == -1) + return -1; + + method_request = ACE_dynamic_cast (TAO_NS_Method_Request*, mb); + + if (method_request == 0) + return -1; + + --this->global_queue_length_; + + // ACE_DEBUG ((LM_DEBUG, "Dequeued from %x, global_queue_length = %d\n", this, this->global_queue_length_)); + + this->global_queue_not_full_condition_.signal (); + this->local_queue_not_full_condition_.signal (); + + return 1; +} + +int +TAO_NS_Buffering_Strategy::queue (TAO_NS_Method_Request& method_request) +{ + int result; + + // Queue according to order policy + if (this->order_policy_ == CosNotification::AnyOrder || + this->order_policy_ == CosNotification::FifoOrder) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "enqueue in fifo order\n")); + // Insert at the end of the queue. + result = this->msg_queue_.enqueue_tail (&method_request); + } + else if (this->order_policy_ == CosNotification::PriorityOrder) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "enqueue in priority order\n")); + result = this->msg_queue_.enqueue_prio (&method_request); + } + else if (this->order_policy_ == CosNotification::DeadlineOrder) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "enqueue in deadline order\n")); + result = this->msg_queue_.enqueue_deadline (&method_request); + } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - Invalid order policy\n")); + + result = -1; + } + + return result; +} + +int +TAO_NS_Buffering_Strategy::discard (void) +{ + ACE_Message_Block *mb; + int result; + + if (this->discard_policy_ == CosNotification::AnyOrder || + this->discard_policy_ == CosNotification::FifoOrder) + { + result = this->msg_queue_.dequeue_head (mb); + } + else if (this->discard_policy_ == CosNotification::LifoOrder) + { + result = this->msg_queue_.dequeue_tail (mb); + } + else if (this->discard_policy_ == CosNotification::DeadlineOrder) + { + result = this->msg_queue_.dequeue_deadline (mb); + } + else if (this->discard_policy_ == CosNotification::PriorityOrder) + { + result = this->msg_queue_.dequeue_prio (mb); + } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "Invalid discard policy\n")); + result = -1; + } + + return result; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h new file mode 100644 index 00000000000..7b854a47508 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h @@ -0,0 +1,137 @@ +/* -*- C++ -*- */ +/** + * @file Buffering_Strategy.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_BUFFERING_STRATEGY_H +#define TAO_NS_BUFFERING_STRATEGY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +#include "ace/Message_Queue.h" +#include "orbsvcs/TimeBaseC.h" +#include "Property.h" +#include "Property_T.h" +#include "AdminProperties.h" + +class TAO_NS_Method_Request; +class TAO_NS_QoSProperties; + +typedef ACE_Message_Queue TAO_NS_Message_Queue; + +/** + * @class TAO_NS_Buffering_Strategy + * + * @brief Base Strategy to enqueue and dequeue items from a Message Queue. + * + */ +class TAO_Notify_Export TAO_NS_Buffering_Strategy +{ +public: + /// Constuctor + TAO_NS_Buffering_Strategy (TAO_NS_Message_Queue& msg_queue, TAO_NS_AdminProperties_var& admin_properties, CORBA::Long batch_size); + + /// Destructor + ~TAO_NS_Buffering_Strategy (); + + /// Update state with the following QoS Properties: + /// Order Policy + /// Discard Policy + /// MaxEventsPerConsumer + /// TAO_Notify_Extensions::BlockingPolicy + void update_qos_properties (const TAO_NS_QoSProperties& qos_properties); + + /// Enqueue according the enqueing strategy. + /// Return -1 on error else the number of items in the queue. + int enqueue (TAO_NS_Method_Request& method_request); + + /// Dequeue batch. This method will block for if non-zero or else blocks till an item is available. + /// Return -1 on error or if nothing is available, else the number of items actually dequeued (1). + int dequeue (TAO_NS_Method_Request* &method_request, const ACE_Time_Value *abstime); + + /// Shutdown + void shutdown (void); + + /// Set the new batch size. + void batch_size (CORBA::Long batch_size); + + /// Obtain our batch size + CORBA::Long batch_size (void); + + /// Set the max local queue length. + void max_local_queue_length (CORBA::Long length); + +protected: + /// Apply the Order Policy and queue. return -1 on error. + int queue (TAO_NS_Method_Request& method_request); + + /// Discard as per the Discard Policy. + int discard (void); + + ///= Data Members + + /// The local Message Queue + TAO_NS_Message_Queue& msg_queue_; + + /// Reference to the properties per event channel. + TAO_NS_AdminProperties_var admin_properties_; + + /// The shared global lock used by all the queues. + ACE_SYNCH_MUTEX& global_queue_lock_; + + /// The shared Condition for global queue not full. + ACE_SYNCH_CONDITION& global_queue_not_full_condition_; + + /// The global queue length - queue length accross all the queues. + CORBA::Long& global_queue_length_; + + /// The maximum events that can be queued overall. + const TAO_NS_Property_Long& max_global_queue_length_; + + /// The maximum queue length for the local queue. + CORBA::Long max_local_queue_length_; + + /// Order of events in internal buffers. + TAO_NS_Property_Short order_policy_; + + /// Policy to discard when buffers are full. + TAO_NS_Property_Short discard_policy_; + + /// Flag that we should use discarding(1) or blocking (0). + int use_discarding_; + + /// The blocking timeout will be used in place of discarding + /// This is a TAO specific extension. + ACE_Time_Value blocking_time_; // 0 means wait forever. + + /// Condition that the local queue is not full. + ACE_SYNCH_CONDITION local_queue_not_full_condition_; + + /// The batch size that we want to monitor for dequeuing. + CORBA::Long batch_size_; + + /// Condition that batch size reached. + ACE_SYNCH_CONDITION batch_size_reached_condition_; + + /// Flag to shutdown. + int shutdown_; +}; + +#if defined (__ACE_INLINE__) +#include "Buffering_Strategy.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_BUFFERING_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl new file mode 100644 index 00000000000..3dbfa925c5b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl @@ -0,0 +1,19 @@ +// $Id$ + +ACE_INLINE void +TAO_NS_Buffering_Strategy::batch_size (CORBA::Long batch_size) +{ + this->batch_size_ = batch_size; +} + +ACE_INLINE CORBA::Long +TAO_NS_Buffering_Strategy::batch_size (void) +{ + return this->batch_size_; +} + +ACE_INLINE void +TAO_NS_Buffering_Strategy::max_local_queue_length (CORBA::Long length) +{ + this->max_local_queue_length_ = length; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp new file mode 100644 index 00000000000..7f260d10cca --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp @@ -0,0 +1,426 @@ +// $Id$ +#include "Builder.h" + +#if ! defined (__ACE_INLINE__) +#include "Builder.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Builder, "$Id$") + +#include "ace/Dynamic_Service.h" +#include "tao/PortableServer/PortableServerC.h" +#include "Factory.h" +#include "Properties.h" +#include "POA_Helper.h" +#include "ID_Factory.h" +#include "EventChannelFactory.h" +#include "EventChannel.h" +#include "SupplierAdmin.h" +#include "ConsumerAdmin.h" +#include "Event_Manager.h" +#include "Worker_Task.h" +#include "Reactive_Task.h" +#include "ThreadPool_Task.h" +#include "FilterFactory.h" +#include "Object.h" +#include "EventType.h" +#include "Event.h" +#include "Any/AnyEvent.h" +#include "Any/ProxyPushConsumer.h" +#include "Any/ProxyPushSupplier.h" +#include "Any/CosEC_ProxyPushConsumer.h" +#include "Any/CosEC_ProxyPushSupplier.h" +#include "Structured/StructuredProxyPushConsumer.h" +#include "Structured/StructuredProxyPushSupplier.h" +#include "Sequence/SequenceProxyPushConsumer.h" +#include "Sequence/SequenceProxyPushSupplier.h" +#include "ETCL_FilterFactory.h" +#include "Container_T.h" + +template +class TAO_NS_Proxy_Builder_T +{ +public: + PROXY_PTR + build (PARENT *parent, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) + { + PROXY_VAR proxy_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + PROXY_IMPL* proxy = 0; + factory->create (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + PortableServer::ServantBase_var servant (proxy); + + proxy->init (parent ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + CORBA::Object_var obj = proxy->activate (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = proxy->id (); + + proxy_ret = PROXY::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + parent->insert (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (PROXY::_nil ()); + + return proxy_ret._retn (); + } +}; + +// define the ProxyConsumer Builders. +typedef TAO_NS_Proxy_Builder_T +TAO_NS_ProxyPushConsumer_Builder; + +typedef TAO_NS_Proxy_Builder_T +TAO_NS_StructuredProxyPushConsumer_Builder; + +typedef TAO_NS_Proxy_Builder_T +TAO_NS_SequenceProxyPushConsumer_Builder; + +typedef TAO_NS_Proxy_Builder_T +TAO_NS_CosEC_ProxyPushConsumer_Builder; + +// define the ProxySupplier Builders. +typedef TAO_NS_Proxy_Builder_T +TAO_NS_ProxyPushSupplier_Builder; + +typedef TAO_NS_Proxy_Builder_T +TAO_NS_StructuredProxyPushSupplier_Builder; + +typedef TAO_NS_Proxy_Builder_T +TAO_NS_SequenceProxyPushSupplier_Builder; + +typedef TAO_NS_Proxy_Builder_T +TAO_NS_CosEC_ProxyPushSupplier_Builder; + +TAO_NS_Builder::TAO_NS_Builder (void) +{ + // Init the static members. + TAO_NS_AnyEvent::event_type_ = TAO_NS_EventType::special (); +} + +TAO_NS_Builder::~TAO_NS_Builder () +{ +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_Builder::build_filter_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_FilterFactory* ff = ACE_Dynamic_Service::instance ("TAO_NS_FilterFactory"); + + if (ff == 0) + { + ACE_NEW_THROW_EX (ff, + TAO_NS_ETCL_FilterFactory (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CosNotifyFilter::FilterFactory::_nil ()); + } + + PortableServer::POA_var default_poa = TAO_NS_PROPERTIES::instance ()->default_poa (); + + return ff->create (default_poa ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_NS_Builder::build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::EventChannelFactory_var ecf_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + // Create ECF + TAO_NS_EventChannelFactory* ecf = 0; + factory->create (ecf ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + PortableServer::ServantBase_var servant_var (ecf); + + ecf->TAO_NS_EventChannelFactory::init (poa ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = ecf->activate (ecf ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + ecf_ret = CosNotifyChannelAdmin::EventChannelFactory::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + return (ecf_ret._retn ()); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_Builder::build_event_channel (TAO_NS_EventChannelFactory* ecf, const CosNotification::QoSProperties & initial_qos, const CosNotification::AdminProperties & initial_admin, CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::EventChannel_var ec_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_EventChannel* ec = 0; + factory->create (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + PortableServer::ServantBase_var servant_var (ec); + + ec->init (ecf, initial_qos, initial_admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + // insert ec in ec container. + ecf->ec_container_->insert (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + CORBA::Object_var obj = ec->activate (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + // Populate the ID to return. + id = ec->id (); + + ec_ret = CosNotifyChannelAdmin::EventChannel::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + return ec_ret._retn (); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_Builder::build_consumer_admin (TAO_NS_EventChannel* ec, CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::ConsumerAdmin_var ca_ret; + + 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 ()); + + PortableServer::ServantBase_var servant_var (ca); + + ca->init (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + ca->filter_operator (op); + + CORBA::Object_var obj = ca->activate (ca ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + id = ca->id (); + + ca_ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + // insert admin in CA container. + ec->ca_container_->insert (ca ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + return ca_ret._retn (); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_Builder::build_supplier_admin (TAO_NS_EventChannel* ec, CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::SupplierAdmin_var sa_ret; + + 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 ()); + + PortableServer::ServantBase_var servant_var (sa); + + sa->init (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + sa->filter_operator (op); + + CORBA::Object_var obj = sa->activate (sa ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + id = sa->id (); + + sa_ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + // insert admin in SA container. + ec->sa_container_->insert (sa ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + return sa_ret._retn (); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_Builder::build_proxy(TAO_NS_SupplierAdmin* sa + , CosNotifyChannelAdmin::ClientType ctype + , CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) +{ + switch (ctype) + { + case CosNotifyChannelAdmin::ANY_EVENT: + { + TAO_NS_ProxyPushConsumer_Builder pb; + return pb.build (sa, proxy_id ACE_ENV_ARG_PARAMETER); + } + break; + + case CosNotifyChannelAdmin::STRUCTURED_EVENT: + { + TAO_NS_StructuredProxyPushConsumer_Builder pb; + return pb.build (sa, proxy_id ACE_ENV_ARG_PARAMETER); + } + break; + + case CosNotifyChannelAdmin::SEQUENCE_EVENT: + { + TAO_NS_SequenceProxyPushConsumer_Builder pb; + return pb.build (sa, proxy_id ACE_ENV_ARG_PARAMETER); + } + break; + + default: + ACE_THROW_RETURN (CORBA::BAD_PARAM (), + CosNotifyChannelAdmin::ProxyConsumer::_nil ()); + } +} + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_Builder::build_proxy(TAO_NS_ConsumerAdmin* ca + , CosNotifyChannelAdmin::ClientType ctype + , CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) +{ + switch (ctype) + { + case CosNotifyChannelAdmin::ANY_EVENT: + { + TAO_NS_ProxyPushSupplier_Builder pb; + return pb.build (ca, proxy_id ACE_ENV_ARG_PARAMETER); + } + break; + + case CosNotifyChannelAdmin::STRUCTURED_EVENT: + { + TAO_NS_StructuredProxyPushSupplier_Builder pb; + return pb.build (ca, proxy_id ACE_ENV_ARG_PARAMETER); + } + break; + + case CosNotifyChannelAdmin::SEQUENCE_EVENT: + { + TAO_NS_SequenceProxyPushSupplier_Builder pb; + return pb.build (ca, proxy_id ACE_ENV_ARG_PARAMETER); + } + break; + + default: + ACE_THROW_RETURN (CORBA::BAD_PARAM (), + CosNotifyChannelAdmin::ProxySupplier::_nil ()); + } +} + +CosEventChannelAdmin::ProxyPushSupplier_ptr +TAO_NS_Builder::build_proxy (TAO_NS_ConsumerAdmin* ca ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::ProxyID proxy_id; + + TAO_NS_CosEC_ProxyPushSupplier_Builder pb; + + return pb.build (ca, proxy_id ACE_ENV_ARG_PARAMETER); +} + +CosEventChannelAdmin::ProxyPushConsumer_ptr +TAO_NS_Builder::build_proxy (TAO_NS_SupplierAdmin* sa ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::ProxyID proxy_id; + + TAO_NS_CosEC_ProxyPushConsumer_Builder pb; + + return pb.build (sa, proxy_id ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Builder::apply_reactive_concurrency (TAO_NS_Object& object ACE_ENV_ARG_DECL) +{ + TAO_NS_Reactive_Task* worker_task; + + ACE_NEW_THROW_EX (worker_task, + TAO_NS_Reactive_Task (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + worker_task->init (object.admin_properties_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + object.worker_task_own (worker_task); + + object.worker_task_->_decr_refcnt (); +} + +void +TAO_NS_Builder::apply_thread_pool_concurrency (TAO_NS_Object& object, const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL) +{ + TAO_NS_ThreadPool_Task* worker_task; + + ACE_NEW_THROW_EX (worker_task, + TAO_NS_ThreadPool_Task (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + worker_task->init (tp_params, object.admin_properties_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + object.worker_task_own (worker_task); + + object.worker_task_->_decr_refcnt (); +} + +void +TAO_NS_Builder::apply_lane_concurrency (TAO_NS_Object& object, const NotifyExt::ThreadPoolLanesParams& /*tpl_params*/ ACE_ENV_ARG_DECL) +{ + // No lane support + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Dynamic_Service; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Dynamic_Service + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.h b/TAO/orbsvcs/orbsvcs/Notify/Builder.h new file mode 100644 index 00000000000..6bee188690d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.h @@ -0,0 +1,115 @@ +/* -*- C++ -*- */ +/** + * @file Builder.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_BUILDER_H +#define TAO_NS_BUILDER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/CosNotifyChannelAdminC.h" +#include "orbsvcs/NotifyExtC.h" +#include "AdminProperties.h" + +class TAO_NS_EventChannelFactory; +class TAO_NS_EventChannel; +class TAO_NS_SupplierAdmin; +class TAO_NS_ConsumerAdmin; +class TAO_NS_FilterFactory; +class TAO_NS_Object; + +/** + * @class TAO_NS_Builder + * + * @brief Helper class to create and activate CORBA objects. + * + */ +class TAO_Notify_Export TAO_NS_Builder +{ +public: + TAO_NS_Builder (void); + + virtual ~TAO_NS_Builder (); + + ///= Factory Methods + + /// Build EventChannel Factory. + virtual CosNotifyChannelAdmin::EventChannelFactory_ptr + build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + + /// Build the Filter Factory. + virtual CosNotifyFilter::FilterFactory_ptr build_filter_factory (ACE_ENV_SINGLE_ARG_DECL); + + /// Build EventChannel. + virtual CosNotifyChannelAdmin::EventChannel_ptr + build_event_channel (TAO_NS_EventChannelFactory* ecf + , const CosNotification::QoSProperties & initial_qos + , const CosNotification::AdminProperties & initial_admin + , CosNotifyChannelAdmin::ChannelID_out id + ACE_ENV_ARG_DECL); + + /// Build ConsumerAdmin + virtual CosNotifyChannelAdmin::ConsumerAdmin_ptr + build_consumer_admin (TAO_NS_EventChannel* ec + , CosNotifyChannelAdmin::InterFilterGroupOperator op + , CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL); + + /// Build SupplierAdmin + virtual CosNotifyChannelAdmin::SupplierAdmin_ptr + build_supplier_admin (TAO_NS_EventChannel* ec + , CosNotifyChannelAdmin::InterFilterGroupOperator op + , CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL); + + /// Build ProxyConsumer + virtual CosNotifyChannelAdmin::ProxyConsumer_ptr + build_proxy (TAO_NS_SupplierAdmin* sa + , CosNotifyChannelAdmin::ClientType ctype + , CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL); + + /// Build ProxySupplier. + virtual CosNotifyChannelAdmin::ProxySupplier_ptr + build_proxy (TAO_NS_ConsumerAdmin* ca + , CosNotifyChannelAdmin::ClientType ctype + , CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL); + + /// Build CosEC style ProxySupplier. + virtual CosEventChannelAdmin::ProxyPushSupplier_ptr + build_proxy (TAO_NS_ConsumerAdmin* ca ACE_ENV_ARG_DECL); + + /// Build CosEC style ProxyConsumer. + virtual CosEventChannelAdmin::ProxyPushConsumer_ptr + build_proxy (TAO_NS_SupplierAdmin* sa ACE_ENV_ARG_DECL); + + /// Apply Reactive concurrency. + virtual void apply_reactive_concurrency (TAO_NS_Object& object ACE_ENV_ARG_DECL); + + /// Apply Thread Pools. + virtual void apply_thread_pool_concurrency (TAO_NS_Object& object, const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL); + + /// Apply Thread Pools with Lanes. + virtual void apply_lane_concurrency (TAO_NS_Object& object, const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL); +}; + +#if defined (__ACE_INLINE__) +#include "Builder.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_BUILDER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.inl b/TAO/orbsvcs/orbsvcs/Notify/Builder.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp new file mode 100644 index 00000000000..2210c3ca7ad --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp @@ -0,0 +1,105 @@ +// $Id$ + +#include "Consumer.h" + +#if ! defined (__ACE_INLINE__) +#include "Consumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Consumer, "$Id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Unbounded_Queue.h" +#include "tao/debug.h" + +TAO_NS_Consumer::TAO_NS_Consumer (TAO_NS_ProxySupplier* proxy) + :proxy_ (proxy), event_collection_ (0), is_suspended_ (0) +{ + this->event_collection_ = new TAO_NS_Event_Collection (); +} + +TAO_NS_Consumer::~TAO_NS_Consumer () +{ + delete this->event_collection_; +} + +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) +{ + if (this->is_suspended_ == 1) // If we're suspended, queue for later delivery. + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->event_collection_->enqueue_head (event); + + return; + } + + ACE_TRY + { + this->push_i (event ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::OBJECT_NOT_EXIST, not_exist) + { + this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::SystemException, sysex) + { + this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; +} + +void +TAO_NS_Consumer::dispatch_pending (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + if (this->is_suspended_ == 1) + return; // Do nothing if we're suspended. + + TAO_NS_Event_Collection event_collection_copy; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + event_collection_copy = *this->event_collection_; // Payload is never copied, this is a collection 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); + } + } +} + +void +TAO_NS_Consumer::resume (ACE_ENV_SINGLE_ARG_DECL) +{ + this->is_suspended_ = 0; + + this->dispatch_pending (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_Consumer::dispatch_updates_i (const CosNotification::EventTypeSeq& added, const CosNotification::EventTypeSeq& removed + ACE_ENV_ARG_DECL) +{ + if (!CORBA::is_nil (this->publish_.in ())) + this->publish_->offer_change (added, removed ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.h b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h new file mode 100644 index 00000000000..9537e8f3398 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ +/** + * @file Consumer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_CONSUMER_H +#define TAO_NS_CONSUMER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "orbsvcs/CosNotificationC.h" +#include "Peer.h" +#include "Event.h" + +class TAO_NS_ProxySupplier; +class TAO_NS_Proxy; + +/** + * @class TAO_NS_Consumer + * + * @brief Astract Base class for wrapping consumer objects that connect to the EventChannel + * + */ +class TAO_Notify_Export TAO_NS_Consumer : public TAO_NS_Peer +{ +public: + /// Constuctor + TAO_NS_Consumer (TAO_NS_ProxySupplier* proxy); + + /// Destructor + virtual ~TAO_NS_Consumer (); + + /// Access Specific Proxy. + TAO_NS_ProxySupplier* proxy_supplier (void); + + /// Access Base Proxy. + virtual TAO_NS_Proxy* proxy (void); + + /// Push to this consumer. + void push (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); + + /// Push to this consumer. + virtual void push (const CORBA::Any& event ACE_ENV_ARG_DECL) = 0; + + /// Push to this consumer. + virtual void push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) = 0; + + /// Dispatch the pending events + void dispatch_pending (ACE_ENV_SINGLE_ARG_DECL); + + /// Is the connection suspended? + CORBA::Boolean is_suspended (void); + + /// Suspend Connection + void suspend (ACE_ENV_SINGLE_ARG_DECL); + + /// Resume Connection + void resume (ACE_ENV_SINGLE_ARG_DECL); + +protected: + // Dispatch updates + virtual void dispatch_updates_i (const CosNotification::EventTypeSeq& added, + const CosNotification::EventTypeSeq& removed + ACE_ENV_ARG_DECL); + + /// Push Implementation. + virtual void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL) = 0; + + /// Get the shared Proxy Lock + TAO_SYNCH_MUTEX* proxy_lock (void); + + /// The Proxy that we associate with. + TAO_NS_ProxySupplier* proxy_; + + /// Events pending to be delivered. + TAO_NS_Event_Collection* event_collection_; + + /// Suspended Flag. + CORBA::Boolean is_suspended_; + + /// Interface that accepts offer_changes + CosNotifyComm::NotifyPublish_var publish_; +}; + +#if defined (__ACE_INLINE__) +#include "Consumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_CONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl new file mode 100644 index 00000000000..d2a5a104c85 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl @@ -0,0 +1,27 @@ +// $Id$ + +#include "ProxySupplier.h" + +ACE_INLINE TAO_SYNCH_MUTEX* +TAO_NS_Consumer::proxy_lock (void) +{ + return &this->proxy_->lock_; +} + +ACE_INLINE TAO_NS_ProxySupplier* +TAO_NS_Consumer::proxy_supplier (void) +{ + return this->proxy_; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Consumer::is_suspended (void) +{ + return this->is_suspended_; +} + +ACE_INLINE void +TAO_NS_Consumer::suspend (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->is_suspended_ = 1; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp new file mode 100644 index 00000000000..458a73b6ad7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp @@ -0,0 +1,328 @@ +// $Id$ + +#include "ConsumerAdmin.h" + +#if ! defined (__ACE_INLINE__) +#include "ConsumerAdmin.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ConsumerAdmin, "$Id$") + +#include "ace/Auto_Ptr.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Subscription_Change_Worker.h" +#include "Proxy.h" +#include "EventChannel.h" +#include "Properties.h" +#include "Factory.h" +#include "Builder.h" +#include "Find_Worker_T.h" +#include "Seq_Worker_T.h" + +TAO_NS_ConsumerAdmin::TAO_NS_ConsumerAdmin (void) +{ +} + +TAO_NS_ConsumerAdmin::~TAO_NS_ConsumerAdmin () +{ +} + +void +TAO_NS_ConsumerAdmin::init (TAO_NS_EventChannel *ec ACE_ENV_ARG_DECL) +{ + TAO_NS_Admin::init (ec ACE_ENV_ARG_PARAMETER); + + const CosNotification::QoSProperties &default_ca_qos = + TAO_NS_PROPERTIES::instance ()->default_consumer_admin_qos_properties (); + + this->set_qos (default_ca_qos ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_ConsumerAdmin::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_ConsumerAdmin::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_ConsumerAdmin::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_ConsumerAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; + + this->ec_->remove (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) +{ + return TAO_NS_PROPERTIES::instance()->builder()->build_proxy (this + , ctype + , proxy_id + ACE_ENV_ARG_PARAMETER); +} + +CosEventChannelAdmin::ProxyPushSupplier_ptr +TAO_NS_ConsumerAdmin::obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return TAO_NS_PROPERTIES::instance()->builder()->build_proxy (this ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminID +TAO_NS_ConsumerAdmin::MyID (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->id (); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_ConsumerAdmin::MyChannel (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->ec_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +::CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_ConsumerAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_operator_; +} + +CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_ConsumerAdmin::push_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Seq_Worker_T seq_worker; + + return seq_worker.create (*this->proxy_container_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::get_proxy_supplier (CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )) +{ + TAO_NS_Find_Worker_T find_worker; + + return find_worker.resolve (proxy_id, *this->proxy_container_ ACE_ENV_ARG_PARAMETER); +} + +void TAO_NS_ConsumerAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + + +CosNotification::QoSProperties* +TAO_NS_ConsumerAdmin::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +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 + )) +{ + 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->proxy_container_->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 + )) +{ + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_ConsumerAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::Filter_ptr +TAO_NS_ConsumerAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::FilterIDSeq* +TAO_NS_ConsumerAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_ConsumerAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->filter_admin_.remove_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +/************ UNIMPLMENTED METHODS *************************/ + +CosNotifyFilter::MappingFilter_ptr +TAO_NS_ConsumerAdmin::priority_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ()); +} + +void +TAO_NS_ConsumerAdmin::priority_filter (CosNotifyFilter::MappingFilter_ptr /*priority_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosNotifyFilter::MappingFilter_ptr +TAO_NS_ConsumerAdmin::lifetime_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ()); +} + +void +TAO_NS_ConsumerAdmin::lifetime_filter (CosNotifyFilter::MappingFilter_ptr /*lifetime_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +::CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_ConsumerAdmin::pull_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::obtain_notification_pull_supplier (CosNotifyChannelAdmin::ClientType /*ctype*/, + CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyChannelAdmin::ProxySupplier::_nil ()); +} + +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 + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosEventChannelAdmin::ProxyPullSupplier_ptr +TAO_NS_ConsumerAdmin::obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosEventChannelAdmin::ProxyPullSupplier::_nil ()); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h new file mode 100644 index 00000000000..4c4244c5a4f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h @@ -0,0 +1,217 @@ +/* -*- C++ -*- */ +/** + * @file ConsumerAdmin.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_CONSUMERADMIN_H +#define TAO_NS_CONSUMERADMIN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "Admin.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_NS_ConsumerAdmin + * + * @brief Implementation of CosNotifyChannelAdmin::ConsumerAdmin + * + */ +class TAO_Notify_Export TAO_NS_ConsumerAdmin : public POA_CosNotifyChannelAdmin::ConsumerAdmin + , public virtual TAO_NS_Admin +{ +public: + /// Constuctor + TAO_NS_ConsumerAdmin (void); + + /// Destructor + ~TAO_NS_ConsumerAdmin (); + + /// Init + void init (TAO_NS_EventChannel *ec ACE_ENV_ARG_DECL); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Release this object. + virtual void release (void); + +protected: + + /// = CosNotifyChannelAdmin::ConsumerAdmin methods + virtual CosNotifyChannelAdmin::AdminID MyID (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyFilter::MappingFilter_ptr priority_filter (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void priority_filter (CosNotifyFilter::MappingFilter_ptr priority_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyFilter::MappingFilter_ptr lifetime_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void lifetime_filter (CosNotifyFilter::MappingFilter_ptr lifetime_filter + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr get_proxy_supplier (CosNotifyChannelAdmin::ProxyID proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )); + + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr + obtain_notification_pull_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr + obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotification::QoSProperties * get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos (const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void subscription_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )); + + 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 + )); + + virtual ::CosEventChannelAdmin::ProxyPushSupplier_ptr obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPullSupplier_ptr obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "ConsumerAdmin.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_CONSUMERADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer_Map.h b/TAO/orbsvcs/orbsvcs/Notify/Consumer_Map.h new file mode 100644 index 00000000000..ca248f949a4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer_Map.h @@ -0,0 +1,36 @@ +/* -*- C++ -*- */ +/** + * @file Consumer_Map.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_CONSUMER_MAP_H +#define TAO_NS_CONSUMER_MAP_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +#include "Event_Map_T.h" +#include "ProxySupplier.h" + +/** + * @class TAO_NS_Consumer_Map + * + * @brief The Event Map for Consumers. + * + */ + +typedef TAO_NS_Event_Map_T TAO_NS_Consumer_Map; + +#include "ace/post.h" +#endif /* TAO_NS_CONSUMER_MAP_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp new file mode 100644 index 00000000000..ad43477e2da --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp @@ -0,0 +1,62 @@ +// $Id$ + +#ifndef TAO_NS_CONTAINER_T_CPP +#define TAO_NS_CONTAINER_T_CPP + +#include "Container_T.h" + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "orbsvcs/ESF/ESF_Shutdown_Proxy.h" +#include "Properties.h" +#include "Factory.h" +#include "POA_Helper.h" + +#if ! defined (__ACE_INLINE__) +#include "Container_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Container_T, "$Id$") + +template +TAO_NS_Container_T::TAO_NS_Container_T (void) + : collection_ (0) +{ +} + +template +TAO_NS_Container_T::~TAO_NS_Container_T () +{ + delete collection_; +} + +template void +TAO_NS_Container_T::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_ESF_Shutdown_Proxy shutdown_worker; + + this->collection_->for_each (&shutdown_worker ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_Container_T::insert (TYPE* type ACE_ENV_ARG_DECL) +{ + this->collection_->connected (type ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_Container_T::remove (TYPE* type ACE_ENV_ARG_DECL) +{ + this->collection_->disconnected (type ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_Container_T::init (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_ARG_PARAMETER); +} + +#endif /* TAO_NS_CONTAINER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.h b/TAO/orbsvcs/orbsvcs/Notify/Container_T.h new file mode 100644 index 00000000000..003bcf55a7d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.h @@ -0,0 +1,76 @@ +/* -*- C++ -*- */ +/** + * @file Container_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_CONTAINER_T_H +#define TAO_NS_CONTAINER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" + +/** + * @class TAO_NS_Container_T + * + * @brief A template class that manages a collection. + * TYPE = type of collection + * + */ +template +class TAO_Notify_Export TAO_NS_Container_T +{ + typedef TAO_ESF_Proxy_Collection COLLECTION; + public: + + /// Constuctor + TAO_NS_Container_T (void); + + /// Destructor + virtual ~TAO_NS_Container_T (); + + /// Init this object. + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Insert object to this container. + virtual void insert (TYPE* type ACE_ENV_ARG_DECL); + + /// Remove type from container_ + virtual void remove (TYPE* type ACE_ENV_ARG_DECL); + + /// Shutdown + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Collection + COLLECTION* collection (void); + +protected: + /// The collection data structure that we add objects to. + COLLECTION* collection_; +}; + +#if defined (__ACE_INLINE__) +#include "Container_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Container_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Container_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_CONTAINER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Container_T.inl new file mode 100644 index 00000000000..3bb19f4afb4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.inl @@ -0,0 +1,7 @@ +// $Id$ + +template ACE_INLINE TAO_NS_Container_T::COLLECTION* +TAO_NS_Container_T:: collection (void) +{ + return this->collection_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.cpp b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.cpp new file mode 100644 index 00000000000..7714f21d186 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.cpp @@ -0,0 +1,13 @@ +// $Id$ + +#include "CosNotify_Initializer.h" + +ACE_RCSID(Notify, TAO_NS_CosNotify_Initializer, "$id$") + +#include "CosNotify_Service.h" + +TAO_NS_CosNotify_Initializer::TAO_NS_CosNotify_Initializer (void) +{ + // ACE_Service_Config::static_svcs ()->insert (&ace_svc_desc_TAO_NS_CosNotify_Service); + ACE_Service_Config::static_svcs ()->insert (&ace_svc_desc_TAO_Notify_Default_EMO_Factory_OLD); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.h b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.h new file mode 100644 index 00000000000..a2e73f4898a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Initializer.h @@ -0,0 +1,38 @@ +/* -*- C++ -*- */ +/** + * @file CosNotify_Initializer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_COSNOTIFY_INITIALIZER_H +#define TAO_NS_COSNOTIFY_INITIALIZER_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_CosNotify_Initializer + * + * @brief Helper to load the Cos Notification service into the service conf. for static links. + * + */ +class TAO_Notify_Export TAO_NS_CosNotify_Initializer +{ +public: + /// Constuctor + TAO_NS_CosNotify_Initializer (void); +}; + +static TAO_NS_CosNotify_Initializer TAO_NS_CosNotify_initializer; + +#include "ace/post.h" +#endif /* TAO_NS_COSNOTIFY_INITIALIZER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp new file mode 100644 index 00000000000..722802d9273 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp @@ -0,0 +1,327 @@ +// $Id$ + +#include "CosNotify_Service.h" +#include "Properties.h" +#include "Default_Factory.h" +#include "Builder.h" +#include "ace/Sched_Params.h" +#include "ace/Arg_Shifter.h" +#include "ace/Dynamic_Service.h" +#include "tao/ORB_Core.h" +#include "orbsvcs/NotifyExtC.h" +#include "tao/debug.h" + +ACE_RCSID(RT_Notify, TAO_NS_CosNotify_Service, "$Id$") + +TAO_NS_CosNotify_Service::TAO_NS_CosNotify_Service (void) + : factory_ (0) + , builder_ (0) +{ +} + +TAO_NS_CosNotify_Service::~TAO_NS_CosNotify_Service () +{ + delete this->factory_; + delete this->builder_; +} + +int +TAO_NS_CosNotify_Service::init (int argc, char *argv[]) +{ + ACE_Arg_Shifter arg_shifter (argc, argv); + + const ACE_TCHAR *current_arg = 0; + + // Default to an all reactive system. + int ec_threads = 0; + int dispatching_threads = 0; + int listener_threads = 0; + int source_threads = 0; + int lookup_threads = 0; + + int task_per_proxy = 0; + + TAO_NS_Properties *properties = TAO_NS_PROPERTIES::instance(); + + while (arg_shifter.is_anything_left ()) + { + if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-MTDispatching")) == 0) + { + // If Dispatching Threads are initalized, the option is implicit. + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-DispatchingThreads")))) + { + dispatching_threads = ACE_OS::atoi (current_arg); + arg_shifter.consume_arg (); + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-MTSourceEval")) == 0) + { + // If Source Threads are initalized, the option is implicit. + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-SourceThreads")))) + { + source_threads = ACE_OS::atoi (current_arg); + arg_shifter.consume_arg (); + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-MTLookup")) == 0) + { + // If Source Threads are initalized, the option is implicit. + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-LookupThreads")))) + { + lookup_threads = ACE_OS::atoi (current_arg); + arg_shifter.consume_arg (); + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-MTListenerEval")) == 0) + { + // If Source Threads are initalized, the option is implicit. + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-ListenerThreads")))) + { + listener_threads = ACE_OS::atoi (current_arg); + arg_shifter.consume_arg (); + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-AsynchUpdates")) == 0) + { + arg_shifter.consume_arg (); + + properties->asynch_updates (1); + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-AllocateTaskperProxy")) == 0) + { + task_per_proxy = 1; + arg_shifter.consume_arg (); + } + } + + // Init the EC QoS + { + CosNotification::QoSProperties qos; + this->set_threads (qos, ec_threads); + properties->default_event_channel_qos_properties (qos); + } + + if (task_per_proxy == 0) + { + // Set the per ConsumerAdmin QoS + { + CosNotification::QoSProperties qos; + this->set_threads (qos, dispatching_threads + listener_threads); + properties->default_consumer_admin_qos_properties (qos); + } + + // Set the per SupplierAdmin QoS + { + CosNotification::QoSProperties qos; + this->set_threads (qos, lookup_threads + source_threads); + properties->default_supplier_admin_qos_properties (qos); + } + } + else + { + // Set the per ProxyConsumer QoS + { + CosNotification::QoSProperties qos; + this->set_threads (qos, dispatching_threads + listener_threads); + properties->default_proxy_consumer_qos_properties (qos); + } + + // Set the per ProxySupplier QoS + { + CosNotification::QoSProperties qos; + this->set_threads (qos, source_threads); // lookup thread per proxy doesn't make sense. + properties->default_proxy_supplier_qos_properties (qos); + } + } + + return 0; +} + +void +TAO_NS_CosNotify_Service::set_threads (CosNotification::QoSProperties &qos, int threads) +{ + NotifyExt::ThreadPoolParams tp_params = + {0, (unsigned)threads, 0, 0, 0, 0, 0 }; + + qos.length (1); + qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool); + qos[0].value <<= tp_params; +} + +int +TAO_NS_CosNotify_Service::fini (void) +{ + return 0; +} + +void +TAO_NS_CosNotify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + ACE_DEBUG ((LM_DEBUG, "Loading the Cos Notification Service...\n")); + + this->init_i (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_CosNotify_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" ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (object.in ())) + ACE_ERROR ((LM_ERROR, + " (%P|%t) Unable to resolve the RootPOA.\n")); + + 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->orb (orb); + 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 + this->init_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->init_builder (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_CosNotify_Service::init_main_thread (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL_NOT_USED) +{ + 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_CosNotify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + this->factory_ = ACE_Dynamic_Service::instance ("TAO_NS_Factory"); + + if (this->factory_ == 0) + ACE_NEW_THROW_EX (this->factory_, + TAO_NS_Default_Factory (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + TAO_NS_PROPERTIES::instance()->factory (this->factory_); +} + +void +TAO_NS_CosNotify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->builder_, + TAO_NS_Builder (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + TAO_NS_PROPERTIES::instance()->builder (this->builder_); +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_NS_CosNotify_Service::create (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + return this->builder_->build_event_channel_factory (poa ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_CosNotify_Service::remove (TAO_NS_EventChannelFactory* /*ecf*/ ACE_ENV_ARG_DECL_NOT_USED) +{ + // NOP. +} + +/*********************************************************************************************************************/ + +ACE_STATIC_SVC_DEFINE (TAO_Notify_Default_EMO_Factory_OLD, + ACE_TEXT (TAO_NOTIFY_DEF_EMO_FACTORY_NAME), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_NS_CosNotify_Service), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) + +/*********************************************************************************************************************/ +/* +ACE_STATIC_SVC_DEFINE (TAO_NS_CosNotify_Service, + ACE_TEXT (TAO_NS_COS_NOTIFICATION_SERVICE_NAME), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_NS_CosNotify_Service), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) + +*/ +ACE_FACTORY_DEFINE (TAO_Notify, TAO_NS_CosNotify_Service) + +/*********************************************************************************************************************/ diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h new file mode 100644 index 00000000000..fd29b69d2a8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h @@ -0,0 +1,90 @@ +/* -*- C++ -*- */ +/** + * @file CosNotify_Service.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_COSNOTIFY_SERVICE_H +#define TAO_NS_COSNOTIFY_SERVICE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Service.h" + +class TAO_NS_Factory; +class TAO_NS_Builder; +class TAO_NS_Properties; +class TAO_NS_EventChannelFactory; + +/** + * @class TAO_NS_CosNotify_Service + * + * @brief A service object for creating the Notify Service Factory. + * + */ +class TAO_Notify_Export TAO_NS_CosNotify_Service : public TAO_NS_Service +{ +public: + /// Constuctor + TAO_NS_CosNotify_Service (void); + + /// Destructor + virtual ~TAO_NS_CosNotify_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); + + /// Called by the factory when it is destroyed. + virtual void remove (TAO_NS_EventChannelFactory* ecf ACE_ENV_ARG_DECL); + +protected: + /// Init the data members + virtual void init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + + /// Create the Factory for Notify objects. + virtual void init_factory (ACE_ENV_SINGLE_ARG_DECL); + + /// Create the Builder for Notify objects. + virtual void init_builder (ACE_ENV_SINGLE_ARG_DECL); + + /// Apply ORB Scheduling policy to main thread and set its priority to the lowest available. + void init_main_thread (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + + /// Set thread options on . + void set_threads (CosNotification::QoSProperties &qos, int threads); + + /// Service component for object factory operations. + TAO_NS_Factory* factory_; + + /// Service component for building NS participants. + TAO_NS_Builder* builder_; +}; + +//ACE_STATIC_SVC_DECLARE (TAO_NS_CosNotify_Service) +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_CosNotify_Service) + +ACE_STATIC_SVC_DECLARE (TAO_Notify_Default_EMO_Factory_OLD) + +#if defined (__ACE_INLINE__) +#include "CosNotify_Service.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_COSNOTIFY_SERVICE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.inl b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp new file mode 100644 index 00000000000..e7d26a9d90a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp @@ -0,0 +1,395 @@ +// $Id$ + +#include "Default_Factory.h" + +#if ! defined (__ACE_INLINE__) +#include "Default_Factory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RN_Notify, TAO_NS_Default_Factory, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_List.h" +#include "orbsvcs/ESF/ESF_Copy_On_Write.h" + +#include "EventChannelFactory.h" +#include "EventChannel.h" +#include "Admin.h" +#include "Proxy.h" +#include "SupplierAdmin.h" +#include "ConsumerAdmin.h" +#include "Structured/StructuredProxyPushConsumer.h" +#include "Structured/StructuredProxyPushSupplier.h" +#include "Any/ProxyPushConsumer.h" +#include "Any/ProxyPushSupplier.h" +#include "Any/CosEC_ProxyPushConsumer.h" +#include "Any/CosEC_ProxyPushSupplier.h" +#include "Sequence/SequenceProxyPushConsumer.h" +#include "Sequence/SequenceProxyPushSupplier.h" +#include "Supplier.h" + +template +class COW_Collection_Default_Factory +{ +public: + typedef TAO_ESF_Proxy_List::Iterator PROXY_ITER; + typedef TAO_ESF_Copy_On_Write,PROXY_ITER, ACE_SYNCH> COLLECTION; + typedef TAO_ESF_Proxy_Collection BASE_COLLECTION; + + void create (BASE_COLLECTION* &collection ACE_ENV_ARG_DECL) + { + ACE_NEW_THROW_EX (collection, + COLLECTION (), + CORBA::INTERNAL ()); + } +}; + +TAO_NS_Default_Factory::TAO_NS_Default_Factory (void) +{ +} + +TAO_NS_Default_Factory::~TAO_NS_Default_Factory () +{ +} + +void +TAO_NS_Default_Factory::create (TAO_NS_ProxySupplier_Collection* &collection ACE_ENV_ARG_DECL) +{ + COW_Collection_Default_Factory f; + f.create (collection ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_ProxyConsumer_Collection* &collection ACE_ENV_ARG_DECL) +{ + COW_Collection_Default_Factory f; + f.create (collection ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_EventChannel_Collection* &collection ACE_ENV_ARG_DECL) +{ + COW_Collection_Default_Factory f; + f.create (collection ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_ConsumerAdmin_Collection* &collection ACE_ENV_ARG_DECL) +{ + COW_Collection_Default_Factory f; + f.create (collection ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_SupplierAdmin_Collection* &collection ACE_ENV_ARG_DECL) +{ + COW_Collection_Default_Factory f; + f.create (collection ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_Proxy_Collection* &collection ACE_ENV_ARG_DECL) +{ + COW_Collection_Default_Factory f; + f.create (collection ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_EventChannelFactory*& factory ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (factory, + TAO_NS_EventChannelFactory (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_EventChannel*& channel ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (channel, + TAO_NS_EventChannel (), + CORBA::NO_MEMORY ()); +} + + +void +TAO_NS_Default_Factory::create (TAO_NS_SupplierAdmin*& admin ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (admin, + TAO_NS_SupplierAdmin (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_ConsumerAdmin*& admin ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (admin, + TAO_NS_ConsumerAdmin (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_StructuredProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_StructuredProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_ProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_ProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_CosEC_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_CosEC_ProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_CosEC_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_CosEC_ProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_SequenceProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_SequenceProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Default_Factory::create (TAO_NS_SequenceProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_SequenceProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_Default_Factory) + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_ProxySupplier_T ; +template class TAO_NS_Proxy_T ; +template class TAO_NS_ProxySupplier_T ; +template class TAO_NS_Proxy_T ; +template class TAO_NS_ProxySupplier_T ; +template class TAO_NS_Proxy_T ; +template class TAO_NS_ProxySupplier_T ; +template class TAO_NS_Proxy_T ; + +template class TAO_NS_ProxyConsumer_T ; +template class TAO_NS_Proxy_T ; +template class TAO_NS_ProxyConsumer_T ; +template class TAO_NS_Proxy_T ; +template class TAO_NS_ProxyConsumer_T ; +template class TAO_NS_Proxy_T ; +template class TAO_NS_ProxyConsumer_T ; +template class TAO_NS_Proxy_T ; + +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; +template class TAO_ESF_Proxy_Collection; + +template class ACE_Unbounded_Set; +//template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; + +template class ACE_Unbounded_Set_Const_Iterator; +template class ACE_Unbounded_Set_Iterator; + +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; + +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH>; + + + +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; +template class TAO_ESF_Proxy_List; + +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set; + +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; +template class ACE_Unbounded_Set_Iterator; + +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH>; + +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator >; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_ProxySupplier_T +#pragma instantiate TAO_NS_Proxy_T +#pragma instantiate TAO_NS_ProxySupplier_T +#pragma instantiate TAO_NS_Proxy_T +#pragma instantiate TAO_NS_ProxySupplier_T +#pragma instantiate TAO_NS_Proxy_T +#pragma instantiate TAO_NS_ProxySupplier_T +#pragma instantiate TAO_NS_Proxy_T + +#pragma instantiate TAO_NS_ProxyConsumer_T +#pragma instantiate TAO_NS_Proxy_T +#pragma instantiate TAO_NS_ProxyConsumer_T +#pragma instantiate TAO_NS_Proxy_T +#pragma instantiate TAO_NS_ProxyConsumer_T +#pragma instantiate TAO_NS_Proxy_T +#pragma instantiate TAO_NS_ProxyConsumer_T +#pragma instantiate TAO_NS_Proxy_T + +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection +#pragma instantiate TAO_ESF_Proxy_Collection + +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set + +#pragma instantiate ACE_Unbounded_Set_Const_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator + +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write, ACE_Unbounded_Set_Iterator, ACE_SYNCH> + +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantitae TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard,ACE_Unbounded_Set_Iterator,ACE_SYNCH> + + + +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List +#pragma instantiate TAO_ESF_Proxy_List + +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set + +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator +#pragma instantiate ACE_Unbounded_Set_Iterator + +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard, ACE_Unbounded_Set_Iterator, ACE_SYNCH> + +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection, ACE_Unbounded_Set_Iterator > + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.h new file mode 100644 index 00000000000..61f7086bf5e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.h @@ -0,0 +1,101 @@ +/* -*- C++ -*- */ +/** + * @file Default_Factory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_DEFAULT_FACTORY_H +#define TAO_NS_DEFAULT_FACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Factory.h" + +/** + * @class TAO_NS_Default_Factory + * + * @brief Default_Factory interface for creating Notify Objects. + * + */ +class TAO_Notify_Export TAO_NS_Default_Factory : public TAO_NS_Factory +{ +public: + /// Constructor + TAO_NS_Default_Factory (void); + + /// Destructor + virtual ~TAO_NS_Default_Factory (); + + /// Create ProxySupplier Collection + virtual void create (TAO_NS_ProxySupplier_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create ProxyConsumer Collection + virtual void create (TAO_NS_ProxyConsumer_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create EventChannel Collection + virtual void create (TAO_NS_EventChannel_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create ConsumerAdmin Collection + virtual void create (TAO_NS_ConsumerAdmin_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create SupplierAdmin Collection + virtual void create (TAO_NS_SupplierAdmin_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create Proxy Collection + virtual void create (TAO_NS_Proxy_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create EventChannelDefault_Factory + virtual void create (TAO_NS_EventChannelFactory*& channel_factory ACE_ENV_ARG_DECL); + + /// Create EventChannel + virtual void create (TAO_NS_EventChannel*& channel ACE_ENV_ARG_DECL); + + /// Create SupplierAdmin + virtual void create (TAO_NS_SupplierAdmin*& admin ACE_ENV_ARG_DECL); + + /// Create ConsumerAdmin + virtual void create (TAO_NS_ConsumerAdmin*& admin ACE_ENV_ARG_DECL); + + /// Create ProxyPushConsumer + virtual void create (TAO_NS_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create ProxyPushSupplier + virtual void create (TAO_NS_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); + + /// Create CosEC_ProxyPushConsumer + virtual void create (TAO_NS_CosEC_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create CosEC_ProxyPushSupplier + virtual void create (TAO_NS_CosEC_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); + + /// Create StructuredProxyPushConsumer + virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create StructuredProxyPushSupplier + virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); + + /// Create SequenceProxyPushConsumer + virtual void create (TAO_NS_SequenceProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create SequenceProxyPushSupplier + virtual void create (TAO_NS_SequenceProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); +}; + +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_Default_Factory) + +#if defined (__ACE_INLINE__) +#include "Default_Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_DEFAULT_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.inl b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp new file mode 100644 index 00000000000..84046b5f46d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp @@ -0,0 +1,488 @@ +// $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 "Notify_Constraint_Visitors.h" + +TAO_NS_ETCL_Filter::TAO_NS_ETCL_Filter (void) +{ +} + +TAO_NS_ETCL_Filter::~TAO_NS_ETCL_Filter () +{ + ACE_TRY_NEW_ENV + { + this->remove_all_constraints (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, "Error in Filter dtor\n")); + + // @@ eat exception. + } + ACE_ENDTRY; + + if (TAO_debug_level > 1) + 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_NEW_THROW_EX (notify_constr_expr, + TAO_NS_Constraint_Expr (), + CORBA::NO_MEMORY ()); + auto_ptr auto_expr (notify_constr_expr); + + 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_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::INTERNAL ()); + + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG, "Added constraint to filter %x\n", this, expr.constraint_expr.in ())); + + auto_expr.release (); + } +} + +CosNotifyFilter::ConstraintInfoSeq* +TAO_NS_ETCL_Filter::add_constraints (const CosNotifyFilter::ConstraintExpSeq& constraint_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + 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_ptr; + ACE_NEW_THROW_EX (infoseq_ptr, + CosNotifyFilter::ConstraintInfoSeq (constraint_length), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::ConstraintInfoSeq_var infoseq (infoseq_ptr); + infoseq->length (constraint_length); + + // 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.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return infoseq._retn (); +} + +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 + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // 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 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)) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq_ptr; + ACE_NEW_THROW_EX (infoseq_ptr, + CosNotifyFilter::ConstraintInfoSeq (id_list.length ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::ConstraintInfoSeq_var infoseq (infoseq_ptr); + + 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]; + } + + return infoseq._retn (); +} + +CosNotifyFilter::ConstraintInfoSeq * +TAO_NS_ETCL_Filter::get_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + size_t current_size = this->constraint_expr_list_.current_size (); + + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq_ptr; + ACE_NEW_THROW_EX (infoseq_ptr, + CosNotifyFilter::ConstraintInfoSeq (current_size), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::ConstraintInfoSeq_var infoseq (infoseq_ptr); + + infoseq->length (current_size); + + CONSTRAINT_EXPR_LIST::ITERATOR iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_LIST::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._retn (); +} + +void +TAO_NS_ETCL_Filter::remove_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->remove_all_constraints_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_ETCL_Filter::remove_all_constraints_i (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CONSTRAINT_EXPR_LIST::ITERATOR iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_LIST::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)) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->remove_all_constraints_i (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)) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // We want to return true if at least one constraint matches. + CONSTRAINT_EXPR_LIST::ITERATOR iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_LIST::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; +template class ACE_Hash_Map_Manager; +template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; + +#if !defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION) +template class ACE_Equal_To; +#endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ + +template class ACE_Array; +template class ACE_Array_Base; + +template class auto_ptr; +template class ACE_Auto_Basic_Ptr; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Entry +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> + +#if !defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION) +#pragma instantiate ACE_Equal_To +#endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ + +#pragma instantiate ACE_Array +#pragma instantiate ACE_Array_Base + +#pragma instantiate auto_ptr +#pragma instantiate ACE_Auto_Basic_Ptr + +#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..07448213366 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h @@ -0,0 +1,175 @@ +/* -*- C++ -*- */ +/** + * @file ETCL_Filter.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_ETCL_FILTER_H +#define TAO_NS_ETCL_FILTER_H +#include "ace/pre.h" + +#include "notify_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 "Notify_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 Implementation of CosNotifyFilter::Filter servant. + * + */ +class TAO_Notify_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 + )); + + void remove_all_constraints_i (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + 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. + }; + + /// Lock to serialize access to data members. + TAO_SYNCH_MUTEX lock_; + + /// Id generator for ConstraintInfo's. + ACE_Atomic_Op constraint_expr_ids_; + + /// A list of the constraints stored in this filter. + typedef ACE_Hash_Map_Manager + CONSTRAINT_EXPR_LIST; + + CONSTRAINT_EXPR_LIST constraint_expr_list_; +}; + +#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..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp new file mode 100644 index 00000000000..91f08daa78f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp @@ -0,0 +1,81 @@ +// $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 (PortableServer::POA_var& filter_poa ACE_ENV_ARG_DECL) +{ + this->filter_poa_ = filter_poa; // save the filter poa. + + PortableServer::ServantBase_var servant_var (this); + + 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_OS::strcmp (constraint_grammar, "EXTENDED_TCL") != 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::ServantBase_var filter_var (filter); + + PortableServer::ObjectId_var oid = + this->filter_poa_->activate_object (filter + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + CORBA::Object_var obj = + this->filter_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 + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ()); +} + +ACE_FACTORY_DEFINE (TAO_Notify, 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..2257259fc0a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h @@ -0,0 +1,88 @@ +/* -*- C++ -*- */ +/** + * @file ETCL_FilterFactory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_ETCL_FILTERFACTORY_H +#define TAO_NS_ETCL_FILTERFACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyFilterS.h" +#include "FilterFactory.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_NS_ETCL_FilterFactory + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_ETCL_FilterFactory : public virtual PortableServer::RefCountServantBase + , public virtual 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 (PortableServer::POA_var& filter_poa ACE_ENV_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 + )); + +protected: + /// The POA in which to activate the Filters. + PortableServer::POA_var filter_poa_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +ACE_FACTORY_DECLARE (TAO_Notify, 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..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp new file mode 100644 index 00000000000..dba27e9dffd --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "Event.h" + +#if ! defined (__ACE_INLINE__) +#include "Event.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Event, "$Id$") + +#include "tao/debug.h" +#include "orbsvcs/CosNotificationC.h" + +TAO_NS_Event::TAO_NS_Event (void) + :priority_ (CosNotification::Priority, CosNotification::DefaultPriority), + timeout_ (CosNotification::Timeout) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG,"event:%x created\n", this )); +} + +TAO_NS_Event::~TAO_NS_Event () +{ + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG,"event:%x destroyed\n", this )); +} + +void +TAO_NS_Event::translate (const CORBA::Any& any, CosNotification::StructuredEvent& notification) +{ + notification.remainder_of_body <<= any; + notification.header.fixed_header.event_type.type_name = CORBA::string_dup ("%ANY"); + notification.header.fixed_header.event_type.domain_name = CORBA::string_dup (""); +} + +void +TAO_NS_Event::translate (const CosNotification::StructuredEvent& notification, CORBA::Any& any) +{ + any <<= notification; // is the typecode set by this operation or do we need to set it explicity. +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Auto_Basic_Ptr; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Auto_Basic_Ptr +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.h b/TAO/orbsvcs/orbsvcs/Notify/Event.h new file mode 100644 index 00000000000..bbe45c870e3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.h @@ -0,0 +1,104 @@ +/* -*- C++ -*- */ +/** + * @file Event.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENT_H +#define TAO_NS_EVENT_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 "orbsvcs/Event_ForwarderS.h" +#include "orbsvcs/CosNotifyFilterC.h" +#include "orbsvcs/CosNotificationC.h" +#include "Property.h" +#include "Property_T.h" + +class TAO_NS_Consumer; +class TAO_NS_EventType; + +/** + * @class TAO_NS_Event + * + * @brief Base class abstraction for Events flowing through the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_Event : private ACE_Copy_Disabled +{ +public: + /// Constuctor + TAO_NS_Event (void); + + /// Destructor + virtual ~TAO_NS_Event (); + + /// Translate Any to Structured + static void translate (const CORBA::Any& any, CosNotification::StructuredEvent& notification); + + /// Translate Structured to Any + static void translate (const CosNotification::StructuredEvent& notification, CORBA::Any& any); + + /// 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; + + /// Convert to CosNotification::Structured type + virtual void convert (CosNotification::StructuredEvent& notification) = 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 (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + ///= Accessors + /// Priority + TAO_NS_Property_Short& priority (void); + + /// Timeout + TAO_NS_Property_Time& timeout (void); + +protected: + /// = QoS properties + + /// Priority. + TAO_NS_Property_Short priority_; + + /// Timeout. + TAO_NS_Property_Time timeout_; +}; + +template class ACE_Refcounted_Auto_Ptr; +template class ACE_Unbounded_Queue; +typedef ACE_Refcounted_Auto_Ptr TAO_NS_Event_var; +typedef ACE_Unbounded_Queue TAO_NS_Event_Collection; + +#if defined (__ACE_INLINE__) +#include "Event.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.inl b/TAO/orbsvcs/orbsvcs/Notify/Event.inl new file mode 100644 index 00000000000..019194c78aa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE TAO_NS_Property_Short& +TAO_NS_Event::priority (void) +{ + return this->priority_; +} + +ACE_INLINE TAO_NS_Property_Time& +TAO_NS_Event::timeout (void) +{ + return this->timeout_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp new file mode 100644 index 00000000000..c816c90acd0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp @@ -0,0 +1,379 @@ +// $Id$ + +#include "EventChannel.h" + +#if ! defined (__ACE_INLINE__) +#include "EventChannel.inl" +#endif /* __ACE_INLINE__ */ + +#include "Container_T.h" +#include "EventChannelFactory.h" +#include "ConsumerAdmin.h" +#include "SupplierAdmin.h" +#include "Event_Manager.h" +#include "Properties.h" +#include "Factory.h" +#include "Builder.h" +#include "Find_Worker_T.h" +#include "Seq_Worker_T.h" + +ACE_RCSID(RT_Notify, TAO_NS_EventChannel, "$Id$") + +TAO_NS_EventChannel::TAO_NS_EventChannel (void) + : ecf_ (0) + , ca_container_ (0) + , sa_container_ (0) +{ +} + +TAO_NS_EventChannel::~TAO_NS_EventChannel () +{ + delete this->event_manager_; // The EventChannel always owns the EventManager. + + this->ecf_->_decr_refcnt (); +} + +void +TAO_NS_EventChannel::init (TAO_NS_EventChannelFactory* ecf + , const CosNotification::QoSProperties & initial_qos + , const CosNotification::AdminProperties & initial_admin + ACE_ENV_ARG_DECL) +{ + this->TAO_NS_Object::init (ecf); + + this->ecf_ = ecf; + + this->ecf_->_incr_refcnt (); + + // Init ca_container_ + ACE_NEW_THROW_EX (this->ca_container_, + TAO_NS_ConsumerAdmin_Container (), + CORBA::INTERNAL ()); + ACE_CHECK; + + this->ca_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Init ca_container_ + ACE_NEW_THROW_EX (this->sa_container_, + TAO_NS_SupplierAdmin_Container (), + CORBA::INTERNAL ()); + ACE_CHECK; + + this->sa_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + TAO_NS_AdminProperties* admin_properties = 0; + + // Set the admin properties. + ACE_NEW_THROW_EX (admin_properties, + TAO_NS_AdminProperties (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + this->admin_properties_ = admin_properties; + + // create the event manager. @@ use factory + ACE_NEW_THROW_EX (this->event_manager_, + TAO_NS_Event_Manager (), + CORBA::INTERNAL ()); + ACE_CHECK; + + this->event_manager_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + const CosNotification::QoSProperties &default_ec_qos = + TAO_NS_PROPERTIES::instance ()->default_event_channel_qos_properties (); + + this->set_qos (default_ec_qos ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->set_qos (initial_qos ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->set_admin (initial_admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CosNotifyChannelAdmin::AdminID id; + + // Set the default ConsumerAdmin. + this->default_consumer_admin_ = this->new_for_consumers (CosNotifyChannelAdmin::OR_OP, id ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Set the default SupplierAdmin. + this->default_supplier_admin_ = this->new_for_suppliers (CosNotifyChannelAdmin::OR_OP, id ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_EventChannel::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_EventChannel::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_EventChannel::release (void) +{ + delete this; + //@@ inform factory +} + +int +TAO_NS_EventChannel::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return 1; + + this->ca_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + this->sa_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + delete this->ca_container_; + delete this->sa_container_; + + this->event_manager_->shutdown (); + + return 0; +} + +void +TAO_NS_EventChannel::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; + + this->ecf_->remove (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_EventChannel::remove (TAO_NS_ConsumerAdmin* consumer_admin ACE_ENV_ARG_DECL) +{ + this->ca_container_->remove (consumer_admin ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_EventChannel::remove (TAO_NS_SupplierAdmin* supplier_admin ACE_ENV_ARG_DECL) +{ + this->sa_container_->remove (supplier_admin ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_EventChannel::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +CosNotification::QoSProperties* +TAO_NS_EventChannel::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_NS_EventChannel::MyFactory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->ecf_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::default_consumer_admin (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (this->default_consumer_admin_.in ()); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::default_supplier_admin (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::SupplierAdmin::_duplicate (this->default_supplier_admin_.in ()); +} + +::CosNotifyFilter::FilterFactory_ptr TAO_NS_EventChannel::default_filter_factory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->ecf_->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 ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + return TAO_NS_PROPERTIES::instance()->builder()->build_consumer_admin (this, op, id ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return TAO_NS_PROPERTIES::instance()->builder()->build_supplier_admin (this, op, id ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::get_consumeradmin (CosNotifyChannelAdmin::AdminID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )) +{ + TAO_NS_Find_Worker_T find_worker; + + return find_worker.resolve (id, *this->ca_container_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::get_supplieradmin (CosNotifyChannelAdmin::AdminID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )) +{ + TAO_NS_Find_Worker_T find_worker; + + return find_worker.resolve (id, *this->sa_container_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminIDSeq* +TAO_NS_EventChannel::get_all_consumeradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Seq_Worker_T seq_worker; + + return seq_worker.create (*this->ca_container_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminIDSeq* +TAO_NS_EventChannel::get_all_supplieradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Seq_Worker_T seq_worker; + + return seq_worker.create (*this->sa_container_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_EventChannel::set_admin (const CosNotification::AdminProperties & admin ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedAdmin + )) +{ + this->admin_properties_->init (admin); +} + +CosNotification::AdminProperties* +TAO_NS_EventChannel::get_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotification::AdminProperties_var properties; + + ACE_NEW_THROW_EX (properties, + CosNotification::AdminProperties (), + CORBA::NO_MEMORY ()); + + this->admin_properties_->populate (properties); + + return properties._retn (); +} + +CosEventChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::for_consumers (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosEventChannelAdmin::ConsumerAdmin::_duplicate (this->default_consumer_admin_.in ()); +} + +CosEventChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::for_suppliers (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosEventChannelAdmin::SupplierAdmin::_duplicate (this->default_supplier_admin_.in ()); +} + +void +TAO_NS_EventChannel::validate_qos (const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_Find_Worker_T; +template class TAO_NS_Find_Worker_T; +template class TAO_NS_Seq_Worker_T; +template class TAO_NS_Seq_Worker_T; +template class TAO_NS_Container_T ; +template class TAO_NS_Container_T ; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Find_Worker_T +#pragma instantiate TAO_NS_Find_Worker_T +#pragma instantiate TAO_NS_Seq_Worker_T +#pragma instantiate TAO_NS_Seq_Worker_T +#pragma instantiate TAO_NS_Container_T +#pragma instantiate TAO_NS_Container_T + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h new file mode 100644 index 00000000000..d49929af4fa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h @@ -0,0 +1,221 @@ +/* -*- C++ -*- */ +/** + * @file EventChannel.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENTCHANNEL_H +#define TAO_NS_EVENTCHANNEL_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "Object.h" + +class TAO_NS_ConsumerAdmin; +class TAO_NS_SupplierAdmin; +class TAO_NS_EventChannelFactory; +template class TAO_NS_Container_T; + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_EventChannel + * + * @brief Implementation of CosNotifyChannelAdmin::EventChannel + * + */ +class TAO_Notify_Export TAO_NS_EventChannel : public POA_CosNotifyChannelAdmin::EventChannel + , public virtual TAO_NS_Object +{ + friend class TAO_NS_Builder; + +public: + typedef CosNotifyChannelAdmin::ChannelIDSeq SEQ; + typedef CosNotifyChannelAdmin::ChannelIDSeq_var SEQ_VAR; + + /// Constuctor + TAO_NS_EventChannel (void); + + /// Destructor + ~TAO_NS_EventChannel (); + + /// Init + void init (TAO_NS_EventChannelFactory* ecf + , const CosNotification::QoSProperties & initial_qos + , const CosNotification::AdminProperties & initial_admin + ACE_ENV_ARG_DECL); + + /// Remove ConsumerAdmin from its container. + void remove (TAO_NS_ConsumerAdmin* consumer_admin ACE_ENV_ARG_DECL); + + /// Remove SupplierAdmin from its container. + void remove (TAO_NS_SupplierAdmin* supplier_admin ACE_ENV_ARG_DECL); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Release + virtual void release (void); + + /// Shutdown + virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); + +protected: + typedef TAO_NS_Container_T TAO_NS_ConsumerAdmin_Container; + typedef TAO_NS_Container_T TAO_NS_SupplierAdmin_Container; + + /// = Data Members + /// The parent object. + TAO_NS_EventChannelFactory* ecf_; + + /// ConsumerAdmin Container. + TAO_NS_ConsumerAdmin_Container *ca_container_; + + /// SupplierAdmin Container. + TAO_NS_SupplierAdmin_Container *sa_container_; + + // Default Consumer Admin + CosNotifyChannelAdmin::ConsumerAdmin_var default_consumer_admin_; + + // Default Supplier Admin + CosNotifyChannelAdmin::SupplierAdmin_var default_supplier_admin_; + + /// =CosNotifyChannelAdmin::EventChannel methods + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannelFactory_ptr MyFactory (ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr default_consumer_admin (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr default_supplier_admin (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyFilter::FilterFactory_ptr default_filter_factory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr get_consumeradmin (CosNotifyChannelAdmin::AdminID id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )); + + virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr get_supplieradmin (CosNotifyChannelAdmin::AdminID id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )); + + virtual ::CosNotifyChannelAdmin::AdminIDSeq * get_all_consumeradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::AdminIDSeq * get_all_supplieradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotification::QoSProperties * get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos (const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual ::CosNotification::AdminProperties * get_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_admin (const CosNotification::AdminProperties & admin ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedAdmin + )); + + virtual ::CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "EventChannel.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTCHANNEL_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp new file mode 100644 index 00000000000..bc0eb18f7f2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp @@ -0,0 +1,192 @@ +// $Id$ + +#include "EventChannelFactory.h" + +#if ! defined (__ACE_INLINE__) +#include "EventChannelFactory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_EventChannelFactory, "$Id$") + +#include "ace/Dynamic_Service.h" +#include "Properties.h" +#include "Factory.h" +#include "Builder.h" +#include "EventChannel.h" +#include "Container_T.h" +#include "Find_Worker_T.h" +#include "Seq_Worker_T.h" + +TAO_NS_EventChannelFactory::TAO_NS_EventChannelFactory (void) + :ec_container_ (0) +{ +} + +TAO_NS_EventChannelFactory::~TAO_NS_EventChannelFactory () +{ +} + +void +TAO_NS_EventChannelFactory::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + this->ec_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + TAO_NS_Properties* properties = TAO_NS_PROPERTIES::instance(); + + delete this->ec_container_; + + // Shutdown the ORB. + CORBA::ORB_var orb = properties->orb (); + orb->shutdown (); + + // Reset references to CORBA objects. + properties->orb (CORBA::ORB::_nil ()); + properties->default_poa (PortableServer::POA::_nil ()); +} + +void +TAO_NS_EventChannelFactory::init (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + this->default_filter_factory_ = + TAO_NS_PROPERTIES::instance()->builder()->build_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Init ec_container_ + ACE_NEW_THROW_EX (this->ec_container_, + TAO_NS_EventChannel_Container (), + CORBA::INTERNAL ()); + ACE_CHECK; + + this->ec_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + TAO_NS_POA_Helper* object_poa = 0; + + // Bootstrap initial Object POA + ACE_NEW_THROW_EX (object_poa, + TAO_NS_POA_Helper (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + auto_ptr auto_object_poa (object_poa); + + object_poa->init (poa ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // release auto_ref. + auto_object_poa.release (); + + this->object_poa_own (object_poa); + + // We are also activated in the same Object POA. + this->poa_ = this->object_poa_; +} + +void +TAO_NS_EventChannelFactory::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_EventChannelFactory::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_EventChannelFactory::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_EventChannelFactory::remove (TAO_NS_EventChannel* event_channel ACE_ENV_ARG_DECL) +{ + this->ec_container_->remove (event_channel ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +int +TAO_NS_EventChannelFactory::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return 1; + + this->ec_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + return 0; +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_EventChannelFactory::get_default_filter_factory (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + 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, + CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + , CosNotification::UnsupportedAdmin + )) +{ + 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_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Seq_Worker_T seq_worker; + + return seq_worker.create (*this->ec_container_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_EventChannelFactory::get_event_channel (CosNotifyChannelAdmin::ChannelID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ChannelNotFound + )) +{ + TAO_NS_Find_Worker_T find_worker; + + return find_worker.resolve (id, *this->ec_container_ ACE_ENV_ARG_PARAMETER); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_Find_Worker_T; +template class TAO_NS_Seq_Worker_T; +template class TAO_NS_Container_T ; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Find_Worker_T +#pragma instantiate TAO_NS_Seq_Worker_T +#pragma instantiate TAO_NS_Container_T + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h new file mode 100644 index 00000000000..268618aaf32 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h @@ -0,0 +1,122 @@ +/* -*- C++ -*- */ +/** + * @file EventChannelFactory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENTCHANNELFACTORY_H +#define TAO_NS_EVENTCHANNELFACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/NotifyExtS.h" +#include "Object.h" + +class TAO_NS_EventChannel; +template class TAO_NS_Container_T; + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_EventChannelFactory + * + * @brief Implementation of CosNotifyChannelAdmin::EventChannelFactory + * + */ +class TAO_Notify_Export TAO_NS_EventChannelFactory : public virtual POA_NotifyExt::EventChannelFactory + , public virtual TAO_NS_Object +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_EventChannelFactory (void); + + /// Init the factory + void init (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + + /// Destructor + virtual ~TAO_NS_EventChannelFactory (); + + /// = ServantBase Methods + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Release this object. + virtual void release (void); + + /// Remove from the + void remove (TAO_NS_EventChannel* channel ACE_ENV_ARG_DECL); + + /// Accesor for the default filter factory shared by all EC's. + virtual CosNotifyFilter::FilterFactory_ptr get_default_filter_factory (ACE_ENV_SINGLE_ARG_DECL); + + /// shutdown + virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); + + protected: + typedef TAO_NS_Container_T TAO_NS_EventChannel_Container; + + /// = Data Members + /// Container for Event Channels. + TAO_NS_EventChannel_Container *ec_container_; + + /// The default filter factory. + CosNotifyFilter::FilterFactory_var default_filter_factory_; + + /// = NotifyExt method + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// = CosNotifyChannelAdmin Methods + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr create_channel (const CosNotification::QoSProperties & initial_qos, + const CosNotification::AdminProperties & initial_admin, + CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + , CosNotification::UnsupportedAdmin + )); + + virtual ::CosNotifyChannelAdmin::ChannelIDSeq * get_all_channels (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr get_event_channel (CosNotifyChannelAdmin::ChannelID id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ChannelNotFound + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "EventChannelFactory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTCHANNELFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp new file mode 100644 index 00000000000..9ac68b89aad --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp @@ -0,0 +1,129 @@ +// $Id$ + +#include "EventType.h" + +#if ! defined (__ACE_INLINE__) +#include "EventType.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_EventType, "$Id$") + +TAO_NS_EventType +TAO_NS_EventType::special (void) +{ + return TAO_NS_EventType ("*", "%ALL"); +} + +TAO_NS_EventType::TAO_NS_EventType (void) +{ +} + +void +TAO_NS_EventType::init_i (const char* domain_name, const char* type_name) +{ + this->event_type_.domain_name = domain_name; + this->event_type_.type_name = type_name; + + if (this->is_special () == 1) + { + this->event_type_.domain_name = (const char* )"*"; + this->event_type_.type_name = (const char* )"%ALL"; + } + + this->recompute_hash (); +} + +TAO_NS_EventType::TAO_NS_EventType (const char* domain_name, const char* type_name) +{ + this->init_i (domain_name, type_name); +} + +TAO_NS_EventType::TAO_NS_EventType (const CosNotification::EventType& event_type) +{ + this->init_i (event_type.domain_name.in (), event_type.type_name.in ()); +} + +TAO_NS_EventType::~TAO_NS_EventType () +{ +} + +void +TAO_NS_EventType::recompute_hash (void) +{ + // @@ Pradeep: this code is bound to crash someday if the strings + // are too long.... See if the hash_pjw () function can be modified + // to take accumulate multiple strings, as in: + // hash = ACE::hash_pjw_accummulate (0, str1); + // hash = ACE::hash_pjw_accummulate (hash, str2); + // + // @@ Or use grow the buffer when needed, or just add the two hash + // values or something, but fix this code! + // + char buffer[BUFSIZ]; + ACE_OS::strcpy (buffer, this->event_type_.domain_name.in ()); + ACE_OS::strcat (buffer, this->event_type_.type_name.in ()); + + this->hash_value_ = ACE::hash_pjw (buffer); +} + +TAO_NS_EventType& +TAO_NS_EventType::operator=(const CosNotification::EventType& event_type) +{ + this->init_i (event_type.domain_name.in (),event_type.type_name.in ()); + + return *this; +} + +TAO_NS_EventType& +TAO_NS_EventType::operator=(const TAO_NS_EventType& event_type) +{ + if (this == &event_type) + return *this; + + this->init_i (event_type.event_type_.domain_name.in (),event_type.event_type_.type_name.in ()); + + return *this; +} + +int +TAO_NS_EventType::operator==(const TAO_NS_EventType& event_type) const +{ + if (this->hash () != event_type.hash ()) + return 0; + else // compare the strings + return (ACE_OS::strcmp (this->event_type_.type_name, event_type.event_type_.type_name) == 0 && + ACE_OS::strcmp (this->event_type_.domain_name, event_type.event_type_.domain_name) == 0 + ); +} + +int +TAO_NS_EventType::operator!=(const TAO_NS_EventType& event_type) const +{ + if (this->hash () != event_type.hash ()) + return 1; + else // compare the strings + return (ACE_OS::strcmp (this->event_type_.type_name, event_type.event_type_.type_name) != 0 || + ACE_OS::strcmp (this->event_type_.domain_name, event_type.event_type_.domain_name) != 0 + ); +} + +CORBA::Boolean +TAO_NS_EventType::is_special (void) const +{ + if ((this->event_type_.domain_name == 0 || + ACE_OS::strcmp (this->event_type_.domain_name, "") == 0 || + ACE_OS::strcmp (this->event_type_.domain_name, "*") == 0) && + (this->event_type_.type_name == 0 || + ACE_OS::strcmp (this->event_type_.type_name, "") == 0 || + ACE_OS::strcmp (this->event_type_.type_name, "*") == 0 || + ACE_OS::strcmp (this->event_type_.type_name, "%ALL") == 0)) + return 1; + else + return 0; +} + +void +TAO_NS_EventType::dump (void) const +{ + ACE_DEBUG ((LM_DEBUG, "(%s,%s)", this->event_type_.domain_name.in (), this->event_type_.type_name.in ())); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.h b/TAO/orbsvcs/orbsvcs/Notify/EventType.h new file mode 100644 index 00000000000..edeaca96cbc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.h @@ -0,0 +1,92 @@ +/* -*- C++ -*- */ +/** + * @file EventType.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENTTYPE_H +#define TAO_NS_EVENTTYPE_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" + +/** + * @class TAO_NS_EventType + * + * @brief + * + * This type is used to compare different event types. + * It is used by the Event Manager as a key to find subscription lists. + * + */ +class TAO_Notify_Export TAO_NS_EventType +{ +public: + /// Constuctor + TAO_NS_EventType (void); + TAO_NS_EventType (const char* domain_name, const char* type_name); + TAO_NS_EventType (const CosNotification::EventType& event_type); + // Constuctor + + /// Destructor + ~TAO_NS_EventType (); + + /// hash value + u_long hash (void) const; + + /// Assignment from CosNotification::EventType + TAO_NS_EventType& operator=(const CosNotification::EventType& event_type); + + /// Assignment operator. + TAO_NS_EventType& operator=(const TAO_NS_EventType& event_type); + + /// == operator + int operator==(const TAO_NS_EventType& notify_event_type) const; + + /// != operator + int operator!=(const TAO_NS_EventType& notify_event_type) const; + + static TAO_NS_EventType special (void); + // Return the special event type. + + CORBA::Boolean is_special (void) const; + // Is this the special event (accept everything). + + const CosNotification::EventType& native (void) const; + // Get the type underneath us. + + /// Helper to print contents. + void dump (void) const; + +protected: + /// Init this object. + void init_i (const char* domain_name, const char* type_name); + + void recompute_hash (void); + // Recompute the hash value. + + // = Data Members + CosNotification::EventType event_type_; + // The event_type that we're decorating. + + u_long hash_value_; + // The hash value computed. +}; + +#if defined (__ACE_INLINE__) +#include "EventType.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTTYPE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.inl b/TAO/orbsvcs/orbsvcs/Notify/EventType.inl new file mode 100644 index 00000000000..93af3791bf9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE u_long +TAO_NS_EventType::hash (void) const +{ + return this->hash_value_; +} + +ACE_INLINE const CosNotification::EventType& +TAO_NS_EventType::native (void) const +{ + return event_type_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp new file mode 100644 index 00000000000..ccd6389e10c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp @@ -0,0 +1,223 @@ +// $Id$ + +#include "EventTypeSeq.h" + +#if ! defined (__ACE_INLINE__) +#include "EventTypeSeq.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_EventTypeSeq, "$Id$") + +TAO_NS_EventTypeSeq::TAO_NS_EventTypeSeq (void) +{ +} + +TAO_NS_EventTypeSeq::TAO_NS_EventTypeSeq (const CosNotification::EventTypeSeq& event_type_seq) +{ + this->insert_seq (event_type_seq); +} + +void +TAO_NS_EventTypeSeq::populate (CosNotification::EventTypeSeq& event_type_seq) const +{ + event_type_seq.length (this->size ()); + + inherited::CONST_ITERATOR iter (*this); + + TAO_NS_EventType* event_type; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (event_type); iter.advance (), ++i) + event_type_seq[i] = event_type->native (); +} + +void +TAO_NS_EventTypeSeq::populate_no_special (CosNotification::EventTypeSeq& event_type_seq) const +{ + // If the special exists in us, don't include it. + const TAO_NS_EventType& special = TAO_NS_EventType::special (); + + if (this->find (special) == 0) + { + event_type_seq.length (this->size () - 1); + } + else + event_type_seq.length (this->size ()); + + inherited::CONST_ITERATOR iter (*this); + + TAO_NS_EventType* event_type; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (event_type); iter.advance (), ++i) + { + if (event_type->is_special () == 0) // if its not the special event type. + event_type_seq[i] = event_type->native (); + } +} + +void +TAO_NS_EventTypeSeq::insert_seq (const CosNotification::EventTypeSeq& event_type_seq) +{ + TAO_NS_EventType event_type; + + for (CORBA::ULong i = 0; i < event_type_seq.length (); ++i) + { + event_type = event_type_seq[i]; + inherited::insert (event_type); + } +} + +void +TAO_NS_EventTypeSeq::remove_seq (const CosNotification::EventTypeSeq& event_type_seq) +{ + TAO_NS_EventType event_type; + + for (CORBA::ULong i = 0; i < event_type_seq.length (); ++i) + { + event_type = event_type_seq[i]; + inherited::remove (event_type); + } +} + +void +TAO_NS_EventTypeSeq::insert_seq (const TAO_NS_EventTypeSeq& event_type_seq) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (event_type_seq); + + TAO_NS_EventType* event_type; + + for (iter.first (); iter.next (event_type); iter.advance ()) + inherited::insert (*event_type); +} + +void +TAO_NS_EventTypeSeq::remove_seq (const TAO_NS_EventTypeSeq& event_type_seq) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (event_type_seq); + + TAO_NS_EventType* event_type; + + 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) +{ + const TAO_NS_EventType& special = TAO_NS_EventType::special (); + + if (this->find (special) == 0) // If this object has the special type. + { + if (seq_added.find (special) == 0) // if the seq. being added has the special type, you cannot be adding or removing anythings. * overrides. + { + seq_added.reset (); // remove everything from the sequence bening added. + seq_remove.reset (); // remove everything form whats being removed. + } + else // sequence being added does not have * + { + this->reset (); // take away the * from this object. + this->insert_seq (seq_added); // insert the sequence being added as the new list of types. + + seq_remove.reset (); // reset all that is being removed. + seq_remove.insert (special); // remove * + } + } + else // if this object does not have the special type. + { + if (seq_added.find (special) == 0) // but the seq. being added has the special type, + { + if (seq_remove.find (special) == 0) // and you're removing * as well + { + seq_added.reset (); // ignore the request + seq_remove.reset (); // ignore the request + } + else // seq being removed does not have the special type + { + seq_remove.reset (); // everything that we're subscribed for is being removed. + seq_remove.insert_seq (*this); + + this->reset (); // insert the special in this object. + this->insert (special); + + seq_added.reset (); // also clear our set and add only * + seq_added.insert (special); + } + } + else // seq being added does not have special. + { + if (seq_remove.find (special) == 0) // but we're removing everything. + { + seq_remove.reset (); // move all that we have currently to removed. + seq_remove.insert_seq (*this); + } + + // so now there are no specials anywhere.. + { + //= First remove the duplicates in the added and removes lists. + // compute the intersection. + + TAO_NS_EventTypeSeq common; + common.intersection (seq_added, seq_remove); + + // remove the common elements from both the lists so Added {BCDK} and Removed {CDEA} will yield Added {BK} and Removed {EA} + seq_added.remove_seq (common); + seq_remove.remove_seq (common); + + // If we're already subscribed for an element we should not subscribe again (duplicate events). + // so if we currently subscribe for ABC and we Added {BK} we should now get ABCK as current subscription and Added {K} + common.reset (); + common.intersection (*this, seq_added); + // remove the common elements from the added list. i,e. doent ask to add what we're already added for. + seq_added.remove_seq (common); + // update the current subscription. + this->insert_seq (seq_added); + + + // Similarly for removed.. if we're removing EA and now our current list looks like ABC we should emd up with + // current subscription BC and Removed {A} + common.reset (); + common.intersection (*this, seq_remove); + + seq_remove.reset (); + seq_remove.insert_seq (common); // only remove what we currently have. + + this->remove_seq (seq_remove); + } + } + } +} + +void +TAO_NS_EventTypeSeq::intersection (const TAO_NS_EventTypeSeq& rhs, const TAO_NS_EventTypeSeq& lhs) +{ + // linear search. + TAO_NS_EventTypeSeq::CONST_ITERATOR rhs_iter (rhs); + TAO_NS_EventType* rhs_event_type; + + TAO_NS_EventTypeSeq::CONST_ITERATOR lhs_iter (lhs); + TAO_NS_EventType* lhs_event_type; + + for (rhs_iter.first (); rhs_iter.next (rhs_event_type); rhs_iter.advance ()) + { + for (lhs_iter.first (); lhs_iter.next (lhs_event_type); lhs_iter.advance ()) + { + if (*rhs_event_type == *lhs_event_type) // if both are same add to this object. + this->insert (*rhs_event_type); + } + } +} + +void +TAO_NS_EventTypeSeq::dump (void) const +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (*this); + + TAO_NS_EventType* event_type; + + for (iter.first (); iter.next (event_type); iter.advance ()) + { + event_type->dump (); + ACE_DEBUG ((LM_DEBUG, ", ")); + } +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h new file mode 100644 index 00000000000..b695dc9ea10 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h @@ -0,0 +1,74 @@ +/* -*- C++ -*- */ +/** + * @file EventTypeSeq.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENTTYPESEQ_H +#define TAO_NS_EVENTTYPESEQ_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "EventType.h" +#include "ace/Unbounded_Set.h" + +/** + * @class TAO_NS_EventTypeSeq + * + * @brief Allows operations using the CosNotification::EventTypeSeq type. + * + */ +class TAO_Notify_Export TAO_NS_EventTypeSeq : public ACE_Unbounded_Set +{ + typedef ACE_Unbounded_Set inherited; + +public: + /// Constructor + 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); + + /// Populate this sequence with the intersection of rhs and lhs. + void intersection (const TAO_NS_EventTypeSeq& rhs, const TAO_NS_EventTypeSeq& lhs); + + /// insert_seq the contents of into this object. + void insert_seq (const CosNotification::EventTypeSeq& event_type_seq); + + /// remove_seq the contents of from this object. + void remove_seq (const CosNotification::EventTypeSeq& event_type_seq); + + /// insert_seq the contents of into this object. + void insert_seq (const TAO_NS_EventTypeSeq& event_type_seq); + + /// remove_seq the contents of from this object. + void remove_seq (const TAO_NS_EventTypeSeq& event_type_seq); + + /// Populate with the contents of this object. + void populate (CosNotification::EventTypeSeq& event_type) const; + + /// Populate with the contents of this object. + // Excludes the special event type. This is used to avoid sending * type updates to proxys. + void populate_no_special (CosNotification::EventTypeSeq& event_type) const; + + /// Print the contents. + void dump (void) const; +}; + +#if defined (__ACE_INLINE__) +#include "EventTypeSeq.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTTYPESEQ_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp new file mode 100644 index 00000000000..2392dee4a63 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp @@ -0,0 +1,328 @@ +// $Id$ + +#include "Event_Manager.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Manager.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Event_Manager, "$Id$") + +#include "ProxyConsumer.h" +#include "ProxySupplier.h" +#include "Consumer_Map.h" +#include "Supplier_Map.h" + +TAO_NS_Event_Manager::TAO_NS_Event_Manager (void) + :consumer_map_ (0), supplier_map_ (0) +{ +} + +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_->proxy_count (), this->supplier_map_->proxy_count ())); + } + + delete this->consumer_map_; + delete this->supplier_map_; +} + +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 ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->supplier_map_, + TAO_NS_Supplier_Map (), + 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; +} + +void +TAO_NS_Event_Manager::shutdown (void) +{ +} + +void +TAO_NS_Event_Manager::connect (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL) +{ + this->consumer_map_->connect (proxy_supplier ACE_ENV_ARG_PARAMETER); + + // Inform about offered types. + TAO_NS_EventTypeSeq removed; + proxy_supplier->types_changed (this->offered_types (), removed ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Event_Manager::disconnect (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL) +{ + this->consumer_map_->disconnect (proxy_supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Event_Manager::connect (TAO_NS_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL) +{ + this->supplier_map_->connect (proxy_consumer ACE_ENV_ARG_PARAMETER); + + // Inform about subscription types. + TAO_NS_EventTypeSeq removed; + proxy_consumer->types_changed (this->subscription_types (), removed ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Event_Manager::disconnect (TAO_NS_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL) +{ + this->supplier_map_->disconnect (proxy_consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Event_Manager::offer_change (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq new_added, last_removed; + + this->publish (proxy_consumer, added, new_added ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->un_publish (proxy_consumer, removed, last_removed ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + TAO_NS_Consumer_Map::ENTRY::COLLECTION* updates_collection = this->consumer_map_->updates_collection (); + + TAO_NS_ProxySupplier_Update_Worker worker (new_added, last_removed); + + if (updates_collection != 0) + updates_collection->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Event_Manager::subscription_change (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq new_added, last_removed; + + this->subscribe (proxy_supplier, added, new_added ACE_ENV_ARG_PARAMETER); + this->un_subscribe (proxy_supplier, removed, last_removed ACE_ENV_ARG_PARAMETER); + + TAO_NS_Supplier_Map::ENTRY::COLLECTION* updates_collection = this->supplier_map_->updates_collection (); + + TAO_NS_ProxyConsumer_Update_Worker worker (new_added, last_removed); + + if (updates_collection != 0) + updates_collection->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Event_Manager::subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& new_seq ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); + + TAO_NS_EventType* event_type; + + for (iter.first (); iter.next (event_type) != 0; iter.advance ()) + { + int result = consumer_map_->insert (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (result == 1) + new_seq.insert (*event_type); + } +} + +void +TAO_NS_Event_Manager::un_subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& last_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 ()) + { + int result = consumer_map_->remove (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (result == 1) + last_seq.insert (*event_type); + } +} + +void +TAO_NS_Event_Manager::publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& new_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 ()) + { + int result = supplier_map_->insert (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (result == 1) + new_seq.insert (*event_type); + } +} + +void +TAO_NS_Event_Manager::un_publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& last_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 ()) + { + int result = supplier_map_->remove (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (result == 1) + last_seq.insert (*event_type); + } +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_Event_Map_T; +template class TAO_NS_Event_Map_T; + +template class ACE_Hash; +template class ACE_Equal_To; + +template class TAO_NS_Event_Map_Entry_T; +template class TAO_NS_Event_Map_Entry_T; + +template class ACE_Hash_Map_Manager_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager *, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager *, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager; + +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set_Const_Iterator; +template class ACE_Unbounded_Queue >; +template class ACE_Unbounded_Set_Iterator; + +template class TAO_ESF_Worker; +template class TAO_ESF_Worker; +template class TAO_ESF_Worker; +template class TAO_ESF_Worker; +template class TAO_ESF_Worker; +template class TAO_ESF_Worker; +template class TAO_ESF_Worker; + +template class ACE_Refcounted_Auto_Ptr; +template class ACE_Unbounded_Queue_Iterator >; + +template class ACE_Node >; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; +template class ACE_Node; + +template class ACE_Hash_Map_Entry *>; +template class ACE_Hash_Map_Entry; +template class ACE_Hash_Map_Entry *>; + +template class ACE_Hash_Map_Iterator_Base_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Reverse_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Reverse_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex>; +template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex>; + +template class TAO_ESF_Shutdown_Proxy; +template class TAO_ESF_Shutdown_Proxy; +template class TAO_ESF_Shutdown_Proxy; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Event_Map_T +#pragma instantiate TAO_NS_Event_Map_T + +#pragma instantiate ACE_Hash +#pragma instantiate ACE_Equal_To + +#pragma instantiate TAO_NS_Event_Map_Entry_T +#pragma instantiate TAO_NS_Event_Map_Entry_T + +#pragma instantiate ACE_Hash_Map_Manager_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager *, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager *, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager + +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set_Const_Iterator +#pragma instantiate ACE_Unbounded_Queue > +#pragma instantiate ACE_Unbounded_Set_Iterator + +#pragma instantiate TAO_ESF_Worker +#pragma instantiate TAO_ESF_Worker +#pragma instantiate TAO_ESF_Worker +#pragma instantiate TAO_ESF_Worker +#pragma instantiate TAO_ESF_Worker +#pragma instantiate TAO_ESF_Worker +#pragma instantiate TAO_ESF_Worker + +#pragma instantiate ACE_Refcounted_Auto_Ptr +#pragma instantiate ACE_Unbounded_Queue_Iterator > + +#pragma instantiate ACE_Node > +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node +#pragma instantiate ACE_Node + +#pragma instantiate ACE_Hash_Map_Entry *> +#pragma instantiate ACE_Hash_Map_Entry +#pragma instantiate ACE_Hash_Map_Entry *> + +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> + +#pragma instantiate ACE_Hash_Map_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> + +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex *, ACE_Hash, ACE_Equal_To, ACE_Null_Mutex> + +#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> + +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> + +#pragma instantiate TAO_ESF_Shutdown_Proxy +#pragma instantiate TAO_ESF_Shutdown_Proxy +#pragma instantiate TAO_ESF_Shutdown_Proxy + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h new file mode 100644 index 00000000000..efc8b257831 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h @@ -0,0 +1,150 @@ +/* -*- C++ -*- */ +/** + * @file Event_Manager.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENT_MANAGER_H +#define TAO_NS_EVENT_MANAGER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Worker.h" + +class TAO_NS_ProxySupplier; +class TAO_NS_ProxyConsumer; +class TAO_NS_EventTypeSeq; + +template class TAO_NS_Event_Map_T; +typedef TAO_NS_Event_Map_T TAO_NS_Consumer_Map; +typedef TAO_NS_Event_Map_T TAO_NS_Supplier_Map; + +/** + * @class TAO_NS_Event_Manager + * + * @brief A class that manages the Consumer and Supplier maps. + * + */ +class TAO_Notify_Export TAO_NS_Event_Manager +{ +public: + /// Constuctor + TAO_NS_Event_Manager (void); + + /// Destructor + ~TAO_NS_Event_Manager (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Init + void shutdown (void); + + /// Connect ProxySupplier + void connect (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL); + + /// Disconnect ProxySupplier + void disconnect (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL); + + /// Connect ProxyConsumer + void connect (TAO_NS_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL); + + /// Disconnect ProxyConsumer + void disconnect (TAO_NS_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL); + + /// Map accessors. + TAO_NS_Consumer_Map* consumer_map (void); + TAO_NS_Supplier_Map* supplier_map (void); + + /// Offer change received on . + void offer_change (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed ACE_ENV_ARG_DECL); + + /// Subscription change received on . + void subscription_change (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed ACE_ENV_ARG_DECL); + + /// What are the types being offered. + const TAO_NS_EventTypeSeq& offered_types (void); + + /// What are the types being subscribed. + const TAO_NS_EventTypeSeq& subscription_types (void); + +protected: + /// Subscribe to the event type sequence list . + void subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& new_seq ACE_ENV_ARG_DECL); + + /// Unsubscribe to the event type sequence list . + void un_subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& last_seq ACE_ENV_ARG_DECL); + + /// Subscribe to the event type sequence list . + void publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& new_seq ACE_ENV_ARG_DECL); + + /// Subscribe to the event type sequence list . + void un_publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq, TAO_NS_EventTypeSeq& last_seq ACE_ENV_ARG_DECL); + + /// Consumer Map + TAO_NS_Consumer_Map* consumer_map_; + + /// Supplier Map + TAO_NS_Supplier_Map* supplier_map_; +}; + +/********************************************************************************/ + +/** + * @class TAO_NS_ProxyConsumer_Update_Worker + * + * @brief Inform ProxyConsumer of updates. + * + */ +class TAO_Notify_Export TAO_NS_ProxyConsumer_Update_Worker : public TAO_ESF_Worker +{ +public: + TAO_NS_ProxyConsumer_Update_Worker (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed); + +protected: + ///= TAO_ESF_Worker method + void work (TAO_NS_ProxyConsumer* proxy ACE_ENV_ARG_DECL); + + const TAO_NS_EventTypeSeq& added_; + const TAO_NS_EventTypeSeq& removed_; +}; + +/********************************************************************************/ + +/** + * @class TAO_NS_ProxySupplier_Update_Worker + * + * @brief Inform ProxySupplier of updates. + * + */ +class TAO_Notify_Export TAO_NS_ProxySupplier_Update_Worker : public TAO_ESF_Worker +{ +public: + TAO_NS_ProxySupplier_Update_Worker (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed); + +protected: + ///= TAO_ESF_Worker method + void work (TAO_NS_ProxySupplier* proxy ACE_ENV_ARG_DECL); + + const TAO_NS_EventTypeSeq& added_; + const TAO_NS_EventTypeSeq& removed_; +}; + +/********************************************************************************/ + +#if defined (__ACE_INLINE__) +#include "Event_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MANAGER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl new file mode 100644 index 00000000000..3ad395f331a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl @@ -0,0 +1,57 @@ +// $Id$ + +#include "ProxyConsumer.h" +#include "ProxySupplier.h" +#include "Event_Map_T.h" + +ACE_INLINE TAO_NS_Consumer_Map* +TAO_NS_Event_Manager::consumer_map (void) +{ + return this->consumer_map_; +} + +ACE_INLINE TAO_NS_Supplier_Map* +TAO_NS_Event_Manager::supplier_map (void) +{ + return this->supplier_map_; +} + +ACE_INLINE const TAO_NS_EventTypeSeq& +TAO_NS_Event_Manager::offered_types (void) +{ + return this->supplier_map_->event_types (); +} + +ACE_INLINE const TAO_NS_EventTypeSeq& +TAO_NS_Event_Manager::subscription_types (void) +{ + return this->consumer_map_->event_types (); +} + +/********************************************************************************/ + +ACE_INLINE TAO_NS_ProxyConsumer_Update_Worker::TAO_NS_ProxyConsumer_Update_Worker (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed) + :added_ (added), removed_ (removed) +{ +} + +ACE_INLINE void +TAO_NS_ProxyConsumer_Update_Worker::work (TAO_NS_ProxyConsumer* proxy ACE_ENV_ARG_DECL) +{ + proxy->types_changed (added_, removed_ ACE_ENV_ARG_PARAMETER); +} + +/********************************************************************************/ + +ACE_INLINE TAO_NS_ProxySupplier_Update_Worker::TAO_NS_ProxySupplier_Update_Worker (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed) + :added_ (added), removed_ (removed) +{ +} + +ACE_INLINE void +TAO_NS_ProxySupplier_Update_Worker::work (TAO_NS_ProxySupplier* proxy ACE_ENV_ARG_DECL) +{ + proxy->types_changed (added_, removed_ ACE_ENV_ARG_PARAMETER); +} + +/********************************************************************************/ 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..53573dafa90 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp @@ -0,0 +1,52 @@ +// $Id$ + +#ifndef TAO_NS_EVENT_MAP_ENTRY_CPP +#define TAO_NS_EVENT_MAP_ENTRY_CPP + +#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 +TAO_NS_Event_Map_Entry_T::TAO_NS_Event_Map_Entry_T (void) + : collection_ (0), count_ (0), usage_count_ (1) +{ +} + +template +TAO_NS_Event_Map_Entry_T::~TAO_NS_Event_Map_Entry_T () +{ + delete collection_; +} + +template void +TAO_NS_Event_Map_Entry_T::init (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + factory->create (collection_ ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_Event_Map_Entry_T::connected (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->collection_->connected (proxy ACE_ENV_ARG_PARAMETER); + ++count_; +} + +template void +TAO_NS_Event_Map_Entry_T::disconnected (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->collection_->disconnected (proxy ACE_ENV_ARG_PARAMETER); + --count_; +} + +#endif /* TAO_NS_EVENT_MAP_ENTRY_CPP */ 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..caca41aecf3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h @@ -0,0 +1,93 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Entry_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#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 "ace/Atomic_Op.h" +#include "tao/corba.h" + +template class TAO_NS_Event_Map_T; +template class TAO_ESF_Proxy_Collection; + +/** + * @class TAO_NS_Event_Map_Entry_T + * + * @brief The entry stored in the event map. + * + */ +template +class TAO_NS_Event_Map_Entry_T : private ACE_Copy_Disabled +{ +public: + typedef TAO_ESF_Proxy_Collection 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); + + ///= Reference counting methods. + // Incr the ref count. + CORBA::ULong _incr_refcnt (void); + + // Decr the ref count. This object is destroyed when the count is 0. + CORBA::ULong _decr_refcnt (void); + +protected: + /// The Collection + COLLECTION* collection_; + + /// Count of PROXY's connected in the collection; + int count_; + + /// Count of users accessing this entry. + ACE_Atomic_Op usage_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..b0dfa7c4676 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl @@ -0,0 +1,25 @@ +// $Id$ + +template ACE_INLINE ACE_TYPENAME +TAO_NS_Event_Map_Entry_T::COLLECTION* +TAO_NS_Event_Map_Entry_T::collection (void) { + return collection_; +} + +template ACE_INLINE int +TAO_NS_Event_Map_Entry_T::count (void) +{ + return this->count_; +} + +template ACE_INLINE CORBA::ULong +TAO_NS_Event_Map_Entry_T::_incr_refcnt (void) +{ + return ++this->usage_count_; +} + +template ACE_INLINE CORBA::ULong +TAO_NS_Event_Map_Entry_T::_decr_refcnt (void) +{ + return --this->usage_count_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp new file mode 100644 index 00000000000..fc2ba2f0c71 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp @@ -0,0 +1,164 @@ +// $Id$ + +#ifndef TAO_NS_EVENT_MAP_T_C +#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" + +#if ! defined (__ACE_INLINE__) +#include "Event_Map_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Event_Map_T, "$Id$") + +template +TAO_NS_Event_Map_T::TAO_NS_Event_Map_T (void) + :proxy_count_ (0) +{ + +} + +template +TAO_NS_Event_Map_T::~TAO_NS_Event_Map_T () +{ +} + +template void +TAO_NS_Event_Map_T::init (ACE_ENV_SINGLE_ARG_DECL) +{ + this->broadcast_entry_.init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->updates_entry_.init (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template void +TAO_NS_Event_Map_T::connect (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->updates_entry_.connected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); + ++this->proxy_count_; +} + +template void +TAO_NS_Event_Map_T::disconnect (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->updates_entry_.disconnected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); + --this->proxy_count_; +} + +template int +TAO_NS_Event_Map_T::insert (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) +{ + ENTRY* entry; + + int result = -1; + + if (event_type.is_special () == 1) + { + entry = &this->broadcast_entry_; + + result = 0; + } + else + { + ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + result = this->map_.find (event_type, entry); + } + + if (result == -1) // This type is being seen for the first time. + { + ACE_NEW_THROW_EX (entry, + 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); + ACE_CHECK_RETURN (-1); + + ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + if (map_.bind (event_type, entry) == -1) + ACE_THROW_RETURN (CORBA::NO_MEMORY (), -1); + + if (this->event_types_.insert (event_type) == -1) + return -1; + + return 1; + } + else // Add to existing entry or the broadcast entry. + { + entry->connected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } + + return 0; +} + +template int +TAO_NS_Event_Map_T::remove (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) +{ + ENTRY* entry; + + if (event_type.is_special () == 1) + { + entry = &this->broadcast_entry_; + + entry->disconnected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } + else + { + int result = -1; + + { + ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + result = this->map_.find (event_type, entry); + } + + if (result == 0) + { + entry->disconnected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (entry->count () == 0) + { + /// Exec a strategy for removing entries. + /// Strategy 1: remove_immediately + /// Strategy 2: remove a bunch_after crossing a threshold + /// Strategy 3: use cached allocator and 1 + + // Strategy 1: + ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + this->map_.unbind (event_type); + + if (entry->_decr_refcnt () == 0) + delete entry; + + if (this->event_types_.remove (event_type) == -1) + return -1; + + return 1; + } + } + } + + return 0; +} + +#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 new file mode 100644 index 00000000000..b7219b3f509 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h @@ -0,0 +1,119 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_EVENT_MAP_T_H +#define TAO_NS_EVENT_MAP_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/Hash_Map_Manager.h" +#include "ace/CORBA_macros.h" + +#include "EventType.h" +#include "Event_Map_Entry_T.h" +#include "EventTypeSeq.h" + +/** + * @class TAO_NS_Event_Map_T + * + * @brief Template class for storing the collection of Proxys. + * + */ +template +class TAO_NS_Event_Map_T +{ + +public: + typedef TAO_NS_Event_Map_Entry_T ENTRY; + + /// Constuctor + TAO_NS_Event_Map_T (void); + + /// Destructor + ~TAO_NS_Event_Map_T (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Connect a PROXY + void connect (PROXY* proxy ACE_ENV_ARG_DECL); + + /// Disconnect a PROXY + void disconnect (PROXY* proxy ACE_ENV_ARG_DECL); + + /// Associate PROXY and event_type. + /// Returns 1 if is being seem for the 1st time otherwise returns 0. + /// Returns -1 on error. + int insert (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// Remove association of PROXY and event_type. + /// Returns 1 if is being seem for the last time otherwise returns 0. + /// Returns -1 on error. + int remove (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// Find the collection mapped to the + /// The usage_count on the entry returned is incremented. + ENTRY* find (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// Find the default broadcast list. + ACE_TYPENAME ENTRY::COLLECTION* broadcast_collection (void); + + /// Find the update list. This is all the PROXYS connected to this Map. + ACE_TYPENAME ENTRY::COLLECTION* updates_collection (void); + + /// Release the usage count on this entry. + void release (ENTRY* entry); + + /// Access all the event types available + const TAO_NS_EventTypeSeq& event_types (void); + + /// Access number of proxys connected in all. + int proxy_count (void); + +protected: + /// The Map that stores eventtype to entry mapping. + ACE_Hash_Map_Manager map_; + + /// The lock to use. + ACE_LOCK lock_; + + /// Count of proxys connected. + int proxy_count_; + + /// The default broadcast list for EventType::special. + ENTRY broadcast_entry_; + + /// Update Entry - Keeps a list of all PROXY's connected to this Map. Updates are send to this list. + ENTRY updates_entry_; + + /// The event types that are available in this map. + TAO_NS_EventTypeSeq event_types_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Map_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Event_Map_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Map_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MAP_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl new file mode 100644 index 00000000000..fb81c86a0b0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl @@ -0,0 +1,50 @@ +// $Id$ + +template ACE_INLINE TAO_NS_Event_Map_Entry_T* +TAO_NS_Event_Map_T::find (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL_NOT_USED) +{ + TAO_NS_Event_Map_Entry_T* entry; + + ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0); + + if (map_.find (event_type, entry) == 0) + { + entry->_incr_refcnt (); + return entry; + } + else + return 0; +} + +template ACE_INLINE void +TAO_NS_Event_Map_T::release (ENTRY* entry) +{ + ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + if (entry->_decr_refcnt () == 0) + delete entry; +} + +template ACE_INLINE ACE_TYPENAME TAO_NS_Event_Map_Entry_T::COLLECTION* +TAO_NS_Event_Map_T::broadcast_collection (void) +{ + return this->broadcast_entry_.collection (); +} + +template ACE_INLINE ACE_TYPENAME TAO_NS_Event_Map_Entry_T::COLLECTION* +TAO_NS_Event_Map_T::updates_collection (void) +{ + return this->updates_entry_.collection (); +} + +template ACE_INLINE int +TAO_NS_Event_Map_T::proxy_count (void) +{ + return this->proxy_count_; +} + +template ACE_INLINE const TAO_NS_EventTypeSeq& +TAO_NS_Event_Map_T::event_types (void) +{ + return this->event_types_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Factory.h new file mode 100644 index 00000000000..4f84b9aaffe --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Factory.h @@ -0,0 +1,126 @@ +/* -*- C++ -*- */ +/** + * @file Factory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_FACTORY_H +#define TAO_NS_FACTORY_H +#include "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/corba.h" +#include "ace/CORBA_macros.h" +#include "ace/Service_Object.h" + +class ACE_Lock; +class TAO_NS_Object; +class TAO_NS_EventChannelFactory; +class TAO_NS_EventChannel; +class TAO_NS_SupplierAdmin; +class TAO_NS_ConsumerAdmin; +class TAO_NS_ProxyPushConsumer; +class TAO_NS_CosEC_ProxyPushSupplier; +class TAO_NS_CosEC_ProxyPushConsumer; +class TAO_NS_ProxyPushSupplier; +class TAO_NS_StructuredProxyPushConsumer; +class TAO_NS_StructuredProxyPushSupplier; +class TAO_NS_SequenceProxyPushConsumer; +class TAO_NS_SequenceProxyPushSupplier; +class TAO_NS_ProxyConsumer; +class TAO_NS_ProxySupplier; +class TAO_NS_ConsumerAdmin; +class TAO_NS_SupplierAdmin; +class TAO_NS_Proxy; +class TAO_NS_Consumer; +class TAO_NS_Supplier; +class TAO_NS_Peer; + +template class TAO_ESF_Proxy_Collection; + +typedef TAO_ESF_Proxy_Collection TAO_NS_ProxyConsumer_Collection; +typedef TAO_ESF_Proxy_Collection TAO_NS_ProxySupplier_Collection; + +typedef TAO_ESF_Proxy_Collection TAO_NS_EventChannel_Collection; +typedef TAO_ESF_Proxy_Collection TAO_NS_ConsumerAdmin_Collection; +typedef TAO_ESF_Proxy_Collection TAO_NS_SupplierAdmin_Collection; +typedef TAO_ESF_Proxy_Collection TAO_NS_Proxy_Collection; + +/** + * @class TAO_NS_Factory + * + * @brief Factory interface for creating Notify Objects. + * + */ +class /*TAO_Notify_Export*/ TAO_NS_Factory : public ACE_Service_Object +{ +public: + /// Create ProxySupplier Collection + virtual void create (TAO_NS_ProxySupplier_Collection*& collection ACE_ENV_ARG_DECL) = 0; + + /// Create ProxyConsumer Collection + virtual void create (TAO_NS_ProxyConsumer_Collection*& collection ACE_ENV_ARG_DECL) = 0; + + /// Create EventChannel Collection + virtual void create (TAO_NS_EventChannel_Collection*& collection ACE_ENV_ARG_DECL) = 0; + + /// Create ConsumerAdmin Collection + virtual void create (TAO_NS_ConsumerAdmin_Collection*& collection ACE_ENV_ARG_DECL) = 0; + + /// Create SupplierAdmin Collection + virtual void create (TAO_NS_SupplierAdmin_Collection*& collection ACE_ENV_ARG_DECL) = 0; + + /// Create Proxy Collection + virtual void create (TAO_NS_Proxy_Collection*& collection ACE_ENV_ARG_DECL) = 0; + + /// Create EventChannelFactory + virtual void create (TAO_NS_EventChannelFactory*& channel_factory ACE_ENV_ARG_DECL) = 0; + + /// Create EventChannel + virtual void create (TAO_NS_EventChannel*& channel ACE_ENV_ARG_DECL) = 0; + + /// Create SupplierAdmin + virtual void create (TAO_NS_SupplierAdmin*& admin ACE_ENV_ARG_DECL) = 0; + + /// Create ConsumerAdmin + virtual void create (TAO_NS_ConsumerAdmin*& admin ACE_ENV_ARG_DECL) = 0; + + /// Create ProxyPushConsumer + virtual void create (TAO_NS_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create ProxyPushSupplier + virtual void create (TAO_NS_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create CosEC_ProxyPushConsumer + virtual void create (TAO_NS_CosEC_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create CosEC_ProxyPushSupplier + virtual void create (TAO_NS_CosEC_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create StructuredProxyPushConsumer + virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create StructuredProxyPushSupplier + virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create SequenceProxyPushConsumer + virtual void create (TAO_NS_SequenceProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) = 0; + + /// Create SequenceProxyPushSupplier + virtual void create (TAO_NS_SequenceProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) = 0; +}; + +#if defined (__ACE_INLINE__) +#include "Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp new file mode 100644 index 00000000000..4a804fe3f4b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp @@ -0,0 +1,177 @@ +/* -*- 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 (const TAO_NS_Event_var &event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + // If no filter is active, match is successfull. + if (this->filter_list_.current_size () == 0) + 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); + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (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 + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + if (this->filter_list_.unbind (filter_id) == -1) + ACE_THROW (CosNotifyFilter::FilterNotFound ()); +} + +CosNotifyFilter::Filter_ptr +TAO_NS_FilterAdmin::get_filter (CosNotifyFilter::FilterID filter_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + CosNotifyFilter::Filter_var filter_var; + + if (this->filter_list_.find (filter_id, + filter_var) == -1) + ACE_THROW_RETURN (CosNotifyFilter::FilterNotFound (), + 0); + + return filter_var._retn (); +} + +CosNotifyFilter::FilterIDSeq* +TAO_NS_FilterAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + // Figure out the length of the list. + size_t len = this->filter_list_.current_size (); + + CosNotifyFilter::FilterIDSeq* list_ptr; + + // Allocate the list of length. + ACE_NEW_THROW_EX (list_ptr, + CosNotifyFilter::FilterIDSeq, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::FilterIDSeq_var list (list_ptr); + + list->length (len); + + FILTER_LIST::ITERATOR iter (this->filter_list_); + FILTER_LIST::ENTRY *entry; + + u_int index; + + for (index = 0; iter.next (entry) != 0; iter.advance (), ++index) + { + list[index] = entry->ext_id_; + } + + return list._retn (); +} + +void +TAO_NS_FilterAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->filter_list_.unbind_all (); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Hash_Map_Entry; +template class ACE_Hash_Map_Manager; +template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Hash_Map_Entry +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To,TAO_SYNCH_MUTEX> + +#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..89998714834 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h @@ -0,0 +1,88 @@ +//============================================================================= +/** + * @file FilterAdmin.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore + */ +//============================================================================= + + +#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" + +/** + * @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 (const 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 FILTER_LIST; + + /// Mutex to serialize access to data members. + TAO_SYNCH_MUTEX lock_; + + /// 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..27708b31cd9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h @@ -0,0 +1,40 @@ +/* -*- C++ -*- */ +/** + * @file FilterFactory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#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" +#include "tao/PortableServer/PortableServer.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. The filters created are activated in the . + virtual CosNotifyFilter::FilterFactory_ptr create (PortableServer::POA_var& filter_poa ACE_ENV_ARG_DECL) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_FILTERFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.cpp new file mode 100644 index 00000000000..1c560a73503 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#ifndef TAO_NS_FIND_WORKER_T_CPP +#define TAO_NS_FIND_WORKER_T_CPP + +#include "Find_Worker_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Find_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Find_Worker_T, "$id$") + +template +TAO_NS_Find_Worker_T::TAO_NS_Find_Worker_T (void) + :id_ (0), result_ (0) +{ +} + +template TYPE* +TAO_NS_Find_Worker_T::find (TAO_NS_Object::ID id, CONTAINER& container ACE_ENV_ARG_DECL) +{ + this->id_ = id; + + container.collection ()->for_each (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->result_; +} + +template INTERFACE_PTR +TAO_NS_Find_Worker_T::resolve (TAO_NS_Object::ID id, CONTAINER& container ACE_ENV_ARG_DECL) +{ + this->find (id, container ACE_ENV_ARG_PARAMETER); + + if (this->result_ == 0) + ACE_THROW_RETURN (EXCEPTION () + , INTERFACE::_nil ()); + + CORBA::Object_var object = this->result_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (INTERFACE::_nil ()); + + return INTERFACE::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + +} + +#endif /* TAO_NS_FIND_WORKER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.h b/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.h new file mode 100644 index 00000000000..172b64c2b56 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.h @@ -0,0 +1,72 @@ +/* -*- C++ -*- */ +/** + * @file Find_Worker_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_FIND_WORKER_T_H +#define TAO_NS_FIND_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 "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "orbsvcs/ESF/ESF_Worker.h" +#include "Container_T.h" + +/** + * @class TAO_NS_Find_Worker_T + * + * @brief Helper to locate a TYPE given its ID. + * + */ +template +class TAO_Notify_Export TAO_NS_Find_Worker_T : public TAO_ESF_Worker +{ + typedef TAO_NS_Container_T CONTAINER; + typedef TAO_ESF_Proxy_Collection COLLECTION; + +public: + /// Constructor + TAO_NS_Find_Worker_T (void); + + /// Find the Type. + TYPE* find (TAO_NS_Object::ID id, CONTAINER& container ACE_ENV_ARG_DECL); + + /// Find and resolve to the Interface. + INTERFACE_PTR resolve (TAO_NS_Object::ID id, CONTAINER& container ACE_ENV_ARG_DECL); + +protected: + ///= TAO_ESF_Worker method + void work (TYPE* object ACE_ENV_ARG_DECL); + + /// The id we're looking for. + TAO_NS_Object::ID id_; + + /// The result + TYPE* result_; +}; + +#if defined (__ACE_INLINE__) +#include "Find_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Find_Worker_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Find_Worker_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_FIND_WORKER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.inl new file mode 100644 index 00000000000..b93dd01c819 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Find_Worker_T.inl @@ -0,0 +1,8 @@ +// $Id$ + +template ACE_INLINE void +TAO_NS_Find_Worker_T::work (TYPE* type ACE_ENV_ARG_DECL_NOT_USED) +{ + if (type->id () == this->id_) + this->result_ = type; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp new file mode 100644 index 00000000000..466a2ea8fb4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp @@ -0,0 +1,17 @@ +// $Id$ + +#include "ID_Factory.h" + +#if ! defined (__ACE_INLINE__) +#include "ID_Factory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ID_Factory, "$Id$") + +TAO_NS_ID_Factory::TAO_NS_ID_Factory (void) +{ +} + +TAO_NS_ID_Factory::~TAO_NS_ID_Factory () +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h new file mode 100644 index 00000000000..bd756a57ed3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h @@ -0,0 +1,52 @@ +/* -*- C++ -*- */ +/** + * @file ID_Factory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_ID_FACTORY_H +#define TAO_NS_ID_FACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Atomic_Op.h" +#include "Object.h" + +/** + * @class TAO_NS_ID_Factory + * + * @brief A simple factory for generating ID's for objects created by Notify. + * + */ +class TAO_Notify_Export TAO_NS_ID_Factory +{ +public: + /// Constuctor + TAO_NS_ID_Factory (void); + + /// Destructor + ~TAO_NS_ID_Factory (); + + TAO_NS_Object::ID id (void); + +private: + ACE_Atomic_Op seed_; +}; + + +#if defined (__ACE_INLINE__) +#include "ID_Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ID_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl new file mode 100644 index 00000000000..3520fc9bb7a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE TAO_NS_Object::ID +TAO_NS_ID_Factory::id (void) +{ + return ++seed_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp new file mode 100644 index 00000000000..345c9da754e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp @@ -0,0 +1,70 @@ +// $Id$ + +#include "Method_Request.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request, "$Id$") + +TAO_NS_Method_Request_Event::TAO_NS_Method_Request_Event (const TAO_NS_Event_var& event) + :event_ (event) +{ + // Set the parameters that affect queuing in the message queue. + // The ACE_Message_Block priorities go from 0 (lowest) to ULONG_MAX + // (highest), while the Notification Events go from -32767 (lowest, + // even though CORBA::Short goes to -32768) to 32767 (highest). + + // Convert to CORBA::Long to preserve the sign. Conversion to + // unsigned long will happen automatically and we do not have to worry + // about losing the number in the addition since priority () returns a + // CORBA::Short. + this->msg_priority ((CORBA::Long)this->event_->priority ().value () + + PRIORITY_BASE); + + // The deadline time for the message block is absolute, while the + // timeout for the event is relative to the time it was received. + // So, we do a little conversion and set it on the message block (us) + + TAO_NS_Property_Time& timeout = this->event_->timeout (); + + if (timeout.is_valid () && timeout != 0) + { + // I am multiplying timeout () by 1 because it returns a + // CORBA::ULongLong, which on some platforms doesn't automatically + // convert to the long that the ACE_Time_Value expects. The / + // operator returns a 32-bit integer. + ACE_Time_Value current = ACE_OS::gettimeofday () + +# if defined (ACE_CONFIG_WIN32_H) + ACE_Time_Value ( + ACE_static_cast (long, + timeout.value ())); +# else + ACE_Time_Value (timeout.value () / 1); +# endif /* ACE_CONFIG_WIN32_H */ + this->msg_deadline_time (current); + } +} + +TAO_NS_Method_Request_Event::~TAO_NS_Method_Request_Event () +{ +} + +int +TAO_NS_Method_Request_Event::execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return -1; +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Event::copy (void) +{ + return new TAO_NS_Method_Request_Event (this->event_); +} + +const TAO_NS_Event_var& +TAO_NS_Method_Request_Event::event (void) +{ + return this->event_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h new file mode 100644 index 00000000000..4124b82b21e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h @@ -0,0 +1,80 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_METHOD_REQUEST_H +#define TAO_NS_METHOD_REQUEST_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Message_Block.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "Event.h" + +/** + * @class TAO_NS_Method_Request + * + * @brief Interface for NS method Requests + * + */ +class TAO_Notify_Export TAO_NS_Method_Request : public ACE_Message_Block +{ +public: + enum {PRIORITY_BASE = 32768}; + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL) = 0; + + /// Create a copy of this object. + virtual TAO_NS_Method_Request* copy (void) = 0; +}; + +/***********************************************************************/ + +/** + * @class TAO_NS_Method_Request_Event + * + * @brief Base class for NS method Requests on Events. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Event : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Event (const TAO_NS_Event_var& event); + + /// Destructor + virtual ~TAO_NS_Method_Request_Event (); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + + /// Create a copy of this object. + virtual TAO_NS_Method_Request* copy (void); + + /// Obtain the event. + const TAO_NS_Event_var& event (void); + +protected: + const TAO_NS_Event_var event_; +}; + + +#if defined (__ACE_INLINE__) +#include "Method_Request.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_METHOD_REQUEST_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp new file mode 100644 index 00000000000..caa1d7de399 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp @@ -0,0 +1,71 @@ +// $Id$ + +#include "Method_Request_Dispatch.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Dispatch.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Dispatch, "$Id$") + +#include "tao/debug.h" +#include "ProxySupplier.h" +#include "Consumer.h" +#include "Admin.h" +#include "ConsumerAdmin.h" + +TAO_NS_Method_Request_Dispatch::TAO_NS_Method_Request_Dispatch (const TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier) + : TAO_NS_Method_Request_Event (event), proxy_supplier_ (proxy_supplier), refcountable_guard_ (*proxy_supplier) +{ +} + +TAO_NS_Method_Request_Dispatch::~TAO_NS_Method_Request_Dispatch () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Dispatch::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Dispatch (this->event_, this->proxy_supplier_); +} + +int +TAO_NS_Method_Request_Dispatch::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_supplier_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + TAO_NS_Admin* parent = this->proxy_supplier_->consumer_admin (); + + CORBA::Boolean val = this->proxy_supplier_->check_filters (this->event_, + parent->filter_admin (), + parent->filter_operator () + 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 + { + TAO_NS_Consumer* consumer = this->proxy_supplier_->consumer (); + + if (consumer != 0) + { + consumer->push (this->event_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_NS_Method_Request_Dispatch::: error sending event. \n "); + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h new file mode 100644 index 00000000000..862608c46a3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h @@ -0,0 +1,61 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Dispatch.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_DISPATCH_METHOD_REQUEST_H +#define TAO_NS_DISPATCH_METHOD_REQUEST_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 "Refcountable.h" + +class TAO_NS_ProxySupplier; + +/** + * @class TAO_NS_Method_Request_Dispatch + * + * @brief Dispatchs an event to a proxy supplier. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Dispatch : public TAO_NS_Method_Request_Event +{ +public: + /// Constuctor + TAO_NS_Method_Request_Dispatch (const TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier); + + /// Destructor + ~TAO_NS_Method_Request_Dispatch (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// Proxy Supplier that we use. + TAO_NS_ProxySupplier* proxy_supplier_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Dispatch.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_DISPATCH_METHOD_REQUEST_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl @@ -0,0 +1 @@ +// $Id$ 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..83626a87a1c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp @@ -0,0 +1,57 @@ +// $Id$ + +#include "Method_Request_Dispatch_No_Filtering.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$") + +#include "tao/debug.h" +#include "ProxySupplier.h" +#include "Consumer.h" + +TAO_NS_Method_Request_Dispatch_No_Filtering::TAO_NS_Method_Request_Dispatch_No_Filtering (const TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier) + : TAO_NS_Method_Request_Event (event), proxy_supplier_ (proxy_supplier), refcountable_guard_ (*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::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_supplier_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + 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..153caadc5d5 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h @@ -0,0 +1,61 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Dispatch_No_Filtering.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#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 "Refcountable.h" + +class TAO_NS_ProxySupplier; + +/** + * @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_Event +{ +public: + /// Constuctor + TAO_NS_Method_Request_Dispatch_No_Filtering (const 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 the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// Proxy Supplier that we use. + TAO_NS_ProxySupplier* proxy_supplier_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#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..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp new file mode 100644 index 00000000000..5dc8208a752 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp @@ -0,0 +1,84 @@ +// $Id$ + +#include "Method_Request_Lookup.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Lookup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Lookup, "$Id$") + +#include "tao/debug.h" +#include "Consumer_Map.h" +#include "ProxySupplier.h" +#include "ProxyConsumer.h" +#include "Proxy.h" +#include "Admin.h" +#include "SupplierAdmin.h" + +TAO_NS_Method_Request_Lookup::TAO_NS_Method_Request_Lookup (const TAO_NS_Event_var& event, TAO_NS_ProxyConsumer* proxy_consumer, TAO_NS_Consumer_Map* map) + : TAO_NS_Method_Request_Event (event), proxy_consumer_ (proxy_consumer), map_ (map), + refcountable_guard_ (*proxy_consumer) +{ +} + +TAO_NS_Method_Request_Lookup::~TAO_NS_Method_Request_Lookup () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Lookup::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Lookup (this->event_, this->proxy_consumer_, this->map_); +} + +int +TAO_NS_Method_Request_Lookup::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_consumer_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + TAO_NS_Admin* parent = this->proxy_consumer_->supplier_admin (); + + CORBA::Boolean val = this->proxy_consumer_->check_filters (this->event_, + parent->filter_admin (), + parent->filter_operator () + 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_Consumer_Map::ENTRY* entry = map_->find (this->event_->type () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + TAO_NS_ProxySupplier_Collection* consumers = 0; + + if (entry != 0) + { + consumers = entry->collection (); + + if (consumers != 0) + consumers->for_each (this ACE_ENV_ARG_PARAMETER); + + this->map_->release (entry); + } + + // Get the default consumers + consumers = map_->broadcast_collection (); + + if (consumers != 0) + consumers->for_each (this ACE_ENV_ARG_PARAMETER); + + return 0; +} + +void +TAO_NS_Method_Request_Lookup::work (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL_NOT_USED) +{ + proxy_supplier->push (this->event_); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h new file mode 100644 index 00000000000..4de8749c7e9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h @@ -0,0 +1,69 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Lookup.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_LOOKUP_METHOD_REQUEST_H +#define TAO_NS_LOOKUP_METHOD_REQUEST_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Worker.h" +#include "Method_Request.h" +#include "ProxySupplier.h" +#include "Consumer_Map.h" + +class TAO_NS_ProxyConsumer; + +/** + * @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. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Lookup : public TAO_NS_Method_Request_Event, public TAO_ESF_Worker +{ +public: + /// Constuctor + TAO_NS_Method_Request_Lookup (const TAO_NS_Event_var& event, TAO_NS_ProxyConsumer* proxy_consumer, TAO_NS_Consumer_Map* map); + + /// Destructor + ~TAO_NS_Method_Request_Lookup (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + + ///= TAO_ESF_Worker method + void work (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL); + +private: + /// ProxyConsumer supplying event. + TAO_NS_ProxyConsumer* proxy_consumer_; + + /// The map of subscriptions. + TAO_NS_Consumer_Map* map_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Lookup.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_LOOKUP_METHOD_REQUEST_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp new file mode 100644 index 00000000000..cc52c47852f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp @@ -0,0 +1,35 @@ +// $Id$ + +#include "Method_Request_Shutdown.h" +#include "ThreadPool_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Shutdown, "$Id$") + +TAO_NS_Method_Request_Shutdown::TAO_NS_Method_Request_Shutdown (TAO_NS_ThreadPool_Task* task) + : task_ (task) +{ +} + +TAO_NS_Method_Request_Shutdown::~TAO_NS_Method_Request_Shutdown () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Shutdown::copy (void) +{ + return new TAO_NS_Method_Request_Shutdown (this->task_); +} + +int +TAO_NS_Method_Request_Shutdown::execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + // Shut down the scheduler by deactivating the activation queue's + // underlying message queue - should pop all worker threads off their + // wait and they'll exit. + 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 new file mode 100644 index 00000000000..433dea36e51 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Shutdown.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_METHOD_REQUEST_SHUTDOWN_H +#define TAO_NS_METHOD_REQUEST_SHUTDOWN_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" + +class TAO_NS_ThreadPool_Task; + +/** + * @class TAO_NS_Method_Request_Shutdown + * + * @brief Shutdown message for the ThreadPool_Task + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Shutdown : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Shutdown (TAO_NS_ThreadPool_Task* task); + + /// Destructor + ~TAO_NS_Method_Request_Shutdown (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + // Task to shutdown + TAO_NS_ThreadPool_Task* task_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_METHOD_REQUEST_SHUTDOWN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp new file mode 100644 index 00000000000..60049cf0bef --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp @@ -0,0 +1,55 @@ +// $Id$ + +#include "Method_Request_Updates.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Updates.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Method_Request_Updates, "$id$") + +#include "tao/debug.h" +#include "Proxy.h" +#include "Peer.h" + +TAO_NS_Method_Request_Updates::TAO_NS_Method_Request_Updates (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed, TAO_NS_Proxy* proxy) + :added_ (added), removed_ (removed), proxy_ (proxy), refcountable_guard_ (*proxy) +{ +} + +TAO_NS_Method_Request_Updates::~TAO_NS_Method_Request_Updates () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Updates::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Updates (this->added_, this->removed_, this->proxy_); +} + +int +TAO_NS_Method_Request_Updates::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + ACE_TRY + { + TAO_NS_Peer* peer = this->proxy_->peer(); + + if (peer != 0) + { + peer->dispatch_updates (this->added_, this->removed_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_NS_Method_Request_Updates::execute error sending updates\n "); + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h new file mode 100644 index 00000000000..282b5df3097 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Updates.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_METHOD_REQUEST_UPDATES_H +#define TAO_NS_METHOD_REQUEST_UPDATES_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 "EventTypeSeq.h" +#include "Refcountable.h" + +class TAO_NS_Proxy; + +/** + * @class TAO_NS_Method_Request_Updates + * + * @brief Command Object to send updates to proxys. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Updates : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Updates (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed, TAO_NS_Proxy* proxy); + + /// Destructor + ~TAO_NS_Method_Request_Updates (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// The Updates + const TAO_NS_EventTypeSeq added_; + const TAO_NS_EventTypeSeq removed_; + + /// The proxy that will receive the updates. + TAO_NS_Proxy* proxy_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Updates.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_METHOD_REQUEST_UPDATES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.inl new file mode 100644 index 00000000000..bf5cc3848c2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "Method_Request_Updates.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.cpp new file mode 100644 index 00000000000..0dc683e4f0b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "Notify_Constraint_Interpreter.h" +#include "Notify_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/Notify_Constraint_Interpreter.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h new file mode 100644 index 00000000000..03ca6f6d4f4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Constraint_Interpreter.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore + */ +//============================================================================= + + +#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 "notify_export.h" + +class TAO_NS_Constraint_Visitor; + +/** + * @class TAO_NS_Constraint_Interpreter + * + * @brief "ETCL" Interpreter for the Notify queries. + */ +class TAO_Notify_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 , 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/Notify_Constraint_Visitors.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp new file mode 100644 index 00000000000..e7224c069a0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp @@ -0,0 +1,1564 @@ +/* -*- C++ -*- */ +/* $Id$ */ + +#include "Notify_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; +template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Entry ; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Node; +template class ACE_Unbounded_Queue; +template class ACE_Unbounded_Queue_Iterator; + + +template class ACE_Hash_Map_Manager; +template class ACE_Hash_Map_Manager_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Entry ; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Entry +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Node +#pragma instantiate ACE_Unbounded_Queue +#pragma instantiate ACE_Unbounded_Queue_Iterator + +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Manager_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Entry +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, TAO_SYNCH_MUTEX> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h new file mode 100644 index 00000000000..4b356c9945f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h @@ -0,0 +1,149 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Constraint_Visitors.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore + * @author Jeff Parsons + */ +//============================================================================= + + +#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 "notify_export.h" + +class TAO_ETCL_Constraint; +class TAO_ETCL_Literal_Constraint; +class TAO_Notify_Property_Constraint; + +class TAO_Notify_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 , 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 + implicit_ids_; + + /// Used to lookup names and values in the event's 'filterable_data' field. + ACE_Hash_Map_Manager + filterable_data_; + + /// Used to lookup names and values in the event's 'variable_header' field. + ACE_Hash_Map_Manager + 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 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/Notify_Default_CO_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.cpp new file mode 100644 index 00000000000..fcc7dacc7df --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.cpp @@ -0,0 +1,12 @@ +// $Id$ + +#include "Notify_Default_CO_Factory.h" + +ACE_RCSID(Notify, Notify_Default_CO_Factory, "$Id$") + +int +TAO_Notify_Default_CO_Factory::init_svc (void) +{ + // NOP. + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.h new file mode 100644 index 00000000000..0cbba6a2173 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_CO_Factory.h @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Default_CO_Factory.h + * + * $Id$ + * + * + * @author Pradeep Gore + */ +//============================================================================= + + +#ifndef NOTIFY_DEFAULT_CO_FACTORY_H +#define NOTIFY_DEFAULT_CO_FACTORY_H + +#include "ace/pre.h" +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_Notify_Default_CO_Factory + * + * @brief TAO_Notify_Default_CO_Factory + * + * Maintained for backward compatibility. + */ +class TAO_Notify_Export TAO_Notify_Default_CO_Factory +{ +public: + /// Helper function to register the default factory into the service + /// configurator. + static int init_svc (void); + +}; + +#include "ace/post.h" + +#endif /* NOTIFY_DEFAULT_CO_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.cpp new file mode 100644 index 00000000000..d1ac87b35e1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.cpp @@ -0,0 +1,12 @@ +// $Id$ + +#include "Notify_Default_Collection_Factory.h" + +ACE_RCSID(Notify, Notify_Default_Collection_Factory, "$Id$") + +int +TAO_Notify_Default_Collection_Factory::init_svc (void) +{ + // NOP. + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.h new file mode 100644 index 00000000000..8a6916dbc76 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_Collection_Factory.h @@ -0,0 +1,40 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Default_Collection_Factory.h + * + * $Id$ + * + * @author Pradeep Gore + */ +//============================================================================= + + +#ifndef NOTIFY_DEFAULT_COLLECTION_FACTORY_H +#define NOTIFY_DEFAULT_COLLECTION_FACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_Notify_Default_Collection_Factory + * + * @brief Maintained for backward compatibility. + * + * + */ +class TAO_Notify_Export TAO_Notify_Default_Collection_Factory +{ +public: + + /// Helper function to register the default factory into the service + /// configurator. + static int init_svc (void); +}; + +#include "ace/post.h" +#endif /* NOTIFY_DEFAULT_COLLECTION_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.cpp new file mode 100644 index 00000000000..5cfb1d7e8cb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.cpp @@ -0,0 +1,12 @@ +// $Id$ + +#include "Notify_Default_EMO_Factory.h" + +ACE_RCSID(Notify, Notify_Default_EMO_Factory, "$Id$") + +int +TAO_Notify_Default_EMO_Factory::init_svc (void) +{ + // NOP. + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.h new file mode 100644 index 00000000000..0b666380e84 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_EMO_Factory.h @@ -0,0 +1,38 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Default_EMO_Factory.h + * + * $Id$ + * + * @author Pradeep Gore + */ +//============================================================================= + + +#ifndef NOTIFY_DEFAULT_EMO_FACTORY_H +#define NOTIFY_DEFAULT_EMO_FACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_Notify_Default_EMO_Factory + * + * @brief Maintained for backward compatibility. + * + */ +class TAO_Notify_Export TAO_Notify_Default_EMO_Factory +{ +public: + /// Helper function to register the default factory into the service + /// configurator. + static int init_svc (void); +}; + +#include "ace/post.h" +#endif /* NOTIFY_DEFAULT_EMO_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.cpp new file mode 100644 index 00000000000..046d1c507ff --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.cpp @@ -0,0 +1,12 @@ +// $Id$ + +#include "Notify_Default_POA_Factory.h" + +ACE_RCSID(Notify, Notify_Default_POA_Factory, "$Id$") + +int +TAO_Notify_Default_POA_Factory::init_svc (void) +{ + // NOP. + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.h new file mode 100644 index 00000000000..c2dc512c414 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Default_POA_Factory.h @@ -0,0 +1,37 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Default_POA_Factory.h + * + * $Id$ + * + * @author Pradeep Gore + */ +//============================================================================= + + +#ifndef TAO_NOTIFY_DEFAULT_POA_FACTORY_H +#define TAO_NOTIFY_DEFAULT_POA_FACTORY_H + +#include "ace/pre.h" +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_Notify_Default_POA_Factory + * + * @brief Maintained for backward compatibility. + */ +class TAO_Notify_Export TAO_Notify_Default_POA_Factory +{ +public: + /// Helper function to register the default factory into the service + /// configurator. + static int init_svc (void); +}; + +#include "ace/post.h" +#endif /* TAO_NOTIFY_DEFAULT_POA_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp new file mode 100644 index 00000000000..d2c836538e2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#include "Notify_EventChannelFactory_i.h" + +#include "Service.h" +#include "ace/Dynamic_Service.h" +#include "tao/PortableServer/POA.h" +#include "tao/ORB_Core.h" + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_Notify_EventChannelFactory_i::create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::EventChannelFactory_var notify_factory; + + TAO_NS_Service* notify_service = ACE_Dynamic_Service::instance (TAO_NS_COS_NOTIFICATION_SERVICE_NAME); + + if (notify_service == 0) + { + ACE_DEBUG ((LM_DEBUG, "Service not found! check conf. file\n")); + return notify_factory._retn (); + } + + TAO_POA *poa = default_POA->_tao_poa_downcast(); + + if (poa == 0) + return notify_factory._retn (); + + CORBA::ORB_ptr orb = poa->orb_core ().orb () ; + + notify_service->init (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (notify_factory._retn ()); + + notify_factory = notify_service->create (default_POA ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (notify_factory._retn ()); + + return notify_factory._retn (); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Dynamic_Service; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Dynamic_Service + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.h new file mode 100644 index 00000000000..89bf1bf98c9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.h @@ -0,0 +1,39 @@ +//============================================================================= +/** + * @file Notify_EventChannelFactory_i.h + * + * $Id$ + * + * + * @author Pradeep Gore + */ +//============================================================================= + + +#ifndef NOTIFY_EVENTCHANNELFACTORY_I_H +#define NOTIFY_EVENTCHANNELFACTORY_I_H +#include "ace/pre.h" + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_Notify_EventChannelFactory_i + * + * @brief Class maintained for Backward compatibility. + * + */ +class TAO_Notify_Export TAO_Notify_EventChannelFactory_i +{ +public: + /// Create a factory servant and activates it with the default POA. + /// Also creates a resource factory and assigns it this default_POA. + static CosNotifyChannelAdmin::EventChannelFactory_ptr create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL); +}; + +#include "ace/post.h" +#endif /* NOTIFY_EVENTCHANNELFACTORY_I_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.cpp new file mode 100644 index 00000000000..628b37fc18e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.cpp @@ -0,0 +1,452 @@ +// $Id$ + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Notify_EventChannel_i.h" +#include "Notify_EventChannelFactory_i.h" +#include "Notify_SupplierAdmin_i.h" +#include "Notify_ConsumerAdmin_i.h" +#include "Notify_Event_Manager.h" +#include "Notify_Channel_Objects_Factory.h" +#include "Notify_POA_Factory.h" +#include "Notify_Factory.h" +#include "Notify_Event_Manager_Objects_Factory.h" +#include "Notify_Collection_Factory.h" +#include "Notify_AdminProperties.h" + +#include "tao/debug.h" + +ACE_RCSID(Notify, Notify_EventChannel_i, "$Id$") + +TAO_Notify_EventChannel_i::TAO_Notify_EventChannel_i (TAO_Notify_EventChannelFactory_i* my_factory) + :lock_ (0), + destory_child_POAs_ (0), + channel_factory_ (my_factory), + channel_objects_factory_ (TAO_Notify_Factory:: + get_channel_objects_factory ()), + poa_factory_ (TAO_Notify_Factory::get_poa_factory ()), + event_manager_objects_factory_ (TAO_Notify_Factory::create_event_manager_objects_factory ()), + default_op_ (CosNotifyChannelAdmin::OR_OP), + default_id_ (0), + event_listener_list_ (0) +{ + this->channel_factory_->_add_ref (); +} + +// Implementation skeleton destructor +TAO_Notify_EventChannel_i::~TAO_Notify_EventChannel_i (void) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG,"in EC dtor\n")); + // Cleanup all resources.. + + delete this->event_manager_; + delete this->lock_; + delete this->event_listener_list_; + + this->channel_factory_->event_channel_destroyed (this->channel_id_); + this->channel_factory_->_remove_ref (); + + delete event_manager_objects_factory_; +} + +void +TAO_Notify_EventChannel_i::init (CosNotifyChannelAdmin::ChannelID channel_id, const CosNotification::QoSProperties& initial_qos, const CosNotification::AdminProperties& initial_admin, PortableServer::POA_ptr default_POA, PortableServer::POA_ptr my_POA ACE_ENV_ARG_DECL) +{ + this->channel_id_ = channel_id; + + this->my_POA_ = PortableServer::POA::_duplicate (my_POA); + this->default_POA_ = PortableServer::POA::_duplicate (default_POA); + + this->lock_ = + this->channel_objects_factory_->create_event_channel_lock (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->event_manager_ = + this->event_manager_objects_factory_->create_event_manager (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Set these before initializing the event manger. + this->set_qos (initial_qos ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_manager_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // try to set initial admin params + // This must be set after initializing the event manager + // since it is the one that owns the admin properties. + this->set_admin (initial_admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Create the POA for the CA's + this->CA_POA_ = + this->poa_factory_->create_consumer_admin_POA (this->my_POA_.in (), channel_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Create the POA for the SA's + this->SA_POA_ = + this->poa_factory_->create_supplier_admin_POA (this->my_POA_.in (), channel_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_listener_list_ = + TAO_Notify_Factory::get_collection_factory ()->create_event_listener_list (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Create the default Consumer Admin. Because the ID_Pool is being used + // the first time here, it will generate the id 0. + CosNotifyChannelAdmin::AdminID id_unused; + + CosNotifyChannelAdmin::ConsumerAdmin_var def_consumer_admin = + this->new_for_consumers (default_op_, id_unused ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CosNotifyChannelAdmin::SupplierAdmin_var def_supplier_admin = + this->new_for_suppliers (default_op_, id_unused ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +TAO_Notify_Event_Manager* +TAO_Notify_EventChannel_i::get_event_manager (void) +{ + return this->event_manager_; +} + +void +TAO_Notify_EventChannel_i::consumer_admin_destroyed (CosNotifyChannelAdmin::AdminID CA_ID) +{ + this->consumer_admin_ids_.put (CA_ID); +} + +void +TAO_Notify_EventChannel_i::supplier_admin_destroyed (CosNotifyChannelAdmin::AdminID SA_ID) +{ + this->supplier_admin_ids_.put (SA_ID); +} + +PortableServer::POA_ptr +TAO_Notify_EventChannel_i::get_default_POA (void) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_Notify_EventChannel_i::get_ref (ACE_ENV_SINGLE_ARG_DECL) +{ + CORBA::Object_var obj = this->poa_factory_-> + servant_to_reference (this->my_POA_.in (), this ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + return CosNotifyChannelAdmin::EventChannel::_narrow (obj.in ()); +} + + +void +TAO_Notify_EventChannel_i::unregister_listener (TAO_Notify_EventListener* group_listener ACE_ENV_ARG_DECL) +{ + // UnRegister the group listener. + this->event_listener_list_->disconnected (group_listener ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_Notify_EventChannel_i::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->event_manager_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Deactivate ourselves. + this->poa_factory_->deactivate_object (this, + this->my_POA_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // shutdown consumer admins's. + TAO_Notify_Shutdown_Worker shutdown_worker; + + this->event_listener_list_->for_each (&shutdown_worker ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // release all references. + this->event_listener_list_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // @@ TODO: We need a way to send shutdown messages to the proxy consumers too. + // (event listeners are proxy suppliers or CA's in disguise) + + this->poa_factory_->destroy_POA (this->CA_POA_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->poa_factory_->destroy_POA (this->SA_POA_.in () + ACE_ENV_ARG_PARAMETER); +} + +const TAO_Notify_QoSAdmin_i& +TAO_Notify_EventChannel_i::qos_admin (void) const +{ + return this->qos_admin_; +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_Notify_EventChannel_i::MyFactory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->channel_factory_->get_ref (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_Notify_EventChannel_i::default_consumer_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->get_consumeradmin (this->default_id_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_Notify_EventChannel_i::default_supplier_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->get_supplieradmin (this->default_id_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyFilter::FilterFactory_ptr +TAO_Notify_EventChannel_i::default_filter_factory (ACE_ENV_SINGLE_ARG_DECL_NOT_USED/*ACE_ENV_SINGLE_ARG_PARAMETER*/) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->channel_factory_->get_default_filter_factory (); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_Notify_EventChannel_i::new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + // @@ use auto_ptr + TAO_Notify_ConsumerAdmin_i* consumer_admin = + this->channel_objects_factory_->create_consumer_admin (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + PortableServer::ServantBase_var consumeradmin_var (consumer_admin); + + { + ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + id = this->consumer_admin_ids_.get (); + } + + consumer_admin->init (id, op, this->CA_POA_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + CORBA::Object_var obj = + this->poa_factory_->activate_object_with_id (id, + this->CA_POA_.in (), + consumer_admin + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + // Register the group listener. + this->event_listener_list_->connected (consumer_admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + this->consumer_admin_ids_.next (); + return CosNotifyChannelAdmin::ConsumerAdmin::_narrow (obj.in ()); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_Notify_EventChannel_i::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_Notify_SupplierAdmin_i* supplieradmin = + this->channel_objects_factory_->create_supplier_admin (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + PortableServer::ServantBase_var supplieradmin_var (supplieradmin); + + { + ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + id = this->supplier_admin_ids_.get (); + } + + supplieradmin->init (id, op, this->SA_POA_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + CORBA::Object_var obj = this->poa_factory_-> + activate_object_with_id (id, + this->SA_POA_.in (), + supplieradmin + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + this->supplier_admin_ids_.next (); + return CosNotifyChannelAdmin::SupplierAdmin::_narrow (obj.in ()); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_Notify_EventChannel_i::get_consumeradmin (CosNotifyChannelAdmin::AdminID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::AdminNotFound + )) +{ + CORBA::Object_var obj = + this->poa_factory_->id_to_reference (id, this->CA_POA_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + return CosNotifyChannelAdmin::ConsumerAdmin::_narrow (obj.in ()); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_Notify_EventChannel_i::get_supplieradmin (CosNotifyChannelAdmin::AdminID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::AdminNotFound + )) +{ + CORBA::Object_var obj = + this->poa_factory_->id_to_reference (id, this->SA_POA_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + return CosNotifyChannelAdmin::SupplierAdmin::_narrow (obj.in ()); +} + +CosNotifyChannelAdmin::AdminIDSeq* +TAO_Notify_EventChannel_i::get_all_consumeradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->consumer_admin_ids_.get_sequence (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminIDSeq* +TAO_Notify_EventChannel_i::get_all_supplieradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + return this->supplier_admin_ids_.get_sequence (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotification::QoSProperties* +TAO_Notify_EventChannel_i::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->qos_admin_.get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_Notify_EventChannel_i::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + this->qos_admin_.set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +void +TAO_Notify_EventChannel_i::validate_qos (const CosNotification::QoSProperties & required_qos, CosNotification::NamedPropertyRangeSeq_out available_qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + this->qos_admin_.validate_qos (required_qos, available_qos ACE_ENV_ARG_PARAMETER); +} + +CosNotification::AdminProperties* +TAO_Notify_EventChannel_i::get_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + // Delegate to Event Manager. + return this->event_manager_->admin_properties ()->get_admin (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_Notify_EventChannel_i::set_admin (const CosNotification::AdminProperties & admin ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedAdmin + )) +{ + this->event_manager_->admin_properties ()->set_admin (admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_manager_->update_task_admins (); +} + +CosEventChannelAdmin::ConsumerAdmin_ptr +TAO_Notify_EventChannel_i::for_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + // There is no way to destroy CosEventChannelAdmin::ConsumerAdmin's + // so we just return the default Consumer Admin here. + // TODO: find a way to disable the destroy method in the default Admin. + + CORBA::Object_var obj = + this->get_consumeradmin (this->default_id_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosEventChannelAdmin::ConsumerAdmin::_nil ()); + + return CosEventChannelAdmin::ConsumerAdmin::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); +} + +CosEventChannelAdmin::SupplierAdmin_ptr +TAO_Notify_EventChannel_i::for_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CORBA::Object_var obj = + this->get_supplieradmin (this->default_id_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosEventChannelAdmin::SupplierAdmin::_nil ()); + + return CosEventChannelAdmin::SupplierAdmin::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_Notify_ID_Pool_Ex; +template class TAO_Notify_ID_Pool; + +template class ACE_Unbounded_Set; +template class ACE_Unbounded_Set_Iterator; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_Notify_ID_Pool_Ex +#pragma instantiate TAO_Notify_ID_Pool + +#pragma instantiate ACE_Unbounded_Set +#pragma instantiate ACE_Unbounded_Set_Iterator + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.h new file mode 100644 index 00000000000..74d7a6601d8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannel_i.h @@ -0,0 +1,318 @@ +//============================================================================= +/** + * @file Notify_EventChannel_i.h + * + * $Id$ + * + * Implements the CosNotifyChannelAdmin::EventChannel interface. + * + * + * @author Pradeep Gore + */ +//============================================================================= + + +#ifndef TAO_NOTIFY_EVENTCHANNEL_I_H_ +#define TAO_NOTIFY_EVENTCHANNEL_I_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/CosNotifyChannelAdminS.h" +#include "Notify_ID_Pool_T.h" +#include "Notify_QoSAdmin_i.h" +#include "Notify_Collection.h" + +class TAO_Notify_EventChannelFactory_i; +class TAO_Notify_Resource_Manager; +class TAO_Notify_Event_Manager; +class TAO_Notify_CO_Factory; +class TAO_Notify_POA_Factory; +class TAO_Notify_EMO_Factory; +class TAO_Notify_EventListener; + +#if defined (_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning (push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning (disable:4250) +#endif /* _MSC_VER */ + + /** + * @class TAO_Notify_EventChannel_i + * + * @brief TAO_Notify_EventChannel_i + * + * This class handles all the object factory functionality.All the event + * routing is handled by its contained Event Manager class. + * = MISC. NOTES + * This class creates and owns 2 child POA's. one to contain CA's and the other for SA's. + * Now, a Channel object can be destoyed in 2 ways - as a side effect of its parent POA being + * destroyed or if this class's method is invoked. If the object is being destroyed + * as a result of its Parent POA being destroyed, it is illegal to destroy a childPOA + * because, the root poa destruction will destroy all child poa's. + * So in the destructor we conditionally check if the child POAs should be destroyed explicitly + * or not. + */ +class TAO_Notify_Export TAO_Notify_EventChannel_i : public virtual POA_CosNotifyChannelAdmin::EventChannel, public PortableServer::RefCountServantBase +{ + public: + /// Constructor. + /// is the parent. + TAO_Notify_EventChannel_i (TAO_Notify_EventChannelFactory_i* channel_factory); + + /// Destructor + virtual ~TAO_Notify_EventChannel_i (void); + + /** + * Initialize this object. + * checks if the and are valid. + * creates default filter, consumer admin and supplier admin. + */ + void init (CosNotifyChannelAdmin::ChannelID channel_id, + const CosNotification::QoSProperties& initial_qos, + const CosNotification::AdminProperties& initial_admin, + PortableServer::POA_ptr default_POA, + PortableServer::POA_ptr my_POA + ACE_ENV_ARG_DECL); + + // = Accessors + /// Get the default POA. + PortableServer::POA_ptr get_default_POA (void); + + /// Get the CORBA object for this servant + CosNotifyChannelAdmin::EventChannel_ptr get_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Get the event manager. + TAO_Notify_Event_Manager* get_event_manager (void); + + // = Child destroyed notification. + /// This id is no longer in use.It can be reused by . + void consumer_admin_destroyed (CosNotifyChannelAdmin::AdminID CA_ID); + + /// This id is no longer in use.It can be reused by . + void supplier_admin_destroyed (CosNotifyChannelAdmin::AdminID SA_ID); + + /// Consumer Admin's are Group Listeners that are registered automatically with the EC when a ConsumerAdmin + /// is created. When a consumer is destroyed, it asks the EC to unregister itself. + void unregister_listener (TAO_Notify_EventListener* group_listener ACE_ENV_ARG_DECL); + + // = Interface methods + virtual CosNotifyChannelAdmin::EventChannelFactory_ptr MyFactory ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyChannelAdmin::ConsumerAdmin_ptr default_consumer_admin ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyChannelAdmin::SupplierAdmin_ptr default_supplier_admin ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyFilter::FilterFactory_ptr default_filter_factory ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyChannelAdmin::ConsumerAdmin_ptr new_for_consumers ( + CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyChannelAdmin::SupplierAdmin_ptr new_for_suppliers ( + CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyChannelAdmin::ConsumerAdmin_ptr get_consumeradmin ( + CosNotifyChannelAdmin::AdminID id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::AdminNotFound + )); + +virtual CosNotifyChannelAdmin::SupplierAdmin_ptr get_supplieradmin ( + CosNotifyChannelAdmin::AdminID id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::AdminNotFound + )); + +virtual CosNotifyChannelAdmin::AdminIDSeq * get_all_consumeradmins ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotifyChannelAdmin::AdminIDSeq * get_all_supplieradmins ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +virtual CosNotification::QoSProperties * get_qos ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos ( + const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual void validate_qos ( + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual CosNotification::AdminProperties * get_admin ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_admin ( + const CosNotification::AdminProperties & admin + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedAdmin + )); + + virtual CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void destroy ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + const TAO_Notify_QoSAdmin_i& qos_admin (void) const; + +protected: + // = Data Members + /// The locking strategy. + ACE_Lock* lock_; + + /** + * Flag to tell our destructor if we should destroy the CA and SA POA's. + * default is false, the parent poa destruction will remove these. + * set to true if the method is invoked. + */ + CORBA::Boolean destory_child_POAs_; + + /// The factory that created us. + TAO_Notify_EventChannelFactory_i* channel_factory_; + + /// The default POA in which we activate objects that don't have ids' pre-assigned. + PortableServer::POA_var default_POA_; + + /// The POA in which i live. + PortableServer::POA_var my_POA_; + + /// The POA in which we should activate ConsumerAdmins in. + /// We create and own this. + PortableServer::POA_var CA_POA_; + + /// The POA in which we should activate SupplierAdmins in. + /// We create and own this. + PortableServer::POA_var SA_POA_; + + /// The ID assigned to this channel. + CosNotifyChannelAdmin::ChannelID channel_id_; + + /// The factory for channel objects. + TAO_Notify_CO_Factory* channel_objects_factory_; + + /// The factory for POA based containers. + TAO_Notify_POA_Factory* poa_factory_; + + /// Event manager objects factory, + TAO_Notify_EMO_Factory* event_manager_objects_factory_; + + /// Id generator for consumer admins. + TAO_Notify_ID_Pool_Ex consumer_admin_ids_; + + /// Id generator for supplier admins. + TAO_Notify_ID_Pool_Ex supplier_admin_ids_; + + /// Default InterFilterGroupOperator operator used when creating + /// the default ConsumerAdmin and SupplierAdmin. + const CosNotifyChannelAdmin::InterFilterGroupOperator default_op_; + + /// Default id's to CosEventChannelAdmin::ConsumerAdmin, SupplierAdmin. + const CosNotifyChannelAdmin::AdminID default_id_; + + /// Handle QoS admin methods. + TAO_Notify_QoSAdmin_i qos_admin_; + + /// The event manager. + TAO_Notify_Event_Manager* event_manager_; + + /// The list of group event listeners that have registered with us. + TAO_Notify_EventListener_List* event_listener_list_; +}; + +#if defined (_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning (pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /* TAO_NOTIFY_EVENTCHANNEL_I_H_ */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.cpp new file mode 100644 index 00000000000..3768d3b8f42 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.cpp @@ -0,0 +1,9 @@ +// -*- C++ -*- +// $Id$ + +#include "Notify_Extensions.h" + +TAO_NAMESPACE_TYPE (const char *const) +TAO_NAMESPACE_BEGIN (TAO_Notify_Extensions) +TAO_NAMESPACE_DEFINE (const char *const, BlockingPolicy, "BlockingPolicy") +TAO_NAMESPACE_END diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.h new file mode 100644 index 00000000000..1706476d845 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Extensions.h @@ -0,0 +1,28 @@ +// -*- C++ -*- +// $Id$ + +#ifndef TAO_NOTIFY_EXTENSIONS_H +#define TAO_NOTIFY_EXTENSIONS_H + +#include "ace/pre.h" +#include "tao/corba.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "notify_export.h" + +#if defined (TAO_EXPORT_MACRO) +# undef TAO_EXPORT_MACRO +#endif /* TAO_EXPORT_MACRO */ +#define TAO_EXPORT_MACRO TAO_Notify_Export + +TAO_NAMESPACE TAO_Notify_Extensions +{ + TAO_NAMESPACE_STORAGE_CLASS const char *const BlockingPolicy; +} +TAO_NAMESPACE_CLOSE + +#include "ace/post.h" +#endif /* TAO_NOTIFY_EXTENSIONS_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp new file mode 100644 index 00000000000..825f6ab6075 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp @@ -0,0 +1,265 @@ +// $Id$ + +#include "Object.h" +#include "POA_Helper.h" +#include "Worker_Task.h" +#include "Properties.h" +#include "Builder.h" +#include "ThreadPool_Task.h" +#include "Reactive_Task.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Object.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Object, "$Id$") + +TAO_NS_Object::TAO_NS_Object (void) + : event_manager_ (0) + , admin_properties_ (0) + , id_ (0) + , poa_ (0) + , proxy_poa_ (0) + , own_proxy_poa_ (0) + , object_poa_ (0) + , own_object_poa_ (0) + , worker_task_ (0) + , own_worker_task_ (0) + , shutdown_ (0) +{ + if (TAO_debug_level > 2 ) + ACE_DEBUG ((LM_DEBUG,"object:%x created\n", this )); +} + +TAO_NS_Object::~TAO_NS_Object () +{ + if (TAO_debug_level > 2 ) + ACE_DEBUG ((LM_DEBUG,"object:%x destroyed\n", this )); +} + +void +TAO_NS_Object::init (TAO_NS_Object* parent) +{ + this->event_manager_ = parent->event_manager_; + this->admin_properties_ = parent->admin_properties_; + + this->poa_ = parent->poa_; + this->object_poa_ = parent->object_poa_; + this->proxy_poa_ = parent->proxy_poa_; + this->worker_task_ = parent->worker_task_; + + if (this->worker_task_) + this->worker_task_->_incr_refcnt (); + + // Pass QoS + parent->qos_properties_.transfer (this->qos_properties_); + this->qos_changed (this->qos_properties_); +} + +CORBA::Object_ptr +TAO_NS_Object::activate (PortableServer::Servant servant ACE_ENV_ARG_DECL) +{ + return this->poa_->activate (servant, this->id_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Object::deactivate (ACE_ENV_SINGLE_ARG_DECL) +{ + this->poa_->deactivate (this->id_ ACE_ENV_ARG_PARAMETER); +} + +int +TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 1); + + if (this->shutdown_ == 1) + return 1; // Another thread has already run shutdown. + + this->shutdown_ = 1; + } + + this->deactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + + this->shutdown_worker_task (); + this->shutdown_proxy_poa (); + + return 0; +} + +CORBA::Object_ptr +TAO_NS_Object::ref (ACE_ENV_SINGLE_ARG_DECL) +{ + return this->poa_->id_to_reference (this->id_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Object::shutdown_worker_task (void) +{ + // Only do this if we are the owner. + if (this->own_worker_task_ == 1) + { + this->worker_task_->shutdown (); // the worker deletes itself when its hook is eventually called. + } + + if (this->worker_task_) + this->worker_task_->_decr_refcnt (); +} + +void +TAO_NS_Object::shutdown_proxy_poa (void) +{ + if (this->own_proxy_poa_ == 1) + { + ACE_TRY_NEW_ENV + { + this->proxy_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + delete this->proxy_poa_; + } + ACE_CATCHANY + { + if (TAO_debug_level > 2) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Proxy shutdown error (%P|%t)\n"); + } + ACE_ENDTRY; + } +} + +void +TAO_NS_Object::shutdown_object_poa (void) +{ + if (this->own_object_poa_ == 1) + { + ACE_TRY_NEW_ENV + { + this->object_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + delete this->object_poa_; + } + ACE_CATCHANY + { + if (TAO_debug_level > 2) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Proxy shutdown error (%P|%t)\n"); + } + ACE_ENDTRY; + } +} + +void +TAO_NS_Object::worker_task_own (TAO_NS_Worker_Task* worker_task) +{ + this->worker_task (worker_task); + + // claim ownership. + this->own_worker_task_ = 1; +} + +void +TAO_NS_Object::worker_task (TAO_NS_Worker_Task* worker_task) +{ + // shutdown the current worker. + this->shutdown_worker_task (); + + this->worker_task_ = worker_task; + + this->own_worker_task_ = 0; + + if (this->worker_task_) + this->worker_task_->_incr_refcnt (); +} + +void +TAO_NS_Object::proxy_poa_own (TAO_NS_POA_Helper* proxy_poa) +{ + // shutdown current proxy poa. + this->shutdown_proxy_poa (); + + this->proxy_poa_ = proxy_poa; + + // claim ownership. + own_proxy_poa_ = 1; +} + +void +TAO_NS_Object::object_poa_own (TAO_NS_POA_Helper* object_poa) +{ + // shutdown current object poa. + this->shutdown_object_poa (); + + // shutdown current object poa + this->object_poa_ = object_poa; + + // claim ownership. + this->own_object_poa_ = 1; +} + +void +TAO_NS_Object::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) +{ + CosNotification::PropertyErrorSeq err_seq; + + TAO_NS_QoSProperties new_qos_properties; + + if (new_qos_properties.init (qos, err_seq) == -1) + ACE_THROW (CORBA::INTERNAL ()); + + // Apply the appropriate concurrency QoS + if (new_qos_properties.thread_pool ().is_valid ()) + { + if (new_qos_properties.thread_pool ().value ().static_threads == 0) + TAO_NS_PROPERTIES::instance()->builder()->apply_reactive_concurrency (*this ACE_ENV_ARG_PARAMETER); + else + TAO_NS_PROPERTIES::instance()->builder()-> + apply_thread_pool_concurrency (*this, new_qos_properties.thread_pool ().value () ACE_ENV_ARG_PARAMETER); + } + else if (new_qos_properties.thread_pool_lane ().is_valid ()) + TAO_NS_PROPERTIES::instance()->builder()-> + apply_lane_concurrency (*this, new_qos_properties.thread_pool_lane ().value () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Update the Thread Task's QoS properties.. + this->worker_task_->update_qos_properties (new_qos_properties); + + // Inform subclasses of QoS changed. + this->qos_changed (new_qos_properties); + + // Init the the overall QoS on this object. + if (new_qos_properties.copy (this->qos_properties_) == -1) + ACE_THROW (CORBA::INTERNAL ()); + + if (err_seq.length () > 0) // Unsupported Property + ACE_THROW (CosNotification::UnsupportedQoS (err_seq)); +} + +CosNotification::QoSProperties* +TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_DECL) +{ + CosNotification::QoSProperties_var properties; + + ACE_NEW_THROW_EX (properties, + CosNotification::QoSProperties (), + CORBA::NO_MEMORY ()); + + this->qos_properties_.populate (properties); + + return properties._retn (); +} + +void +TAO_NS_Object::qos_changed (const TAO_NS_QoSProperties& /*qos_properties*/) +{ + // NOP. +} + +TAO_NS_Timer* +TAO_NS_Object::timer (void) +{ + return this->worker_task_->timer (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.h b/TAO/orbsvcs/orbsvcs/Notify/Object.h new file mode 100644 index 00000000000..43c2906996b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.h @@ -0,0 +1,164 @@ +/* -*- C++ -*- */ +/** + * @file Object.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_OBJECT_H +#define TAO_NS_OBJECT_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/Servant_Base.h" +#include "orbsvcs/NotifyExtC.h" +#include "QoSProperties.h" +#include "AdminProperties.h" +#include "Refcountable.h" + +class TAO_NS_POA_Helper; +class TAO_NS_Worker_Task; +class TAO_NS_Event_Manager; +class TAO_NS_Timer; + +/** + * @class TAO_NS_Object + * + * @brief Base Object for RT_Notify's CORBA Objects. + * + */ +class TAO_Notify_Export TAO_NS_Object : public TAO_NS_Refcountable +{ + friend class TAO_NS_Builder; + +public: + /// Id for Objects. + typedef CORBA::Long ID; + + /// Constuctor + TAO_NS_Object (void); + + /// Destructor + virtual ~TAO_NS_Object (void); + + /// This Object's ID + ID id (void); + + /// Activate + virtual CORBA::Object_ptr activate (PortableServer::Servant servant ACE_ENV_ARG_DECL); + + /// Deactivate + void deactivate (ACE_ENV_SINGLE_ARG_DECL); + + /// Have we been shutdown. returns 1 if shutdown. + int has_shutdown (void); + + /// Get CORBA Ref. + CORBA::Object_ptr ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Get Worker Task. + TAO_NS_Worker_Task* worker_task (void); + + /// Get the POA assigned to us. + TAO_NS_POA_Helper* poa (void); + + /// Setting the proxy_poa_ gives ownership to this class. + void proxy_poa_own (TAO_NS_POA_Helper* proxy_poa); + + /// Accessor for the proxy_poa_ + TAO_NS_POA_Helper* proxy_poa (void); + + /// Setting the object_poa_ gives ownership to this class. + void object_poa_own (TAO_NS_POA_Helper* object_poa); + + /// Accessor for the object_poa_ + TAO_NS_POA_Helper* object_poa (void); + + /// Set Worker Task. This object assume ownership of the set object. + void worker_task_own (TAO_NS_Worker_Task* worker_task); + + /// Set Worker Task. Does not assume ownership. + void worker_task (TAO_NS_Worker_Task* worker_task); + + /// Set the QoS Properties. + virtual void set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL); + + /// Get the QoS Properties. + CosNotification::QoSProperties* get_qos (ACE_ENV_SINGLE_ARG_DECL); + + /// Obtain the Timer manager associated with this object. + virtual TAO_NS_Timer* timer (void); + + /// shutdown. Returns 1 ifif the shutdown was already run once before. + virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); + +protected: + /// Init this object with data from . + void init (TAO_NS_Object* parent); + + /// Shutdown the current worker task and delete it if we own it. + void shutdown_worker_task (void); + + /// Shutdown the current proxy poa. + void shutdown_proxy_poa (void); + + /// Shutdown the current object poa. + void shutdown_object_poa (void); + + /// Notification that can be overridden by subclasses to be informed that have been modified. + virtual void qos_changed (const TAO_NS_QoSProperties& qos_properties); + + ///= Protected data members. + + /// The event manager. + TAO_NS_Event_Manager* event_manager_; + + /// Admin Properties. + TAO_NS_AdminProperties_var admin_properties_; + + /// QoS Properties. + TAO_NS_QoSProperties qos_properties_; + + /// Id assigned to this object + ID id_; + + /// The POA in which the object is activated. + TAO_NS_POA_Helper* poa_; + + /// The POA in which the proxys are activated. + TAO_NS_POA_Helper* proxy_poa_; + + /// Flag that indicates if we own + int own_proxy_poa_; + + /// The POA in which the object's children are activated. + TAO_NS_POA_Helper* object_poa_; + + /// Flag that indicates if we own + int own_object_poa_; + + /// Worker Task. + TAO_NS_Worker_Task* worker_task_; + + /// Ownership flag + int own_worker_task_; + + /// Are we shutdown (i,e. scheduled for destroy). + int shutdown_; +}; + +#if defined (__ACE_INLINE__) +#include "Object.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_OBJECT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.inl b/TAO/orbsvcs/orbsvcs/Notify/Object.inl new file mode 100644 index 00000000000..251c0655e6d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.inl @@ -0,0 +1,37 @@ +// $Id$ + +ACE_INLINE CORBA::Long +TAO_NS_Object::id (void) +{ + return id_; +} + +ACE_INLINE TAO_NS_Worker_Task* +TAO_NS_Object::worker_task (void) +{ + return this->worker_task_; +} + +ACE_INLINE TAO_NS_POA_Helper* +TAO_NS_Object::poa (void) +{ + return this->poa_; +} + +ACE_INLINE TAO_NS_POA_Helper* +TAO_NS_Object::object_poa (void) +{ + return this->object_poa_; +} + +ACE_INLINE TAO_NS_POA_Helper* +TAO_NS_Object::proxy_poa (void) +{ + return this->proxy_poa_; +} + +ACE_INLINE int +TAO_NS_Object::has_shutdown (void) +{ + return this->shutdown_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp new file mode 100644 index 00000000000..36b950eec2b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp @@ -0,0 +1,165 @@ +// $Id$ + +#include "POA_Helper.h" + +#if ! defined (__ACE_INLINE__) +#include "POA_Helper.inl" +#endif /* __ACE_INLINE__ */ + +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; + + 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]; + ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10); + + this->init (parent_poa, child_poa_name ACE_ENV_ARG_PARAMETER); +} + +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_CHECK; + + policy_list[1] = + parent_poa->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + + +void +TAO_NS_POA_Helper::create_i (PortableServer::POA_ptr parent_poa, const char* poa_name, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL) +{ + PortableServer::POAManager_var manager = + parent_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Create the child POA. + this->poa_ = parent_poa->create_POA (poa_name, + 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) + { + policy_list[index]->destroy (); + } + */ +} + +PortableServer::ObjectId * +TAO_NS_POA_Helper::long_to_ObjectId (CORBA::Long id ACE_ENV_ARG_DECL) const +{ + // Modified code from string_to_ObjectId .. + // + + CORBA::ULong buffer_size = 4; + + // Create the buffer for the Id + CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size); + + // Copy the contents + ACE_OS::memcpy (buffer, (char*)&id, buffer_size); + + // @@ Pradeep: TAO guarantees that Long is 4 bytes wide, but the + // standard only guarantees that it is at least 4 bytes wide. You + // may want to think about that.... + + // Create and return a new ID + PortableServer::ObjectId *obj_id = 0; + ACE_NEW_THROW_EX (obj_id, + PortableServer::ObjectId (buffer_size, + buffer_size, + buffer, + 1), + CORBA::NO_MEMORY ()); + + return obj_id; +} + +CORBA::Object_ptr +TAO_NS_POA_Helper::activate (PortableServer::Servant servant, CORBA::Long& id ACE_ENV_ARG_DECL) +{ + // 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); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + return poa_->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_POA_Helper::deactivate (CORBA::Long id ACE_ENV_ARG_DECL) const +{ + // Convert CORBA::Long to ObjectId + PortableServer::ObjectId_var oid = + this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + poa_->deactivate_object (oid.in () ACE_ENV_ARG_PARAMETER); +} + +CORBA::Object_ptr +TAO_NS_POA_Helper::id_to_reference (CORBA::Long id ACE_ENV_ARG_DECL) const +{ + // Convert CORBA::Long to ObjectId + PortableServer::ObjectId_var oid = + this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + return poa_->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_POA_Helper::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + poa_->destroy (1,0 ACE_ENV_ARG_PARAMETER); + // The flag = 0 +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h new file mode 100644 index 00000000000..122286482f3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h @@ -0,0 +1,84 @@ +/* -*- C++ -*- */ +/** + * @file POA_Helper.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_POA_Helper_H +#define TAO_NS_POA_Helper_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 "tao/PortableServer/PortableServer.h" +#include "ID_Factory.h" + +/** + * @class TAO_NS_POA_Helper + * + * @brief POA Abstraction. + * + */ +class TAO_Notify_Export TAO_NS_POA_Helper : private ACE_Copy_Disabled +{ +public: + /// Default Constructor + TAO_NS_POA_Helper (void); + + /// Create a new PortableServer::POA. + void init (PortableServer::POA_ptr parent_poa, const char* poa_name ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. The name is chosen at random. + void init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL); + + /// Destructor + virtual ~TAO_NS_POA_Helper (); + + /// Get underlying POA + PortableServer::POA_ptr poa (void); + + /// Destroy underlying POA. + void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// Activate Object, the POA will assign an ID and return its value. + CORBA::Object_ptr activate (PortableServer::Servant servant, CORBA::Long& id ACE_ENV_ARG_DECL); + + /// Deactivate Object with ID + void deactivate (CORBA::Long id ACE_ENV_ARG_DECL) const; + + /// Convert ID to reference. + CORBA::Object_ptr id_to_reference (CORBA::Long id ACE_ENV_ARG_DECL) const; + +protected: + /// Set default POA policies. + virtual void set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL); + + /// Apply the polices and create child POA. + void create_i (PortableServer::POA_ptr parent_poa, const char* poa_name, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL); + + /// 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; +}; + +#if defined (__ACE_INLINE__) +#include "POA_Helper.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_POA_Helper_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl new file mode 100644 index 00000000000..3fc996c803c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE PortableServer::POA_ptr +TAO_NS_POA_Helper::poa (void) +{ + return this->poa_.in (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp new file mode 100644 index 00000000000..4a26d732d85 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp @@ -0,0 +1,111 @@ +// $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 "Proxy.h" + +TAO_NS_Peer::TAO_NS_Peer (void) +{ +} + +TAO_NS_Peer::~TAO_NS_Peer () +{ +} + +void +TAO_NS_Peer::qos_changed (const TAO_NS_QoSProperties& /*qos_properties*/) +{ + // NOP. +} + +void +TAO_NS_Peer::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + // NOP. +} + +void +TAO_NS_Peer::handle_dispatch_exception (ACE_ENV_SINGLE_ARG_DECL) +{ + // Sever all association when a remote client misbehaves. Other strategies like reties are possible but not implemented. + this->proxy ()->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_Peer::dispatch_updates (const TAO_NS_EventTypeSeq & added, const TAO_NS_EventTypeSeq & removed ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq subscribed_types ; + this->proxy ()->subscribed_types (subscribed_types ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + CosNotification::EventTypeSeq cos_added; + CosNotification::EventTypeSeq cos_removed; + + const TAO_NS_EventType& special = TAO_NS_EventType::special (); + + // Don;t inform of types that we already know about. + // E.g. if we're subscribed for {A,B,C,F} + // and we receive an update with added list {A,B,G} + // then, we should only send {G} because peer already knows about {A, B} + // However if we're subscribed for everything, send all kinds of adds. + + // Don;t inform of removed types that we don;t care about. + // e.g. if we're currently subscribed for {A,B,C,F} + // and we receive an update with removed list {A, B, D} + // then, we should only send {A,B} because the peer is not interested in D. + // However if we're subscribed for everything, send all kinds of removes. + + TAO_NS_EventTypeSeq added_result = added; + TAO_NS_EventTypeSeq removed_result; + + if (subscribed_types.find (special) != 0) + { + added_result.remove_seq (subscribed_types); + removed_result.intersection (subscribed_types, removed); + } + else + { + removed_result = removed; + } + + added_result.populate_no_special (cos_added); + removed_result.populate_no_special (cos_removed); + + if (cos_added.length () != 0 || cos_removed.length () != 0) + { + TAO_NS_Refcountable_Guard ref_guard(*this->proxy ()); // Protect this object from being destroyed in this scope. + + this->dispatch_updates_i (cos_added, cos_removed ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCH (CORBA::OBJECT_NOT_EXIST, not_exist) + { + this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::NO_IMPLEMENT, no_impl) + { + // The peer does not implement the offer/subscription_change method + // Do nothing. Later, perhaps set a flag that helps us decide if we should dispatch_updates_i. + } + ACE_CATCH (CORBA::SystemException, sysex) + { + this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Do nothing + } + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.h b/TAO/orbsvcs/orbsvcs/Notify/Peer.h new file mode 100644 index 00000000000..13dd08e5ab2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +/** + * @file Peer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#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" + +class TAO_NS_Proxy; +class TAO_NS_QoSProperties; +class TAO_NS_Peer; + +/** + * @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 + virtual ~TAO_NS_Peer (); + + /// This method sigantures deliberately match the RefCounting methods required for ESF Proxy + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + + /// Release + virtual void release (void) = 0; + + /// Shutdown the peer. + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Access Proxy. + virtual TAO_NS_Proxy* proxy (void) = 0; + + // Dispatch updates + virtual void dispatch_updates (const TAO_NS_EventTypeSeq & added, + const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + /// QoS changed notification from the Peer. + virtual void qos_changed (const TAO_NS_QoSProperties& qos_properties); + + /// Handle dispatch exceptions. + void handle_dispatch_exception (ACE_ENV_SINGLE_ARG_DECL); + +protected: + /// Implementation of Peer specific dispatch_updates + virtual void dispatch_updates_i (const CosNotification::EventTypeSeq& added, + const CosNotification::EventTypeSeq& removed + ACE_ENV_ARG_DECL) = 0; +}; + +#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..9fc05856b37 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.inl @@ -0,0 +1,15 @@ +// $Id$ + +#include "Proxy.h" + +ACE_INLINE CORBA::ULong +TAO_NS_Peer::_incr_refcnt (void) +{ + return this->proxy ()->_incr_refcnt (); +} + +ACE_INLINE CORBA::ULong +TAO_NS_Peer::_decr_refcnt (void) +{ + return this->proxy ()->_decr_refcnt (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp b/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp new file mode 100644 index 00000000000..421fd42a00a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp @@ -0,0 +1,44 @@ +// $Id$ + +#include "Properties.h" +#include "orbsvcs/NotifyExtC.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Properties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Properties, "$Id$") + +TAO_NS_Properties::TAO_NS_Properties (void) + : factory_ (0) + , builder_ (0) + , thr_sched_policy_ (THR_SCHED_DEFAULT) + , thr_scope_policy_ (THR_SCOPE_PROCESS) + , asynch_updates_ (0) +{ + // In case no conf. file is specified, the EC will default to reactive concurrency. + NotifyExt::ThreadPoolParams tp_params = + {0, 0, 0, 0, 0, 0, 0 }; + + this->ec_qos_.length (1); + this->ec_qos_[0].name = CORBA::string_dup (NotifyExt::ThreadPool); + this->ec_qos_[0].value <<= tp_params; + + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG, "in TAO_Properties ctos %x\n", this)); +} + +TAO_NS_Properties::~TAO_NS_Properties () +{ +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_Singleton; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_Singleton + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.h b/TAO/orbsvcs/orbsvcs/Notify/Properties.h new file mode 100644 index 00000000000..4a0a6a03ffc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.h @@ -0,0 +1,149 @@ +/* -*- C++ -*- */ +/** + * @file Properties.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROPERTIES_H +#define TAO_NS_PROPERTIES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TAO_Singleton.h" +#include "tao/ORB.h" +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/CosNotificationC.h" + +class TAO_NS_Factory; +class TAO_NS_Builder; + +/** + * @class TAO_NS_Properties + * + * @brief Global properties that strategize Notify's run-time behaviour. + * + */ +class TAO_Notify_Export TAO_NS_Properties +{ + friend class TAO_Singleton; + +public: + /// Constuctor + TAO_NS_Properties (void); + + /// Destructor + ~TAO_NS_Properties (); + + // = Property Accessors + TAO_NS_Factory* factory (void); + void factory (TAO_NS_Factory* factory); + + TAO_NS_Builder* builder (void); + void builder (TAO_NS_Builder* builder); + + CORBA::ORB_ptr orb (void); + void orb (CORBA::ORB_ptr orb); + + PortableServer::POA_ptr default_poa (void); + void default_poa (PortableServer::POA_ptr default_poa); + + long scope_policy (void); + void scope_policy (long scope_policy); + + long sched_policy (void); + void sched_policy (long sched_policy); + + CORBA::Boolean asynch_updates (void); + void asynch_updates (CORBA::Boolean asynch_updates); + + // The QoS Property that must be applied to each newly created Event Channel + const CosNotification::QoSProperties& default_event_channel_qos_properties (void); + + // Set the default EC QoS Property. + void default_event_channel_qos_properties (const CosNotification::QoSProperties &ec_qos); + + // The QoS Property that must be applied to each newly created Supplier Admin + const CosNotification::QoSProperties& default_supplier_admin_qos_properties (void); + + // Set the default SA QoS Property. + void default_supplier_admin_qos_properties (const CosNotification::QoSProperties &sa_qos); + + // The QoS Property that must be applied to each newly created Consumer Admin + const CosNotification::QoSProperties& default_consumer_admin_qos_properties (void); + + // Set the default CA QoS Property. + void default_consumer_admin_qos_properties (const CosNotification::QoSProperties &ca_qos); + + // The QoS Property that must be applied to each newly created Proxy Supplier + const CosNotification::QoSProperties& default_proxy_supplier_qos_properties (void); + + // Set the default PS QoS Property. + void default_proxy_supplier_qos_properties (const CosNotification::QoSProperties &ps_qos); + + // The QoS Property that must be applied to each newly created Proxy Consumer + const CosNotification::QoSProperties& default_proxy_consumer_qos_properties (void); + + // Set the default PC QoS Property. + void default_proxy_consumer_qos_properties (const CosNotification::QoSProperties &pc_qos); + +protected: + /// Object Factory + TAO_NS_Factory* factory_; + + /// Object Builder + TAO_NS_Builder* builder_; + + /// ORB + CORBA::ORB_var orb_; + + // POA + PortableServer::POA_var default_poa_; + + /// Sched policy + long thr_sched_policy_; + + /// Scope policy + long thr_scope_policy_; + + /// True if send asynch updates. + CORBA::Boolean asynch_updates_; + + /// The Update period for updates. + ACE_Time_Value update_period_; + + /// The default EC QoS Properties. + CosNotification::QoSProperties ec_qos_; + + /// The default SA QoS Properties. + CosNotification::QoSProperties sa_qos_; + + /// The default CA QoS Properties. + CosNotification::QoSProperties ca_qos_; + + /// The default PS QoS Properties. + CosNotification::QoSProperties ps_qos_; + + /// The default PC QoS Properties. + CosNotification::QoSProperties pc_qos_; +}; + +typedef TAO_Singleton TAO_NS_PROPERTIES; + +TAO_NOTIFY_SINGLETON_DECLARE (TAO_Singleton, TAO_NS_Properties, TAO_SYNCH_MUTEX); + +#if defined (__ACE_INLINE__) +#include "Properties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.inl b/TAO/orbsvcs/orbsvcs/Notify/Properties.inl new file mode 100644 index 00000000000..a066c3907a5 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.inl @@ -0,0 +1,145 @@ +// $Id$ + +ACE_INLINE TAO_NS_Factory* +TAO_NS_Properties::factory (void) +{ + return this->factory_; +} + +ACE_INLINE void +TAO_NS_Properties::factory (TAO_NS_Factory* factory) +{ + this->factory_ = factory; +} + +ACE_INLINE TAO_NS_Builder* +TAO_NS_Properties::builder (void) +{ + return this->builder_; +} + +ACE_INLINE void +TAO_NS_Properties::builder (TAO_NS_Builder* builder) +{ + this->builder_ = builder; +} + +ACE_INLINE CORBA::ORB_ptr +TAO_NS_Properties::orb (void) +{ + return CORBA::ORB::_duplicate (orb_.in ()); +} + +ACE_INLINE void +TAO_NS_Properties::orb (CORBA::ORB_ptr orb) +{ + orb_ = CORBA::ORB::_duplicate (orb); +} + +ACE_INLINE PortableServer::POA_ptr +TAO_NS_Properties::default_poa (void) +{ + return PortableServer::POA::_duplicate (this->default_poa_.in ()); +} + +ACE_INLINE void +TAO_NS_Properties::default_poa (PortableServer::POA_ptr default_poa) +{ + this->default_poa_ = PortableServer::POA::_duplicate (default_poa); +} + +ACE_INLINE long +TAO_NS_Properties::scope_policy (void) +{ + return thr_scope_policy_; +} + +ACE_INLINE void +TAO_NS_Properties::scope_policy (long scope_policy) +{ + thr_scope_policy_ = scope_policy; +} + +ACE_INLINE long +TAO_NS_Properties::sched_policy (void) +{ + return thr_sched_policy_; +} + +ACE_INLINE void +TAO_NS_Properties::sched_policy (long sched_policy) +{ + thr_sched_policy_ = sched_policy; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Properties::asynch_updates (void) +{ + return this->asynch_updates_; +} + +ACE_INLINE void +TAO_NS_Properties::asynch_updates (CORBA::Boolean asynch_updates) +{ + this->asynch_updates_ = asynch_updates; +} + +ACE_INLINE const CosNotification::QoSProperties& +TAO_NS_Properties::default_event_channel_qos_properties (void) +{ + return this->ec_qos_; +} + +ACE_INLINE void +TAO_NS_Properties::default_event_channel_qos_properties (const CosNotification::QoSProperties &ec_qos) +{ + this->ec_qos_ = ec_qos; +} + +ACE_INLINE const CosNotification::QoSProperties& +TAO_NS_Properties::default_supplier_admin_qos_properties (void) +{ + return this->sa_qos_; +} + +ACE_INLINE void +TAO_NS_Properties::default_supplier_admin_qos_properties (const CosNotification::QoSProperties &sa_qos) +{ + this->sa_qos_ = sa_qos; +} + +ACE_INLINE const CosNotification::QoSProperties& +TAO_NS_Properties::default_consumer_admin_qos_properties (void) +{ + return this->ca_qos_; +} + +ACE_INLINE void +TAO_NS_Properties::default_consumer_admin_qos_properties (const CosNotification::QoSProperties &ca_qos) +{ + this->ca_qos_ = ca_qos; +} + +ACE_INLINE const CosNotification::QoSProperties& +TAO_NS_Properties::default_proxy_supplier_qos_properties (void) +{ + return this->ps_qos_; +} + +ACE_INLINE void +TAO_NS_Properties::default_proxy_supplier_qos_properties (const CosNotification::QoSProperties &ps_qos) +{ + this->ps_qos_ = ps_qos; +} + +ACE_INLINE const CosNotification::QoSProperties& +TAO_NS_Properties::default_proxy_consumer_qos_properties (void) +{ + return this->pc_qos_; +} + +ACE_INLINE void +TAO_NS_Properties::default_proxy_consumer_qos_properties (const CosNotification::QoSProperties &pc_qos) +{ + this->pc_qos_ = pc_qos; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property.h b/TAO/orbsvcs/orbsvcs/Notify/Property.h new file mode 100644 index 00000000000..ae91ce42aff --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +/** + * @file Property.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROPERTY_H +#define TAO_NS_PROPERTY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/corba.h" +#include "tao/orbconf.h" +#include "tao/TimeBaseC.h" +#include "orbsvcs/NotifyExtC.h" + +template class ACE_Atomic_Op; +template class TAO_NS_Property_T; +template class TAO_NS_StructProperty_T; + +typedef ACE_Atomic_Op TAO_NS_Atomic_Property_Long; +typedef TAO_NS_Property_T TAO_NS_Property_Long; +typedef TAO_NS_Property_T TAO_NS_Property_Short; +typedef TAO_NS_Property_T TAO_NS_Property_Time; +typedef TAO_NS_StructProperty_T TAO_NS_Property_ThreadPool; +typedef TAO_NS_StructProperty_T TAO_NS_Property_ThreadPoolLanes; + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp new file mode 100644 index 00000000000..ad5042b9e87 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp @@ -0,0 +1,53 @@ +// $Id$ + +#include "PropertySeq.h" + +#if ! defined (__ACE_INLINE__) +#include "PropertySeq.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_PropertySeq, "$id$") + +TAO_NS_PropertySeq::TAO_NS_PropertySeq (void) +{ +} + +TAO_NS_PropertySeq::~TAO_NS_PropertySeq () +{ +} + +int +TAO_NS_PropertySeq::init (const CosNotification::PropertySeq& prop_seq) +{ + ACE_CString name; + + for (CORBA::ULong i = 0; i < prop_seq.length (); ++i) + { + name = prop_seq[i].name.in (); + + if (this->property_map_.rebind (name, prop_seq[i].value) == -1) + return -1; + } + // Note call to rebind. This allows to call to set updates. + + return 0; +} + +int +TAO_NS_PropertySeq::populate (CosNotification::PropertySeq_var& prop_seq) +{ + PROPERTY_MAP::ITERATOR iterator (this->property_map_); + + int index = prop_seq->length (); + prop_seq->length (index + this->property_map_.current_size ()); + + for (PROPERTY_MAP::ENTRY *entry = 0; + iterator.next (entry) != 0; + iterator.advance (), ++index) + { + (*prop_seq)[index].name = CORBA::string_dup (entry->ext_id_.c_str ()); + (*prop_seq)[index].value = entry->int_id_; + } + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h new file mode 100644 index 00000000000..4371aea34f9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +/** + * @file PropertySeq.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROPERTYSEQ_H +#define TAO_NS_PROPERTYSEQ_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 "ace/Hash_Map_Manager.h" +#include "ace/SString.h" + +/** + * @class TAO_NS_PropertySeq + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_PropertySeq +{ +public: + /// Constuctor + TAO_NS_PropertySeq (void); + + /// Destructor + ~TAO_NS_PropertySeq (); + + /// Return 0 on success, -1 on error. + int init (const CosNotification::PropertySeq& prop_seq); + + /// Find the for property . Returns 0 on success. + int find (const ACE_CString& name, CosNotification::PropertyValue& value) const; + + /// Return -1 on error. + int populate (CosNotification::PropertySeq_var& prop_seq); + +protected: + /// Property Map. + typedef ACE_Hash_Map_Manager PROPERTY_MAP; + + PROPERTY_MAP property_map_; +}; + +#if defined (__ACE_INLINE__) +#include "PropertySeq.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTYSEQ_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl new file mode 100644 index 00000000000..271543a2f82 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE int +TAO_NS_PropertySeq::find (const ACE_CString& name, CosNotification::PropertyValue& value) const +{ + return this->property_map_.find (name, value); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp new file mode 100644 index 00000000000..4c240b12bd9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp @@ -0,0 +1,43 @@ +// $Id$ + +#include "Property_Boolean.h" + +#if ! defined (__ACE_INLINE__) +#include "Property_Boolean.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Property_Boolean, "$id$") + +#include "PropertySeq.h" + +TAO_NS_Property_Boolean::TAO_NS_Property_Boolean (const ACE_CString& name) + :name_ (name), valid_(0) +{ +} + +TAO_NS_Property_Boolean::TAO_NS_Property_Boolean (const ACE_CString& name, CORBA::Boolean initial) + :name_ (name), value_ (initial), valid_ (1) +{ +} + +int +TAO_NS_Property_Boolean::set (const TAO_NS_PropertySeq& property_seq) +{ + CosNotification::PropertyValue value; + + if (property_seq.find (this->name_, value) == -1) + return -1; + + value >>= CORBA::Any::to_boolean (this->value_); + + return 0; +} + +void +TAO_NS_Property_Boolean::get (CosNotification::PropertySeq& prop_seq) +{ + /// Make space + prop_seq.length (prop_seq.length () + 1); + + prop_seq[prop_seq.length () - 1].value <<= CORBA::Any::from_boolean (this->value_); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h new file mode 100644 index 00000000000..1ddb447f418 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +/** + * @file Property_Boolean.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROPERTY_BOOLEAN_H +#define TAO_NS_PROPERTY_BOOLEAN_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" + +class TAO_NS_PropertySeq; + +/** + * @class TAO_NS_Property_Boolean + * + * @brief Boolean Property. + * + */ +/*******************************************************************************/ + +class TAO_Notify_Export TAO_NS_Property_Boolean +{ +public: + /// Constuctor + TAO_NS_Property_Boolean (const ACE_CString& name, CORBA::Boolean initial); + + /// Constuctor + TAO_NS_Property_Boolean (const ACE_CString& name); + + /// Assignment from TAO_NS_Property_Boolean + TAO_NS_Property_Boolean& operator= (const TAO_NS_Property_Boolean& rhs); + + /// Assignment from CORBA::Boolean + TAO_NS_Property_Boolean& operator= (const CORBA::Boolean& rhs); + + /// Equality comparison operator. + int operator== (const CORBA::Boolean &rhs) const; + + /// Inequality comparison operator. + int operator!= (const CORBA::Boolean &rhs) const; + + int set (const TAO_NS_PropertySeq& property_seq); + + void get (CosNotification::PropertySeq& prop_seq); + + /// Return the value. + CORBA::Boolean value (void) const; + + /// Is the current value valid + CORBA::Boolean is_valid (void) const; + +protected: + /// The Property name. + ACE_CString name_; + + /// The value + CORBA::Boolean value_; + + /// Is the value valid + CORBA::Boolean valid_; +}; + +#if defined (__ACE_INLINE__) +#include "Property_Boolean.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTY_BOOLEAN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl new file mode 100644 index 00000000000..d30cabb4e39 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl @@ -0,0 +1,49 @@ +// $Id$ + +ACE_INLINE TAO_NS_Property_Boolean& +TAO_NS_Property_Boolean::operator= (const TAO_NS_Property_Boolean& rhs) +{ + if (this == &rhs) + return *this; + + if (rhs.is_valid ()) + { + this->name_ = rhs.name_; + this->value_ = rhs.value_; + this->valid_ = rhs.valid_; + } + + return *this; +} + +ACE_INLINE TAO_NS_Property_Boolean& +TAO_NS_Property_Boolean::operator= (const CORBA::Boolean& value) +{ + this->value_ = value; + + return *this; +} + +ACE_INLINE int +TAO_NS_Property_Boolean::operator== (const CORBA::Boolean &rhs) const +{ + return (this->value_ == rhs); +} + +ACE_INLINE int +TAO_NS_Property_Boolean::operator!= (const CORBA::Boolean &rhs) const +{ + return (this->value_ != rhs); +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Property_Boolean::value (void) const +{ + return this->value_; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Property_Boolean::is_valid (void) const +{ + return this->valid_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp new file mode 100644 index 00000000000..051345844c1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp @@ -0,0 +1,119 @@ +// $Id$ + +#ifndef TAO_NS_PROPERTY_T_CPP +#define TAO_NS_PROPERTY_T_CPP + +#include "Property_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Property_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Property_T, "$id$") + +#include "PropertySeq.h" + +/*******************************************************************************/ + +template +TAO_NS_PropertyBase_T::TAO_NS_PropertyBase_T (const ACE_CString& name) + :name_ (name), valid_(0) +{ +} + +template +TAO_NS_PropertyBase_T::TAO_NS_PropertyBase_T (const ACE_CString& name, const TYPE& initial) + :name_ (name), value_ (initial), valid_ (1) +{ +} + +template +TAO_NS_PropertyBase_T::TAO_NS_PropertyBase_T (const TAO_NS_PropertyBase_T &rhs) +{ + this->name_ = rhs.name_; + this->value_ = rhs.value_; + this->valid_ = rhs.valid_; +} + +template +TAO_NS_PropertyBase_T::~TAO_NS_PropertyBase_T () +{ +} + +template void +TAO_NS_PropertyBase_T::get (CosNotification::PropertySeq& prop_seq) +{ + /// Make space + prop_seq.length (prop_seq.length () + 1); + + prop_seq[prop_seq.length () - 1].value <<= this->value_; +} + +/*******************************************************************************/ + +template +TAO_NS_Property_T::TAO_NS_Property_T (const ACE_CString& name) + :TAO_NS_PropertyBase_T (name) +{ +} + +template +TAO_NS_Property_T::TAO_NS_Property_T (const ACE_CString& name, const TYPE& initial) + :TAO_NS_PropertyBase_T (name, initial) +{ +} + +template int +TAO_NS_Property_T::set (const TAO_NS_PropertySeq& property_seq) +{ + CosNotification::PropertyValue value; + + if (property_seq.find (this->name_, value) == -1) + { + this->valid_ = 0; + return -1; + } + + value >>= this->value_; + + this->valid_ = 1; + + return 0; +} + +/*******************************************************************************/ + +template +TAO_NS_StructProperty_T::TAO_NS_StructProperty_T (const ACE_CString& name) + :name_ (name), valid_(0) +{ +} + +template +TAO_NS_StructProperty_T::TAO_NS_StructProperty_T (const ACE_CString& name, const TYPE& initial) + :name_ (name), value_ (initial), valid_ (1) +{ +} + +template int +TAO_NS_StructProperty_T::set (const TAO_NS_PropertySeq& property_seq) +{ + CosNotification::PropertyValue value; + + if (property_seq.find (this->name_, value) == -1) + { + this->valid_ = 0; + return -1; + } + + TYPE* extract_type; + value >>= extract_type; + + this->value_ = *extract_type; // copy + + this->valid_ = 1; + + return 0; +} + +#endif /* TAO_NS_PROPERTY_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_T.h b/TAO/orbsvcs/orbsvcs/Notify/Property_T.h new file mode 100644 index 00000000000..5b05d472b9f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_T.h @@ -0,0 +1,161 @@ +/* -*- C++ -*- */ +/** + * @file Property_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROPERTY_T_H +#define TAO_NS_PROPERTY_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/SString.h" +#include "orbsvcs/CosNotificationC.h" + +class TAO_NS_PropertySeq; + +/** + * @class TAO_NS_PropertyBase_T + * + * @brief + * + */ +template +class TAO_NS_PropertyBase_T +{ +public: + /// Constuctor + TAO_NS_PropertyBase_T (const ACE_CString& name, const TYPE& initial); + + /// Constuctor + TAO_NS_PropertyBase_T (const ACE_CString& name); + + /// Copy Constuctor + TAO_NS_PropertyBase_T (const TAO_NS_PropertyBase_T &rhs); + + /// Destructor + ~TAO_NS_PropertyBase_T (); + + /// Assignment from TAO_NS_PropertyBase_T + TAO_NS_PropertyBase_T& operator= (const TAO_NS_PropertyBase_T& rhs); + + /// Assignment from TYPE + TAO_NS_PropertyBase_T& operator= (const TYPE& rhs); + + /// Equality comparison operator. + int operator== (const TYPE &rhs) const; + + /// Inequality comparison operator. + int operator!= (const TYPE &rhs) const; + + /// Populate the Property Sequence with this valid value. + void get (CosNotification::PropertySeq& prop_seq); + + /// Return the value. + const TYPE& value (void) const; + + /// Is the current value valid + CORBA::Boolean is_valid (void) const; + + /// Invalidate this property's value. + void invalidate (void); + +protected: + /// The Property name. + ACE_CString name_; + + /// The value + TYPE value_; + + /// Is the value valid + CORBA::Boolean valid_; +}; + + +/*******************************************************************************/ +/** + * @class TAO_NS_Property_T + * + * @brief + * + */ +template +class TAO_NS_Property_T : public TAO_NS_PropertyBase_T +{ +public: + /// Constuctor + TAO_NS_Property_T (const ACE_CString& name, const TYPE& initial); + + /// Constuctor + TAO_NS_Property_T (const ACE_CString& name); + + /// Assignment from TYPE + TAO_NS_Property_T& operator= (const TYPE& rhs); + + /// Init this Property from the sequence. + /// Returns 0 on success, -1 on error + int set (const TAO_NS_PropertySeq& property_seq); +}; + +/*******************************************************************************/ +/** + * @class TAO_NS_StructProperty_T + * + * @brief + * + */ +template +class TAO_NS_StructProperty_T +{ +public: + /// Constuctor + TAO_NS_StructProperty_T (const ACE_CString& name, const TYPE& initial); + + /// Constuctor + TAO_NS_StructProperty_T (const ACE_CString& name); + + /// Init this Property from the sequence. + /// Returns 0 on success, -1 on error + int set (const TAO_NS_PropertySeq& property_seq); + + /// Return the value. + const TYPE& value (void) const; + + /// Is the current value valid + CORBA::Boolean is_valid (void) const; + +protected: + /// The Property name. + ACE_CString name_; + + /// The value + TYPE value_; + + /// Is the value valid + CORBA::Boolean valid_; +}; + +#if defined (__ACE_INLINE__) +#include "Property_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Property_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Property_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Property_T.inl new file mode 100644 index 00000000000..3442b0fe7c4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_T.inl @@ -0,0 +1,78 @@ +// $Id$ + +template ACE_INLINE const TYPE& +TAO_NS_PropertyBase_T::value (void) const +{ + return this->value_; +} + +template ACE_INLINE CORBA::Boolean +TAO_NS_PropertyBase_T::is_valid (void) const +{ + return this->valid_; +} + +template ACE_INLINE int +TAO_NS_PropertyBase_T::operator== (const TYPE &rhs) const +{ + return (this->value_ == rhs); +} + +template ACE_INLINE int +TAO_NS_PropertyBase_T::operator!= (const TYPE &rhs) const +{ + return (this->value_ != rhs); +} + +template ACE_INLINE TAO_NS_PropertyBase_T& +TAO_NS_PropertyBase_T::operator= (const TAO_NS_PropertyBase_T& rhs) +{ + if (this == &rhs) + return *this; + + if (rhs.is_valid ()) + { + this->name_ = rhs.name_; + this->value_ = rhs.value_; + this->valid_ = rhs.valid_; + } + + return *this; +} + +template ACE_INLINE TAO_NS_PropertyBase_T& +TAO_NS_PropertyBase_T::operator=(const TYPE& value) +{ + this->value_ = value; + + return *this; +} + +template ACE_INLINE void +TAO_NS_PropertyBase_T:: invalidate (void) +{ + this->valid_ = 0; +} + +/******************************************************************************/ + +template ACE_INLINE TAO_NS_Property_T& +TAO_NS_Property_T::operator=(const TYPE& value) +{ + this->TAO_NS_PropertyBase_T::operator= (value); + return *this; +} + +/******************************************************************************/ + +template ACE_INLINE const TYPE& +TAO_NS_StructProperty_T::value (void) const +{ + return this->value_; +} + +template ACE_INLINE CORBA::Boolean +TAO_NS_StructProperty_T::is_valid (void) const +{ + return this->valid_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp new file mode 100644 index 00000000000..dd1cd160f13 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp @@ -0,0 +1,133 @@ +// $Id$ + +#include "Proxy.h" + +#if ! defined (__ACE_INLINE__) +#include "Proxy.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Proxy, "$Id$") + +#include "Peer.h" +#include "Proxy.h" +#include "Method_Request_Updates.h" +#include "Worker_Task.h" +#include "Properties.h" + +TAO_NS_Proxy::TAO_NS_Proxy (void) + :updates_off_ (0) +{ +} + +TAO_NS_Proxy::~TAO_NS_Proxy () +{ +} + +void +TAO_NS_Proxy::init (TAO_NS_Admin *admin ACE_ENV_ARG_DECL_NOT_USED) +{ + TAO_NS_Object::init (admin); + + // For Proxy's the object should be activated in the proxy poa. + // so we override the default initialization in TAO_NS_Object + + this->poa_ = this->proxy_poa_; +} + +void +TAO_NS_Proxy::subscribed_types (TAO_NS_EventTypeSeq& subscribed_types ACE_ENV_ARG_DECL) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // copy + subscribed_types = this->subscribed_types_; +} + +void +TAO_NS_Proxy::types_changed (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed ACE_ENV_ARG_DECL_NOT_USED) +{ + TAO_NS_Method_Request_Updates request (added, removed, this); + + if (TAO_NS_PROPERTIES::instance()->asynch_updates () == 1) // if we should send the updates synchronously. + { + this->worker_task ()->exec (request); + } + else // execute in the current thread context. + { + ACE_DECLARE_NEW_CORBA_ENV; + request.execute (ACE_ENV_SINGLE_ARG_PARAMETER); + } +} + +CORBA::Boolean +TAO_NS_Proxy::check_filters (const TAO_NS_Event_var &event + , TAO_NS_FilterAdmin& parent_filter_admin + , CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator + ACE_ENV_ARG_DECL) +{ + // check if it passes the parent filter. + CORBA::Boolean parent_val = + parent_filter_admin.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Boolean val = 0; + + if (filter_operator == CosNotifyChannelAdmin::AND_OP) + { + val = parent_val && this->filter_admin_.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + else + { + val = parent_val || this->filter_admin_.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + return val; +} + +CosNotification::EventTypeSeq* +TAO_NS_Proxy::obtain_types (CosNotifyChannelAdmin::ObtainInfoMode mode, const TAO_NS_EventTypeSeq& types ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotification::EventTypeSeq_var event_type_seq; + + ACE_NEW_THROW_EX (event_type_seq, + CosNotification::EventTypeSeq (), + CORBA::NO_MEMORY ()); + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); + ACE_CHECK_RETURN (event_type_seq._retn ()); + + if (mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_OFF || + mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_ON) + { + types.populate (event_type_seq); + } + + if (mode == CosNotifyChannelAdmin::NONE_NOW_UPDATES_ON || + mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_ON) + { + this->updates_off_ = 0; + } + else + { + this->updates_off_ = 1; + } + + return event_type_seq._retn (); +} + +void +TAO_NS_Proxy::qos_changed (const TAO_NS_QoSProperties& qos_properties) +{ + //Inform Peers of qos changes. + TAO_NS_Peer* peer = this->peer (); + + if (peer != 0) + peer->qos_changed (qos_properties); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.h b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h new file mode 100644 index 00000000000..27f8e3ea518 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ +/** + * @file Proxy.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROXY_H +#define TAO_NS_PROXY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Object.h" +#include "EventTypeSeq.h" +#include "FilterAdmin.h" +#include "Admin.h" + +class TAO_NS_Admin; +class TAO_NS_Peer; + +/** + * @class TAO_NS_Proxy + * + * @brief Base class proxy for all proxys in NS. + * + */ +class TAO_Notify_Export TAO_NS_Proxy : public virtual TAO_NS_Object +{ + friend class TAO_NS_Peer; + +public: + typedef CosNotifyChannelAdmin::ProxyIDSeq SEQ; + typedef CosNotifyChannelAdmin::ProxyIDSeq_var SEQ_VAR; + + /// Constuctor + TAO_NS_Proxy (void); + + /// Destructor + ~TAO_NS_Proxy (); + + /// Init + void init (TAO_NS_Admin *admin ACE_ENV_ARG_DECL); + + /// Obtain the Proxy's subscribed types. + void subscribed_types (TAO_NS_EventTypeSeq& subscribed_types ACE_ENV_ARG_DECL); + + /// Check if this event passes the admin and proxy filters. + CORBA::Boolean check_filters (const TAO_NS_Event_var &event + , TAO_NS_FilterAdmin& parent_filter_admin + , CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator + ACE_ENV_ARG_DECL); + + /// Inform this proxy that the following types are being advertised. + void types_changed (const TAO_NS_EventTypeSeq& added, const TAO_NS_EventTypeSeq& removed ACE_ENV_ARG_DECL); + + /// Have updates been turned off. + CORBA::Boolean updates_off (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) = 0; + + /// Access our Peer. + virtual TAO_NS_Peer* peer (void) = 0; + + /// Implement the Obtain Types. + virtual CosNotification::EventTypeSeq* obtain_types (CosNotifyChannelAdmin::ObtainInfoMode mode, const TAO_NS_EventTypeSeq& types ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// Notification of subscriptions/offers set at the admin. + virtual void admin_types_changed (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) = 0; + + + /// Override, TAO_NS_Object::qos_changed + virtual void qos_changed (const TAO_NS_QoSProperties& qos_properties); + +protected: + + /// Filter Administration + TAO_NS_FilterAdmin filter_admin_; + + /// The types that we're subscribed with the event manager. + TAO_NS_EventTypeSeq subscribed_types_; + + /// True if updates have been turned off. + CORBA::Boolean updates_off_; +}; + +#if defined (__ACE_INLINE__) +#include "Proxy.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl b/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl new file mode 100644 index 00000000000..3610f2b3167 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE CORBA::Boolean +TAO_NS_Proxy::updates_off (void) +{ + return this->updates_off_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp new file mode 100644 index 00000000000..b2191768a07 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp @@ -0,0 +1,152 @@ +// $Id$ + +#include "ProxyConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxyConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ProxyConsumer, "$Id$") + +#include "tao/debug.h" +#include "ace/Atomic_Op.h" +#include "Supplier.h" +#include "AdminProperties.h" +#include "Property.h" +#include "Proxy.h" +#include "Event_Manager.h" +#include "Method_Request_Lookup.h" +#include "Worker_Task.h" +#include "Properties.h" +#include "SupplierAdmin.h" + +TAO_NS_ProxyConsumer::TAO_NS_ProxyConsumer (void) + : supplier_admin_ (0) + , supplier_ (0) +{ +} + +TAO_NS_ProxyConsumer::~TAO_NS_ProxyConsumer () +{ + this->supplier_admin_->_decr_refcnt (); +} + +TAO_NS_Peer* +TAO_NS_ProxyConsumer::peer (void) +{ + return this->supplier (); +} + +void +TAO_NS_ProxyConsumer::init (TAO_NS_SupplierAdmin* supplier_admin ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Proxy::init (supplier_admin ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->supplier_admin_ = supplier_admin; + + this->supplier_admin_->_incr_refcnt (); + + const CosNotification::QoSProperties &default_ps_qos = + TAO_NS_PROPERTIES::instance ()->default_proxy_consumer_qos_properties (); + + this->set_qos (default_ps_qos ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_ProxyConsumer::connect (TAO_NS_Supplier *supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + TAO_NS_Atomic_Property_Long& supplier_count = this->admin_properties_->suppliers (); + const TAO_NS_Property_Long& max_suppliers = this->admin_properties_->max_suppliers (); + + if (max_suppliers != 0 && + supplier_count >= max_suppliers.value ()) + ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of suppliers connected. + + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + if (this->is_connected ()) + { + supplier->release (); + ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); + } + + supplier_ = supplier; + + this->supplier_admin_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types. + ACE_CHECK; + } + + // Inform QoS values. + supplier_->qos_changed (this->qos_properties_); + + TAO_NS_EventTypeSeq removed; + + this->event_manager_->offer_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_manager_->connect (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Increment the global supplier count + ++supplier_count; +} + +void +TAO_NS_ProxyConsumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_EventTypeSeq added; + + event_manager_->offer_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_manager_->disconnect (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Decrement the global supplier count + this->admin_properties_->suppliers ()--; +} + +int +TAO_NS_ProxyConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return 1; + + ACE_CHECK_RETURN (1); + + this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + if (this->supplier_ != 0) + this->supplier_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + return 0; +} + +void +TAO_NS_ProxyConsumer::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; + + this->supplier_admin_->remove (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +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 new file mode 100644 index 00000000000..807bcf152f3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h @@ -0,0 +1,93 @@ +/* -*- C++ -*- */ +/** + * @file ProxyConsumer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROXYCONSUMER_H +#define TAO_NS_PROXYCONSUMER_H +#include "ace/pre.h" + +#include "notify_export.h" +#include "ace/Auto_Ptr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Event.h" +#include "Proxy.h" +#include "orbsvcs/CosEventChannelAdminC.h" + +class TAO_NS_SupplierAdmin; +class TAO_NS_Supplier; + +/** + * @class TAO_NS_ProxyConsumer + * + * @brief Base class for all types of ProxyConsumer implementations. + * + */ +class TAO_Notify_Export TAO_NS_ProxyConsumer : public virtual TAO_NS_Proxy +{ +public: + /// Constuctor + TAO_NS_ProxyConsumer (void); + + /// Destructor + ~TAO_NS_ProxyConsumer (); + + /// Init + void init (TAO_NS_SupplierAdmin* supplier_admin ACE_ENV_ARG_DECL); + + /// Connect + void connect (TAO_NS_Supplier* supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )); + + /// Disconnect + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + /// Shutdown (TAO_NS_Container_T method) + virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// Start event propagation. + 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); + + /// Return 1 if connected + int is_connected (void); + + /// The SA parent. + TAO_NS_SupplierAdmin* supplier_admin (void); + +protected: + ///= Data Members. + /// The SA parent. + TAO_NS_SupplierAdmin* supplier_admin_; + + /// The Supplier that we're connect to. + TAO_NS_Supplier* supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "ProxyConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl new file mode 100644 index 00000000000..ea4b07f8474 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl @@ -0,0 +1,19 @@ +// $Id$ + +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_; +} + +ACE_INLINE TAO_NS_SupplierAdmin* +TAO_NS_ProxyConsumer::supplier_admin (void) +{ + return this->supplier_admin_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp new file mode 100644 index 00000000000..7c75dd56b49 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp @@ -0,0 +1,81 @@ +// $Id$ + +#ifndef TAO_NS_PROXYCONSUMER_T_CPP +#define TAO_NS_PROXYCONSUMER_T_CPP + +#include "ProxyConsumer_T.h" +#include "SupplierAdmin.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxyConsumer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_ProxyConsumer_T, "$id$") + +#include "Event_Manager.h" + +template +TAO_NS_ProxyConsumer_T::TAO_NS_ProxyConsumer_T (void) +{ +} + +template +TAO_NS_ProxyConsumer_T::~TAO_NS_ProxyConsumer_T () +{ +} + +template void +TAO_NS_ProxyConsumer_T::admin_types_changed (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) +{ + this->offer_change (added, removed ACE_ENV_ARG_PARAMETER); +} + +template CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_ProxyConsumer_T::MyAdmin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::SupplierAdmin_var ret; + + CORBA::Object_var object = this->supplier_admin_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ret._retn ()); + + ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + + return ret._retn (); +} + +template void +TAO_NS_ProxyConsumer_T::offer_change (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyComm::InvalidEventType + )) +{ + 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); + } + + this->event_manager_->offer_change (this, seq_added, seq_removed ACE_ENV_ARG_PARAMETER); +} + +template CosNotification::EventTypeSeq* +TAO_NS_ProxyConsumer_T::obtain_subscription_types (CosNotifyChannelAdmin::ObtainInfoMode mode ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->obtain_types (mode, this->event_manager_->subscription_types () ACE_ENV_ARG_PARAMETER); +} + +#endif /* TAO_NS_PROXYCONSUMER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h new file mode 100644 index 00000000000..6ccc7dcec1d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h @@ -0,0 +1,84 @@ +/* -*- C++ -*- */ +/** + * @file ProxyConsumer_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROXYCONSUMER_T_H +#define TAO_NS_PROXYCONSUMER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Proxy_T.h" +#include "ProxyConsumer.h" + +/** + * @class TAO_NS_ProxyConsumer_T + * + * @brief + * + */ +template +class TAO_Notify_Export TAO_NS_ProxyConsumer_T : public virtual TAO_NS_Proxy_T , public virtual TAO_NS_ProxyConsumer +{ +public: + /// Constuctor + TAO_NS_ProxyConsumer_T (void); + + /// Destructor + ~TAO_NS_ProxyConsumer_T (); + + /// Notification of subscriptions set at the admin. + virtual void admin_types_changed (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + virtual CosNotifyChannelAdmin::SupplierAdmin_ptr MyAdmin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotification::EventTypeSeq * obtain_subscription_types ( + CosNotifyChannelAdmin::ObtainInfoMode mode + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void offer_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyComm::InvalidEventType + )); + +}; + +#if defined (__ACE_INLINE__) +#include "ProxyConsumer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ProxyConsumer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("ProxyConsumer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYCONSUMER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp new file mode 100644 index 00000000000..ade8865cb78 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp @@ -0,0 +1,180 @@ +// $Id$ + +#include "ProxySupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxySupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ProxySupplier, "$Id$") + +#include "Method_Request_Dispatch_No_Filtering.h" +#include "Event_Manager.h" +#include "AdminProperties.h" +#include "Consumer.h" +#include "Method_Request_Dispatch.h" +#include "Worker_Task.h" +#include "Buffering_Strategy.h" +#include "Properties.h" +#include "ConsumerAdmin.h" + +TAO_NS_ProxySupplier::TAO_NS_ProxySupplier (void) + : consumer_admin_ (0) + , consumer_ (0) +{ +} + +TAO_NS_ProxySupplier::~TAO_NS_ProxySupplier () +{ + this->consumer_admin_->_decr_refcnt (); +} + +void +TAO_NS_ProxySupplier::init (TAO_NS_ConsumerAdmin* consumer_admin ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Proxy::init (consumer_admin ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->consumer_admin_ = consumer_admin; + + this->consumer_admin_->_incr_refcnt (); + + const CosNotification::QoSProperties &default_ps_qos = + TAO_NS_PROPERTIES::instance ()->default_proxy_supplier_qos_properties (); + + this->set_qos (default_ps_qos ACE_ENV_ARG_PARAMETER); +} + +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 (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + TAO_NS_Atomic_Property_Long& consumer_count = this->admin_properties_->consumers (); + const TAO_NS_Property_Long& max_consumers = this->admin_properties_->max_consumers (); + + if (max_consumers != 0 && + consumer_count >= max_consumers.value ()) + ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of consumers connected. + + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + if (this->is_connected ()) + { + consumer->release (); + ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); + } + + consumer_ = consumer; + + this->consumer_admin_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types. + ACE_CHECK; + } + + // Inform QoS values. + consumer_->qos_changed (this->qos_properties_); + + TAO_NS_EventTypeSeq removed; + + this->event_manager_->subscription_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER); + + this->event_manager_->connect (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Increment the global consumer count + ++consumer_count; +} + +void +TAO_NS_ProxySupplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_EventTypeSeq added; + + this->event_manager_->subscription_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_manager_->disconnect (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Decrement the global consumer count + this->admin_properties_->consumers ()--; +} + +int +TAO_NS_ProxySupplier::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return 1; + + ACE_CHECK_RETURN (1); + + this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + if (this->consumer_ != 0) + this->consumer_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + return 0; +} + +void +TAO_NS_ProxySupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; + + this->consumer_admin_->remove (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_ProxySupplier::push (const TAO_NS_Event_var &event) +{ + TAO_NS_Method_Request_Dispatch request (event, this); + + this->worker_task ()->exec (request); +} + +void +TAO_NS_ProxySupplier::push_no_filtering (const TAO_NS_Event_var &event) +{ + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} + +void +TAO_NS_ProxySupplier::qos_changed (const TAO_NS_QoSProperties& qos_properties) +{ + TAO_NS_Property_Long mepc_qos (CosNotification::MaxEventsPerConsumer); + + if (mepc_qos.set (qos_properties) != -1) + { + // Does the Proxy own the Worker Task? + if (own_worker_task_) + { + TAO_NS_Buffering_Strategy* bs = this->worker_task_->buffering_strategy (); + + // Apply this QoS to the Proxy's Buffering Strategy. + if (bs) + { + bs->max_local_queue_length (mepc_qos.value ()); + } + } + } + + TAO_NS_Proxy::qos_changed (qos_properties); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h new file mode 100644 index 00000000000..dfb5bb590b9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h @@ -0,0 +1,100 @@ +/* -*- C++ -*- */ +/** + * @file ProxySupplier.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROXYSUPPLIER_H +#define TAO_NS_PROXYSUPPLIER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Event.h" +#include "Proxy.h" +#include "orbsvcs/CosEventChannelAdminC.h" + +class TAO_NS_Consumer; +class TAO_NS_ConsumerAdmin; + +/** + * @class TAO_NS_ProxySupplier + * + * @brief Base class for all the ProxySuppliers. + * + */ +class TAO_Notify_Export TAO_NS_ProxySupplier : public virtual TAO_NS_Proxy +{ + friend class TAO_NS_Consumer; + +public: + /// Constuctor + TAO_NS_ProxySupplier (void); + + /// Destructor + virtual ~TAO_NS_ProxySupplier (); + + /// Init + virtual void init (TAO_NS_ConsumerAdmin* consumer_admin ACE_ENV_ARG_DECL); + + /// Connect + void connect (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )); + /// Disconnect + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + /// Dispatch Event to consumer + virtual void push (const TAO_NS_Event_var &event); + + /// Dispatch Event to consumer, no filtering + virtual void push_no_filtering (const TAO_NS_Event_var &event); + + /// Override TAO_NS_Container_T::shutdown method + virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// Override, TAO_NS_Proxy::qos_changed to apply MaxEventssPerConsumer QoS. + virtual void qos_changed (const TAO_NS_QoSProperties& qos_properties); + + /// Access our Peer. + virtual TAO_NS_Peer* peer (void); + + /// Access the Consumer + TAO_NS_Consumer* consumer (void); + + /// Return 1 if connected + int is_connected (void); + + /// The CA parent. + TAO_NS_ConsumerAdmin* consumer_admin (void); + +protected: + + ///= Data Members. + /// The CA parent. + TAO_NS_ConsumerAdmin* consumer_admin_; + + /// The Consumer that we're connect to. + TAO_NS_Consumer* consumer_; +}; + +#if defined (__ACE_INLINE__) +#include "ProxySupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl new file mode 100644 index 00000000000..3c7852c9858 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl @@ -0,0 +1,19 @@ +// $Id$ + +ACE_INLINE int +TAO_NS_ProxySupplier::is_connected (void) +{ + return consumer_ == 0 ? 0 : 1; +} + +ACE_INLINE TAO_NS_Consumer* +TAO_NS_ProxySupplier::consumer (void) +{ + return this->consumer_; +} + +ACE_INLINE TAO_NS_ConsumerAdmin* +TAO_NS_ProxySupplier::consumer_admin (void) +{ + return this->consumer_admin_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp new file mode 100644 index 00000000000..04db7d0d999 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp @@ -0,0 +1,223 @@ +// $Id$ + +#ifndef TAO_NS_PROXYSUPPLIER_T_C +#define TAO_NS_PROXYSUPPLIER_T_C + +#include "ProxySupplier_T.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxySupplier_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_ProxySupplier_T, "$id$") + +#include "Consumer.h" +#include "Structured/StructuredEvent.h" +#include "Any/AnyEvent.h" + +#include "Method_Request_Dispatch.h" +#include "Method_Request_Dispatch_No_Filtering.h" +#include "Worker_Task.h" +#include "Event_Manager.h" +#include "ConsumerAdmin.h" + +template +TAO_NS_ProxySupplier_T::TAO_NS_ProxySupplier_T (void) + :is_suspended_ (0) +{ +} + +template +TAO_NS_ProxySupplier_T::~TAO_NS_ProxySupplier_T () +{ +} + +template void +TAO_NS_ProxySupplier_T::admin_types_changed (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) +{ + this->subscription_change (added, removed ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_ProxySupplier_T::forward_structured (const CosNotification::StructuredEvent& notification ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + TAO_NS_Method_Request_Dispatch request (event, this); + + this->worker_task ()->exec (request); +} + +template void +TAO_NS_ProxySupplier_T::forward_structured_no_filtering (const CosNotification::StructuredEvent& notification ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + 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); +} + +template void +TAO_NS_ProxySupplier_T::forward_any (const CORBA::Any & data ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_AnyEvent (data)); + + TAO_NS_Method_Request_Dispatch request (event, this); + + this->worker_task ()->exec (request); +} + +template void +TAO_NS_ProxySupplier_T::forward_any_no_filtering (const CORBA::Any& data ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_AnyEvent (data)); + + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} + +template CosNotification::EventTypeSeq* +TAO_NS_ProxySupplier_T::obtain_offered_types (CosNotifyChannelAdmin::ObtainInfoMode mode ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->obtain_types (mode, this->event_manager_->offered_types () ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_ProxySupplier_T::subscription_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyComm::InvalidEventType)) +{ + 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); + } + + this->event_manager_->subscription_change (this, seq_added, seq_removed ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_ProxySupplier_T::suspend_connection (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyInactive, + CosNotifyChannelAdmin::NotConnected + )) +{ + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); + + if (this->is_connected () == 0) + ACE_THROW (CosNotifyChannelAdmin::NotConnected ()); + + if (this->consumer_->is_suspended () == 1) + ACE_THROW (CosNotifyChannelAdmin::ConnectionAlreadyInactive ()); + } + + this->consumer_->suspend (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template void +TAO_NS_ProxySupplier_T::resume_connection (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyActive, + CosNotifyChannelAdmin::NotConnected + )) +{ + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); + + if (this->is_connected () == 0) + ACE_THROW (CosNotifyChannelAdmin::NotConnected ()); + + if (this->consumer_->is_suspended () == 0) + ACE_THROW (CosNotifyChannelAdmin::ConnectionAlreadyActive ()); + } + + this->consumer_->resume (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_ProxySupplier_T::MyAdmin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::ConsumerAdmin_var ret; + + CORBA::Object_var object = this->consumer_admin_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ret._retn ()); + + ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + + return ret._retn (); +} + +/***************************** UNIMPLEMENTED METHODS***************************************/ + +template CosNotifyFilter::MappingFilter_ptr +TAO_NS_ProxySupplier_T::priority_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + CosNotifyFilter::MappingFilter::_nil ()); +} + +template void +TAO_NS_ProxySupplier_T::priority_filter (CosNotifyFilter::MappingFilter_ptr /*priority_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +template CosNotifyFilter::MappingFilter_ptr +TAO_NS_ProxySupplier_T::lifetime_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + CosNotifyFilter::MappingFilter::_nil ()); +} + +template void +TAO_NS_ProxySupplier_T::lifetime_filter (CosNotifyFilter::MappingFilter_ptr /*lifetime_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +#endif /* #define TAO_NS_PROXYSUPPLIER_T_C */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h new file mode 100644 index 00000000000..c0e8d2054fb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h @@ -0,0 +1,162 @@ +/* -*- C++ -*- */ +/** + * @file ProxySupplier_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROXYSUPPLIER_T_H +#define TAO_NS_PROXYSUPPLIER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Proxy_T.h" +#include "ProxySupplier.h" + +/** + * @class TAO_NS_ProxySupplier_T + * + * @brief + * + */ +template +class TAO_NS_ProxySupplier_T : public virtual TAO_NS_Proxy_T , public virtual TAO_NS_ProxySupplier +{ +public: + /// Constuctor + TAO_NS_ProxySupplier_T (void); + + /// Destructor + ~TAO_NS_ProxySupplier_T (); + + /// Notification of subscriptions set at the admin. + virtual void admin_types_changed (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + ///= POA_Notify_Internal methods + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_structured (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_structured_no_filtering (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_any (const CORBA::Any & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_any_no_filtering (const CORBA::Any & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +protected: + //= Data Members + CORBA::Boolean is_suspended_; + + // = Interface methods + virtual CosNotifyChannelAdmin::ConsumerAdmin_ptr MyAdmin ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void suspend_connection ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyInactive, + CosNotifyChannelAdmin::NotConnected + )); + + virtual void resume_connection ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyActive, + CosNotifyChannelAdmin::NotConnected + )); + + virtual CosNotifyFilter::MappingFilter_ptr priority_filter ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void priority_filter ( + CosNotifyFilter::MappingFilter_ptr priority_filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotifyFilter::MappingFilter_ptr lifetime_filter ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void lifetime_filter ( + CosNotifyFilter::MappingFilter_ptr lifetime_filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotification::EventTypeSeq * obtain_offered_types ( + CosNotifyChannelAdmin::ObtainInfoMode mode + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void subscription_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyComm::InvalidEventType + )); +}; + +#if defined (__ACE_INLINE__) +#include "ProxySupplier_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ProxySupplier_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("ProxySupplier_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYSUPPLIER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp new file mode 100644 index 00000000000..dd340c2b592 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp @@ -0,0 +1,160 @@ +// $Id$ + +#include "Proxy_T.h" + +#ifndef TAO_NS_PROXY_T_CPP +#define TAO_NS_PROXY_T_CPP + +#if ! defined (__ACE_INLINE__) +#include "Proxy_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Proxy_T, "$id$") + +template +TAO_NS_Proxy_T::TAO_NS_Proxy_T (void) +{ +} + +template +TAO_NS_Proxy_T::~TAO_NS_Proxy_T () +{ +} + +template PortableServer::Servant +TAO_NS_Proxy_T::servant (void) +{ + return this; +} + +template void +TAO_NS_Proxy_T::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +template void +TAO_NS_Proxy_T::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +template void +TAO_NS_Proxy_T::validate_event_qos (const CosNotification::QoSProperties & /*required_qos*/, CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +template CosNotification::QoSProperties* +TAO_NS_Proxy_T::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template void +TAO_NS_Proxy_T::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_Proxy_T::validate_qos ( + const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +template CosNotifyFilter::FilterID +TAO_NS_Proxy_T::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} + +template void +TAO_NS_Proxy_T::remove_filter ( + CosNotifyFilter::FilterID filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} + +template CosNotifyFilter::Filter_ptr +TAO_NS_Proxy_T::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} + +template CosNotifyFilter::FilterIDSeq* +TAO_NS_Proxy_T::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template void +TAO_NS_Proxy_T::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + + this->filter_admin_.remove_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +#endif /* TAO_NS_PROXY_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h new file mode 100644 index 00000000000..090d4edd49a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h @@ -0,0 +1,158 @@ +/* -*- C++ -*- */ +/** + * @file Proxy_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_PROXY_T_H +#define TAO_NS_PROXY_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Proxy.h" + +/** + * @class TAO_NS_Proxy_T + * + * @brief The is a base class for all proxys , templatized by the servant + * type. All the Filter Admin and QoS Admin interface methods are + * implemented here by delegating to the admin implementations. + * + */ +template +class TAO_NS_Proxy_T : public SERVANT_TYPE, public virtual TAO_NS_Proxy +{ +public: + /// Constuctor + TAO_NS_Proxy_T (void); + + /// Destructor + ~TAO_NS_Proxy_T (); + + /// Implements TAO_NS_Object::servant method. + virtual PortableServer::Servant servant (void); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + virtual void validate_event_qos ( + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual CosNotification::QoSProperties * get_qos ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos ( + const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual void validate_qos ( + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + 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 + )); +}; + +#if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +template class TAO_Notify_Export +TAO_NS_Proxy_T; +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ + +#if defined (__ACE_INLINE__) +#include "Proxy_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Proxy_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Proxy_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp new file mode 100644 index 00000000000..ca2e0da3330 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp @@ -0,0 +1,138 @@ +// $Id$ + +#include "QoSProperties.h" + +#if ! defined (__ACE_INLINE__) +#include "QoSProperties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_QoSProperties, "$id$") + +#include "Property.h" + +TAO_NS_QoSProperties::TAO_NS_QoSProperties (void) + :priority_ (CosNotification::Priority), + timeout_ (CosNotification::Timeout), + stop_time_supported_ (CosNotification::StopTimeSupported), + maximum_batch_size_ (CosNotification::MaximumBatchSize), + pacing_interval_ (CosNotification::PacingInterval), + thread_pool_ (NotifyExt::ThreadPool), + thread_pool_lane_ (NotifyExt::ThreadPoolLanes) +{ + unsupported_[0] = CosNotification::EventReliability; + unsupported_[1] = CosNotification::ConnectionReliability; + unsupported_[2] = CosNotification::StartTimeSupported; +} + +TAO_NS_QoSProperties::~TAO_NS_QoSProperties () +{ +} + +int +TAO_NS_QoSProperties::unsupported (ACE_CString& name) +{ + for (int i = 0; i < UNSUPPORTED_PROPERTY_COUNT; ++i) + { + if (this->unsupported_[i] == name) + return 1; + } + + return 0; +} + +int +TAO_NS_QoSProperties::init (const CosNotification::PropertySeq& prop_seq, CosNotification::PropertyErrorSeq& err_seq) +{ + int err_index = -1; + + ACE_CString name; + for (CORBA::ULong i = 0; i < prop_seq.length (); ++i) + { + name = prop_seq[i].name.in(); + + if (this->unsupported (name)) + { + err_index = err_seq.length (); + err_seq.length (err_seq.length () + 1); + + err_seq[err_index].code = CosNotification::UNSUPPORTED_PROPERTY; + err_seq[err_index].name = CORBA::string_dup (prop_seq[i].name); + } + else if (this->property_map_.rebind (prop_seq[i].name.in (), prop_seq[i].value) == -1) + return -1; + // Note call to rebind. This allows to call to set updates. + } + + // Now, init the supported properties + this->priority_.set (*this); + this->timeout_.set (*this); + this->stop_time_supported_.set (*this); + this->maximum_batch_size_.set (*this); + this->pacing_interval_.set (*this); + this->thread_pool_.set (*this); + this->thread_pool_lane_.set (*this); + + return err_index == -1 ? 0 : 1; +} + +int +TAO_NS_QoSProperties::copy (TAO_NS_QoSProperties& qos_properties) +{ + qos_properties.priority_ = this->priority_; + qos_properties.timeout_ = this->timeout_; + qos_properties.stop_time_supported_ = this->stop_time_supported_; + qos_properties.maximum_batch_size_ = this->maximum_batch_size_; + qos_properties.pacing_interval_ = this->pacing_interval_; + + PROPERTY_MAP::ITERATOR iter (this->property_map_); + PROPERTY_MAP::ENTRY *entry; + + for (; iter.next (entry); iter.advance ()) + { + if (qos_properties.property_map_.rebind (entry->ext_id_, entry->int_id_) == -1) + return -1; + } + + return 0; +} + +int +TAO_NS_QoSProperties::transfer (TAO_NS_QoSProperties& qos_properties) +{ + if (this->copy (qos_properties) == -1) + return -1; + + // unbind the properties that we don't want to transfer. + qos_properties.property_map_.unbind (NotifyExt::ThreadPool); + qos_properties.property_map_.unbind (NotifyExt::ThreadPoolLanes); + + return 0; +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_PropertyBase_T; +template class TAO_NS_PropertyBase_T; +template class TAO_NS_PropertyBase_T; + +template class TAO_NS_Property_T; +template class TAO_NS_Property_T; +template class TAO_NS_Property_T; + +template class TAO_NS_StructProperty_T; +template class TAO_NS_StructProperty_T; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_PropertyBase_T +#pragma instantiate TAO_NS_PropertyBase_T +#pragma instantiate TAO_NS_PropertyBase_T + +#pragma instantiate TAO_NS_Property_T +#pragma instantiate TAO_NS_Property_T +#pragma instantiate TAO_NS_Property_T + +#pragma instantiate TAO_NS_StructProperty_T +#pragma instantiate TAO_NS_StructProperty_T + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h new file mode 100644 index 00000000000..0b65e375865 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ +/** + * @file QoSProperties.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_QOSPROPERTIES_H +#define TAO_NS_QOSPROPERTIES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "PropertySeq.h" +#include "Property_T.h" +#include "Property_Boolean.h" +#include "Property.h" + +/** + * @class TAO_NS_QoSProperties + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_QoSProperties : public TAO_NS_PropertySeq +{ +public: + /// Constuctor + TAO_NS_QoSProperties (void); + + /// Destructor + ~TAO_NS_QoSProperties (); + + /// Return 0 on success, 1 if unsupported properties were detected and -1 on error. + int init (const CosNotification::PropertySeq& prop_seq, CosNotification::PropertyErrorSeq& err_seq); + + /// Populate with all properties from this object. Returns -1 on error. + int copy (TAO_NS_QoSProperties& qos_properties); + + /// Populate with properties that can be transfered.Returns -1 on error. + int transfer (TAO_NS_QoSProperties& qos_properties); + + ///= Accessors + /// ThreadPool + const TAO_NS_Property_ThreadPool& thread_pool (void) const; + + /// ThreadPoolLane + const TAO_NS_Property_ThreadPoolLanes& thread_pool_lane (void) const; + + /// Maximum Batch Size + const TAO_NS_Property_Long& maximum_batch_size (void) const; + + /// Pacing Interval + const TAO_NS_Property_Time& pacing_interval (void) const; + +protected: + /// Return 1 if is unsupported. + int unsupported (ACE_CString& name); + + enum {UNSUPPORTED_PROPERTY_COUNT = 3}; + + ///= Unsupported Properties. + ACE_CString unsupported_[UNSUPPORTED_PROPERTY_COUNT]; + + ///= Supported properties + + /// Priority + TAO_NS_Property_Short priority_; + + /// Timeout + TAO_NS_Property_Time timeout_; + + /// Stop Time Supported + TAO_NS_Property_Boolean stop_time_supported_; + + /// Maximum Batch Size + TAO_NS_Property_Long maximum_batch_size_; + + /// Pacing Interval + TAO_NS_Property_Time pacing_interval_; + + /// ThreadPool Params. + TAO_NS_Property_ThreadPool thread_pool_; + + /// ThreadPoolLane Params. + TAO_NS_Property_ThreadPoolLanes thread_pool_lane_; +}; + +#if defined (__ACE_INLINE__) +#include "QoSProperties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_QOSPROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl new file mode 100644 index 00000000000..e331e8b1046 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl @@ -0,0 +1,25 @@ +// $Id$ + +ACE_INLINE const TAO_NS_Property_ThreadPool& +TAO_NS_QoSProperties::thread_pool (void) const +{ + return this->thread_pool_; +} + +ACE_INLINE const TAO_NS_Property_ThreadPoolLanes& +TAO_NS_QoSProperties::thread_pool_lane (void) const +{ + return this->thread_pool_lane_; +} + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_QoSProperties::maximum_batch_size (void) const +{ + return this->maximum_batch_size_; +} + +ACE_INLINE const TAO_NS_Property_Time& +TAO_NS_QoSProperties::pacing_interval (void) const +{ + return this->pacing_interval_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp new file mode 100644 index 00000000000..be618793360 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp @@ -0,0 +1,106 @@ +// $Id$ + +#include "RT_Builder.h" + +#include "ace/Auto_Ptr.h" +#include "ace/Dynamic_Service.h" +#include "ETCL_FilterFactory.h" +#include "RT_POA_Helper.h" +#include "Properties.h" +#include "orbsvcs/NotifyExtC.h" + +#if ! defined (__ACE_INLINE__) +#include "RT_Builder.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RT_Builder, "$Id$") + +TAO_NS_RT_Builder::TAO_NS_RT_Builder (void) +{ +} + +TAO_NS_RT_Builder::~TAO_NS_RT_Builder () +{ +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_RT_Builder::build_filter_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + return TAO_NS_Builder::build_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + + TAO_NS_FilterFactory* ff = ACE_Dynamic_Service::instance ("TAO_NS_FilterFactory"); + + if (ff == 0) + { + ACE_NEW_THROW_EX (ff, + TAO_NS_ETCL_FilterFactory (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CosNotifyFilter::FilterFactory::_nil ()); + } + + PortableServer::POA_var default_poa = TAO_NS_PROPERTIES::instance ()->default_poa (); + + TAO_NS_RT_POA_Helper filter_poa; + + NotifyExt::ThreadPoolParams tp_params = {0, 1, 0, 0, 0, 0, 0 }; + + //filter_poa.init (default_poa.in (), tp_params ACE_ENV_ARG_PARAMETER); + filter_poa.init (default_poa.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::POA_var filter_poa_var = filter_poa.poa (); + + return ff->create (filter_poa_var ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RT_Builder::apply_thread_pool_concurrency (TAO_NS_Object& object + , const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL) +{ + TAO_NS_RT_POA_Helper* proxy_poa = 0; + + // Bootstrap EC Proxy POA + ACE_NEW_THROW_EX (proxy_poa, + TAO_NS_RT_POA_Helper (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (ec_ret._retn ()); + + auto_ptr 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 + object.proxy_poa_own (proxy_poa); + + // release auto ref. + auto_proxy_poa.release (); +} + +void +TAO_NS_RT_Builder::apply_lane_concurrency (TAO_NS_Object& object + , const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL) +{ + TAO_NS_RT_POA_Helper* proxy_poa = 0; + + // Bootstrap EC Proxy POA + ACE_NEW_THROW_EX (proxy_poa, + TAO_NS_RT_POA_Helper (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (ec_ret._retn ()); + + auto_ptr auto_proxy_poa (proxy_poa); + + PortableServer::POA_var default_poa = TAO_NS_PROPERTIES::instance ()->default_poa (); + + proxy_poa->init (default_poa.in (), tpl_params ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Give ownership of proxy_poa + object.proxy_poa_own (proxy_poa); + + // release auto ref. + auto_proxy_poa.release (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.h b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.h new file mode 100644 index 00000000000..89591289e0a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.h @@ -0,0 +1,54 @@ +/* -*- C++ -*- */ +/** + * @file RT_Builder.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_BUILDER_H +#define TAO_NS_RT_BUILDER_H +#include "ace/pre.h" + +#include "rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Builder.h" + +/** + * @class TAO_NS_RT_Builder + * + * @brief Builder for RT specific classes. + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_Builder : public TAO_NS_Builder +{ +public: + /// Constuctor + TAO_NS_RT_Builder (void); + + /// Destructor + virtual ~TAO_NS_RT_Builder (); + + /// Build the Filter Factory. + virtual CosNotifyFilter::FilterFactory_ptr build_filter_factory (ACE_ENV_SINGLE_ARG_DECL); + + /// Apply Thread Pools. + virtual void apply_thread_pool_concurrency (TAO_NS_Object& object, const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL); + + /// Apply Thread Pools with Lanes. + virtual void apply_lane_concurrency (TAO_NS_Object& object, const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL); +}; + +#if defined (__ACE_INLINE__) +#include "RT_Builder.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_BUILDER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.inl b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.inl new file mode 100644 index 00000000000..1ce3c730804 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RT_Builder.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.cpp new file mode 100644 index 00000000000..5467527c8fc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.cpp @@ -0,0 +1,29 @@ +// $Id$ + +#include "RT_Factory.h" + +#if ! defined (__ACE_INLINE__) +#include "RT_Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "Structured/RT_StructuredProxyPushSupplier.h" + +ACE_RCSID(RT_Notify, TAO_NS_RT_Factory, "$Id$") + +TAO_NS_RT_Factory::TAO_NS_RT_Factory (void) +{ +} + +TAO_NS_RT_Factory::~TAO_NS_RT_Factory () +{ +} + +void +TAO_NS_RT_Factory::create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_RT_StructuredProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_RT_Factory) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.h new file mode 100644 index 00000000000..f447f01f0ca --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.h @@ -0,0 +1,50 @@ +/* -*- C++ -*- */ +/** + * @file RT_Factory.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_FACTORY_H +#define TAO_NS_RT_FACTORY_H +#include "ace/pre.h" + +#include "rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Default_Factory.h" + +/** + * @class TAO_NS_RT_Factory + * + * @brief The Factory for the RT aware Notify classes. + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_Factory : public TAO_NS_Default_Factory +{ +public: + /// Constuctor + TAO_NS_RT_Factory (void); + + /// Destructor + virtual ~TAO_NS_RT_Factory (); + + /// Create StructuredProxyPushSupplier + virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); +}; + +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_RT_Factory) + +#if defined (__ACE_INLINE__) +#include "RT_Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.inl b/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.inl new file mode 100644 index 00000000000..adb4497a7fa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Factory.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RT_Factory.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp new file mode 100644 index 00000000000..448ac8a612d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp @@ -0,0 +1,96 @@ +// $Id$ + +#include "RT_Notify_Service.h" + +#if ! defined (__ACE_INLINE__) +#include "RT_Notify_Service.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RT_Notify_Service, "$Id$") + +#include "Properties.h" +#include "RT_Properties.h" +#include "RT_Factory.h" +#include "RT_Builder.h" + +TAO_NS_RT_Notify_Service::TAO_NS_RT_Notify_Service (void) +{ +} + +TAO_NS_RT_Notify_Service::~TAO_NS_RT_Notify_Service () +{ +} + +void +TAO_NS_RT_Notify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + ACE_DEBUG ((LM_DEBUG, "Loading the Real-Time Notification Service...\n")); + + this->init_i (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_RT_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + //init the base class. + TAO_NS_CosNotify_Service::init_i (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + TAO_NS_RT_Properties* properties = TAO_NS_RT_PROPERTIES::instance(); + + // Resolve RTORB + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + RTCORBA::RTORB_var rt_orb = + RTCORBA::RTORB::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // Resolve RTCurrent + object = + orb->resolve_initial_references ("RTCurrent" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + RTCORBA::Current_var current = + RTCORBA::Current::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + /// Set the properties + properties->rt_orb (rt_orb.in ()); + properties->current (current.in ()); +} + +void +TAO_NS_RT_Notify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + this->factory_ = ACE_Dynamic_Service::instance ("TAO_NS_Factory"); + + if (this->factory_ == 0) + { + ACE_NEW_THROW_EX (this->factory_, + TAO_NS_RT_Factory (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + } + + TAO_NS_PROPERTIES::instance()->factory (this->factory_); +} + +void +TAO_NS_RT_Notify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->builder_, + TAO_NS_RT_Builder (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + TAO_NS_PROPERTIES::instance()->builder (this->builder_); +} + +ACE_FACTORY_DEFINE (TAO_RT_Notify,TAO_NS_RT_Notify_Service) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h new file mode 100644 index 00000000000..4ea50500350 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h @@ -0,0 +1,60 @@ +/* -*- C++ -*- */ +/** + * @file RT_Notify_Service.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_NOTIFY_SERVICE_H +#define TAO_NS_RT_NOTIFY_SERVICE_H + +#include "ace/pre.h" +#include "rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "CosNotify_Service.h" + +/** + * @class TAO_NS_RT_Notify_Service + * + * @brief Implemetation of the TAO_NS_Service interface for RT Notification. + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_Notify_Service : public TAO_NS_CosNotify_Service +{ +public: + /// Constuctor + TAO_NS_RT_Notify_Service (void); + + /// Destructor + ~TAO_NS_RT_Notify_Service (); + + /// Init the service. + virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + +protected: + /// Init the data members + virtual void init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + + /// Create the Factory for RT Notify objects. + virtual void init_factory (ACE_ENV_SINGLE_ARG_DECL); + + /// Creates the Builder for RT Notify objects. + virtual void init_builder (ACE_ENV_SINGLE_ARG_DECL); +}; + +ACE_FACTORY_DECLARE (TAO_RT_Notify,TAO_NS_RT_Notify_Service) + +#if defined (__ACE_INLINE__) +#include "RT_Notify_Service.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_NOTIFY_SERVICE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.inl b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.inl new file mode 100644 index 00000000000..2274b4dbd69 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RT_Notify_Service.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.cpp new file mode 100644 index 00000000000..7e0868f8bf9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.cpp @@ -0,0 +1,153 @@ +// $Id$ + +#include "RT_POA_Helper.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "tao/debug.h" +#include "orbsvcs/NotifyExtC.h" +#include "RT_Properties.h" + +#if ! defined (__ACE_INLINE__) +#include "RT_POA_Helper.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RT_POA_Helper, "$Id$") + +TAO_NS_RT_POA_Helper::~TAO_NS_RT_POA_Helper () +{ +} + +void +TAO_NS_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const NotifyExt::ThreadPoolParams& tp_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, tp_params ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name + , const NotifyExt::ThreadPoolParams& tp_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_RT_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 (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)); + + // 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); + 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_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const 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_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name + , const 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_RT_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; + + // 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); + ACE_CHECK; + + this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL) +{ + CORBA::PolicyList policy_list (1); + + RTCORBA::RTORB_var rt_orb = TAO_NS_RT_PROPERTIES::instance ()->rt_orb (); + + policy_list.length (1); + + policy_list[0] = + rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + char child_poa_name[32]; + ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10); + + this->create_i (parent_poa, child_poa_name, policy_list ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.h b/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.h new file mode 100644 index 00000000000..63150165467 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.h @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ +/** + * @file RT_POA_Helper.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_POA_Helper_H +#define TAO_NS_RT_POA_Helper_H +#include "ace/pre.h" + +#include "rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "POA_Helper.h" +#include "orbsvcs/NotifyExtC.h" + +/** + * @class TAO_NS_RT_POA_Helper + * + * @brief Helper for creating RT POA objects. + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_POA_Helper : public TAO_NS_POA_Helper +{ +public: + /// Destructor + ~TAO_NS_RT_POA_Helper (); + + /// Create a new PortableServer::POA. + /// The UNIQUE_ID, USER_ID , CLIENT_PROPAGATED and thread pool policy is applied to the new POA. + void init (PortableServer::POA_ptr parent_poa, const char* poa_name, const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. The name is chosen at random. + /// The UNIQUE_ID, USER_ID , CLIENT_PROPAGATED and thread pool policy is applied to the new POA. + void init (PortableServer::POA_ptr parent_poa, const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. + /// The UNIQUE_ID, USER_ID , CLIENT_PROPAGATED and thread lane policy is applied to the new POA. + void init (PortableServer::POA_ptr parent_poa, const char* poa_name, + const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. The name is chosen at random. + /// The UNIQUE_ID, USER_ID , CLIENT_PROPAGATED and thread lane policy is applied to the new POA. + void init (PortableServer::POA_ptr parent_poa, const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. The name is chosen at random. + /// The CLIENT_PROPAGATED policy is applied to the new POA. + void init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL); +}; + +#if defined (__ACE_INLINE__) +#include "RT_POA_Helper.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_POA_Helper_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.inl b/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.inl new file mode 100644 index 00000000000..a06831e3235 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_POA_Helper.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RT_POA_Helper.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.cpp new file mode 100644 index 00000000000..b732a196e4d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.cpp @@ -0,0 +1,17 @@ +// $Id$ + +#include "RT_Properties.h" + +#if ! defined (__ACE_INLINE__) +#include "RT_Properties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RT_Properties, "$Id$") + +TAO_NS_RT_Properties::TAO_NS_RT_Properties (void) +{ +} + +TAO_NS_RT_Properties::~TAO_NS_RT_Properties () +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.h b/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.h new file mode 100644 index 00000000000..415d0dbd79c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.h @@ -0,0 +1,65 @@ +/* -*- C++ -*- */ +/** + * @file RT_Properties.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_PROPERTIES_H +#define TAO_NS_RT_PROPERTIES_H +#include "ace/pre.h" + +#include "rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TAO_Singleton.h" +#include "tao/RTCORBA/RTCORBA.h" + +/** + * @class TAO_NS_RT_Properties + * + * @brief RT specifc global properties are stored here. + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_Properties +{ + friend class TAO_Singleton; + +public: + /// Constuctor + TAO_NS_RT_Properties (void); + + /// Destructor + ~TAO_NS_RT_Properties (); + + RTCORBA::RTORB_ptr rt_orb (void); + void rt_orb (RTCORBA::RTORB_ptr rt_orb); + + RTCORBA::Current_ptr current (void); + void current (RTCORBA::Current_ptr current); + +protected: + /// RT-ORB + RTCORBA::RTORB_var rt_orb_; + + /// Current + RTCORBA::Current_var current_; +}; + +typedef TAO_Singleton TAO_NS_RT_PROPERTIES; + +TAO_RT_NOTIFY_SINGLETON_DECLARE (TAO_Singleton, TAO_NS_RT_Properties, TAO_SYNCH_MUTEX); + +#if defined (__ACE_INLINE__) +#include "RT_Properties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_PROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.inl b/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.inl new file mode 100644 index 00000000000..77ba96126a0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Properties.inl @@ -0,0 +1,27 @@ +// $Id$ + +#include "RT_Properties.h" + +ACE_INLINE RTCORBA::RTORB_ptr +TAO_NS_RT_Properties::rt_orb (void) +{ + return RTCORBA::RTORB::_duplicate (rt_orb_.in ()); +} + +ACE_INLINE void +TAO_NS_RT_Properties::rt_orb (RTCORBA::RTORB_ptr rt_orb) +{ + rt_orb_ = RTCORBA::RTORB::_duplicate (rt_orb); +} + +ACE_INLINE RTCORBA::Current_ptr +TAO_NS_RT_Properties::current (void) +{ + return RTCORBA::Current::_duplicate (current_.in()); +} + +ACE_INLINE void +TAO_NS_RT_Properties::current (RTCORBA::Current_ptr current) +{ + current_ = RTCORBA::Current::_duplicate (current); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.cpp new file mode 100644 index 00000000000..a902546e7ce --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.cpp @@ -0,0 +1,48 @@ +// $Id$ + +#include "RT_ProxySupplier.h" + +#include "ace/Refcounted_Auto_Ptr.h" +#include "tao/debug.h" +#include "RT_Properties.h" +#include "Event.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 "RT_ProxySupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RT_ProxySupplier, "$Id$") + +TAO_NS_RT_ProxySupplier::TAO_NS_RT_ProxySupplier (void) +{ +} + +TAO_NS_RT_ProxySupplier::~TAO_NS_RT_ProxySupplier () +{ +} + +void +TAO_NS_RT_ProxySupplier::init (TAO_NS_ConsumerAdmin* consumer_admin ACE_ENV_SINGLE_ARG_DECL) +{ + // Obtain our ref. + CORBA::Object_var obj = this->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->event_forwarder_ = Notify_Internal::Event_Forwarder::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RT_ProxySupplier::push (TAO_NS_Event_var &event) +{ + event->push (this->event_forwarder_.in () ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RT_ProxySupplier::push_no_filtering (TAO_NS_Event_var &event) +{ + event->push_no_filtering (this->event_forwarder_.in () ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.h new file mode 100644 index 00000000000..0969e4ad403 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.h @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ +/** + * @file RT_ProxySupplier.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_PROXYSUPPLIER_H +#define TAO_NS_RT_PROXYSUPPLIER_H +#include "ace/pre.h" + +#include "rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ProxySupplier.h" + +/** + * @class TAO_NS_RT_ProxySupplier + * + * @brief ProxySupplier implementation for RT aware Suppliers. + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_ProxySupplier : public virtual TAO_NS_ProxySupplier +{ +public: + /// Constuctor + TAO_NS_RT_ProxySupplier (void); + + /// Destructor + virtual ~TAO_NS_RT_ProxySupplier (); + + /// Init + virtual void init (TAO_NS_ConsumerAdmin* consumer_admin ACE_ENV_ARG_DECL); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + 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_; +}; + +#if defined (__ACE_INLINE__) +#include "RT_ProxySupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_PROXYSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.inl new file mode 100644 index 00000000000..d012e5d0036 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_ProxySupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RTCORBA_ProxySupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp new file mode 100644 index 00000000000..705ebf295f9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp @@ -0,0 +1,54 @@ +// $Id$ + +#include "Reactive_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Reactive_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Reactive_Task, "$Id$") + +#include "Timer_Reactor.h" + +TAO_NS_Reactive_Task::TAO_NS_Reactive_Task (void) + :timer_ (0) +{ +} + +TAO_NS_Reactive_Task::~TAO_NS_Reactive_Task () +{ +} + +void +TAO_NS_Reactive_Task::init (TAO_NS_AdminProperties_var& /*admin_properties*/ ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->timer_, + TAO_NS_Timer_Reactor (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Reactive_Task::release (void) +{ + this->timer_->_decr_refcnt (); + delete this; //TODO: Release via factory. +} + +void +TAO_NS_Reactive_Task::shutdown (void) +{ +} + +void +TAO_NS_Reactive_Task::exec (TAO_NS_Method_Request& method_request) +{ + ACE_DECLARE_NEW_CORBA_ENV; + method_request.execute (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +TAO_NS_Timer* +TAO_NS_Reactive_Task::timer (void) +{ + this->timer_->_incr_refcnt (); + return this->timer_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h new file mode 100644 index 00000000000..8b1d7e7dbea --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +/** + * @file Reactive_Task.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_REACTIVE_TASK_H +#define TAO_NS_REACTIVE_TASK_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Worker_Task.h" +#include "AdminProperties.h" +#include "Destroy_Callback.h" + +class TAO_NS_Timer_Reactor; + +/** + * @class TAO_NS_Reactive_Task + * + * @brief A reactive worker task. Simply executes the command in the caller's context. + * + */ +class TAO_Notify_Export TAO_NS_Reactive_Task : public TAO_NS_Worker_Task, public TAO_NS_Destroy_Callback +{ +public: + /// Constuctor + TAO_NS_Reactive_Task (void); + + /// Destructor + ~TAO_NS_Reactive_Task (); + + /// Release + virtual void release (void); + + /// Init the reactive task. + void init (TAO_NS_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL); + + /// Shutdown task + virtual void shutdown (void); + + /// Exec the request. + virtual void exec (TAO_NS_Method_Request& method_request); + + /// The object used by clients to register timers. This method returns a Reactor based Timer. + virtual TAO_NS_Timer* timer (void); + + /// Returns NULL. + virtual TAO_NS_Buffering_Strategy* buffering_strategy (void); + +protected: + /// The timer. + TAO_NS_Timer_Reactor* timer_; +}; + +#if defined (__ACE_INLINE__) +#include "Reactive_Task.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_REACTIVE_TASK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl new file mode 100644 index 00000000000..348e107c4ad --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE TAO_NS_Buffering_Strategy* +TAO_NS_Reactive_Task::buffering_strategy (void) +{ + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp new file mode 100644 index 00000000000..a5c277a611d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp @@ -0,0 +1,51 @@ +// $Id$ + +#include "Refcountable.h" +#include "tao/debug.h" +#include "ace/Log_Msg.h" + +#if ! defined (__ACE_INLINE__) +#include "Refcountable.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Refcountable, "$Id$") + +TAO_NS_Refcountable::TAO_NS_Refcountable (void) + :refcount_ (1) +{ +} + +TAO_NS_Refcountable::~TAO_NS_Refcountable () +{ +} + +CORBA::ULong +TAO_NS_Refcountable::_incr_refcnt (void) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + + if (TAO_debug_level > 1 ) + ACE_DEBUG ((LM_DEBUG,"object:%x incr refcount = %d\n", this, refcount_+1 )); + + + return this->refcount_++; +} + +CORBA::ULong +TAO_NS_Refcountable::_decr_refcnt (void) +{ + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + + if (TAO_debug_level > 1 ) + ACE_DEBUG ((LM_DEBUG,"object:%x decr refcount = %d\n", this, refcount_-1 )); + + this->refcount_--; + if (this->refcount_ != 0) + return this->refcount_; + } + + this->release (); + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h new file mode 100644 index 00000000000..77a45cd16fa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +/** + * @file Refcountable.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_REFCOUNTABLE_H +#define TAO_NS_REFCOUNTABLE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Synch_T.h" +#include "tao/orbconf.h" +#include "tao/corbafwd.h" + +/** + * @class TAO_NS_Refcountable + * + * @brief Thread-safe refounting, calls the method when refcount falls to 0. + * + */ +class TAO_Notify_Export TAO_NS_Refcountable +{ +public: + /// Constuctor + TAO_NS_Refcountable (void); + + /// Destructor + virtual ~TAO_NS_Refcountable (); + + /// This method sigantures deliberately match the RefCounting methods required for ESF Proxy + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + + /// The release method is called when the refcount reaches 0. + virtual void release (void) = 0; + +protected: + /// The reference count. + CORBA::ULong refcount_; + + /// The mutex to serialize access to state variables. + TAO_SYNCH_MUTEX lock_; +}; + +/***********************************************************************/ + +/** + * @class TAO_NS_Refcountable_Guard + * + * @brief Ref. Count Guard + * Increments the reference count in the constructor, the count is decremented when the guard's is destructor. + * + */ +class TAO_Notify_Export TAO_NS_Refcountable_Guard +{ +public: + TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable); + + ~TAO_NS_Refcountable_Guard (); + +protected: + TAO_NS_Refcountable& refcountable_; +}; + +#if defined (__ACE_INLINE__) +#include "Refcountable.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_REFCOUNTABLE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl new file mode 100644 index 00000000000..be75f075cd8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl @@ -0,0 +1,14 @@ +// $Id$ + +ACE_INLINE +TAO_NS_Refcountable_Guard::TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable) + :refcountable_ (refcountable) +{ + this->refcountable_._incr_refcnt (); +} + +ACE_INLINE +TAO_NS_Refcountable_Guard::~TAO_NS_Refcountable_Guard () +{ + this->refcountable_._decr_refcnt (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.cpp new file mode 100644 index 00000000000..d6a9d03f7f2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.cpp @@ -0,0 +1,37 @@ +// $Id$ + +#ifndef TAO_NS_SEQ_WORKER_T_CPP +#define TAO_NS_SEQ_WORKER_T_CPP + +#include "Seq_Worker_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Seq_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Seq_Worker_T, "$id$") + +template +TAO_NS_Seq_Worker_T::TAO_NS_Seq_Worker_T (void) +{ +} + +template TAO_NS_Seq_Worker_T::SEQ* +TAO_NS_Seq_Worker_T::create (CONTAINER &container ACE_ENV_ARG_DECL) +{ + SEQ* tmp; + ACE_NEW_THROW_EX (tmp, //this->seq_, + SEQ (), + CORBA::INTERNAL ()); + + this->seq_ = tmp; + + container.collection ()->for_each (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->seq_._retn (); + +} + +#endif /* TAO_NS_SEQ_WORKER_T_CPP */ + diff --git a/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.h b/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.h new file mode 100644 index 00000000000..c4cb69c2f6d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.h @@ -0,0 +1,68 @@ +/* -*- C++ -*- */ +/** + * @file Seq_Worker_T.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_SEQ_WORKER_T_H +#define TAO_NS_SEQ_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 "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "orbsvcs/ESF/ESF_Worker.h" +#include "Container_T.h" + +/** + * @class TAO_NS_Seq_Worker_T + * + * @brief Helper to construct a sequence of IDS in a collections. + * + */ +template +class TAO_Notify_Export TAO_NS_Seq_Worker_T : public TAO_ESF_Worker +{ + typedef TAO_NS_Container_T CONTAINER; + typedef TAO_ESF_Proxy_Collection COLLECTION; + typedef typename TYPE::SEQ SEQ; + typedef typename TYPE::SEQ_VAR SEQ_VAR; + +public: + /// Constructor + TAO_NS_Seq_Worker_T (void); + + /// create a SEQ + SEQ* create (CONTAINER& container ACE_ENV_ARG_DECL); + +protected: + ///= TAO_ESF_Worker method + void work (TYPE* object ACE_ENV_ARG_DECL); + + /// The result + SEQ_VAR seq_; +}; + +#if defined (__ACE_INLINE__) +#include "Seq_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Seq_Worker_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Seq_Worker_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_SEQ_WORKER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.inl new file mode 100644 index 00000000000..97489c1811e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Seq_Worker_T.inl @@ -0,0 +1,9 @@ +// $Id$ + +template ACE_INLINE void +TAO_NS_Seq_Worker_T::work (TYPE* type ACE_ENV_ARG_DECL_NOT_USED) +{ + this->seq_->length (this->seq_->length () + 1); + + this->seq_[this->seq_->length () - 1] = type->id (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Service.h b/TAO/orbsvcs/orbsvcs/Notify/Service.h new file mode 100644 index 00000000000..d10636f5b12 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Service.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ +/** + * @file Service.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_SERVICE_H +#define TAO_NS_SERVICE_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" +#include "ace/Service_Config.h" +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "tao/PortableServer/PortableServer.h" + +/** + * @class TAO_NS_Service + * + * @brief Abstract ACE_Service_Object interface that is a + * factory for creating a Notify EventChannelFactory. + * Note that a Service creates only 1 Factory object. + * + */ +class TAO_Notify_Export TAO_NS_Service : public ACE_Service_Object +{ +public: + /// Define Service_Object method otherwise SunCC compiler complains. + virtual int init (int argc, char *argv[]) = 0; + + /// Init the service. + virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) = 0; + + /// Create the Channel Factory. + virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create ( + PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL + ) = 0; +}; + +#define TAO_NOTIFY_DEF_EMO_FACTORY_NAME "Notify_Default_Event_Manager_Objects_Factory" + +#define TAO_NS_NOTIFICATION_SERVICE_NAME "TAO_NS_Service" + +#define TAO_NS_COS_NOTIFICATION_SERVICE_NAME "TAO_NS_CosNotify_Service" + +#define TAO_NS_RT_NOTIFICATION_SERVICE_NAME "TAO_NS_RT_Notify_Service" + +#include "ace/post.h" +#endif /* TAO_NS_SERVICE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp new file mode 100644 index 00000000000..4d15210ad6c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp @@ -0,0 +1,44 @@ +// $Id$ + +#include "RT_StructuredProxyPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "RT_StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_RT_StructuredProxyPushSupplier, "$id$") + +TAO_NS_RT_StructuredProxyPushSupplier::TAO_NS_RT_StructuredProxyPushSupplier (void) +{ +} + +TAO_NS_RT_StructuredProxyPushSupplier::~TAO_NS_RT_StructuredProxyPushSupplier () +{ +} + +CORBA::Object_ptr +TAO_NS_RT_StructuredProxyPushSupplier::activate (PortableServer::Servant servant ACE_ENV_ARG_DECL) +{ + CORBA::Object_var object = TAO_NS_Object::activate (servant ACE_ENV_ARG_DECL); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + // Obtain our ref. + CORBA::Object_var obj = this->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + this->event_forwarder_ = Event_Forwarder::StructuredProxyPushSupplier::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + + return object._retn (); +} + +void +TAO_NS_RT_StructuredProxyPushSupplier::push (const TAO_NS_Event_var &event) +{ + event->push (this->event_forwarder_.in () ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RT_StructuredProxyPushSupplier::push_no_filtering (const TAO_NS_Event_var &event) +{ + event->push_no_filtering (this->event_forwarder_.in () ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h new file mode 100644 index 00000000000..a183a8193c7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h @@ -0,0 +1,58 @@ +/* -*- C++ -*- */ +/** + * @file RT_StructuredProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_RT_STRUCTUREDPROXYPUSHSUPPLIER_H +#define TAO_NS_RT_STRUCTUREDPROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "StructuredProxyPushSupplier.h" + +/** + * @class TAO_NS_RT_StructuredProxyPushSupplier + * + * @brief + * + */ +class TAO_RT_Notify_Export TAO_NS_RT_StructuredProxyPushSupplier : public virtual TAO_NS_StructuredProxyPushSupplier +{ +public: + /// Constuctor + TAO_NS_RT_StructuredProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_RT_StructuredProxyPushSupplier (); + + /// Activate this object and obtain the Event_Forwarder interface. + virtual CORBA::Object_ptr activate (PortableServer::Servant servant ACE_ENV_ARG_DECL); + + /// Override TAO_NS_ProxySupplier::push + virtual void push (const TAO_NS_Event_var &event); + + /// Dispatch Event to consumer, no filtering + virtual void push_no_filtering (const TAO_NS_Event_var &event); + +private: + /// Our ref. + Event_Forwarder::StructuredProxyPushSupplier_var event_forwarder_; +}; + +#if defined (__ACE_INLINE__) +#include "RT_StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RT_STRUCTUREDPROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.inl new file mode 100644 index 00000000000..2387811a56a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RT_StructuredProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp new file mode 100644 index 00000000000..f971a8eb1d9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp @@ -0,0 +1,93 @@ +// $Id$ + +#include "StructuredEvent.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredEvent.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredEvent, "$Id$") + +#include "../PropertySeq.h" +#include "../Consumer.h" +#include "tao/debug.h" + +TAO_NS_StructuredEvent::TAO_NS_StructuredEvent (const CosNotification::StructuredEvent ¬ification) + : notification_ (notification), type_ (notification.header.fixed_header.event_type) +{ + TAO_NS_PropertySeq qos; + + if (qos.init (this->notification_.header.variable_header) != -1) + { + this->priority_.set (qos); + this->timeout_.set (qos); + } +} + +const TAO_NS_EventType& +TAO_NS_StructuredEvent::type (void) const +{ + return this->type_; +} + +TAO_NS_StructuredEvent::~TAO_NS_StructuredEvent () +{ +} + +CORBA::Boolean +TAO_NS_StructuredEvent::do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "TAO_Notify_StructuredEvent::do_match ()\n")); + + return filter->match_structured (this->notification_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::convert (CosNotification::StructuredEvent& notification) +{ + notification = this->notification_; +} + +void +TAO_NS_StructuredEvent::push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "TAO_Notify_StructuredEvent::do_push (" + "CosNotifyComm::StructuredPushConsumer_ptr)\n")); + + consumer->push (notification_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + forwarder->forward_structured (notification_ ACE_ENV_ARG_PARAMETER); +} +void +TAO_NS_StructuredEvent::push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + forwarder->forward_structured_no_filtering (notification_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + CORBA::Any any; + + TAO_NS_Event::translate (this->notification_, any); + + forwarder->forward_any (any ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + CORBA::Any any; + + TAO_NS_Event::translate (this->notification_, any); + + forwarder->forward_any_no_filtering (any ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h new file mode 100644 index 00000000000..5cf88887188 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h @@ -0,0 +1,77 @@ +/* -*- C++ -*- */ +/** + * @file StructuredEvent.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ +#ifndef TAO_NS_STRUCTUREDEVENT_H +#define TAO_NS_STRUCTUREDEVENT_H + +#include "ace/pre.h" +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "../Event.h" +#include "../EventType.h" +#include "orbsvcs/CosNotificationC.h" + +/** + * @class TAO_NS_StructuredEvent + * + * @brief StructuredEvent implementation. + * + */ + +class TAO_Notify_Export TAO_NS_StructuredEvent : public TAO_NS_Event +{ +public: + /// Constuctor + TAO_NS_StructuredEvent (const CosNotification::StructuredEvent& notification); + + /// Destructor + ~TAO_NS_StructuredEvent (); + + CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL); + + /// Convert to CosNotification::Structured type + virtual void convert (CosNotification::StructuredEvent& notification); + + /// Get the event type. + virtual const TAO_NS_EventType& type (void) const; + + /// Push event to consumer + virtual void push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const; + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + +protected: + /// Structured Event + CosNotification::StructuredEvent notification_; + + /// Our type. + const TAO_NS_EventType type_; +}; + +#if defined (__ACE_INLINE__) +#include "StructuredEvent.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDEVENT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl new file mode 100644 index 00000000000..f92715e126c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl @@ -0,0 +1,4 @@ +// $Id$ + +#include "StructuredEvent.h" + diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp new file mode 100644 index 00000000000..858f2f518ef --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp @@ -0,0 +1,107 @@ +// $Id$ + +#include "StructuredProxyPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredProxyPushConsumer, "$Id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Auto_Ptr.h" +#include "tao/debug.h" +#include "StructuredPushSupplier.h" +#include "StructuredEvent.h" +#include "../AdminProperties.h" + +TAO_NS_StructuredProxyPushConsumer::TAO_NS_StructuredProxyPushConsumer (void) +{ +} + +TAO_NS_StructuredProxyPushConsumer::~TAO_NS_StructuredProxyPushConsumer () +{ +} + +void +TAO_NS_StructuredProxyPushConsumer::release (void) +{ + if (this->supplier_) + this->supplier_->release (); + + delete this; + //@@ inform factory +} + +void +TAO_NS_StructuredProxyPushConsumer::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_StructuredProxyPushConsumer::destroy \n")); + + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_StructuredProxyPushConsumer::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_STRUCTURED; +} + +void +TAO_NS_StructuredProxyPushConsumer::connect_structured_push_supplier (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + // Convert Supplier to Base Type + TAO_NS_StructuredPushSupplier * supplier; + ACE_NEW_THROW_EX (supplier, + TAO_NS_StructuredPushSupplier (this), + CORBA::NO_MEMORY ()); + + supplier->init (push_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredProxyPushConsumer::push_structured_event (const CosNotification::StructuredEvent & notification ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventComm::Disconnected + )) +{ + // Check if we should proceed at all. + if (this->admin_properties_->reject_new_events () == 1 + && this->admin_properties_->queue_full ()) + ACE_THROW (CORBA::IMP_LIMIT ()); + + if (this->is_connected () == 0) + { + ACE_THROW (CosEventComm::Disconnected ()); + } + + // Convert + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + // Continue processing. + this->push (event); +} + +void +TAO_NS_StructuredProxyPushConsumer::disconnect_structured_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h new file mode 100644 index 00000000000..70ddb535673 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +/** + * @file StructuredProxyPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPROXYPUSHCONSUMER_H +#define TAO_NS_STRUCTUREDPROXYPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "../ProxyConsumer_T.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_NS_StructuredProxyPushConsumer + * + * @brief CosNotifyChannelAdmin::StructuredProxyPushConsumer implementation. + * + */ +class TAO_Notify_Export TAO_NS_StructuredProxyPushConsumer : public virtual TAO_NS_ProxyConsumer_T +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_StructuredProxyPushConsumer (void); + + /// Destructor + ~TAO_NS_StructuredProxyPushConsumer (); + + /// Release + virtual void release (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + +protected: + + // = interface methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_structured_push_supplier ( + CosNotifyComm::StructuredPushSupplier_ptr push_supplier + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected + )); + +virtual void push_structured_event ( + const CosNotification::StructuredEvent & notification + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventComm::Disconnected + )); + + virtual void disconnect_structured_push_consumer ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "StructuredProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPROXYPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl new file mode 100644 index 00000000000..0ae697976e7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredProxyPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp new file mode 100644 index 00000000000..4072b24f681 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp @@ -0,0 +1,82 @@ +// $Id$ + +#include "StructuredProxyPushSupplier.h" +#include "tao/PortableServer/Servant_Base.h" +#include "tao/debug.h" + +#include "StructuredPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredProxyPushSupplier, "$Id$") + +TAO_NS_StructuredProxyPushSupplier::TAO_NS_StructuredProxyPushSupplier (void) +{ +} + +TAO_NS_StructuredProxyPushSupplier::~TAO_NS_StructuredProxyPushSupplier () +{ +} + +void +TAO_NS_StructuredProxyPushSupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_StructuredProxyPushConsumer::destroy \n")); + + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; +} + +void +TAO_NS_StructuredProxyPushSupplier::release (void) +{ + if (this->consumer_) + this->consumer_->release (); + + delete this; + //@@ inform factory +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_StructuredProxyPushSupplier::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_STRUCTURED; +} + +void +TAO_NS_StructuredProxyPushSupplier::connect_structured_push_consumer (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + , CosEventChannelAdmin::TypeError + )) +{ + // Convert Consumer to Base Type + TAO_NS_StructuredPushConsumer* consumer; + ACE_NEW_THROW_EX (consumer, + TAO_NS_StructuredPushConsumer (this), + CORBA::NO_MEMORY ()); + + consumer->init (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredProxyPushSupplier::disconnect_structured_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h new file mode 100644 index 00000000000..922122dc849 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +/** + * @file StructuredProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPROXYPUSHSUPPLIER_H +#define TAO_NS_STRUCTUREDPROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/Event_ForwarderS.h" +#include "../ProxySupplier_T.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT +template class TAO_Notify_Export +TAO_NS_ProxySupplier_T; +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ + +/** + * @class TAO_NS_StructuredProxyPushSupplier + * + * @brief Implements the CosNotifyChannelAdmin::StructuredProxyPushSupplier methods. + * + * + */ +class TAO_Notify_Export TAO_NS_StructuredProxyPushSupplier : public virtual TAO_NS_ProxySupplier_T +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_StructuredProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_StructuredProxyPushSupplier (); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// Release + virtual void release (void); + + /// = Servant methods + // = interface methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_structured_push_consumer ( + CosNotifyComm::StructuredPushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )); + + virtual void disconnect_structured_push_supplier ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl new file mode 100644 index 00000000000..1e0efbafba2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp new file mode 100644 index 00000000000..e868de67b00 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp @@ -0,0 +1,57 @@ +// $Id$ +#include "StructuredPushConsumer.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "../Event.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredPushConsumer, "$Id$") + +TAO_NS_StructuredPushConsumer::TAO_NS_StructuredPushConsumer (TAO_NS_ProxySupplier* proxy) + :TAO_NS_Consumer (proxy) +{ +} + +TAO_NS_StructuredPushConsumer::~TAO_NS_StructuredPushConsumer () +{ +} + +void +TAO_NS_StructuredPushConsumer::init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL_NOT_USED) +{ + this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (push_consumer); + + this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer); + +} + +void +TAO_NS_StructuredPushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_StructuredPushConsumer::push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL) +{ + event->push (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredPushConsumer::push (const CORBA::Any& event ACE_ENV_ARG_DECL) +{ + CosNotification::StructuredEvent notification; + + TAO_NS_Event::translate (event, notification); + + this->push_consumer_->push_structured_event (notification ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredPushConsumer::push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) +{ + this->push_consumer_->push_structured_event (event ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h new file mode 100644 index 00000000000..28fb81439da --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h @@ -0,0 +1,67 @@ +/* -*- C++ -*- */ +/** + * @file StructuredPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPUSHCONSUMER_H +#define TAO_NS_STRUCTUREDPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Consumer.h" + +class TAO_NS_ProxySupplier; + +/** + * @class TAO_NS_StructuredPushConsumer + * + * @brief Wrapper for the StructuredPushConsumer that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_StructuredPushConsumer : public TAO_NS_Consumer +{ +public: + /// Constuctor + TAO_NS_StructuredPushConsumer (TAO_NS_ProxySupplier* proxy); + + /// Init the Consumer + void init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); + + /// Destructor + ~TAO_NS_StructuredPushConsumer (); + + /// Release + virtual void release (void); + + /// Push to this consumer. + void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); + + /// Push to this consumer. + virtual void push (const CORBA::Any& event ACE_ENV_ARG_DECL); + + /// Push to this consumer. + virtual void push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL); + +protected: + /// The Consumer + CosNotifyComm::StructuredPushConsumer_var push_consumer_; +}; + +#if defined (__ACE_INLINE__) +#include "StructuredPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl new file mode 100644 index 00000000000..24e952b7ae8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp new file mode 100644 index 00000000000..14bd28f93b1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp @@ -0,0 +1,33 @@ +// $Id$ + +#include "StructuredPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredPushSupplier, "$Id$") + +TAO_NS_StructuredPushSupplier::TAO_NS_StructuredPushSupplier (TAO_NS_ProxyConsumer* proxy) + :TAO_NS_Supplier (proxy) +{ +} + +TAO_NS_StructuredPushSupplier::~TAO_NS_StructuredPushSupplier () +{ +} + +void +TAO_NS_StructuredPushSupplier::init (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL_NOT_USED) +{ + this->push_supplier_ = CosNotifyComm::StructuredPushSupplier::_duplicate (push_supplier); + + this->subscribe_ = CosNotifyComm::NotifySubscribe::_duplicate (push_supplier); +} + +void +TAO_NS_StructuredPushSupplier::release (void) +{ + delete this; + //@@ inform factory +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h new file mode 100644 index 00000000000..6c9456befb7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h @@ -0,0 +1,58 @@ +/* -*- C++ -*- */ +/** + * @file StructuredPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPUSHSUPPLIER_H +#define TAO_NS_STRUCTUREDPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Supplier.h" + +class TAO_NS_ProxyConsumer; + +/** + * @class TAO_NS_StructuredPushSupplier + * + * @brief Wrapper for the StructuredPushSupplier that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_StructuredPushSupplier : public TAO_NS_Supplier +{ +public: + /// Constuctor + TAO_NS_StructuredPushSupplier (TAO_NS_ProxyConsumer* proxy); + + /// Destructor + ~TAO_NS_StructuredPushSupplier (); + + /// Init + void init (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); + + /// Release + virtual void release (void); + +protected: + /// The Supplier + CosNotifyComm::StructuredPushSupplier_var push_supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "StructuredPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl new file mode 100644 index 00000000000..12cb29daaef --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredPushSupplier.h" 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 + * + * + */ + +#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 +{ +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..cb6180d5d7a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl @@ -0,0 +1,9 @@ +// $Id$ + +#include "Proxy.h" + +ACE_INLINE void +TAO_NS_Subscription_Change_Worker::work (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + proxy->admin_types_changed (this->added_, this->removed_ ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp new file mode 100644 index 00000000000..f03f91207e2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp @@ -0,0 +1,35 @@ +// $Id$ + +#include "Supplier.h" + +#if ! defined (__ACE_INLINE__) +#include "Supplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Supplier, "$Id$") + +#include "ProxyConsumer.h" +#include "Proxy.h" + +TAO_NS_Supplier::TAO_NS_Supplier (TAO_NS_ProxyConsumer* proxy) + :proxy_ (proxy) +{ +} + +TAO_NS_Supplier::~TAO_NS_Supplier () +{ +} + +TAO_NS_Proxy* +TAO_NS_Supplier::proxy (void) +{ + return this->proxy_consumer (); +} + +void +TAO_NS_Supplier::dispatch_updates_i (const CosNotification::EventTypeSeq& added, const CosNotification::EventTypeSeq& removed + ACE_ENV_ARG_DECL) +{ + if (!CORBA::is_nil (this->subscribe_.in ())) + this->subscribe_->subscription_change (added, removed ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.h b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h new file mode 100644 index 00000000000..f24bddae07c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file Supplier.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_SUPPLIER_H +#define TAO_NS_SUPPLIER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Peer.h" + +#include "orbsvcs/CosNotifyCommC.h" +class TAO_NS_ProxyConsumer; + +/** + * @class TAO_NS_Supplier + * + * @brief Base Wrappers for Suppliers that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_Supplier : public TAO_NS_Peer +{ +public: + /// Constuctor + TAO_NS_Supplier (TAO_NS_ProxyConsumer* proxy); + + /// Destructor + ~TAO_NS_Supplier (); + + /// Access Specific Proxy. + TAO_NS_ProxyConsumer* proxy_consumer (void); + + /// Access Base Proxy. + virtual TAO_NS_Proxy* proxy (void); + +protected: + /// Dispatch updates implementation. + virtual void dispatch_updates_i (const CosNotification::EventTypeSeq& added, + const CosNotification::EventTypeSeq& removed + ACE_ENV_ARG_DECL); + + /// The proxy that we associate with. + TAO_NS_ProxyConsumer* proxy_; + + /// Interface that accepts subscription_changes + CosNotifyComm::NotifySubscribe_var subscribe_; +}; + +#if defined (__ACE_INLINE__) +#include "Supplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl new file mode 100644 index 00000000000..6df91e0fd9a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl @@ -0,0 +1,7 @@ +// $Id$ + +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 new file mode 100644 index 00000000000..a90e8a16e62 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp @@ -0,0 +1,300 @@ +// $Id$ + +#include "SupplierAdmin.h" + +#if ! defined (__ACE_INLINE__) +#include "SupplierAdmin.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_SupplierAdmin, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Builder.h" +#include "Proxy.h" +#include "EventChannel.h" +#include "Subscription_Change_Worker.h" +#include "Find_Worker_T.h" +#include "Seq_Worker_T.h" +#include "Properties.h" + +TAO_NS_SupplierAdmin::TAO_NS_SupplierAdmin (void) +{ +} + +TAO_NS_SupplierAdmin::~TAO_NS_SupplierAdmin () +{ +} + +void +TAO_NS_SupplierAdmin::init (TAO_NS_EventChannel *ec ACE_ENV_ARG_DECL) +{ + TAO_NS_Admin::init (ec); + + const CosNotification::QoSProperties &default_sa_qos = + TAO_NS_PROPERTIES::instance ()->default_supplier_admin_qos_properties (); + + this->set_qos (default_sa_qos ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SupplierAdmin::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_SupplierAdmin::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_SupplierAdmin::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_SupplierAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + if (this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) + return; + + ACE_CHECK; + + this->ec_->remove (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_SupplierAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +CosNotification::QoSProperties* +TAO_NS_SupplierAdmin::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_SupplierAdmin::obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype + , CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + return TAO_NS_PROPERTIES::instance()->builder()->build_proxy (this + , ctype + , proxy_id + ACE_ENV_ARG_PARAMETER); +} + +CosEventChannelAdmin::ProxyPushConsumer_ptr +TAO_NS_SupplierAdmin::obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return TAO_NS_PROPERTIES::instance()->builder()->build_proxy (this ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminID +TAO_NS_SupplierAdmin::MyID (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->id (); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_SupplierAdmin::MyChannel (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->ec_->_this (ACE_ENV_SINGLE_ARG_DECL); +} + +::CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_SupplierAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_operator_; +} + +CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_SupplierAdmin::push_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Seq_Worker_T seq_worker; + + return seq_worker.create (*this->proxy_container_ ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_SupplierAdmin::get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )) +{ + TAO_NS_Find_Worker_T find_worker; + + return find_worker.resolve (proxy_id, *this->proxy_container_ ACE_ENV_ARG_PARAMETER); +} + +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 + )) + +{ + 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->proxy_container_->collection ()->for_each (&worker ACE_ENV_ARG_PARAMETER); + } +} + +CosNotifyFilter::FilterID +TAO_NS_SupplierAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SupplierAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::Filter_ptr +TAO_NS_SupplierAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::FilterIDSeq* +TAO_NS_SupplierAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_SupplierAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->filter_admin_.remove_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +/************** UNIMPLEMENTED METHODS ***************/ + +CosEventChannelAdmin::ProxyPullConsumer_ptr +TAO_NS_SupplierAdmin::obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosEventChannelAdmin::ProxyPullConsumer::_nil ()); +} + +CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_SupplierAdmin::pull_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + +void +TAO_NS_SupplierAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_SupplierAdmin::obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType /*ctype*/, + CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyChannelAdmin::ProxyConsumer::_nil ()); +} + + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_Find_Worker_T; +template class TAO_NS_Find_Worker_T; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Find_Worker_T +#pragma instantiate TAO_NS_Find_Worker_T + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h new file mode 100644 index 00000000000..248c4335d6c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h @@ -0,0 +1,189 @@ +/* -*- C++ -*- */ +/** + * @file SupplierAdmin.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_SUPPLIERADMIN_H +#define TAO_NS_SUPPLIERADMIN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "Admin.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_NS_SupplierAdmin + * + * @brief Implementation of CosNotifyChannelAdmin::SupplierAdmin + * + */ +class TAO_Notify_Export TAO_NS_SupplierAdmin : public virtual POA_CosNotifyChannelAdmin::SupplierAdmin + , public virtual TAO_NS_Admin +{ +public: + /// Constuctor + TAO_NS_SupplierAdmin (void); + + /// Destructor + ~TAO_NS_SupplierAdmin (); + + /// Init + void init (TAO_NS_EventChannel *ec ACE_ENV_ARG_DECL); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Release + virtual void release (void); + +protected: + /// = CosNotifyChannelAdmin::SupplierAdmin methods + virtual CosNotifyChannelAdmin::AdminID MyID (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyConsumer_ptr get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )); + + virtual ::CosNotifyChannelAdmin::ProxyConsumer_ptr obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual ::CosNotifyChannelAdmin::ProxyConsumer_ptr obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotification::QoSProperties* get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos (const CosNotification::QoSProperties& qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void offer_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )); + + 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 + )); + + virtual ::CosEventChannelAdmin::ProxyPushConsumer_ptr obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPullConsumer_ptr obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "SupplierAdmin.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SUPPLIERADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier_Map.h b/TAO/orbsvcs/orbsvcs/Notify/Supplier_Map.h new file mode 100644 index 00000000000..9a1d8034548 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier_Map.h @@ -0,0 +1,35 @@ +/* -*- C++ -*- */ +/** + * @file Supplier_Map.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_SUPPLIER_MAP_H +#define TAO_NS_SUPPLIER_MAP_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Event_Map_T.h" +#include "ProxyConsumer.h" + +/** + * @class TAO_NS_Supplier_Map + * + * @brief The Event Map for Suppliers. + * + */ + +typedef TAO_NS_Event_Map_T TAO_NS_Supplier_Map; + +#include "ace/post.h" +#endif /* TAO_NS_SUPPLIER_MAP_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp new file mode 100644 index 00000000000..5829dd3348e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp @@ -0,0 +1,180 @@ +// $Id$ + +#include "ThreadPool_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "ThreadPool_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ThreadPool_Task, "$Id$") + +#include "tao/debug.h" +#include "Properties.h" +#include "Timer_Queue.h" + +TAO_NS_ThreadPool_Task::TAO_NS_ThreadPool_Task (void) + : buffering_strategy_ (0), shutdown_ (0), timer_ (0) +{ +} + +TAO_NS_ThreadPool_Task::~TAO_NS_ThreadPool_Task () +{ + delete this->buffering_strategy_; +} + +int +TAO_NS_ThreadPool_Task::init (int argc, char **argv) +{ + return this->ACE_Task::init (argc, argv); +} + +TAO_NS_Timer* +TAO_NS_ThreadPool_Task::timer (void) +{ + this->timer_->_incr_refcnt (); + + return this->timer_; +} + +void +TAO_NS_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, TAO_NS_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->timer_, + TAO_NS_Timer_Queue (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->buffering_strategy_, + TAO_NS_Buffering_Strategy (*msg_queue (), admin_properties, 1), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + long flags = THR_NEW_LWP | THR_JOINABLE; + + flags |= + TAO_NS_PROPERTIES::instance()->scope_policy () | + TAO_NS_PROPERTIES::instance()->sched_policy (); + + // Increment the count on this object by the number of threads using it. + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->TAO_NS_Refcountable::lock_); + + this->refcount_+=tp_params.static_threads; + } + + // Become an active object. + if (this->ACE_Task ::activate (flags, + tp_params.static_threads, + 0, + ACE_THR_PRI_OTHER_DEF) == -1) + { + // Decrement the count on this object. We know that this object's owner is holding a count on this object so + // we can neglect our responsibility of checking if the refcount is decremented to 0. + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->TAO_NS_Refcountable::lock_); + + this->refcount_-=tp_params.static_threads; + } + + 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 ()); + } +} + +void +TAO_NS_ThreadPool_Task::exec (TAO_NS_Method_Request& method_request) +{ + TAO_NS_Method_Request& request_copy = *method_request.copy (); + + if (this->buffering_strategy_->enqueue (request_copy) == -1) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "NS_ThreadPool_Task (%P|%t) - " + "failed to enqueue\n")); + } +} + +int +TAO_NS_ThreadPool_Task::svc (void) +{ + TAO_NS_Method_Request* method_request; + + while (!shutdown_) + { + ACE_TRY_NEW_ENV + { + ACE_Time_Value* dequeue_blocking_time = 0; + ACE_Time_Value earliest_time; + + if (!this->timer_->impl().is_empty ()) + { + earliest_time = this->timer_->impl().earliest_time (); + dequeue_blocking_time = &earliest_time; + } + + // Dequeue 1 item + int result = buffering_strategy_->dequeue (method_request, dequeue_blocking_time); + + if (result > 0) + { + method_request->execute (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Message_Block::release (method_request); + } + else if (errno == ETIME) + { + this->timer_->impl ().expire (); + } + else if (result == -1) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "ThreadPool_Task dequeue failed\n")); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ThreadPool_Task (%P|%t) exception in method request\n"); + } + ACE_ENDTRY; + } /* while */ + + return 0; +} + +void +TAO_NS_ThreadPool_Task::shutdown (void) +{ + this->shutdown_ = 1; + + this->buffering_strategy_->shutdown (); + + return; +} + +void +TAO_NS_ThreadPool_Task::release (void) +{ + this->timer_->_decr_refcnt (); + + delete this; +} + +int +TAO_NS_ThreadPool_Task::close (u_long /*flags*/) +{ + this->_decr_refcnt (); + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h new file mode 100644 index 00000000000..256e45c54fd --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h @@ -0,0 +1,95 @@ +/* -*- C++ -*- */ +/** + * @file ThreadPool_Task.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_THREADPOOL_TASK_H +#define TAO_NS_THREADPOOL_TASK_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Task.h" +#include "ace/Message_Queue.h" +#include "ace/Reactor.h" +#include "AdminProperties.h" +#include "Worker_Task.h" +#include "Destroy_Callback.h" + +class TAO_NS_Buffering_Strategy; +class TAO_NS_Timer_Queue; + +/** + * @class TAO_NS_ThreadPool_Task + * + * @brief Implements a Thread Pool Worker Task. + * + */ +class TAO_Notify_Export TAO_NS_ThreadPool_Task : public TAO_NS_Worker_Task, ACE_Task, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Method_Request_Shutdown; + +public: + /// Constuctor + TAO_NS_ThreadPool_Task (void); + + /// Destructor + ~TAO_NS_ThreadPool_Task (); + + /// Call the base class init + virtual int init (int argc, char **argv); + + virtual int close (u_long flags); + + /// Release + virtual void release (void); + + /// Activate the threadpool + void init (const NotifyExt::ThreadPoolParams& tp_params, TAO_NS_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL); + + /// Queue the request + virtual void exec (TAO_NS_Method_Request& method_request); + + /// Shutdown task + virtual void shutdown (void); + + /// Update QoS Properties. + virtual void update_qos_properties (const TAO_NS_QoSProperties& qos_properties); + + /// The object used by clients to register timers. + virtual TAO_NS_Timer* timer (void); + + /// Access the Buffering Strategy. + TAO_NS_Buffering_Strategy* buffering_strategy (void); + +protected: + /// task svc + virtual int svc (void); + +private: + /// The buffering strategy to use. + TAO_NS_Buffering_Strategy* buffering_strategy_; + + /// Shutdown + int shutdown_; + + /// The Queue based timer. + TAO_NS_Timer_Queue* timer_; +}; + +#if defined (__ACE_INLINE__) +#include "ThreadPool_Task.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_THREADPOOL_TASK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl new file mode 100644 index 00000000000..27f363d90ce --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl @@ -0,0 +1,15 @@ +// $Id$ + +#include "Buffering_Strategy.h" + +ACE_INLINE void +TAO_NS_ThreadPool_Task::update_qos_properties (const TAO_NS_QoSProperties& qos_properties) +{ + this->buffering_strategy_->update_qos_properties (qos_properties); +} + +ACE_INLINE TAO_NS_Buffering_Strategy* +TAO_NS_ThreadPool_Task::buffering_strategy (void) +{ + return this->buffering_strategy_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer.h b/TAO/orbsvcs/orbsvcs/Notify/Timer.h new file mode 100644 index 00000000000..84423f943d6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer.h @@ -0,0 +1,49 @@ +/* -*- C++ -*- */ +/** + * @file Timer.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_TIMER_H +#define TAO_NS_TIMER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Time_Value.h" +#include "Refcountable.h" + +class ACE_Event_Handler; + +/** + * @class TAO_NS_Timer + * + * @brief Interface for scheduling timers. + * + */ +class TAO_Notify_Export TAO_NS_Timer : public TAO_NS_Refcountable +{ +public: + /// Destructor + virtual ~TAO_NS_Timer (){}; + + /// Schedule a timer + virtual long schedule_timer (ACE_Event_Handler *handler, + const ACE_Time_Value &delay_time, + const ACE_Time_Value &interval) = 0; + + /// Cancel Timer + virtual int cancel_timer (long timer_id) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_TIMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.cpp b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.cpp new file mode 100644 index 00000000000..aa80ab73163 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#include "Timer_Queue.h" + +#if ! defined (__ACE_INLINE__) +#include "Timer_Queue.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Timer_Queue, "$id$") + +TAO_NS_Timer_Queue::TAO_NS_Timer_Queue (void) +{ +} + +TAO_NS_Timer_Queue::~TAO_NS_Timer_Queue () +{ +} + +void +TAO_NS_Timer_Queue::release (void) +{ + delete this; + //@@ inform factory +} + +long +TAO_NS_Timer_Queue::schedule_timer (ACE_Event_Handler *handler, + const ACE_Time_Value &delay_time, + const ACE_Time_Value &interval) +{ + return this->timer_queue_.schedule (handler, + 0, + timer_queue_.gettimeofday () + delay_time, + interval); +} + +int +TAO_NS_Timer_Queue::cancel_timer (long timer_id) +{ + return this->timer_queue_.cancel (timer_id); +} + +ACE_Timer_Queue& +TAO_NS_Timer_Queue::impl (void) +{ + return this->timer_queue_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h new file mode 100644 index 00000000000..52dea61911b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file Timer_Queue.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_TIMER_QUEUE_H +#define TAO_NS_TIMER_QUEUE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Timer.h" + +#include "ace/Timer_Queue.h" +#include "ace/Timer_Heap.h" + +/** + * @class TAO_NS_Timer_Queue + * + * @brief ACE_Timer_Queue based timer. + * + */ +class TAO_Notify_Export TAO_NS_Timer_Queue : public TAO_NS_Timer +{ +public: + /// Constuctor + TAO_NS_Timer_Queue (void); + + /// Destructor + virtual ~TAO_NS_Timer_Queue (); + + /// Release + virtual void release (void); + + /// Schedule a timer + virtual long schedule_timer (ACE_Event_Handler *handler, + const ACE_Time_Value &delay_time, + const ACE_Time_Value &interval); + + /// Cancel Timer + virtual int cancel_timer (long timer_id); + + /// Get the native impl. + ACE_Timer_Queue& impl (void); + +protected: + /// The Timer Queue + ACE_Timer_Heap timer_queue_; +}; + +#if defined (__ACE_INLINE__) +#include "Timer_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_TIMER_QUEUE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.inl b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.inl new file mode 100644 index 00000000000..eeaf18f3e5f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "Timer_Queue.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.cpp b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.cpp new file mode 100644 index 00000000000..41709be90df --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#include "Timer_Reactor.h" + +#if ! defined (__ACE_INLINE__) +#include "Timer_Reactor.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Timer_Reactor, "$id$") + +#include "ace/Reactor.h" +#include "tao/ORB_Core.h" +#include "Properties.h" + +TAO_NS_Timer_Reactor::TAO_NS_Timer_Reactor (void) + :reactor_ (0) +{ + // Get the ORB + CORBA::ORB_var orb = TAO_NS_PROPERTIES::instance()->orb (); + + this->reactor_ = orb->orb_core ()->reactor (); +} + +TAO_NS_Timer_Reactor::~TAO_NS_Timer_Reactor () +{ +} + +void +TAO_NS_Timer_Reactor::release (void) +{ + delete this; + //@@ inform factory +} + +long +TAO_NS_Timer_Reactor::schedule_timer (ACE_Event_Handler *handler, + const ACE_Time_Value &delay_time, + const ACE_Time_Value &interval) +{ + return this->reactor_->schedule_timer (handler, 0, delay_time, interval); +} + +int +TAO_NS_Timer_Reactor::cancel_timer (long timer_id) +{ + return this->reactor_->cancel_timer (timer_id); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h new file mode 100644 index 00000000000..67953bb5576 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +/** + * @file Timer_Reactor.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_TIMER_REACTOR_H +#define TAO_NS_TIMER_REACTOR_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Timer.h" + +class ACE_Reactor; + +/** + * @class TAO_NS_Timer_Reactor + * + * @brief Reactor::instance based timer. The timers are dispatched by the main thread. + * + */ +class TAO_Notify_Export TAO_NS_Timer_Reactor : public TAO_NS_Timer +{ +public: + /// Constuctor + TAO_NS_Timer_Reactor (void); + + /// Destructor + virtual ~TAO_NS_Timer_Reactor (); + + /// Release + virtual void release (void); + + /// Schedule a timer + virtual long schedule_timer (ACE_Event_Handler *handler, + const ACE_Time_Value &delay_time, + const ACE_Time_Value &interval); + + /// Cancel Timer + virtual int cancel_timer (long timer_id); + +protected: + /// The instance reactor that we use. + ACE_Reactor* reactor_; +}; + +#if defined (__ACE_INLINE__) +#include "Timer_Reactor.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_TIMER_REACTOR_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.inl b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.inl new file mode 100644 index 00000000000..ba9c8b4cae1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "Timer_Reactor.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp new file mode 100644 index 00000000000..ae9f9efab55 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp @@ -0,0 +1,22 @@ +// $Id$ + +#include "Worker_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Worker_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Worker_Task, "$Id$") + +TAO_NS_Worker_Task::TAO_NS_Worker_Task (void) +{ +} + +TAO_NS_Worker_Task::~TAO_NS_Worker_Task () +{ +} + +void +TAO_NS_Worker_Task::update_qos_properties (const TAO_NS_QoSProperties& /*qos_properties*/) +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h new file mode 100644 index 00000000000..2eef3710451 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h @@ -0,0 +1,70 @@ +/* -*- C++ -*- */ +/** + * @file Worker_Task.h + * + * $Id$ + * + * @author Pradeep Gore + * + * + */ + +#ifndef TAO_NS_WORKER_TASK_H +#define TAO_NS_WORKER_TASK_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 "Refcountable.h" + +class TAO_NS_AdminProperties; +class TAO_NS_QoSProperties; +class TAO_NS_Timer; +class TAO_NS_Buffering_Strategy; + +/** + * @class TAO_NS_Worker_Task + * + * @brief Base Worker Task. + * + * Memory Management : The Worker Task should be allocated on the heap and + * the method should be called to release memory. + * + */ +class TAO_Notify_Export TAO_NS_Worker_Task : public TAO_NS_Refcountable +{ +public: + /// Constuctor + TAO_NS_Worker_Task (void); + + /// Update QoS Properties. + virtual void update_qos_properties (const TAO_NS_QoSProperties& qos_properties); + + ///= Public method to be implemented by subclasses. + /// Exec the request. + virtual void exec (TAO_NS_Method_Request& method_request) = 0; + + /// Shutdown task + virtual void shutdown (void) = 0; + + /// The object used by clients to register timers. + virtual TAO_NS_Timer* timer (void) = 0; + + virtual TAO_NS_Buffering_Strategy* buffering_strategy (void) = 0; + +protected: + /// Destructor + virtual ~TAO_NS_Worker_Task (); +}; + +#if defined (__ACE_INLINE__) +#include "Worker_Task.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_WORKER_TASK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/notify_export.h b/TAO/orbsvcs/orbsvcs/Notify/notify_export.h new file mode 100644 index 00000000000..d17be740d41 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/notify_export.h @@ -0,0 +1,40 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_NOTIFY_EXPORT_H +#define TAO_NOTIFY_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_NOTIFY_HAS_DLL) +# define TAO_NOTIFY_HAS_DLL 0 +# endif /* ! TAO_NOTIFY_HAS_DLL */ +#else +# if !defined (TAO_NOTIFY_HAS_DLL) +# define TAO_NOTIFY_HAS_DLL 1 +# endif /* ! TAO_NOTIFY_HAS_DLL */ +#endif + +#if defined (TAO_NOTIFY_HAS_DLL) && (TAO_NOTIFY_HAS_DLL == 1) +# if defined (TAO_NOTIFY_BUILD_DLL) +# define TAO_Notify_Export ACE_Proper_Export_Flag +# define TAO_NOTIFY_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_NOTIFY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_NOTIFY_BUILD_DLL */ +# define TAO_Notify_Export ACE_Proper_Import_Flag +# define TAO_NOTIFY_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_NOTIFY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_NOTIFY_BUILD_DLL */ +#else /* TAO_NOTIFY_HAS_DLL == 1 */ +# define TAO_Notify_Export +# define TAO_NOTIFY_SINGLETON_DECLARATION(T) +# define TAO_NOTIFY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_NOTIFY_HAS_DLL == 1 */ + +#endif /* TAO_NOTIFY_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/orbsvcs/orbsvcs/Notify/rt_notify_export.h b/TAO/orbsvcs/orbsvcs/Notify/rt_notify_export.h new file mode 100644 index 00000000000..288a67cb67f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/rt_notify_export.h @@ -0,0 +1,39 @@ +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_RT_NOTIFY_EXPORT_H +#define TAO_RT_NOTIFY_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_RT_NOTIFY_HAS_DLL) +# define TAO_RT_NOTIFY_HAS_DLL 0 +# endif /* ! TAO_RT_NOTIFY_HAS_DLL */ +#else +# if !defined (TAO_RT_NOTIFY_HAS_DLL) +# define TAO_RT_NOTIFY_HAS_DLL 1 +# endif /* ! TAO_RT_NOTIFY_HAS_DLL */ +#endif + +#if defined (TAO_RT_NOTIFY_HAS_DLL) && (TAO_RT_NOTIFY_HAS_DLL == 1) +# if defined (TAO_RT_NOTIFY_BUILD_DLL) +# define TAO_RT_Notify_Export ACE_Proper_Export_Flag +# define TAO_RT_NOTIFY_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_RT_NOTIFY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_RT_NOTIFY_BUILD_DLL */ +# define TAO_RT_Notify_Export ACE_Proper_Import_Flag +# define TAO_RT_NOTIFY_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_RT_NOTIFY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_RT_NOTIFY_BUILD_DLL */ +#else /* TAO_RT_NOTIFY_HAS_DLL == 1 */ +# define TAO_RT_Notify_Export +# define TAO_RT_NOTIFY_SINGLETON_DECLARATION(T) +# define TAO_RT_NOTIFY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_RT_NOTIFY_HAS_DLL == 1 */ + +#endif /* TAO_RT_NOTIFY_EXPORT_H */ + +// End of auto generated file. -- cgit v1.2.1