diff options
78 files changed, 5259 insertions, 242 deletions
diff --git a/ChangeLog b/ChangeLog index cca30def8aa..70731960b34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +Fri Aug 22 20:10:41 UTC 2003 Justin Michel <michel_j@ociweb.com> + + * ace/SSL/ssl.mpc + * apps/gperf/src/gperf.mpc + * bin/MakeProjectCreator/config/acedefaults.mpb + * bin/MakeProjectCreator/config/openssl.mpb + * bin/MakeProjectCreator/config/ssl.mpb + * bin/MakeProjectCreator/modules/ProjectCreator.pm + * bin/MakeProjectCreator/modules/VC6WorkspaceCreator.pm + * bin/MakeProjectCreator/modules/VC71WorkspaceCreator.pm + * bin/MakeProjectCreator/modules/VC7ProjectCreator.pm + * bin/MakeProjectCreator/modules/VC7WorkspaceCreator.pm + * bin/MakeProjectCreator/modules/WorkspaceCreator.pm + * bin/MakeProjectCreator/templates/bor.mpd + * bin/MakeProjectCreator/templates/vc7.mpd + + SSL now works in a more normal MPC feature fashion similar to all + the other feature-based libraries. I removed the hard-coded ssl logic + from some of the mpd files that still had it. A side-effect of the new + way, is that you must now define an SSL_ROOT environment variable + that the openssl.mpb feature will now use to locate the openssl libraries. + + There were some problems with the existing vc7.mpd template. + I've improved the template, and also added support for lots of new + settings in the corresponding .mpt files. (Although I haven't used them yet.) + I'll probably use this to enable some of the new features in vc71 that + help track down problems that typically only show up in release mode. + + The creation of workspaces for vc71 did not correctly set + dependencies between projects. + + I added an allow_duplicates() method to the WorkspaceCreator. + A warning will always be generated if a workspace contains duplicate + project names, and now the vc6/7/71 creators will abort creation of these + invalid workspaces. I suggest that any future WorkspaceCreator subclasses + that generate IDE projects, override allow_duplicates() to return 0. + + Renamed the gperf_exe to gperf. This was named as a special hack + for vc6 that is now unnecessary. We had already renamed other similar + projects, but missed this one. + Fri Aug 22 15:28:34 UTC 2003 Don Hinton <dhinton@dresystems.com> * ACE.mwc: diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 7a1634d1a3f..8b1f0c59cff 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,89 @@ +Fri Aug 22 20:10:41 UTC 2003 Justin Michel <michel_j@ociweb.com> + + * TAOACE.mwc + + Was picking up Kokyu tests directory. + + * TAO_IDL/tao_idl.mpc + + Renamed gperf_exe to gperf. We used to have a hack for vc6 that + required all exe projects to be named _exe. + + * orbsvcs/examples/Notify/Lanes/Lanes.mpc + * orbsvcs/examples/Notify/Lanes/Notify_Lanes.mpc + * orbsvcs/examples/Notify/ThreadPool/Notify_ThreadPool.mpc + * orbsvcs/examples/Notify/ThreadPool/ThreadPool.mpc + * orbsvcs/examples/RtEC/IIOPGateway/Gateway.mpc + * orbsvcs/examples/RtEC/IIOPGateway/RtEC_IIOPGateway.mpc + * orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/AVStreams_Simple_Two_Stage_With_QoS.mpc + * orbsvcs/tests/Security/Secure_Invocation/Secure_Invocation.mpc + * orbsvcs/tests/Security/SecurityLevel1/SecurityLevel1.mpc + + Fixes to mpc files to avoid duplicate names, and to use + inheritance to get base project info instead of hard-coding libs. + + * orbsvcs/CosEvent_Service/CosEvent_Service.cpp + * orbsvcs/examples/CosEC/TypedSimple/Consumer.cpp + * orbsvcs/examples/CosEC/TypedSimple/CosEC_TypedSimple.mpc + * orbsvcs/examples/CosEC/TypedSimple/Country.idl + * orbsvcs/examples/CosEC/TypedSimple/Country.idl.for_ifr + * orbsvcs/examples/CosEC/TypedSimple/Country_i.cpp + * orbsvcs/examples/CosEC/TypedSimple/Country_i.h + * orbsvcs/examples/CosEC/TypedSimple/README + * orbsvcs/examples/CosEC/TypedSimple/Supplier.cpp + * orbsvcs/orbsvcs/CosEvent.mpb + * orbsvcs/orbsvcs/CosEvent.mpc + * orbsvcs/orbsvcs/CosTypedEventChannelAdmin.idl + * orbsvcs/orbsvcs/CosTypedEventComm.idl + * orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.h + * orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.h + * orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.h + * orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.i + * orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.h + * orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.i + * orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.h + * orbsvcs/orbsvcs/CosEvent/CEC_Factory.h + * orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.h + * orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.h + * orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.i + * orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.h + * orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.h + * orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.i + * orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.h + * orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.h + * orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.i + * orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.h + * orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.i + * orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.h + * orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.i + * orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.h + * orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.i + * orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.cpp + * orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.h + * orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.i + + Added support for typed events to CosEvent. This was submitted by + Jonathan Astle <JNASTLE@qinetiq.com>. I modified the code to use mpc, and + added a new feature. Set ec_typed_event=0 to disable use of typed events. This + works by setting a macro which Jon used throughout the new code. There are actually + now two CosEvent projects in CosEvent.mpc. One uses the avoids keyword and the other + the requires keyword. This could be used as a pattern for similar situations. + + Fri Aug 22 15:58:41 UTC 2003 Don Hinton <dhinton@dresystems.com> * tests/ICMG_Any_Bug/Hello.mpc: diff --git a/TAO/TAOACE.mwc b/TAO/TAOACE.mwc index 27c0c0c9958..c5d195a670f 100644 --- a/TAO/TAOACE.mwc +++ b/TAO/TAOACE.mwc @@ -4,7 +4,7 @@ workspace { ../ACEXML/common ../ACEXML/parser/parser ../ACEXML/apps/svcconf - ../Kokyu + ../Kokyu/Kokyu.mpc tao TAO_IDL utils diff --git a/TAO/TAO_IDL/tao_idl.mpc b/TAO/TAO_IDL/tao_idl.mpc index 1701e371efd..2025d1e0e64 100644 --- a/TAO/TAO_IDL/tao_idl.mpc +++ b/TAO/TAO_IDL/tao_idl.mpc @@ -5,7 +5,7 @@ project(TAO_IDL_EXE) : aceexe, taoversion, core, tao_output { libs += TAO_IDL_BE TAO_IDL_FE includes += include be_include fe install = $(ACE_ROOT)/bin - after += TAO_IDL_BE TAO_IDL_FE gperf_exe + after += TAO_IDL_BE TAO_IDL_FE gperf idlpreprocessor = 1 Source_Files { diff --git a/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp b/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp index cbf898626be..7c7b2d891c3 100644 --- a/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp +++ b/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp @@ -45,9 +45,19 @@ ACE_TMAIN (int argc, ACE_TCHAR* argv[]) // to 1 by default or something like that... // Don't worry about this change yet... Let's get all the changes // in and then we can fix the EC shutdown problem... + // + // As inidicated above, The Typed EC implementation can now be + // destroyed by passing -d at the command line and + // calling destroy on the typed EC interface. + // Calling fini() completes the destruction, although most of + // this is done in TAO_CEC_TypedEventChannel::shutdown(). orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + event_service.fini(); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + // Destroy the ORB orb->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/Consumer.cpp b/TAO/orbsvcs/examples/CosEC/TypedSimple/Consumer.cpp new file mode 100644 index 00000000000..f4e00a5dbbb --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/Consumer.cpp @@ -0,0 +1,95 @@ +// $Id$ + +#include "orbsvcs/CosNamingC.h" +#include "orbsvcs/CosTypedEventChannelAdminC.h" +#include "Country_i.h" + +ACE_RCSID(CosEC_Examples, Consumer, "$Id:") + +int +main (int argc, char* argv[]) +{ + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + // ORB initialization... + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_obj = + orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + PortableServer::POA_var poa = + PortableServer::POA::_narrow (poa_obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + PortableServer::POAManager_var poa_manager = + poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Obtain the event channel using the Naming Service. + CORBA::Object_var nam_obj = + orb->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER ); + ACE_TRY_CHECK; + + CosNaming::NamingContext_var root_context = + CosNaming::NamingContext::_narrow(nam_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CosNaming::Name channel_name (1); + channel_name.length (1); + channel_name[0].id = CORBA::string_dup ("CountryEventChannel"); + + CORBA::Object_var ec_obj = + root_context->resolve(channel_name); + ACE_TRY_CHECK; + + // Downcast the object reference to a TypedEventChannel reference + CosTypedEventChannelAdmin::TypedEventChannel_var typed_event_channel = + CosTypedEventChannelAdmin::TypedEventChannel::_narrow(ec_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Initialise the Country Impl + Country_i country (orb.in ()); + Country_var typed_consumer = country._this(); + + // Connect to the typed channel + CosTypedEventChannelAdmin::TypedConsumerAdmin_var typed_consumer_admin = + typed_event_channel->for_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CosEventChannelAdmin::ProxyPushSupplier_var proxy_push_supplier = + typed_consumer_admin->obtain_typed_push_supplier ("IDL:jon.com/Country:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + proxy_push_supplier->connect_push_consumer (typed_consumer.in () ); + + // Wait for events. + ACE_DEBUG ((LM_DEBUG, "Waiting on orb->run for events...\n")); + orb->run (); + + ACE_DEBUG ((LM_DEBUG, "...ORB shutdown\n")); + + // Destroy the POA + poa->destroy (1, 0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Destroy the ORB + orb->destroy (); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "main"); + return 1; + } + ACE_ENDTRY; + return 0; +} + diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/CosEC_TypedSimple.mpc b/TAO/orbsvcs/examples/CosEC/TypedSimple/CosEC_TypedSimple.mpc new file mode 100644 index 00000000000..c37df08dc66 --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/CosEC_TypedSimple.mpc @@ -0,0 +1,12 @@ +project(*Consumer) : event, taoserver { + source_files { + Consumer.cpp + Country_i.cpp + } +} + +project(*Supplier) : event, taoserver { + source_files { + Supplier.cpp + } +}
\ No newline at end of file diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/Country.idl b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country.idl new file mode 100644 index 00000000000..77c68564272 --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country.idl @@ -0,0 +1,17 @@ +// $Id$ + +//IDL + +#ifndef TAO_COUNTRY_IDL +#define TAO_COUNTRY_IDL + +#include "orbsvcs/CosTypedEventComm.idl" +#pragma prefix "jon.com" + +interface Country : ::CosTypedEventComm::TypedPushConsumer +{ + void update_population (in string country, + in long population); +}; + +#endif /* TAO_COUNTRY_IDL */ diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/Country.idl.for_ifr b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country.idl.for_ifr new file mode 100644 index 00000000000..25f2545f2ee --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country.idl.for_ifr @@ -0,0 +1,17 @@ +// $Id$ + +//IDL + +#ifndef TAO_COUNTRY_IDL +#define TAO_COUNTRY_IDL + +//#include "orbsvcs/CosEventComm.idl" +#pragma prefix "jon.com" + +interface Country //: ::CosTypedEventComm::TypedPushConsumer +{ + void update_population (in string country, + in long population); +}; + +#endif /* TAO_COUNTRY_IDL */ diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/Country_i.cpp b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country_i.cpp new file mode 100644 index 00000000000..0a399c06b6a --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country_i.cpp @@ -0,0 +1,77 @@ +// -*- C++ -*- +// +// $Id$ + +#include "Country_i.h" + +// Implementation skeleton constructor +Country_i::Country_i (CORBA::ORB_ptr orb) : + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +// Implementation skeleton destructor +Country_i::~Country_i (void) +{ +} + +void Country_i::update_population (const char * country, + CORBA::Long population + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + //Add your implementation here + ACE_DEBUG ((LM_DEBUG, "Country %s has population %d\n", + country, population)); +} + +CORBA::Object_ptr +Country_i::get_typed_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + //Add your implementation here + ACE_DEBUG ((LM_DEBUG, "Country_i::get_typed_consumer called...\n")); + + Country_var ret = this->_this(); + + ACE_DEBUG ((LM_DEBUG, "...returning CORBA::Object_ptr for Country_i\n")); + + return Country::_duplicate(ret.in ()); +} + +void +Country_i::push (const CORBA::Any & /* data */ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosEventComm::Disconnected)) + +{ + //Add your implementation here +} + +void +Country_i::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + //Add your implementation here + ACE_DEBUG ((LM_DEBUG, "Country_i::disconnect_push_consumer called...\n")); + + // Deactivate the impl + PortableServer::POA_var t_poa = + this->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var t_id = + t_poa->servant_to_id (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + t_poa->deactivate_object (t_id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Country_i::disconnect_push_consumer, calling ORB shutdown...\n")); + orb_->shutdown(0); + ACE_TRY_CHECK; +} diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/Country_i.h b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country_i.h new file mode 100644 index 00000000000..3d658086c47 --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/Country_i.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +// +// $Id$ + +#ifndef COUNTRYI_H_ +#define COUNTRYI_H_ + +#include "CountryS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +//Class Country_i +class Country_i : public virtual POA_Country +{ +public: + //Constructor + Country_i (CORBA::ORB_ptr orb); + + //Destructor + virtual ~Country_i (void); + + virtual void update_population (const char * country, + CORBA::Long population + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Object_ptr get_typed_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void push (const CORBA::Any & data + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosEventComm::Disconnected)); + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// The ORB + CORBA::ORB_var orb_; +}; + +#endif /* COUNTRYI_H_ */ diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/README b/TAO/orbsvcs/examples/CosEC/TypedSimple/README new file mode 100644 index 00000000000..d722b0a9e0c --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/README @@ -0,0 +1,18 @@ +# $Id$ + + This directory contains an example for a COS Event Service, +using a typed channel. +It contains two executables; a consumer and a supplier. + + To test it use : + +# rm Country.ifr +# IFR_Service -p -b Country.ifr -ORBEndPoint iiop://localhost:12345 +# tao_ifr -ORBInitRef InterfaceRepository=corbaloc:iiop:localhost:12345/InterfaceRepository -I$TAO_ROOT/orbsvcs Country.idl +# Naming_Service -ORBEndPoint iiop://localhost:8000 +# CosEvent_Service -n CountryEventChannel -r -t -d -ORBInitRef InterfaceRepository=corbaloc:iiop:localhost:12345/InterfaceRepository -ORBInitRef NameService=corbaloc:iiop:localhost:8000/NameService +# consumer -ORBInitRef NameService=corbaloc:iiop:localhost:8000/NameService +# supplier -ORBInitRef NameService=corbaloc:iiop:localhost:8000/NameService + +Note: If the tao_ifr fails, use the Country.idl.for_ifr file to upload the idl into the IFR. + Please also report the problem in the usual manner. diff --git a/TAO/orbsvcs/examples/CosEC/TypedSimple/Supplier.cpp b/TAO/orbsvcs/examples/CosEC/TypedSimple/Supplier.cpp new file mode 100644 index 00000000000..c908d935e80 --- /dev/null +++ b/TAO/orbsvcs/examples/CosEC/TypedSimple/Supplier.cpp @@ -0,0 +1,93 @@ +// $Id$ + +#include "orbsvcs/CosNamingC.h" +#include "orbsvcs/CosTypedEventChannelAdminC.h" +#include "CountryC.h" + +ACE_RCSID(CosEC_Examples, Supplier, "$Id:") + +int +main (int argc, char* argv[]) +{ + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + // ORB initialization boiler plate... + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Obtain the event channel using the Naming Service. + CORBA::Object_var nam_obj = + orb->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER ); + ACE_TRY_CHECK; + + CosNaming::NamingContext_var root_context = + CosNaming::NamingContext::_narrow(nam_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CosNaming::Name channel_name (1); + channel_name.length (1); + channel_name[0].id = CORBA::string_dup ("CountryEventChannel"); + + CORBA::Object_var ec_obj = + root_context->resolve(channel_name); + ACE_TRY_CHECK; + + // Downcast the object reference to a TypedEventChannel reference + CosTypedEventChannelAdmin::TypedEventChannel_var typed_event_channel = + CosTypedEventChannelAdmin::TypedEventChannel::_narrow(ec_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Connect to the typed channel + CosTypedEventChannelAdmin::TypedSupplierAdmin_var typed_supplier_admin = + typed_event_channel->for_suppliers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CosTypedEventChannelAdmin::TypedProxyPushConsumer_var typed_proxy_push_consumer = + typed_supplier_admin->obtain_typed_push_consumer ("IDL:jon.com/Country:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + typed_proxy_push_consumer->connect_push_supplier (CosEventComm::PushSupplier::_nil() + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Obtain the interface from the event channel + CORBA::Object_var typed_consumer = + typed_proxy_push_consumer->get_typed_consumer(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Narrow the interface + Country_var typed_supplier = Country::_narrow(typed_consumer.in () ); + ACE_TRY_CHECK; + + // Invoke the events... + for (int i = 0; i != 100; ++i) + { + typed_supplier->update_population ("England", i ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + // Disconnect from the EC + typed_proxy_push_consumer->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Destroy the EC.... + typed_event_channel->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "main"); + return 1; + } + ACE_ENDTRY; + return 0; +} + + + diff --git a/TAO/orbsvcs/examples/Notify/Lanes/Lanes.mpc b/TAO/orbsvcs/examples/Notify/Lanes/Notify_Lanes.mpc index 594f25f77b1..4be8801712b 100644 --- a/TAO/orbsvcs/examples/Notify/Lanes/Lanes.mpc +++ b/TAO/orbsvcs/examples/Notify/Lanes/Notify_Lanes.mpc @@ -1,4 +1,4 @@ -project(Supplier): notify, rtcorba, rtnotify { +project(*Supplier): notify, rtcorba, rtnotify { exename = Supplier Source_Files { Supplier.cpp @@ -8,7 +8,7 @@ project(Supplier): notify, rtcorba, rtnotify { } } -project(Consumer): notifytest, rtcorba, rtnotify { +project(*Consumer): notifytest, rtcorba, rtnotify { exename = Consumer Source_Files { Consumer.cpp diff --git a/TAO/orbsvcs/examples/Notify/ThreadPool/Notify_ThreadPool.mpc b/TAO/orbsvcs/examples/Notify/ThreadPool/Notify_ThreadPool.mpc new file mode 100644 index 00000000000..58f586decc3 --- /dev/null +++ b/TAO/orbsvcs/examples/Notify/ThreadPool/Notify_ThreadPool.mpc @@ -0,0 +1,13 @@ +project(*Supplier): rtnotify { + Source_Files { + Supplier.cpp + Supplier_Client.cpp + } +} + +project(*Consumer): rtnotify, notifytest, rtportableserver { + Source_Files { + Consumer.cpp + Consumer_Client.cpp + } +} diff --git a/TAO/orbsvcs/examples/Notify/ThreadPool/ThreadPool.mpc b/TAO/orbsvcs/examples/Notify/ThreadPool/ThreadPool.mpc deleted file mode 100644 index 96ae396e0ac..00000000000 --- a/TAO/orbsvcs/examples/Notify/ThreadPool/ThreadPool.mpc +++ /dev/null @@ -1,19 +0,0 @@ -project(Supplier): notify { - exename = Supplier - libs += TAO_RT_Notification TAO_Svc_Utils TAO_ETCL TAO_DynamicAny TAO_PortableServer TAO TAO_RTCORBA - - Source_Files { - Supplier.cpp - Supplier_Client.cpp - } -} - -project(Consumer): notifytest { - exename = Consumer - libs += TAO_RT_Notification TAO_Svc_Utils TAO_ETCL TAO_DynamicAny TAO_RT_PortableServer TAO TAO_RTCORBA - - Source_Files { - Consumer.cpp - Consumer_Client.cpp - } -} diff --git a/TAO/orbsvcs/examples/RtEC/IIOPGateway/Gateway.mpc b/TAO/orbsvcs/examples/RtEC/IIOPGateway/Gateway.mpc deleted file mode 100644 index 8226bb9863f..00000000000 --- a/TAO/orbsvcs/examples/RtEC/IIOPGateway/Gateway.mpc +++ /dev/null @@ -1,40 +0,0 @@ -project(Consumer): messaging, rteventexe { - after += CosNaming IORTable - libs += TAO_CosNaming TAO_IORTable - exename = Consumer - - Source_Files { - Consumer.cpp - } -} - -project(Supplier): messaging, rteventexe { - after += CosNaming IORTable - libs += TAO_CosNaming TAO_IORTable - exename = Supplier - - Source_Files { - Supplier.cpp - } -} - -project(Gateway): messaging, rteventexe { - after += CosNaming IORTable - libs += TAO_CosNaming TAO_IORTable - exename = Gateway - - Source_Files { - Gateway.cpp - } -} - -project(EC): messaging, rteventexe { - after += CosNaming IORTable - libs += TAO_CosNaming TAO_IORTable - exename = EC - - Source_Files { - EC.cpp - } -} - diff --git a/TAO/orbsvcs/examples/RtEC/IIOPGateway/RtEC_IIOPGateway.mpc b/TAO/orbsvcs/examples/RtEC/IIOPGateway/RtEC_IIOPGateway.mpc new file mode 100644 index 00000000000..e3d26aeed38 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/IIOPGateway/RtEC_IIOPGateway.mpc @@ -0,0 +1,24 @@ +project(*Consumer): messaging, rteventexe, naming { + Source_Files { + Consumer.cpp + } +} + +project(*Supplier): messaging, rteventexe, naming { + Source_Files { + Supplier.cpp + } +} + +project(*): messaging, rteventexe, naming { + Source_Files { + Gateway.cpp + } +} + +project(*EC): messaging, rteventexe, naming { + Source_Files { + EC.cpp + } +} + diff --git a/TAO/orbsvcs/orbsvcs/CosEvent.mpb b/TAO/orbsvcs/orbsvcs/CosEvent.mpb new file mode 100644 index 00000000000..b4ab81ec15f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent.mpb @@ -0,0 +1,43 @@ +// There are two versions of CosEvent. One supports typed events +// and the other does not. The both inherit common information +// from this file. (see CosEvent.mpc) +project : orbsvcslib, messaging, core, naming { + sharedname = TAO_CosEvent + idlflags += -Wb,export_macro=TAO_Event_Export -Wb,export_include=CosEvent/event_export.h + dynamicflags = TAO_EVENT_BUILD_DLL TAO_NOTIFY_BUILD_DLL + tagchecks = CosEvent + includes += $(TAO_ROOT)/orbsvcs/orbsvcs + + IDL_Files { + CosEventComm.idl + CosEventChannelAdmin.idl + } + + Source_Files(ORBSVCS_COMPONENTS) { + CosEvent { + CosEventCommC.cpp + CosEventChannelAdminC.cpp + CosEventCommS.cpp + CosEventChannelAdminS.cpp + CosEvent\CEC_ConsumerAdmin.cpp + CosEvent\CEC_ConsumerControl.cpp + CosEvent\CEC_Default_Factory.cpp + CosEvent\CEC_Dispatching.cpp + CosEvent\CEC_Dispatching_Task.cpp + CosEvent\CEC_EventChannel.cpp + CosEvent\CEC_Event_Loader.cpp + CosEvent\CEC_Factory.cpp + CosEvent\CEC_MT_Dispatching.cpp + CosEvent\CEC_ProxyPullConsumer.cpp + CosEvent\CEC_ProxyPullSupplier.cpp + CosEvent\CEC_ProxyPushConsumer.cpp + CosEvent\CEC_ProxyPushSupplier.cpp + CosEvent\CEC_Pulling_Strategy.cpp + CosEvent\CEC_Reactive_ConsumerControl.cpp + CosEvent\CEC_Reactive_Pulling_Strategy.cpp + CosEvent\CEC_Reactive_SupplierControl.cpp + CosEvent\CEC_SupplierAdmin.cpp + CosEvent\CEC_SupplierControl.cpp + } + } +} diff --git a/TAO/orbsvcs/orbsvcs/CosEvent.mpc b/TAO/orbsvcs/orbsvcs/CosEvent.mpc index db7986ecc61..7ab7da1eba3 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent.mpc +++ b/TAO/orbsvcs/orbsvcs/CosEvent.mpc @@ -1,24 +1,28 @@ -project(CosEvent) : orbsvcslib, messaging, core, naming { - sharedname = TAO_CosEvent - idlflags += -Wb,export_macro=TAO_Event_Export -Wb,export_include=CosEvent/event_export.h - // Set both DLL flags because of the shared idl files - dynamicflags = TAO_EVENT_BUILD_DLL TAO_NOTIFY_BUILD_DLL - tagchecks = CosEvent - // Add this include path for precompiled headers - includes += $(TAO_ROOT)/orbsvcs/orbsvcs +project(CosEvent) : cosevent, orbsvcslib, messaging, core, naming { + avoids += ec_typed_events +} + +project(CosEvent) : cosevent, orbsvcslib, messaging, core, naming, ifr_client, dynamicinterface { + requires += ec_typed_events + macros += TAO_HAS_TYPED_EVENT_CHANNEL IDL_Files { - CosEventComm.idl - CosEventChannelAdmin.idl + CosTypedEventComm.idl + CosTypedEventChannelAdmin.idl } Source_Files(ORBSVCS_COMPONENTS) { CosEvent { - CosEventCommC.cpp - CosEventCommS.cpp - CosEventChannelAdminC.cpp - CosEventChannelAdminS.cpp - CosEvent + CosTypedEventCommC.cpp + CosTypedEventChannelAdminC.cpp + CosTypedEventCommS.cpp + CosTypedEventChannelAdminS.cpp + CosEvent/CEC_TypedEvent.cpp + CosEvent/CEC_TypedEventChannel.cpp + CosEvent/CEC_TypedProxyPushConsumer.cpp + CosEvent/CEC_TypedConsumerAdmin.cpp + CosEvent/CEC_TypedSupplierAdmin.cpp + CosEvent/CEC_DynamicImplementation.cpp } } } diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.cpp index 0421f66e7ac..2545adc7060 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.cpp @@ -21,6 +21,11 @@ #include "orbsvcs/ESF/ESF_Delayed_Command.h" #include "ace/Arg_Shifter.h" #include "ace/Sched_Params.h" +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "CEC_TypedConsumerAdmin.h" +#include "CEC_TypedSupplierAdmin.h" +#include "CEC_TypedEventChannel.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #if ! defined (__ACE_INLINE__) #include "CEC_Default_Factory.i" @@ -390,6 +395,21 @@ TAO_CEC_Default_Factory::create_dispatching (TAO_CEC_EventChannel *) return 0; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_Dispatching* +TAO_CEC_Default_Factory::create_dispatching (TAO_CEC_TypedEventChannel *) +{ + if (this->dispatching_ == 0) + return new TAO_CEC_Reactive_Dispatching (); + else if (this->dispatching_ == 1) + return new TAO_CEC_MT_Dispatching (this->dispatching_threads_, + this->dispatching_threads_flags_, + this->dispatching_threads_priority_, + this->dispatching_threads_force_active_); + return 0; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_dispatching (TAO_CEC_Dispatching *x) { @@ -425,30 +445,70 @@ TAO_CEC_Default_Factory::create_consumer_admin (TAO_CEC_EventChannel *ec) return new TAO_CEC_ConsumerAdmin (ec); } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_TypedConsumerAdmin* +TAO_CEC_Default_Factory::create_consumer_admin (TAO_CEC_TypedEventChannel *ec) +{ + return new TAO_CEC_TypedConsumerAdmin (ec); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_consumer_admin (TAO_CEC_ConsumerAdmin *x) { delete x; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Default_Factory::destroy_consumer_admin (TAO_CEC_TypedConsumerAdmin *x) +{ + delete x; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_SupplierAdmin* TAO_CEC_Default_Factory::create_supplier_admin (TAO_CEC_EventChannel *ec) { return new TAO_CEC_SupplierAdmin (ec); } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_TypedSupplierAdmin* +TAO_CEC_Default_Factory::create_supplier_admin (TAO_CEC_TypedEventChannel *ec) +{ + return new TAO_CEC_TypedSupplierAdmin (ec); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_supplier_admin (TAO_CEC_SupplierAdmin *x) { delete x; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Default_Factory::destroy_supplier_admin (TAO_CEC_TypedSupplierAdmin *x) +{ + delete x; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_ProxyPushSupplier* TAO_CEC_Default_Factory::create_proxy_push_supplier (TAO_CEC_EventChannel *ec) { return new TAO_CEC_ProxyPushSupplier (ec); } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_ProxyPushSupplier* +TAO_CEC_Default_Factory::create_proxy_push_supplier (TAO_CEC_TypedEventChannel *ec) +{ + return new TAO_CEC_ProxyPushSupplier (ec); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_proxy_push_supplier (TAO_CEC_ProxyPushSupplier *x) { @@ -473,12 +533,28 @@ TAO_CEC_Default_Factory::create_proxy_push_consumer (TAO_CEC_EventChannel *ec) return new TAO_CEC_ProxyPushConsumer (ec); } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_TypedProxyPushConsumer* +TAO_CEC_Default_Factory::create_proxy_push_consumer (TAO_CEC_TypedEventChannel *ec) +{ + return new TAO_CEC_TypedProxyPushConsumer (ec); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_proxy_push_consumer (TAO_CEC_ProxyPushConsumer *x) { delete x; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Default_Factory::destroy_proxy_push_consumer (TAO_CEC_TypedProxyPushConsumer *x) +{ + delete x; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_ProxyPullConsumer* TAO_CEC_Default_Factory::create_proxy_pull_consumer (TAO_CEC_EventChannel *ec) { @@ -498,6 +574,14 @@ typedef typedef TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushConsumer>::Iterator TAO_CEC_PushConsumer_RB_Tree_Iterator; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +typedef + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>::Iterator + TAO_CEC_TypedPushConsumer_List_Iterator; +typedef + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>::Iterator + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ typedef TAO_ESF_Proxy_List<TAO_CEC_ProxyPullConsumer>::Iterator TAO_CEC_PullConsumer_List_Iterator; @@ -604,12 +688,109 @@ TAO_CEC_Default_Factory::create_proxy_push_consumer_collection (TAO_CEC_EventCha return 0; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_TypedProxyPushConsumer_Collection* +TAO_CEC_Default_Factory::create_proxy_push_consumer_collection (TAO_CEC_TypedEventChannel *) +{ + if (this->consumer_collection_ == 0x000) + return new TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->consumer_collection_ == 0x001) + return new TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->consumer_collection_ == 0x002) + return new TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH> (); + else if (this->consumer_collection_ == 0x003) + return new TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH> (); + else if (this->consumer_collection_ == 0x010) + return new TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->consumer_collection_ == 0x011) + return new TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->consumer_collection_ == 0x012) + return new TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH> (); + else if (this->consumer_collection_ == 0x013) + return new TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH> (); + else if (this->consumer_collection_ == 0x100) + return new TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_Null_Mutex> (); + else if (this->consumer_collection_ == 0x101) + return new TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_Null_Mutex> (); + else if (this->consumer_collection_ == 0x102) + return new TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH> (); + else if (this->consumer_collection_ == 0x103) + return new TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH> (); + else if (this->consumer_collection_ == 0x110) + return new TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_Null_Mutex> (); + else if (this->consumer_collection_ == 0x111) + return new TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_Null_Mutex> (); + else if (this->consumer_collection_ == 0x112) + return new TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH> (); + else if (this->consumer_collection_ == 0x113) + return new TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH> (); + + return 0; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_proxy_push_consumer_collection (TAO_CEC_ProxyPushConsumer_Collection *x) { delete x; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Default_Factory::destroy_proxy_push_consumer_collection (TAO_CEC_TypedProxyPushConsumer_Collection *x) +{ + delete x; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_ProxyPullConsumer_Collection* TAO_CEC_Default_Factory::create_proxy_pull_consumer_collection (TAO_CEC_EventChannel *) { @@ -790,6 +971,95 @@ TAO_CEC_Default_Factory::create_proxy_push_supplier_collection (TAO_CEC_EventCha return 0; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_ProxyPushSupplier_Collection* +TAO_CEC_Default_Factory::create_proxy_push_supplier_collection (TAO_CEC_TypedEventChannel *) +{ + if (this->supplier_collection_ == 0x000) + return new TAO_ESF_Immediate_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->supplier_collection_ == 0x001) + return new TAO_ESF_Copy_On_Read<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->supplier_collection_ == 0x002) + return new TAO_ESF_Copy_On_Write<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + ACE_SYNCH> (); + else if (this->supplier_collection_ == 0x003) + return new TAO_ESF_Delayed_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + ACE_SYNCH> (); + else if (this->supplier_collection_ == 0x010) + return new TAO_ESF_Immediate_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->supplier_collection_ == 0x011) + return new TAO_ESF_Copy_On_Read<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + TAO_SYNCH_MUTEX> (); + else if (this->supplier_collection_ == 0x012) + return new TAO_ESF_Copy_On_Write<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + ACE_SYNCH> (); + else if (this->supplier_collection_ == 0x013) + return new TAO_ESF_Delayed_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + ACE_SYNCH> (); + else if (this->supplier_collection_ == 0x100) + return new TAO_ESF_Immediate_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + ACE_Null_Mutex> (); + else if (this->supplier_collection_ == 0x101) + return new TAO_ESF_Copy_On_Read<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + ACE_Null_Mutex> (); + else if (this->supplier_collection_ == 0x102) + return new TAO_ESF_Copy_On_Write<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + ACE_NULL_SYNCH> (); + else if (this->supplier_collection_ == 0x103) + return new TAO_ESF_Delayed_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_List_Iterator, + ACE_NULL_SYNCH> (); + else if (this->supplier_collection_ == 0x110) + return new TAO_ESF_Immediate_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + ACE_Null_Mutex> (); + else if (this->supplier_collection_ == 0x111) + return new TAO_ESF_Copy_On_Read<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + ACE_Null_Mutex> (); + else if (this->supplier_collection_ == 0x112) + return new TAO_ESF_Copy_On_Write<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + ACE_NULL_SYNCH> (); + else if (this->supplier_collection_ == 0x113) + return new TAO_ESF_Delayed_Changes<TAO_CEC_ProxyPushSupplier, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_ProxyPushSupplier>, + TAO_CEC_PushSupplier_RB_Tree_Iterator, + ACE_NULL_SYNCH> (); + + return 0; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_proxy_push_supplier_collection (TAO_CEC_ProxyPushSupplier_Collection *x) { @@ -943,6 +1213,26 @@ TAO_CEC_Default_Factory::create_consumer_control (TAO_CEC_EventChannel* ec) return 0; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_ConsumerControl* +TAO_CEC_Default_Factory::create_consumer_control (TAO_CEC_TypedEventChannel* ec) +{ + if (this->consumer_control_ == 0) + return new TAO_CEC_ConsumerControl (); + else if (this->consumer_control_ == 1) + { + int argc = 0; + char **argv = 0; + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, this->orbid_); + + ACE_Time_Value rate (0, this->consumer_control_period_); + return new TAO_CEC_Reactive_ConsumerControl (rate, consumer_control_timeout_, ec, orb.in ()); + } + return 0; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_consumer_control (TAO_CEC_ConsumerControl* x) { @@ -967,6 +1257,26 @@ TAO_CEC_Default_Factory::create_supplier_control (TAO_CEC_EventChannel* ec) return 0; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_SupplierControl* +TAO_CEC_Default_Factory::create_supplier_control (TAO_CEC_TypedEventChannel* ec) +{ + if (this->supplier_control_ == 0) + return new TAO_CEC_SupplierControl (); + else if (this->supplier_control_ == 1) + { + int argc = 0; + char **argv = 0; + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, this->orbid_); + + ACE_Time_Value rate (0, this->consumer_control_period_); + return new TAO_CEC_Reactive_SupplierControl (rate, supplier_control_timeout_, ec, orb.in ()); + } + return 0; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Default_Factory::destroy_supplier_control (TAO_CEC_SupplierControl* x) { @@ -1014,6 +1324,29 @@ template class ACE_RB_Tree_Node<TAO_CEC_ProxyPushConsumer *, int>; template class ACE_Less_Than<TAO_CEC_ProxyPushConsumer *>; template class TAO_ESF_Proxy_RB_Tree_Iterator<TAO_CEC_ProxyPushConsumer>; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +template class TAO_ESF_Copy_On_Write_Collection< + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator >; +template class TAO_ESF_Copy_On_Write_Collection< + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator >; + +template class TAO_ESF_Proxy_Collection<TAO_CEC_TypedProxyPushConsumer>; +template class TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>; +template class TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>; +template class ACE_Unbounded_Set<TAO_CEC_TypedProxyPushConsumer *>; +template class ACE_Node<TAO_CEC_TypedProxyPushConsumer *>; +template class ACE_Unbounded_Set_Iterator<TAO_CEC_TypedProxyPushConsumer *>; +template class ACE_RB_Tree<TAO_CEC_TypedProxyPushConsumer *, int, ACE_Less_Than<TAO_CEC_TypedProxyPushConsumer *>, ACE_Null_Mutex>; +template class ACE_RB_Tree_Iterator<TAO_CEC_TypedProxyPushConsumer *, int, ACE_Less_Than<TAO_CEC_TypedProxyPushConsumer *>, ACE_Null_Mutex>; +template class ACE_RB_Tree_Reverse_Iterator<TAO_CEC_TypedProxyPushConsumer *, int, ACE_Less_Than<TAO_CEC_TypedProxyPushConsumer *>, ACE_Null_Mutex>; +template class ACE_RB_Tree_Iterator_Base<TAO_CEC_TypedProxyPushConsumer *, int, ACE_Less_Than<TAO_CEC_TypedProxyPushConsumer *>, ACE_Null_Mutex>; +template class ACE_RB_Tree_Node<TAO_CEC_TypedProxyPushConsumer *, int>; +template class ACE_Less_Than<TAO_CEC_TypedProxyPushConsumer *>; +template class TAO_ESF_Proxy_RB_Tree_Iterator<TAO_CEC_TypedProxyPushConsumer>; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + template class TAO_ESF_Copy_On_Write_Collection< TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, TAO_CEC_PushSupplier_List_Iterator >; @@ -1178,6 +1511,101 @@ template class TAO_ESF_Shutdown_Command< TAO_CEC_PushConsumer_RB_Tree_Iterator, ACE_SYNCH> >; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +template class TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + TAO_SYNCH_MUTEX>; +template class TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + TAO_SYNCH_MUTEX>; +template class TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH>; +template class TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH>; +template class TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH> >; +template class ACE_Guard< TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH> > >; +template class TAO_ESF_Connected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Reconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Disconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Shutdown_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH> >; +template class TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + TAO_SYNCH_MUTEX>; +template class TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + TAO_SYNCH_MUTEX>; +template class TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH>; +template class TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH>; +template class TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH> >; +template class ACE_Guard< TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH> > >; +template class TAO_ESF_Connected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Reconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Disconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Shutdown_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH> >; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + template class TAO_ESF_Immediate_Changes<TAO_CEC_ProxyPushSupplier, TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, TAO_CEC_PushSupplier_List_Iterator, @@ -1304,6 +1732,25 @@ template class TAO_ESF_Copy_On_Write_Write_Guard< TAO_CEC_PushSupplier_RB_Tree_Iterator, ACE_SYNCH>; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +template class TAO_ESF_Copy_On_Write_Read_Guard< + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + TAO_SYNCH_MUTEX>; +template class TAO_ESF_Copy_On_Write_Read_Guard< + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + TAO_SYNCH_MUTEX>; +template class TAO_ESF_Copy_On_Write_Write_Guard< + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard< + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_SYNCH>; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + template class TAO_ESF_Copy_On_Write_Read_Guard< TAO_ESF_Proxy_List<TAO_CEC_ProxyPullConsumer>, TAO_CEC_PullConsumer_List_Iterator, @@ -1432,6 +1879,101 @@ template class TAO_ESF_Shutdown_Command< TAO_CEC_PushConsumer_RB_Tree_Iterator, ACE_NULL_SYNCH> >; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +template class TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_Null_Mutex>; +template class TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_Null_Mutex>; +template class TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH>; +template class TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH>; +template class TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH> >; +template class ACE_Guard< TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH> > >; +template class TAO_ESF_Connected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Reconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Disconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Shutdown_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH> >; +template class TAO_ESF_Immediate_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_Null_Mutex>; +template class TAO_ESF_Copy_On_Read<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_Null_Mutex>; +template class TAO_ESF_Copy_On_Write<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH>; +template class TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH>; +template class TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH> >; +template class ACE_Guard< TAO_ESF_Busy_Lock_Adapter< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH> > >; +template class TAO_ESF_Connected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Reconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Disconnected_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH>,TAO_CEC_TypedProxyPushConsumer >; +template class TAO_ESF_Shutdown_Command< + TAO_ESF_Delayed_Changes<TAO_CEC_TypedProxyPushConsumer, + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH> >; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + template class TAO_ESF_Immediate_Changes<TAO_CEC_ProxyPushSupplier, TAO_ESF_Proxy_List<TAO_CEC_ProxyPushSupplier>, TAO_CEC_PushSupplier_List_Iterator, @@ -1940,6 +2482,25 @@ template class TAO_ESF_Copy_On_Write_Write_Guard< TAO_CEC_PushSupplier_RB_Tree_Iterator, ACE_NULL_SYNCH>; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +template class TAO_ESF_Copy_On_Write_Read_Guard< + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_Null_Mutex>; +template class TAO_ESF_Copy_On_Write_Read_Guard< + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_Null_Mutex>; +template class TAO_ESF_Copy_On_Write_Write_Guard< + TAO_ESF_Proxy_List<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_List_Iterator, + ACE_NULL_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard< + TAO_ESF_Proxy_RB_Tree<TAO_CEC_TypedProxyPushConsumer>, + TAO_CEC_TypedPushConsumer_RB_Tree_Iterator, + ACE_NULL_SYNCH>; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + template class TAO_ESF_Copy_On_Write_Read_Guard< TAO_ESF_Proxy_List<TAO_CEC_ProxyPullConsumer>, TAO_CEC_PullConsumer_List_Iterator, diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.h index bb1b6a083d7..efea76cb0ca 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Default_Factory.h @@ -1,3 +1,4 @@ +// $Id$ /* -*- C++ -*- */ //============================================================================= /** @@ -116,6 +117,35 @@ public: virtual void destroy_supplier_control (TAO_CEC_SupplierControl*); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_Dispatching* + create_dispatching (TAO_CEC_TypedEventChannel*); + virtual TAO_CEC_TypedConsumerAdmin* + create_consumer_admin (TAO_CEC_TypedEventChannel*); + virtual void + destroy_consumer_admin (TAO_CEC_TypedConsumerAdmin*); + virtual TAO_CEC_TypedSupplierAdmin* + create_supplier_admin (TAO_CEC_TypedEventChannel*); + virtual void + destroy_supplier_admin (TAO_CEC_TypedSupplierAdmin*); + virtual TAO_CEC_ProxyPushSupplier* + create_proxy_push_supplier (TAO_CEC_TypedEventChannel*); + virtual TAO_CEC_ProxyPushSupplier_Collection* + create_proxy_push_supplier_collection (TAO_CEC_TypedEventChannel*); + virtual TAO_CEC_TypedProxyPushConsumer* + create_proxy_push_consumer (TAO_CEC_TypedEventChannel*); + virtual void + destroy_proxy_push_consumer (TAO_CEC_TypedProxyPushConsumer*); + virtual TAO_CEC_TypedProxyPushConsumer_Collection* + create_proxy_push_consumer_collection (TAO_CEC_TypedEventChannel*); + virtual void + destroy_proxy_push_consumer_collection (TAO_CEC_TypedProxyPushConsumer_Collection*); + virtual TAO_CEC_ConsumerControl* + create_consumer_control (TAO_CEC_TypedEventChannel*); + virtual TAO_CEC_SupplierControl* + create_supplier_control (TAO_CEC_TypedEventChannel*); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + private: /// Parse an argument to set the type of collections used. int parse_collection_arg (ACE_TCHAR* opt); diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.cpp index a2343f4d940..858d3a7581d 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.cpp @@ -44,3 +44,21 @@ TAO_CEC_Reactive_Dispatching::push_nocopy (TAO_CEC_ProxyPushSupplier* proxy, { proxy->reactive_push_to_consumer (event ACE_ENV_ARG_PARAMETER); } + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Reactive_Dispatching::invoke (TAO_CEC_ProxyPushSupplier* proxy, + const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + proxy->reactive_invoke_to_consumer (typed_event ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_Reactive_Dispatching::invoke_nocopy (TAO_CEC_ProxyPushSupplier* proxy, + TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + proxy->reactive_invoke_to_consumer (typed_event ACE_ENV_ARG_PARAMETER); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.h index 5bcb8b242a2..3e2db3ccbe8 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching.h @@ -1,3 +1,4 @@ +// $Id$ /* -*- C++ -*- */ //============================================================================= /** @@ -22,6 +23,9 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ class TAO_CEC_ProxyPushSupplier; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_TypedEvent; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /** * @class TAO_CEC_Dispatching @@ -58,6 +62,14 @@ public: virtual void push_nocopy (TAO_CEC_ProxyPushSupplier *proxy, CORBA::Any &event ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void invoke (TAO_CEC_ProxyPushSupplier *proxy, + const TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0; + virtual void invoke_nocopy (TAO_CEC_ProxyPushSupplier *proxy, + TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ }; // **************************************************************** @@ -86,6 +98,14 @@ public: virtual void push_nocopy (TAO_CEC_ProxyPushSupplier *proxy, CORBA::Any &event ACE_ENV_ARG_DECL_WITH_DEFAULTS); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void invoke (TAO_CEC_ProxyPushSupplier *proxy, + const TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + virtual void invoke_nocopy (TAO_CEC_ProxyPushSupplier *proxy, + TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL_WITH_DEFAULTS); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.cpp index 3c9b579775f..5c93fde761a 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.cpp @@ -73,6 +73,30 @@ TAO_CEC_Dispatching_Task::push (TAO_CEC_ProxyPushSupplier *proxy, this->putq (mb); } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Dispatching_Task::invoke (TAO_CEC_ProxyPushSupplier *proxy, + TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + void* buf = this->allocator_->malloc (sizeof (TAO_CEC_Invoke_Command)); + + if (buf == 0) + ACE_THROW (CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_NO)); + + ACE_Message_Block *mb = + new (buf) TAO_CEC_Invoke_Command (proxy, + typed_event, + this->data_block_.duplicate (), + this->allocator_); + this->putq (mb); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + // **************************************************************** TAO_CEC_Dispatch_Command::~TAO_CEC_Dispatch_Command (void) @@ -102,6 +126,23 @@ TAO_CEC_Push_Command::execute (ACE_ENV_SINGLE_ARG_DECL) return 0; } +// **************************************************************** + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_Invoke_Command::~TAO_CEC_Invoke_Command (void) +{ + this->proxy_->_decr_refcnt (); +} + +int +TAO_CEC_Invoke_Command::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + this->proxy_->invoke_to_consumer (this->typed_event_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + return 0; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Locked_Data_Block<ACE_Lock_Adapter<TAO_SYNCH_MUTEX> >; diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.h index 24694570726..cfc18b78700 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.h @@ -1,3 +1,4 @@ +// $Id$ // -*- C++ -*- //============================================================================= @@ -26,7 +27,9 @@ #include "orbsvcs/CosEvent/event_export.h" #include "CEC_ProxyPushSupplier.h" - +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "CEC_TypedEvent.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /** * @class TAO_CEC_Dispatching_Task @@ -48,6 +51,12 @@ public: CORBA::Any& event ACE_ENV_ARG_DECL); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void invoke (TAO_CEC_ProxyPushSupplier *proxy, + TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + private: /// An per-task allocator ACE_Allocator *allocator_; @@ -112,6 +121,33 @@ private: CORBA::Any event_; }; +// **************************************************************** + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_Event_Export TAO_CEC_Invoke_Command : public TAO_CEC_Dispatch_Command +{ +public: + /// Constructor + TAO_CEC_Invoke_Command (TAO_CEC_ProxyPushSupplier* proxy, + TAO_CEC_TypedEvent& typed_event, + ACE_Data_Block* data_block, + ACE_Allocator *mb_allocator); + + /// Destructor + virtual ~TAO_CEC_Invoke_Command (void); + + /// Command callback + virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + +private: + /// The proxy + TAO_CEC_ProxyPushSupplier* proxy_; + + /// The event + TAO_CEC_TypedEvent typed_event_; +}; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + #if defined (__ACE_INLINE__) #include "CEC_Dispatching_Task.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.i index 7d25e16948e..0bf5b92e030 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.i +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Dispatching_Task.i @@ -53,3 +53,27 @@ TAO_CEC_Push_Command::TAO_CEC_Push_Command (TAO_CEC_ProxyPushSupplier* proxy, this->proxy_->_incr_refcnt (); } + +// **************************************************************** + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +ACE_INLINE +TAO_CEC_Invoke_Command::TAO_CEC_Invoke_Command (TAO_CEC_ProxyPushSupplier* proxy, + TAO_CEC_TypedEvent& typed_event, + ACE_Data_Block* data_block, + ACE_Allocator *mb_allocator) + : TAO_CEC_Dispatch_Command (data_block, mb_allocator), + proxy_ (proxy) +{ + // + // Efficient copy, steal the buffer from <event> + // We cannot do this on the initialization because get_buffer() + // could get called first, effectively setting maximum() and + // length() to 0! + // + // @@ TODO + this->typed_event_ = typed_event; + + this->proxy_->_incr_refcnt (); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.cpp new file mode 100644 index 00000000000..023cbd2a31a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.cpp @@ -0,0 +1,164 @@ +// -*- C++ -*- +// +// $Id$ + +#include "CEC_DynamicImplementation.h" +#include "tao/DynamicInterface/Request.h" +#include "tao/DynamicInterface/Unknown_User_Exception.h" +#include "CEC_TypedEvent.h" + +#if !defined(__ACE_INLINE__) +#include "CEC_DynamicImplementation.i" +#endif /* __ACE_INLINE__ */ + +// Destructor +TAO_CEC_DynamicImplementationServer::~TAO_CEC_DynamicImplementationServer (void) +{ +} + +// The DSI invoke request +void +TAO_CEC_DynamicImplementationServer::invoke (CORBA::ServerRequest_ptr request + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Trap the _is_a request + if (ACE_OS::strcmp ("_is_a", request->operation () ) == 0) + { + this->is_a (request ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + CORBA::NVList_ptr list; + + // Get the operation paramter information from the IFR cache. + TAO_CEC_Operation_Params *oper_params = + this->typed_event_channel_->find_from_ifr_cache (request->operation () ); + + if (oper_params == 0) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Operation not found in IFR cache *****\n")); + } + + this->typed_event_channel_->create_list (0, list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + // Populate the NVList from the parameter information. + this->typed_event_channel_->create_operation_list (oper_params, list); + ACE_CHECK; + + // Get the operation arguments. This ahould demarshal correctly. + request->arguments (list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Populate the TypedEvent with the list and operation name. + TAO_CEC_TypedEvent typed_event (list, request->operation () ); + + // Pass the TypedEvent to the TypedProxyPushConsumer + this->typed_pp_consumer_->invoke (typed_event); + ACE_CHECK; + } + } +} + +CORBA::RepositoryId +TAO_CEC_DynamicImplementationServer::_primary_interface (const PortableServer::ObjectId &, + PortableServer::POA_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (()) +{ + return CORBA::string_dup (repository_id_); +} + +PortableServer::POA_ptr +TAO_CEC_DynamicImplementationServer::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} + +void +TAO_CEC_DynamicImplementationServer::is_a (CORBA::ServerRequest_ptr request + ACE_ENV_ARG_DECL) +{ + CORBA::NVList_ptr list; + + this->typed_event_channel_->create_list (0, list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Any any_1; + any_1._tao_set_typecode(CORBA::_tc_string); + + list->add_value ("value", + any_1, + CORBA::ARG_IN + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + request->arguments (list + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::NamedValue_ptr nv = list->item (0 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Any_ptr ap = nv->value (); + const char *value; + *ap >>= value; + + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** TAO_CEC_DynamicImplementationServer::is_a called with value %s *****\n", + value)); + } + + const char *object_id = + CORBA::_tc_Object->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** is_a using Server's RepositoryId %s *****\n", this->repository_id_)); + ACE_DEBUG ((LM_DEBUG, "***** is_a using base interface %s *****\n", object_id)); + } + + CORBA::Boolean result = 0; + if (ACE_OS::strcmp (value, this->repository_id_) == 0 + || ACE_OS::strcmp (value, object_id) == 0) + { + result = 1; + } + else + { + CORBA::ULong num = this->typed_event_channel_->number_of_base_interfaces (); + for (CORBA::ULong base=0; base<num; base++) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** is_a using base interface %s *****\n", + this->typed_event_channel_->base_interfaces (base) )); + } + + if (ACE_OS::strcmp (value, this->typed_event_channel_->base_interfaces (base) ) == 0) + { + result = 1; + } + } + } + + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** is_a returning %d *****\n", result)); + } + + CORBA::Any result_any; + CORBA::Any::from_boolean from_boolean (result); + result_any <<= from_boolean; + + request->set_result (result_any ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.h new file mode 100644 index 00000000000..008f2cf16e9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.h @@ -0,0 +1,78 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file CEC_DynamicImplementation.h + * + * $Id$ + * + * @author Jon Astle (jon@astle45.fsnet.co.uk) + */ +//============================================================================= + + +#ifndef TAO_CEC_DYNAMICIMPLEMENTATION_H +#define TAO_CEC_DYNAMICIMPLEMENTATION_H + +#include "tao/ORB.h" +#include "tao/DynamicInterface/Server_Request.h" +#include "tao/DynamicInterface/Dynamic_Implementation.h" +#include "CEC_TypedProxyPushConsumer.h" +#include "CEC_TypedEventChannel.h" + +class TAO_CEC_DynamicImplementationServer : public TAO_DynamicImplementation +{ + // = TITLE + // DSI TAO_CEC_DynamicImplementationServer implementation + // + // = DESCRIPTION + // Implements the DSI impl object + // +public: + + // Constructure + TAO_CEC_DynamicImplementationServer (PortableServer::POA_ptr poa, + TAO_CEC_TypedProxyPushConsumer *typed_pp_consumer, + TAO_CEC_TypedEventChannel *typed_event_channel); + + //Destructor + virtual ~TAO_CEC_DynamicImplementationServer (void); + + // = The DynamicImplementation methods. + virtual void invoke (CORBA::ServerRequest_ptr request + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::RepositoryId _primary_interface ( + const PortableServer::ObjectId &oid, + PortableServer::POA_ptr poa + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (()); + + virtual PortableServer::POA_ptr _default_POA ( + ACE_ENV_SINGLE_ARG_DECL + ); + + // Handles the _is_a call + virtual void is_a (CORBA::ServerRequest_ptr request + ACE_ENV_ARG_DECL); + +private: + // The POA + PortableServer::POA_var poa_; + + // The Typed Proxy Push Consumer Implementation + TAO_CEC_TypedProxyPushConsumer *typed_pp_consumer_; + + // The Typed Event Channel Implementation + TAO_CEC_TypedEventChannel *typed_event_channel_; + + // The RepositoryId + CORBA::RepositoryId repository_id_; +}; + +#if defined(__ACE_INLINE__) +#include "CEC_DynamicImplementation.i" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_CEC_DYNAMICIMPLEMENTATION_H */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.i new file mode 100644 index 00000000000..5058927e3c9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_DynamicImplementation.i @@ -0,0 +1,14 @@ +// $Id$ + +ACE_INLINE +TAO_CEC_DynamicImplementationServer::TAO_CEC_DynamicImplementationServer + (PortableServer::POA_ptr poa, + TAO_CEC_TypedProxyPushConsumer *typed_pp_consumer, + TAO_CEC_TypedEventChannel *typed_event_channel) + : poa_ (PortableServer::POA::_duplicate (poa)), + typed_pp_consumer_ (typed_pp_consumer), + typed_event_channel_ (typed_event_channel), + repository_id_ (CORBA::string_dup (typed_event_channel->supported_interface () )) +{ +} + diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp index de30ad6169c..75a841772c0 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp @@ -11,6 +11,7 @@ // AUTHOR // Priyanka Gontla <pgontla@ece.uci.edu> // Carlos O'Ryan <coryan@uci.edu> +// Jon Astle <jon@astle45.fsnet.co.uk> // //=========================================================================== @@ -53,6 +54,9 @@ TAO_CEC_Event_Loader::init (int argc, ACE_TCHAR *argv[]) CORBA::Object_var obj = this->create_object (this->orb_.in (), command_line.get_argc(), command_line.get_TCHAR_argv() ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + + if (CORBA::is_nil (obj.in() )) + return -1; } ACE_CATCHANY { @@ -85,13 +89,20 @@ TAO_CEC_Event_Loader::create_object (CORBA::ORB_ptr orb, // Parse the options, check if we should bind with the naming // service and under what name... - ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("o:n:xr")); + ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("o:n:xrtd")); int opt; const ACE_TCHAR *service_name = ACE_LIB_TEXT("CosEventService"); const ACE_TCHAR *ior_file = 0; this->bind_to_naming_service_ = 1; int use_rebind = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + // Flag to create a typed event channel + int typed_ec = 0; + // Flag to destroy the event channel on shutdown + int destroy = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + while ((opt = get_opt ()) != EOF) { switch (opt) @@ -112,8 +123,29 @@ TAO_CEC_Event_Loader::create_object (CORBA::ORB_ptr orb, use_rebind = 1; break; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + case 't': + typed_ec = 1; + break; + + case 'd': + destroy = 1; + break; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + case '?': default: +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + ACE_DEBUG ((LM_DEBUG, + "Usage: %s " + "-n service_name " + "-x [disable naming service bind] " + "-r [rebind, no AlreadyBound failures] " + "-t [enable typed event channel] " + "-d [destroy typed event channel on shutdown] " + "\n", + argv[0])); +#else ACE_DEBUG ((LM_DEBUG, "Usage: %s " "-n service_name " @@ -121,6 +153,7 @@ TAO_CEC_Event_Loader::create_object (CORBA::ORB_ptr orb, "-r [rebind, no AlreadyBound failures] " "\n", argv[0])); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ return CORBA::Object::_nil (); } } @@ -146,6 +179,11 @@ TAO_CEC_Event_Loader::create_object (CORBA::ORB_ptr orb, // Control the event loop this->terminate_flag_ = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (!typed_ec) + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + // Create and activate the event service this->attributes_ = new TAO_CEC_EventChannel_Attributes(poa.in (), poa.in ()); @@ -206,6 +244,127 @@ TAO_CEC_Event_Loader::create_object (CORBA::ORB_ptr orb, ACE_TRY_CHECK; } } + return CosEventChannelAdmin::EventChannel::_duplicate (event_channel.in () ); + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } + else + { + // If Typed EC, initialize the IFR, then create and activate the typed event service + + // **************************************************************** + // IFR initialization + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Initializing the IFR connection... *****\n")); + } + + CORBA::Repository_var interface_repository; + + CORBA::Object_var ifr_obj_var = + orb->resolve_initial_references ("InterfaceRepository" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil(ifr_obj_var.in () )) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** resolve_initial_references for IFR failed\n *****")); + } + return CORBA::Object::_nil (); + } + else + { + interface_repository = CORBA::Repository::_narrow(ifr_obj_var.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (TAO_debug_level >= 10) + { + if (CORBA::is_nil(interface_repository.in () )) + { + ACE_DEBUG ((LM_DEBUG, "***** CORBA::Repository::_narrow failed *****\n")); + return CORBA::Object::_nil (); + } + else + { + ACE_DEBUG ((LM_DEBUG, "***** ...IFR connection completed *****\n")); + } + } + } + + // Create and activate the typed event service + this->typed_attributes_ = new TAO_CEC_TypedEventChannel_Attributes(poa.in (), + poa.in (), + orb, + interface_repository.in ()); + if (destroy == 1) + { + this->typed_attributes_->destroy_on_shutdown = 1; + } + + this->factory_ = 0; + + this->typed_ec_impl_ = new TAO_CEC_TypedEventChannel (*this->typed_attributes_, + this->factory_, + this->terminate_flag_); + + this->typed_ec_impl_->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CosTypedEventChannelAdmin::TypedEventChannel_var event_channel = + this->typed_ec_impl_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ior_file != 0) + { + CORBA::String_var ior = + orb->object_to_string (event_channel.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + FILE *file = ACE_OS::fopen (ior_file, "w"); + ACE_OS::fprintf (file, "%s\n", ior.in ()); + ACE_OS::fclose (file); + } + + // **************************************************************** + + this->channel_name_.length (1); + + if (this->bind_to_naming_service_) + { + CORBA::Object_var obj = + orb->resolve_initial_references ("NameService" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->naming_context_ = + CosNaming::NamingContext::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->channel_name_.length (1); + this->channel_name_[0].id = CORBA::string_dup (service_name); + + if (use_rebind) + { + this->naming_context_->rebind (this->channel_name_, + event_channel.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + else + { + this->naming_context_->bind (this->channel_name_, + event_channel.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + return CosTypedEventChannelAdmin::TypedEventChannel::_duplicate (event_channel.in () ); + } +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + + // **************************************************************** } ACE_CATCHANY { @@ -226,6 +385,24 @@ TAO_CEC_Event_Loader::fini (void) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + // Release the resources of the Typed Event Channel + this->typed_ec_impl_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Deactivate the Typed EC + // This will raise an exception if destroy == 1 + PortableServer::POA_var t_poa = + this->typed_ec_impl_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var t_id = + t_poa->servant_to_id (this->typed_ec_impl_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + t_poa->deactivate_object (t_id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; +#else // Release the resources of the Event Channel this->ec_impl_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; @@ -241,7 +418,17 @@ TAO_CEC_Event_Loader::fini (void) poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + } + ACE_CATCHANY + { + // Do Nothing + } + ACE_ENDTRY; + + ACE_TRY + { // Unbind the Naming Service if (this->bind_to_naming_service_) { @@ -251,9 +438,13 @@ TAO_CEC_Event_Loader::fini (void) } // Since we created them, we also have to delete them. +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + delete this->typed_attributes_; + delete this->typed_ec_impl_; +#else delete this->attributes_; delete this->ec_impl_; - +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } ACE_CATCHANY { diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.h index 1055d44f41c..ba1b38e1d8a 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.h @@ -18,6 +18,9 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "CEC_EventChannel.h" +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "CEC_TypedEventChannel.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #include "orbsvcs/CosNamingC.h" #include "ace/Service_Config.h" @@ -70,6 +73,14 @@ protected: /// The Event Service implementation class. TAO_CEC_EventChannel *ec_impl_; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + /// Attributes used to configure the Typed Event Service properties. + TAO_CEC_TypedEventChannel_Attributes *typed_attributes_; + + /// The Typed Event Service implementation class. + TAO_CEC_TypedEventChannel *typed_ec_impl_; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// Naming Context needed if '-x' option is passed CosNaming::NamingContext_var naming_context_; diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Factory.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Factory.h index 78fd438a455..bc92de0b99b 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Factory.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Factory.h @@ -39,7 +39,17 @@ template<class PROXY> class TAO_ESF_Proxy_Collection; class TAO_CEC_ConsumerControl; class TAO_CEC_SupplierControl; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_TypedEventChannel; +class TAO_CEC_TypedProxyPushConsumer; +class TAO_CEC_TypedConsumerAdmin; +class TAO_CEC_TypedSupplierAdmin; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + typedef TAO_ESF_Proxy_Collection<TAO_CEC_ProxyPushConsumer> TAO_CEC_ProxyPushConsumer_Collection; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +typedef TAO_ESF_Proxy_Collection<TAO_CEC_TypedProxyPushConsumer> TAO_CEC_TypedProxyPushConsumer_Collection; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ typedef TAO_ESF_Proxy_Collection<TAO_CEC_ProxyPullConsumer> TAO_CEC_ProxyPullConsumer_Collection; typedef TAO_ESF_Proxy_Collection<TAO_CEC_ProxyPushSupplier> TAO_CEC_ProxyPushSupplier_Collection; typedef TAO_ESF_Proxy_Collection<TAO_CEC_ProxyPullSupplier> TAO_CEC_ProxyPullSupplier_Collection; @@ -68,6 +78,10 @@ public: /// Create and destroy the dispatching module. virtual TAO_CEC_Dispatching* create_dispatching (TAO_CEC_EventChannel*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_Dispatching* + create_dispatching (TAO_CEC_TypedEventChannel*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ virtual void destroy_dispatching (TAO_CEC_Dispatching*) = 0; @@ -82,16 +96,32 @@ public: create_consumer_admin (TAO_CEC_EventChannel*) = 0; virtual void destroy_consumer_admin (TAO_CEC_ConsumerAdmin*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_TypedConsumerAdmin* + create_consumer_admin (TAO_CEC_TypedEventChannel*) = 0; + virtual void + destroy_consumer_admin (TAO_CEC_TypedConsumerAdmin*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /// Create and destroy the supplier admin implementation. virtual TAO_CEC_SupplierAdmin* create_supplier_admin (TAO_CEC_EventChannel*) = 0; virtual void destroy_supplier_admin (TAO_CEC_SupplierAdmin*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_TypedSupplierAdmin* + create_supplier_admin (TAO_CEC_TypedEventChannel*) = 0; + virtual void + destroy_supplier_admin (TAO_CEC_TypedSupplierAdmin*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /// Create and destroy a ProxyPushSupplier virtual TAO_CEC_ProxyPushSupplier* create_proxy_push_supplier (TAO_CEC_EventChannel*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_ProxyPushSupplier* + create_proxy_push_supplier (TAO_CEC_TypedEventChannel*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ virtual void destroy_proxy_push_supplier (TAO_CEC_ProxyPushSupplier*) = 0; @@ -107,6 +137,14 @@ public: virtual void destroy_proxy_push_consumer (TAO_CEC_ProxyPushConsumer*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + /// Create and destroy a TypedProxyPushConsumer + virtual TAO_CEC_TypedProxyPushConsumer* + create_proxy_push_consumer (TAO_CEC_TypedEventChannel*) = 0; + virtual void + destroy_proxy_push_consumer (TAO_CEC_TypedProxyPushConsumer*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// Create and destroy a ProxyPullConsumer virtual TAO_CEC_ProxyPullConsumer* create_proxy_pull_consumer (TAO_CEC_EventChannel*) = 0; @@ -119,6 +157,14 @@ public: virtual void destroy_proxy_push_consumer_collection (TAO_CEC_ProxyPushConsumer_Collection*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + /// Create and destroy a collection of TAO_CEC_TypedProxyPushConsumers + virtual TAO_CEC_TypedProxyPushConsumer_Collection* + create_proxy_push_consumer_collection (TAO_CEC_TypedEventChannel*) = 0; + virtual void + destroy_proxy_push_consumer_collection (TAO_CEC_TypedProxyPushConsumer_Collection*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// Create and destroy a collection of TAO_CEC_ProxyPullConsumers virtual TAO_CEC_ProxyPullConsumer_Collection* create_proxy_pull_consumer_collection (TAO_CEC_EventChannel*) = 0; @@ -128,6 +174,10 @@ public: /// Create and destroy a collection of TAO_CEC_ProxyPushSuppliers virtual TAO_CEC_ProxyPushSupplier_Collection* create_proxy_push_supplier_collection (TAO_CEC_EventChannel*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_ProxyPushSupplier_Collection* + create_proxy_push_supplier_collection (TAO_CEC_TypedEventChannel*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ virtual void destroy_proxy_push_supplier_collection (TAO_CEC_ProxyPushSupplier_Collection*) = 0; @@ -148,10 +198,18 @@ public: /// discard non-existent consumers and suppliers virtual TAO_CEC_ConsumerControl* create_consumer_control (TAO_CEC_EventChannel*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_ConsumerControl* + create_consumer_control (TAO_CEC_TypedEventChannel*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ virtual void destroy_consumer_control (TAO_CEC_ConsumerControl*) = 0; virtual TAO_CEC_SupplierControl* create_supplier_control (TAO_CEC_EventChannel*) = 0; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual TAO_CEC_SupplierControl* + create_supplier_control (TAO_CEC_TypedEventChannel*) = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ virtual void destroy_supplier_control (TAO_CEC_SupplierControl*) = 0; }; diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.cpp index bec500f45bf..3a29103cb96 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.cpp @@ -80,3 +80,26 @@ TAO_CEC_MT_Dispatching::push_nocopy (TAO_CEC_ProxyPushSupplier* proxy, this->task_.push (proxy, event ACE_ENV_ARG_PARAMETER); } + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_MT_Dispatching::invoke (TAO_CEC_ProxyPushSupplier* proxy, + const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + TAO_CEC_TypedEvent typed_event_copy = typed_event; + this->invoke_nocopy (proxy, typed_event_copy ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_MT_Dispatching::invoke_nocopy (TAO_CEC_ProxyPushSupplier* proxy, + TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + // Double checked locking.... + if (this->active_ == 0) + this->activate (); + + this->task_.invoke (proxy, typed_event ACE_ENV_ARG_PARAMETER); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.h index fbed6224840..a95b8b59465 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_MT_Dispatching.h @@ -52,6 +52,14 @@ public: virtual void push_nocopy (TAO_CEC_ProxyPushSupplier* proxy, CORBA::Any& event ACE_ENV_ARG_DECL); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void invoke (TAO_CEC_ProxyPushSupplier *proxy, + const TAO_CEC_TypedEvent & typed_event + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + virtual void invoke_nocopy (TAO_CEC_ProxyPushSupplier *proxy, + TAO_CEC_TypedEvent & typed_event + ACE_ENV_ARG_DECL_WITH_DEFAULTS); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ private: /// Use our own thread manager. diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.cpp index 2e2b42161b8..f6153df1220 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.cpp @@ -6,6 +6,11 @@ #include "CEC_ConsumerControl.h" #include "orbsvcs/ESF/ESF_RefCount_Guard.h" #include "orbsvcs/ESF/ESF_Proxy_RefCount_Guard.h" +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "CEC_TypedEvent.h" +#include "CEC_TypedEventChannel.h" +#include "tao/DynamicInterface/Request.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #include "ace/Reverse_Lock_T.h" @@ -19,10 +24,15 @@ ACE_RCSID (CosEvent, typedef ACE_Reverse_Lock<ACE_Lock> TAO_CEC_Unlock; +// TAO_CEC_ProxyPushSupplier Constructure (Un-typed EC) TAO_CEC_ProxyPushSupplier::TAO_CEC_ProxyPushSupplier (TAO_CEC_EventChannel* ec) : event_channel_ (ec), refcount_ (1) { +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + typed_event_channel_ = 0; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + this->lock_ = this->event_channel_->create_supplier_lock (); @@ -30,9 +40,36 @@ TAO_CEC_ProxyPushSupplier::TAO_CEC_ProxyPushSupplier (TAO_CEC_EventChannel* ec) this->event_channel_->supplier_poa (); } +// TAO_CEC_ProxyPushSupplier Constructure (Typed EC) +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_ProxyPushSupplier::TAO_CEC_ProxyPushSupplier (TAO_CEC_TypedEventChannel* ec) + : typed_event_channel_ (ec), + refcount_ (1) +{ + event_channel_ = 0; + + this->lock_ = + this->typed_event_channel_->create_supplier_lock (); + + this->default_POA_ = + this->typed_event_channel_->typed_supplier_poa (); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_ProxyPushSupplier::~TAO_CEC_ProxyPushSupplier (void) { +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + this->typed_event_channel_->destroy_supplier_lock (this->lock_); + } + else + { + this->event_channel_->destroy_supplier_lock (this->lock_); + } +#else this->event_channel_->destroy_supplier_lock (this->lock_); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } void @@ -83,6 +120,44 @@ TAO_CEC_ProxyPushSupplier::deactivate (ACE_ENV_SINGLE_ARG_DECL) void TAO_CEC_ProxyPushSupplier::shutdown (ACE_ENV_SINGLE_ARG_DECL) { +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + // Save the consumer we where connected to, we need to send a + // disconnect message to it. + CosTypedEventComm::TypedPushConsumer_var typed_consumer; + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + typed_consumer = this->typed_consumer_._retn (); + } + + this->deactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (typed_consumer.in ())) + return; + + ACE_TRY + { + typed_consumer->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore exceptions, we must isolate other clients from + // problems on this one. + } + ACE_ENDTRY; + } /* this->is_typed_ec */ + else + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + // Save the consumer we where connected to, we need to send a // disconnect message to it. CosEventComm::PushConsumer_var consumer; @@ -114,6 +189,9 @@ TAO_CEC_ProxyPushSupplier::shutdown (ACE_ENV_SINGLE_ARG_DECL) // problems on this one. } ACE_ENDTRY; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } /* ! this->is_typed_ec */ +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } typedef TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_EventChannel,TAO_CEC_ProxyPushSupplier> Destroy_Guard; @@ -146,6 +224,38 @@ TAO_CEC_ProxyPushSupplier::push (const CORBA::Any &event } } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +typedef TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier> Destroy_Guard_Typed; + +void +TAO_CEC_ProxyPushSupplier::invoke (const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + Destroy_Guard_Typed auto_destroy (this->refcount_, + this->typed_event_channel_, + this); + { + + ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); + + if (this->is_connected_i () == 0) + return; + + TAO_ESF_RefCount_Guard<CORBA::ULong> cnt_mon (this->refcount_); + + { + TAO_CEC_Unlock reverse_lock (*this->lock_); + + ACE_GUARD (TAO_CEC_Unlock, ace_mon, reverse_lock); + this->typed_event_channel_->dispatching ()->invoke (this, + typed_event + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_ProxyPushSupplier::push_nocopy (CORBA::Any &event ACE_ENV_ARG_DECL) @@ -179,6 +289,10 @@ TAO_CEC_ProxyPushSupplier::cleanup_i (void) { this->consumer_ = CosEventComm::PushConsumer::_nil (); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + this->typed_consumer_ = + CosTypedEventComm::TypedPushConsumer::_nil (); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } CORBA::ULong @@ -199,7 +313,18 @@ TAO_CEC_ProxyPushSupplier::_decr_refcnt (void) } // Notify the event channel +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + this->typed_event_channel_->destroy_proxy (this); + } + else + { + this->event_channel_->destroy_proxy (this); + } +#else this->event_channel_->destroy_proxy (this); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ return 0; } @@ -216,6 +341,91 @@ TAO_CEC_ProxyPushSupplier::connect_push_consumer ( ACE_THROW (CORBA::BAD_PARAM ()); { + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + // Check if we have a typed event channel + if (this->is_typed_ec () ) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** connect_push_consumer, Event channel is typed *****\n")); + } + + // Temporary for the TypedPushConsumer and it's Typed interface, + // declared and obtained before the Guard to avoid deadlock during the + // _is_a (during _narrow) and get_typed_consumer invocations. + // They are eventually assigned onto this object inside the Guard. + CosTypedEventComm::TypedPushConsumer_var local_typed_consumer = + CosTypedEventComm::TypedPushConsumer::_narrow (push_consumer + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Obtain the typed object interface from the consumer + CORBA::Object_var local_typed_consumer_obj = + CORBA::Object::_duplicate (local_typed_consumer->get_typed_consumer ( + ACE_ENV_SINGLE_ARG_PARAMETER) ); + ACE_CHECK; + + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + if (this->is_connected_i ()) + { + if (this->typed_event_channel_->consumer_reconnect () == 0) + ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); + + // Re-connections are allowed.... + this->cleanup_i (); + + this->typed_consumer_ = + CosTypedEventComm::TypedPushConsumer::_duplicate (local_typed_consumer.in () ); + ACE_CHECK; + + TAO_CEC_Unlock reverse_lock (*this->lock_); + + { + ACE_GUARD_THROW_EX ( + TAO_CEC_Unlock, ace_mon, reverse_lock, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + this->typed_event_channel_->reconnected (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + return; + + } + + this->typed_consumer_ = + CosTypedEventComm::TypedPushConsumer::_duplicate (local_typed_consumer.in () ); + ACE_CHECK; + + // Store the typed object interface from the consumer + this->typed_consumer_obj_ = + CORBA::Object::_duplicate (local_typed_consumer_obj.in () ); + ACE_CHECK; + } + + // Notify the event channel... + this->typed_event_channel_->connected (this ACE_ENV_ARG_PARAMETER); + + } /* this->is_typed_ec */ + else + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** connect_push_consumer, Event channel is un-typed *****\n")); + } + + { + ACE_GUARD_THROW_EX ( ACE_Lock, ace_mon, *this->lock_, CORBA::INTERNAL ()); @@ -254,6 +464,11 @@ TAO_CEC_ProxyPushSupplier::connect_push_consumer ( // Notify the event channel... this->event_channel_->connected (this ACE_ENV_ARG_PARAMETER); + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } /* ! this->is_typed_ec */ +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + } } void @@ -262,6 +477,9 @@ TAO_CEC_ProxyPushSupplier::disconnect_push_supplier ( ACE_THROW_SPEC ((CORBA::SystemException)) { CosEventComm::PushConsumer_var consumer; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + CosTypedEventComm::TypedPushConsumer_var typed_consumer; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ { ACE_GUARD_THROW_EX ( @@ -273,14 +491,63 @@ TAO_CEC_ProxyPushSupplier::disconnect_push_supplier ( if (this->is_connected_i () == 0) ACE_THROW (CORBA::BAD_INV_ORDER ()); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + typed_consumer = this->typed_consumer_._retn (); + } + else + { + consumer = this->consumer_._retn (); + } +#else consumer = this->consumer_._retn (); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ this->cleanup_i (); } // Notify the event channel.... +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + this->typed_event_channel_->disconnected (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + this->event_channel_->disconnected (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +#else this->event_channel_->disconnected (this ACE_ENV_ARG_PARAMETER); ACE_CHECK; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + + // Disconnect callbacks +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + if (this->typed_event_channel_->disconnect_callbacks ()) + { + ACE_TRY + { + typed_consumer->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore exceptions, we must isolate other clients from + // problems on this one. + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ProxySupplier::disconnect_push_supplier"); + } + ACE_ENDTRY; + } + } /* this->is_typed_ec */ + else + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ if (this->event_channel_->disconnect_callbacks ()) { @@ -298,6 +565,10 @@ TAO_CEC_ProxyPushSupplier::disconnect_push_supplier ( } ACE_ENDTRY; } + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } /* ! this->is_typed_ec */ +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } void @@ -394,6 +665,171 @@ TAO_CEC_ProxyPushSupplier::reactive_push_to_consumer ( ACE_ENDTRY; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_ProxyPushSupplier::invoke_to_consumer (const TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL) +{ + CORBA::Object_var typed_consumer_obj; + + // The DII target request object + CORBA::Request_var target_request; + + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + if (this->is_connected_i () == 0) + return; // ACE_THROW (CosEventComm::Disconnected ());???? + + typed_consumer_obj = + CORBA::Object::_duplicate (this->typed_consumer_obj_.in ()); + } + + // Create the DII request + ACE_TRY + { + typed_consumer_obj_->_create_request (0, // ctx + typed_event.operation_, + typed_event.list_, + 0, // result + 0, // exception_list, + 0, // context_list, + target_request.inout(), + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Call the DII invoke for the operation on the target object + target_request->invoke (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::OBJECT_NOT_EXIST, not_used) + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (not_used, "during TAO_CEC_ProxyPushSupplier::invoke_to_consumer"); + } + + TAO_CEC_ConsumerControl *control = + this->typed_event_channel_->consumer_control (); + + control->consumer_not_exist (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::SystemException, sysex) + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (sysex, "during TAO_CEC_ProxyPushSupplier::invoke_to_consumer"); + } + + TAO_CEC_ConsumerControl *control = + this->typed_event_channel_->consumer_control (); + + control->system_exception (this, + sysex + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Shouldn't happen, but does not hurt + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ACE_ANY_EXCEPTION raised during TAO_CEC_ProxyPushSupplier::invoke_to_consumer"); + } + } + ACE_ENDTRY; +} + +void +TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer ( + const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) +{ + CORBA::Object_var typed_consumer_obj; + + // The DII target request object + CORBA::Request_var target_request; + + { + ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); + if (this->is_connected_i () == 0) + { + return; // TAO_THROW (CosEventComm::Disconnected ());???? + } + if (CORBA::is_nil(this->typed_consumer_obj_.in())) + { + return; // TAO_THROW ... + } + + typed_consumer_obj = + CORBA::Object::_duplicate (this->typed_consumer_obj_.in ()); + } + + // Create the DII request + ACE_TRY + { + typed_consumer_obj_->_create_request (0, // ctx + typed_event.operation_, + typed_event.list_, + 0, // result + 0, // exception_list, + 0, // context_list, + target_request.inout(), + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Call the DII invoke for the operation on the target object + target_request->invoke (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::OBJECT_NOT_EXIST, not_used) + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (not_used, "during TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer"); + } + + TAO_CEC_ConsumerControl *control = + this->typed_event_channel_->consumer_control (); + + control->consumer_not_exist (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::SystemException, sysex) + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (sysex, "during TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer"); + } + + TAO_CEC_ConsumerControl *control = + this->typed_event_channel_->consumer_control (); + + control->system_exception (this, + sysex + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ACE_ANY_EXCEPTION raised during TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer"); + } + } + ACE_ENDTRY; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + CORBA::Boolean TAO_CEC_ProxyPushSupplier::consumer_non_existent ( CORBA::Boolean_out disconnected @@ -412,11 +848,27 @@ TAO_CEC_ProxyPushSupplier::consumer_non_existent ( disconnected = 1; return 0; } + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec () ) + { + if (CORBA::is_nil (this->typed_consumer_.in ())) + { + return 0; + } + consumer = CORBA::Object::_duplicate (this->typed_consumer_.in ()); + } + else + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ if (CORBA::is_nil (this->consumer_.in ())) { return 0; } consumer = CORBA::Object::_duplicate (this->consumer_.in ()); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } /* ! this->is_typed_ec */ +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } #if (TAO_HAS_MINIMUM_CORBA == 0) @@ -448,10 +900,16 @@ TAO_CEC_ProxyPushSupplier::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) template class TAO_ESF_RefCount_Guard<CORBA::ULong>; template class TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_EventChannel,TAO_CEC_ProxyPushSupplier>; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +template class TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier>; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate TAO_ESF_RefCount_Guard<CORBA::ULong> #pragma instantiate TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_EventChannel,TAO_CEC_ProxyPushSupplier> +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#pragma instantiate TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier> +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.h index 7ef8e2e59f4..c590ff510af 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.h @@ -5,7 +5,8 @@ * * $Id$ * - * @author Carlos O'Ryan (coryan@cs.wustl.edu) + * @authors Carlos O'Ryan (coryan@cs.wustl.edu) + * Jon Astle (jon@astle45.fsnet.co.uk) */ //============================================================================= @@ -15,6 +16,9 @@ #include /**/ "ace/pre.h" #include "orbsvcs/CosEventChannelAdminS.h" +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "orbsvcs/CosTypedEventChannelAdminS.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #include "event_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -23,6 +27,10 @@ class TAO_CEC_EventChannel; class TAO_CEC_ProxyPushConsumer; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_TypedEvent; +class TAO_CEC_TypedEventChannel; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /** * @class TAO_CEC_ProxyPushSupplier @@ -50,6 +58,11 @@ public: /// constructor... TAO_CEC_ProxyPushSupplier (TAO_CEC_EventChannel* event_channel); + /// typed ec constructor +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + TAO_CEC_ProxyPushSupplier (TAO_CEC_TypedEventChannel* typed_event_channel); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// destructor... virtual ~TAO_CEC_ProxyPushSupplier (void); @@ -82,12 +95,23 @@ public: ACE_ENV_ARG_DECL); virtual void push_nocopy (CORBA::Any &event ACE_ENV_ARG_DECL); + /// Internal methods to invoke a typed event to each consumer. +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void invoke (const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /// Pushes to the consumer, verifies that it is connected. void push_to_consumer (const CORBA::Any &event ACE_ENV_ARG_DECL); void reactive_push_to_consumer (const CORBA::Any &event ACE_ENV_ARG_DECL); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + void invoke_to_consumer (const TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL); + void reactive_invoke_to_consumer (const TAO_CEC_TypedEvent &typed_event + ACE_ENV_ARG_DECL); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /** * Invoke the _non_existent() pseudo-operation on the consumer. If @@ -121,6 +145,10 @@ protected: /// policies used when invoking operations on the consumer. void consumer (CosEventComm::PushConsumer_ptr consumer); void consumer_i (CosEventComm::PushConsumer_ptr consumer); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + void consumer (CosTypedEventComm::TypedPushConsumer_ptr typed_consumer); + void consumer_i (CosTypedEventComm::TypedPushConsumer_ptr typed_consumer); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /// The private version (without locking) of is_connected(). CORBA::Boolean is_connected_i (void) const; @@ -128,10 +156,19 @@ protected: /// Release the child and the consumer void cleanup_i (void); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + CORBA::Boolean is_typed_ec (void) const; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + private: /// The Event Channel that owns this object. TAO_CEC_EventChannel* event_channel_; + /// The Typed Event Channel that owns this object. +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + TAO_CEC_TypedEventChannel *typed_event_channel_; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// The locking strategy. ACE_Lock* lock_; @@ -141,6 +178,14 @@ private: /// The consumer.... CosEventComm::PushConsumer_var consumer_; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + /// The typed consumer.... + CosTypedEventComm::TypedPushConsumer_var typed_consumer_; + + /// The consumer object returned from get_typed_consumer() + CORBA::Object_var typed_consumer_obj_; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// Store the default POA. PortableServer::POA_var default_POA_; }; diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.i index 54f0c181a35..e7453b533dc 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.i +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_ProxyPushSupplier.i @@ -3,7 +3,18 @@ ACE_INLINE CORBA::Boolean TAO_CEC_ProxyPushSupplier::is_connected_i (void) const { +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec ()) + { + return !CORBA::is_nil (this->typed_consumer_.in ()); + } + else + { return !CORBA::is_nil (this->consumer_.in ()); + } +#else + return !CORBA::is_nil (this->consumer_.in ()); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } ACE_INLINE CORBA::Boolean @@ -19,7 +30,18 @@ TAO_CEC_ProxyPushSupplier::consumer (void) const { ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->is_typed_ec ()) + { + return this->typed_consumer_.in (); + } + else + { + return this->consumer_.in (); + } +#else return this->consumer_.in (); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } ACE_INLINE void @@ -28,6 +50,14 @@ TAO_CEC_ProxyPushSupplier::consumer_i (CosEventComm::PushConsumer_ptr consumer) this->consumer_ = consumer; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +ACE_INLINE void +TAO_CEC_ProxyPushSupplier::consumer_i (CosTypedEventComm::TypedPushConsumer_ptr typed_consumer) +{ + this->typed_consumer_ = typed_consumer; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + ACE_INLINE void TAO_CEC_ProxyPushSupplier::consumer (CosEventComm::PushConsumer_ptr consumer) { @@ -35,3 +65,28 @@ TAO_CEC_ProxyPushSupplier::consumer (CosEventComm::PushConsumer_ptr consumer) this->consumer_i (consumer); } + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +ACE_INLINE void +TAO_CEC_ProxyPushSupplier::consumer (CosTypedEventComm::TypedPushConsumer_ptr typed_consumer) +{ + ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); + + this->consumer_i (typed_consumer); +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +ACE_INLINE CORBA::Boolean +TAO_CEC_ProxyPushSupplier::is_typed_ec (void) const +{ + if (this->typed_event_channel_ != 0) + { + return 1; + } + else + { + return 0; + } +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.cpp index 404fac5d5ba..19952e72a15 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.cpp @@ -3,6 +3,10 @@ #include "CEC_Reactive_ConsumerControl.h" #include "CEC_EventChannel.h" #include "CEC_ConsumerAdmin.h" +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "CEC_TypedEventChannel.h" +#include "CEC_TypedConsumerAdmin.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #include "CEC_ProxyPushSupplier.h" #include "CEC_ProxyPullSupplier.h" #include "tao/Messaging/Messaging.h" @@ -36,6 +40,29 @@ TAO_CEC_Reactive_ConsumerControl:: #endif /* TAO_HAS_CORBA_MESSAGING */ } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_Reactive_ConsumerControl:: + TAO_CEC_Reactive_ConsumerControl (const ACE_Time_Value &rate, + const ACE_Time_Value &timeout, + TAO_CEC_TypedEventChannel *ec, + CORBA::ORB_ptr orb) + : rate_ (rate), + timeout_ (timeout), + adapter_ (this), + typed_event_channel_ (ec), + orb_ (CORBA::ORB::_duplicate (orb)) +{ + this->reactor_ = + this->orb_->orb_core ()->reactor (); + +#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 + // Initialise timer_id_ to an invalid timer id, so that in case we don't + // schedule a timer, we don't cancel a random timer at shutdown + timer_id_ = -1; +#endif /* TAO_HAS_CORBA_MESSAGING */ +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_Reactive_ConsumerControl::~TAO_CEC_Reactive_ConsumerControl (void) { } @@ -45,6 +72,18 @@ TAO_CEC_Reactive_ConsumerControl::query_consumers ( ACE_ENV_SINGLE_ARG_DECL) { TAO_CEC_Ping_Push_Consumer push_worker (this); + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->typed_event_channel_) + { + this->typed_event_channel_->typed_consumer_admin ()->for_each (&push_worker + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + this->event_channel_->consumer_admin ()->for_each (&push_worker ACE_ENV_ARG_PARAMETER); ACE_CHECK; @@ -53,6 +92,10 @@ TAO_CEC_Reactive_ConsumerControl::query_consumers ( this->event_channel_->consumer_admin ()->for_each (&pull_worker ACE_ENV_ARG_PARAMETER); ACE_CHECK; + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } void diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.h index 5742f18a5a3..4062b51eaef 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.h @@ -32,6 +32,10 @@ class TAO_CEC_EventChannel; class TAO_CEC_Reactive_ConsumerControl; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_TypedEventChannel; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /** * @class TAO_CEC_ConsumerControl_Adapter * @@ -77,6 +81,14 @@ public: TAO_CEC_EventChannel *event_channel, CORBA::ORB_ptr orb); + /// Constructor for the typed ec. +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + TAO_CEC_Reactive_ConsumerControl (const ACE_Time_Value &rate, + const ACE_Time_Value &timeout, + TAO_CEC_TypedEventChannel *typed_event_channel, + CORBA::ORB_ptr orb); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// destructor... virtual ~TAO_CEC_Reactive_ConsumerControl (void); @@ -113,6 +125,11 @@ private: /// The event channel TAO_CEC_EventChannel *event_channel_; + /// The typed event channel +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + TAO_CEC_TypedEventChannel *typed_event_channel_; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// The ORB CORBA::ORB_var orb_; diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.cpp index 8c7ca1f703a..96d1e0119cd 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.cpp @@ -4,8 +4,12 @@ #include "CEC_EventChannel.h" #include "CEC_SupplierAdmin.h" #include "CEC_ProxyPushConsumer.h" +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +#include "CEC_TypedEventChannel.h" +#include "CEC_TypedSupplierAdmin.h" +#include "CEC_TypedProxyPushConsumer.h" +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ #include "CEC_ProxyPullConsumer.h" - #include "tao/Messaging/Messaging.h" #include "tao/ORB_Core.h" #include "ace/Reactor.h" @@ -37,6 +41,29 @@ TAO_CEC_Reactive_SupplierControl:: #endif /* TAO_HAS_CORBA_MESSAGING */ } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +TAO_CEC_Reactive_SupplierControl:: + TAO_CEC_Reactive_SupplierControl (const ACE_Time_Value &rate, + const ACE_Time_Value &timeout, + TAO_CEC_TypedEventChannel *ec, + CORBA::ORB_ptr orb) + : rate_ (rate), + timeout_ (timeout), + adapter_ (this), + typed_event_channel_ (ec), + orb_ (CORBA::ORB::_duplicate (orb)) +{ + this->reactor_ = + this->orb_->orb_core ()->reactor (); + +#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 + // Initialise timer_id_ to an invalid timer id, so that in case we don't + // schedule a timer, we don't cancel a random timer at shutdown + timer_id_ = -1; +#endif /* TAO_HAS_CORBA_MESSAGING */ +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_Reactive_SupplierControl::~TAO_CEC_Reactive_SupplierControl (void) { } @@ -45,6 +72,19 @@ void TAO_CEC_Reactive_SupplierControl::query_suppliers ( ACE_ENV_SINGLE_ARG_DECL) { +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + if (this->typed_event_channel_) + { + TAO_CEC_Ping_Typed_Push_Supplier push_worker (this); + + this->typed_event_channel_->typed_supplier_admin ()->for_each (&push_worker + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + TAO_CEC_Ping_Push_Supplier push_worker (this); this->event_channel_->supplier_admin ()->for_each (&push_worker ACE_ENV_ARG_PARAMETER); @@ -54,6 +94,10 @@ TAO_CEC_Reactive_SupplierControl::query_suppliers ( this->event_channel_->supplier_admin ()->for_each (&pull_worker ACE_ENV_ARG_PARAMETER); ACE_CHECK; + +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + } +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ } void @@ -181,6 +225,25 @@ TAO_CEC_Reactive_SupplierControl::supplier_not_exist ( ACE_ENDTRY; } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Reactive_SupplierControl::supplier_not_exist ( + TAO_CEC_TypedProxyPushConsumer *proxy + ACE_ENV_ARG_DECL) +{ + ACE_TRY + { + proxy->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore all exceptions.. + } + ACE_ENDTRY; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_Reactive_SupplierControl::supplier_not_exist ( TAO_CEC_ProxyPullConsumer *proxy @@ -291,6 +354,54 @@ TAO_CEC_Ping_Push_Supplier::work (TAO_CEC_ProxyPushConsumer *consumer // **************************************************************** +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_Ping_Typed_Push_Supplier::work (TAO_CEC_TypedProxyPushConsumer *consumer + ACE_ENV_ARG_DECL) +{ + ACE_TRY + { + CORBA::Boolean disconnected; + CORBA::Boolean non_existent = + consumer->supplier_non_existent (disconnected + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + if (non_existent && !disconnected) + { + this->control_->supplier_not_exist (consumer ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex) + { + this->control_->supplier_not_exist (consumer ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::TRANSIENT, transient) + { + // The current implementation is very strict, and kicks out a + // client on the first system exception. We may + // want to be more lenient in the future, for example, + // this is TAO's minor code for a failed connection. + // + // if (CORBA::TRANSIENT::_narrow (&exception) != 0 + // && exception->minor () == 0x54410085) + // return; + + // Anything else is serious, including timeouts... + this->control_->supplier_not_exist (consumer ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore all exceptions + } + ACE_ENDTRY; +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + +// **************************************************************** + void TAO_CEC_Ping_Pull_Supplier::work (TAO_CEC_ProxyPullConsumer *consumer ACE_ENV_ARG_DECL) diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.h index 99250a70b8d..dfe05105572 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.h @@ -32,6 +32,10 @@ class TAO_CEC_EventChannel; class TAO_CEC_Reactive_SupplierControl; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_TypedEventChannel; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /** * @class TAO_CEC_SupplierControl_Adapter * @@ -77,6 +81,14 @@ public: TAO_CEC_EventChannel *event_channel, CORBA::ORB_ptr orb); + /// Constructor for the typed ec. +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + TAO_CEC_Reactive_SupplierControl (const ACE_Time_Value &rate, + const ACE_Time_Value &timeout, + TAO_CEC_TypedEventChannel *typed_event_channel, + CORBA::ORB_ptr orb); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// destructor... virtual ~TAO_CEC_Reactive_SupplierControl (void); @@ -89,6 +101,10 @@ public: virtual int shutdown (void); virtual void supplier_not_exist (TAO_CEC_ProxyPushConsumer *proxy ACE_ENV_ARG_DECL_NOT_USED); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void supplier_not_exist (TAO_CEC_TypedProxyPushConsumer *proxy + ACE_ENV_ARG_DECL_NOT_USED); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ virtual void supplier_not_exist (TAO_CEC_ProxyPullConsumer *proxy ACE_ENV_ARG_DECL_NOT_USED); virtual void system_exception (TAO_CEC_ProxyPullConsumer *proxy, @@ -113,6 +129,11 @@ private: /// The event channel TAO_CEC_EventChannel *event_channel_; + /// The typed event channel +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + TAO_CEC_TypedEventChannel *typed_event_channel_; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /// The ORB CORBA::ORB_var orb_; @@ -147,6 +168,22 @@ private: // **************************************************************** +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_Ping_Typed_Push_Supplier : public TAO_ESF_Worker<TAO_CEC_TypedProxyPushConsumer> +{ +public: + TAO_CEC_Ping_Typed_Push_Supplier (TAO_CEC_SupplierControl *control); + + virtual void work (TAO_CEC_TypedProxyPushConsumer *consumer + ACE_ENV_ARG_DECL); + +private: + TAO_CEC_SupplierControl *control_; +}; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + +// **************************************************************** + class TAO_CEC_Ping_Pull_Supplier : public TAO_ESF_Worker<TAO_CEC_ProxyPullConsumer> { public: diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.i index ba080617bce..2f242bef904 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.i +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_SupplierControl.i @@ -9,6 +9,17 @@ TAO_CEC_Ping_Push_Supplier:: // **************************************************************** +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +ACE_INLINE +TAO_CEC_Ping_Typed_Push_Supplier:: + TAO_CEC_Ping_Typed_Push_Supplier (TAO_CEC_SupplierControl *control) + : control_ (control) +{ +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + +// **************************************************************** + ACE_INLINE TAO_CEC_Ping_Pull_Supplier:: TAO_CEC_Ping_Pull_Supplier (TAO_CEC_SupplierControl *control) diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.cpp index c87f08c65aa..28ffbd85d1e 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.cpp @@ -34,6 +34,14 @@ TAO_CEC_SupplierControl::supplier_not_exist (TAO_CEC_ProxyPushConsumer * { } +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +void +TAO_CEC_SupplierControl::supplier_not_exist (TAO_CEC_TypedProxyPushConsumer * + ACE_ENV_ARG_DECL_NOT_USED) +{ +} +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + void TAO_CEC_SupplierControl::supplier_not_exist (TAO_CEC_ProxyPullConsumer * ACE_ENV_ARG_DECL_NOT_USED) diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.h index 7d3b5d1fae6..3bdcb86f3cf 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.h +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_SupplierControl.h @@ -30,6 +30,9 @@ class TAO_CEC_EventChannel; class TAO_CEC_ProxyPushConsumer; class TAO_CEC_ProxyPullConsumer; +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) +class TAO_CEC_TypedProxyPushConsumer; +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ /** * @class TAO_CEC_SupplierControl @@ -65,6 +68,11 @@ public: virtual void supplier_not_exist (TAO_CEC_ProxyPushConsumer *proxy ACE_ENV_ARG_DECL_NOT_USED); +#if defined (TAO_HAS_TYPED_EVENT_CHANNEL) + virtual void supplier_not_exist (TAO_CEC_TypedProxyPushConsumer *proxy + ACE_ENV_ARG_DECL_NOT_USED); +#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ + /** * Invoked by helper classes when they detect that a supplier does * not exists (i.e. _non_existent() returns true and/or the diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.cpp new file mode 100644 index 00000000000..01c2f4fd1e9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.cpp @@ -0,0 +1,144 @@ +// -*- C++ -*- +// +// $Id$ + +#include "CEC_TypedConsumerAdmin.h" + +#include "CEC_TypedEventChannel.h" + +#if ! defined (__ACE_INLINE__) +#include "CEC_TypedConsumerAdmin.i" +#endif /* __ACE_INLINE__ */ + +// Implementation skeleton constructor +TAO_CEC_TypedConsumerAdmin::TAO_CEC_TypedConsumerAdmin (TAO_CEC_TypedEventChannel *ec) + : typed_event_channel_ (ec), + typed_push_admin_ (ec) +{ + this->default_POA_ = + this->typed_event_channel_->typed_consumer_poa (); +} + +// Implementation skeleton destructor +TAO_CEC_TypedConsumerAdmin::~TAO_CEC_TypedConsumerAdmin (void) +{ +} + +void +TAO_CEC_TypedConsumerAdmin::invoke (const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_CEC_Propagate_Typed_Event typed_event_worker (typed_event, this->typed_event_channel_); + + this->typed_push_admin_.for_each (&typed_event_worker + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_CEC_TypedConsumerAdmin::connected (TAO_CEC_ProxyPushSupplier *supplier + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.connected (supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedConsumerAdmin::reconnected (TAO_CEC_ProxyPushSupplier *supplier + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.reconnected (supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedConsumerAdmin::disconnected (TAO_CEC_ProxyPushSupplier *supplier + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.disconnected (supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedConsumerAdmin::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + this->typed_push_admin_.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +CosTypedEventChannelAdmin::TypedProxyPullSupplier_ptr +TAO_CEC_TypedConsumerAdmin::obtain_typed_pull_supplier ( + const char * /*supported_interface*/ + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosTypedEventChannelAdmin::InterfaceNotSupported + )) + +{ + ACE_THROW (CosTypedEventChannelAdmin::InterfaceNotSupported ()); +} + +CosEventChannelAdmin::ProxyPushSupplier_ptr +TAO_CEC_TypedConsumerAdmin::obtain_typed_push_supplier ( + const char * uses_interface + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosTypedEventChannelAdmin::NoSuchImplementation + )) + +{ + // Register the consumer uses_interface with the EC + int result = this->typed_event_channel_->consumer_register_uses_interace (uses_interface ACE_ENV_ARG_DECL); + + if (result == -1) + { + ACE_THROW (CosTypedEventChannelAdmin::NoSuchImplementation ()); + } + + return this->typed_push_admin_.obtain (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosEventChannelAdmin::ProxyPushSupplier_ptr +TAO_CEC_TypedConsumerAdmin::obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosEventChannelAdmin::ProxyPullSupplier_ptr +TAO_CEC_TypedConsumerAdmin::obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +PortableServer::POA_ptr +TAO_CEC_TypedConsumerAdmin::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} + +// **************************************************************** + +void +TAO_CEC_Propagate_Typed_Event::work (TAO_CEC_ProxyPushSupplier *supplier + ACE_ENV_ARG_DECL) +{ + supplier->invoke (this->typed_event_ ACE_ENV_ARG_PARAMETER); +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_ESF_Proxy_Admin<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier,CosEventChannelAdmin::ProxyPushSupplier>; +template class TAO_ESF_Shutdown_Proxy<TAO_CEC_ProxyPushSupplier>; +template class TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier>; + +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_ESF_Proxy_Admin<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier,CosEventChannelAdmin::ProxyPushSupplier> +#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_CEC_ProxyPushSupplier> +#pragma instantiate TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.h new file mode 100644 index 00000000000..348d39c9124 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.h @@ -0,0 +1,122 @@ +// $Id$ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file CEC_TypedConsumerAdmin.h + * + * @author Jon Astle (jon@astle45.fsnet.co.uk) + * + * Based on the untyped version by Carlos O'Ryan (coryan@cs.wustl.edu) + */ +//============================================================================= + + +#ifndef TAO_CEC_TYPEDCONSUMERADMIN_H_ +#define TAO_CEC_TYPEDCONSUMERADMIN_H_ + +#include "ace/pre.h" + +#include "orbsvcs/CosTypedEventChannelAdminS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Proxy_Admin.h" +#include "CEC_ProxyPushSupplier.h" +#include "CEC_TypedEvent.h" + +class TAO_CEC_TypedEventChannel; + +//Class TAO_CEC_TypedConsumerAdmin +class TAO_Event_Export TAO_CEC_TypedConsumerAdmin : public POA_CosTypedEventChannelAdmin::TypedConsumerAdmin +{ +public: + + // Constructor + TAO_CEC_TypedConsumerAdmin (TAO_CEC_TypedEventChannel* typed_event_channel); + + // Destructor + virtual ~TAO_CEC_TypedConsumerAdmin (void); + + /// For each elements call <worker->work()>. + void for_each (TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier> *worker + ACE_ENV_ARG_DECL); + + /// Invoke the typed event on all the consumers + virtual void invoke (const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Used to inform the EC that a Supplier has connected or + /// disconnected from it. + virtual void connected (TAO_CEC_ProxyPushSupplier* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void reconnected (TAO_CEC_ProxyPushSupplier* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void disconnected (TAO_CEC_ProxyPushSupplier* + ACE_ENV_ARG_DECL_NOT_USED); + + /// The typed event channel is shutting down, inform all the consumers of + /// this + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + + // = The CosTypedEventChannelAdmin::TypedConsumerAdmin methods... + virtual CosEventChannelAdmin::ProxyPushSupplier_ptr + obtain_typed_push_supplier (const char * uses_interface) + ACE_THROW_SPEC ((CORBA::SystemException, + CosTypedEventChannelAdmin::NoSuchImplementation)); + virtual CosTypedEventChannelAdmin::TypedProxyPullSupplier_ptr + obtain_typed_pull_supplier (const char * supported_interface) + ACE_THROW_SPEC ((CORBA::SystemException, + CosTypedEventChannelAdmin::InterfaceNotSupported)); + + // = The CosEventChannelAdmin::ConsumerAdmin methods... + virtual CosEventChannelAdmin::ProxyPushSupplier_ptr + obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CosEventChannelAdmin::ProxyPullSupplier_ptr + obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // = The PortableServer::ServantBase methods + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// The Event Channel we belong to + TAO_CEC_TypedEventChannel *typed_event_channel_; + + /// Store the default POA. + PortableServer::POA_var default_POA_; + + /// Implement the push side of this class + TAO_ESF_Proxy_Admin<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier,CosEventChannelAdmin::ProxyPushSupplier> typed_push_admin_; +}; + +// **************************************************************** + +class TAO_CEC_Propagate_Typed_Event : public TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier> +{ +public: + TAO_CEC_Propagate_Typed_Event (const TAO_CEC_TypedEvent& typed_event, + TAO_CEC_TypedEventChannel* typed_event_channel); + + void work (TAO_CEC_ProxyPushSupplier *supplier + ACE_ENV_ARG_DECL); + +private: + /// The typed event + const TAO_CEC_TypedEvent typed_event_; + + /// The typed EC + TAO_CEC_TypedEventChannel* typed_event_channel_; +}; + +#if defined (__ACE_INLINE__) +#include "CEC_TypedConsumerAdmin.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" + +#endif /* TAO_CEC_TYPEDCONSUMERADMIN_H_ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.i new file mode 100644 index 00000000000..b534a67483b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedConsumerAdmin.i @@ -0,0 +1,17 @@ +// $Id$ + +ACE_INLINE void +TAO_CEC_TypedConsumerAdmin:: + for_each (TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier> *worker + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.for_each (worker ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE +TAO_CEC_Propagate_Typed_Event::TAO_CEC_Propagate_Typed_Event (const TAO_CEC_TypedEvent& typed_event, + TAO_CEC_TypedEventChannel* typed_event_channel) + : typed_event_ (typed_event), + typed_event_channel_ (typed_event_channel) +{ +} diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.cpp new file mode 100644 index 00000000000..feb1e04e569 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.cpp @@ -0,0 +1,9 @@ +// -*- C++ -*- +// +// $Id$ + +#include "CEC_TypedEvent.h" + +#if ! defined (__ACE_INLINE__) +#include "CEC_TypedEvent.i" +#endif /* __ACE_INLINE__ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.h new file mode 100644 index 00000000000..5b62514f293 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.h @@ -0,0 +1,59 @@ +// $Id$ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file CEC_TypedEvent.h + * + * @author Jon Astle (jon@astle45.fsnet.co.uk) + */ +//============================================================================= + +#ifndef TAO_CEC_TYPEDEVENT_H_ +#define TAO_CEC_TYPEDEVENT_H_ +#include "ace/pre.h" +#include "event_export.h" +#include "tao/corba.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// **************************************************************** + +/** + * @class TAO_CEC_TypedEvent + * + * @brief Defines the operation and args list for the TypedEvent + * + * Used to store the TypedEvent as it is passed from the supplier + * side to the consumer side, in the TypedEventChannel. + */ + +class TAO_CEC_ProxyPushSupplier; + +class TAO_Event_Export TAO_CEC_TypedEvent +{ +public: + /// constructors... + TAO_CEC_TypedEvent (void); + + TAO_CEC_TypedEvent (CORBA::NVList_ptr list, + const char * operation); + + TAO_CEC_TypedEvent & operator= (const TAO_CEC_TypedEvent &); + +private: + /// Only the ProxyPushSupplier can read the private fields. + friend class TAO_CEC_ProxyPushSupplier; + + CORBA::NVList_ptr list_; + CORBA::String_var operation_; +}; + +#if defined (__ACE_INLINE__) +#include "CEC_TypedEvent.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" + +#endif /* TAO_CEC_TYPEDEVENT_H_ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.i new file mode 100644 index 00000000000..6b7203639b1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEvent.i @@ -0,0 +1,24 @@ +// $Id$ + +ACE_INLINE +TAO_CEC_TypedEvent::TAO_CEC_TypedEvent (void) +{ +} + +ACE_INLINE +TAO_CEC_TypedEvent::TAO_CEC_TypedEvent (CORBA::NVList_ptr list, + const char * operation) + : list_ (list), + operation_ (operation) +{ +} + +ACE_INLINE +TAO_CEC_TypedEvent& +TAO_CEC_TypedEvent::operator= (const TAO_CEC_TypedEvent& other) +{ + this->list_ = CORBA::NVList::_duplicate (other.list_); + this->operation_ = CORBA::string_dup (other.operation_); + + return *this; +} diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.cpp new file mode 100644 index 00000000000..240946f5b75 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.cpp @@ -0,0 +1,567 @@ +// -*- C++ -*- +// +// $Id$ + +#include "CEC_TypedEventChannel.h" +#include "CEC_Dispatching.h" +#include "CEC_TypedConsumerAdmin.h" +#include "CEC_TypedSupplierAdmin.h" +#include "CEC_ConsumerControl.h" +#include "CEC_SupplierControl.h" +#include "ace/Dynamic_Service.h" + +#if ! defined (__ACE_INLINE__) +#include "CEC_TypedEventChannel.i" +#endif /* __ACE_INLINE__ */ + + +// Implementation skeleton constructor +TAO_CEC_TypedEventChannel:: +TAO_CEC_TypedEventChannel (const TAO_CEC_TypedEventChannel_Attributes& attr, + TAO_CEC_Factory* factory, + int own_factory) + : typed_supplier_poa_ (PortableServer::POA::_duplicate (attr.typed_supplier_poa)), + typed_consumer_poa_ (PortableServer::POA::_duplicate (attr.typed_consumer_poa)), + orb_ (CORBA::ORB::_duplicate (attr.orb)), + interface_repository_ (CORBA::Repository::_duplicate (attr.interface_repository)), + factory_ (factory), + own_factory_ (own_factory), + consumer_reconnect_ (attr.consumer_reconnect), + supplier_reconnect_ (attr.supplier_reconnect), + disconnect_callbacks_ (attr.disconnect_callbacks), + destroy_on_shutdown_ (attr.destroy_on_shutdown), + destroyed_ (0) +{ + if (this->factory_ == 0) + { + this->factory_ = + ACE_Dynamic_Service<TAO_CEC_Factory>::instance ("CEC_Factory"); + this->own_factory_ = 0; + ACE_ASSERT (this->factory_ != 0); + } + + this->dispatching_ = + this->factory_->create_dispatching (this); + this->typed_consumer_admin_ = + this->factory_->create_consumer_admin (this); + this->typed_supplier_admin_ = + this->factory_->create_supplier_admin (this); + this->consumer_control_ = + this->factory_->create_consumer_control (this); + this->supplier_control_ = + this->factory_->create_supplier_control (this); +} + +// Implementation skeleton destructor +TAO_CEC_TypedEventChannel::~TAO_CEC_TypedEventChannel (void) +{ + this->clear_ifr_cache (); + this->interface_description_.close (); + + this->factory_->destroy_dispatching (this->dispatching_); + this->dispatching_ = 0; + + this->factory_->destroy_consumer_admin (this->typed_consumer_admin_); + this->typed_consumer_admin_ = 0; + this->factory_->destroy_supplier_admin (this->typed_supplier_admin_); + this->typed_supplier_admin_ = 0; + + if (this->own_factory_) + delete this->factory_; +} + +void +TAO_CEC_TypedEventChannel::activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->dispatching_->activate (); + this->consumer_control_->activate (); + this->supplier_control_->activate (); +} + +void +TAO_CEC_TypedEventChannel::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + this->dispatching_->shutdown (); + this->supplier_control_->shutdown (); + this->consumer_control_->shutdown (); + + PortableServer::POA_var typed_consumer_poa = + this->typed_consumer_admin_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var typed_consumer_id = + typed_consumer_poa->servant_to_id (this->typed_consumer_admin_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + typed_consumer_poa->deactivate_object (typed_consumer_id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::POA_var typed_supplier_poa = + this->typed_supplier_admin_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var typed_supplier_id = + typed_supplier_poa->servant_to_id (this->typed_supplier_admin_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + typed_supplier_poa->deactivate_object (typed_supplier_id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->typed_supplier_admin_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + this->typed_consumer_admin_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + if (destroy_on_shutdown_) + { + // Deactivate the Typed EC + PortableServer::POA_var t_poa = + this->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var t_id = + t_poa->servant_to_id (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + t_poa->deactivate_object (t_id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->orb_->shutdown(0); + ACE_TRY_CHECK; + } +} + +void +TAO_CEC_TypedEventChannel::connected (TAO_CEC_TypedProxyPushConsumer* consumer + ACE_ENV_ARG_DECL) +{ + this->typed_supplier_admin_->connected (consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_CEC_TypedEventChannel::reconnected (TAO_CEC_TypedProxyPushConsumer* consumer + ACE_ENV_ARG_DECL) +{ + this->typed_supplier_admin_->reconnected (consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_CEC_TypedEventChannel::disconnected (TAO_CEC_TypedProxyPushConsumer* consumer + ACE_ENV_ARG_DECL) +{ + this->typed_supplier_admin_->disconnected (consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_CEC_TypedEventChannel::connected (TAO_CEC_ProxyPushSupplier* supplier + ACE_ENV_ARG_DECL) +{ + this->typed_consumer_admin_->connected (supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_CEC_TypedEventChannel::reconnected (TAO_CEC_ProxyPushSupplier* supplier + ACE_ENV_ARG_DECL) +{ + this->typed_consumer_admin_->reconnected (supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_CEC_TypedEventChannel::disconnected (TAO_CEC_ProxyPushSupplier* supplier + ACE_ENV_ARG_DECL) +{ + this->typed_consumer_admin_->disconnected (supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +// Find from the ifr cache the operation and return the parameter array pointer. +TAO_CEC_Operation_Params * +TAO_CEC_TypedEventChannel::find_from_ifr_cache (const char *operation) +{ + TAO_CEC_Operation_Params *found = 0; + + this->interface_description_.find (operation, found); + + return found; +} + +// Insert the operation and its parameters into the ifr cache. +int +TAO_CEC_TypedEventChannel::insert_into_ifr_cache (const char *operation_, + TAO_CEC_Operation_Params *parameters_) +{ + // Make sure that the supplied Object reference is valid, + // i.e. not nil. + if (operation_ == 0 || parameters_ == 0) + { + errno = EINVAL; + return -1; + }; + + CORBA::String_var operation = CORBA::string_dup (operation_); + + int result = this->interface_description_.bind (operation.in (), parameters_); + + if (result == 0) + { + // Transfer ownership to the Object InterfaceDescription map. + (void) operation._retn (); + } + + return result; +} + +// Clear the ifr cache, freeing up all its contents. +int +TAO_CEC_TypedEventChannel::clear_ifr_cache (void) +{ + for (Iterator i = this->interface_description_.begin (); + i != this->interface_description_.end (); + ++i) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Destroying operation %s from ifr cache *****\n", + ACE_const_cast (char *, (*i).ext_id_))); + } + + // Deallocate the operation + CORBA::string_free (ACE_const_cast (char *, (*i).ext_id_)); + + // Destroy the parameter + delete ((*i).int_id_); + } + + int result = this->interface_description_.unbind_all (); + + return result; +} + + +// The function performs a lookup_id of the passed interface in the IFR, +// and then obtains the FullInterfaceDescription. +// The base interfaces for the interface are stored on this class. +// All the operations and their parameters are then inserted in the ifr cache. +// Function returns 0 if successful or -1 on a failure. +int +TAO_CEC_TypedEventChannel::cache_interface_description (const char *interface_ + ACE_ENV_ARG_DECL) +{ + ACE_TRY + { + // Lookup the Interface Name in the IFR + CORBA::Contained_var contained = + this->interface_repository_->lookup_id (interface_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Narrow the interface + CORBA::InterfaceDef_var interface = + CORBA::InterfaceDef::_narrow (contained.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (interface.in () )) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** CORBA::InterfaceDef::_narrow failed for interface %s *****\n", interface_ )); + } + return -1; + } + else + { + // Obtain the full interface description + CORBA::InterfaceDef::FullInterfaceDescription_var fid = + interface->describe_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Obtain the base interfaces + this->base_interfaces_ = fid->base_interfaces; + if (TAO_debug_level >= 10) + { + for (CORBA::ULong base=0; base<fid->base_interfaces.length(); base++) + { + ACE_DEBUG ((LM_DEBUG, "***** Base interface %s found on interface %s *****\n", + fid->base_interfaces[base].in(), + interface_ )); + } + } + + // Obtain the operations + for (CORBA::ULong oper=0; oper<fid->operations.length(); oper++) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Operation %s found on interface %s, num params %d *****\n", + fid->operations[oper].name.in(), + interface_, + fid->operations[oper].parameters.length() )); + } + + // Obtain the parameters + CORBA::ULong num_params = fid->operations[oper].parameters.length(); + TAO_CEC_Operation_Params *oper_params = new TAO_CEC_Operation_Params (num_params); + + for (CORBA::ULong param=0; param<num_params; param++) + { + oper_params->parameters_[param].name_ = fid->operations[oper].parameters[param].name.in(); + oper_params->parameters_[param].type_ = fid->operations[oper].parameters[param].type; + switch (fid->operations[oper].parameters[param].mode) + { + case CORBA::PARAM_IN: + oper_params->parameters_[param].direction_ = CORBA::ARG_IN; + break; + case CORBA::PARAM_OUT: + oper_params->parameters_[param].direction_ = CORBA::ARG_OUT; + break; + case CORBA::PARAM_INOUT: + oper_params->parameters_[param].direction_ = CORBA::ARG_INOUT; + break; + } + + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Parameter %s found on operation %s *****\n", + oper_params->parameters_[param].name_.in(), + fid->operations[oper].name.in() )); + } + } + + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Adding operation %s with %d parameters to the IFR cache *****\n", + fid->operations[oper].name.in(), + oper_params->num_params_ )); + } + + int result = insert_into_ifr_cache (fid->operations[oper].name.in(), oper_params); + if (result != 0) + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Adding operation to IFR cache failed *****\n")); + } + } + } + } + } + ACE_CATCH (CORBA::SystemException, sysex) + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (sysex, "during TAO_CEC_TypedEventChannel::cache_interface_description"); + } + return -1; + } + ACE_CATCHANY + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ACE_ANY_EXCEPTION raised during TAO_CEC_TypedEventChannel::cache_interface_description"); + } + return -1; + } + ACE_ENDTRY; + return 0; +} + +// A consumer is attempting to register its uses_interface. +// Note only a single interface can be registered with this version of the EC. +// For users that require more than one interface, start another EC. +// If the passed uses_interface is the same as a registered interface the function returns 0. +// If an attempt is made to register a second interface, this function will return -1 +// and the TypedConsumerAdmin will throw CosTypedEventChannelAdmin::NoSuchImplementation. +// If neither a consumer nor a supplier has registered an interface, +// the function calls cache_interface_description and returns 0 if successful. +int +TAO_CEC_TypedEventChannel::consumer_register_uses_interace (const char *uses_interface_ + ACE_ENV_ARG_DECL) +{ + // Check if a consumer has already registered an inerface with the typed EC + if (this->uses_interface_.length() > 0) + { + // Check if the registered uses_interface_ == the new uses_interface_ + if (this->uses_interface_ == ACE_CString (uses_interface_)) + { + return 0; + } + else + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** different uses_interface_ already registered *****\n")); + } + return -1; + } + } + + // Check if a supplier has already registered an inerface with the typed EC + if (this->supported_interface_.length() > 0) + { + // Check if the registered supported_interface_ == the new uses_interface_ + if (this->supported_interface_ == ACE_CString (uses_interface_)) + { + this->uses_interface_ = uses_interface_; + return 0; + } + else + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** different supported_interface_ already registered *****\n")); + } + return -1; + } + } + else + { + // Neither a consumer nor a supplier has connected yet + int result = cache_interface_description (uses_interface_); + if (result == 0) + { + this->uses_interface_ = uses_interface_; + } + return result; + } + // Should not get here! + return -1; +} + +// A supplier is attempting to register its supported_interface. +// Note only a single interface can be registered with this version of the EC. +// For users that require more than one interface, start another EC. +// If the passed supported_interface is the same as a registered interface the function returns 0. +// If an attempt is made to register a second interface, this function will return -1 +// and the TypedSupplierAdmin will throw CosTypedEventChannelAdmin::InterfaceNotSupported. +// If neither a consumer nor a supplier has registered an interface, +// the function calls cache_interface_description and returns 0 if successful. +int +TAO_CEC_TypedEventChannel::supplier_register_supported_interface (const char *supported_interface_ + ACE_ENV_ARG_DECL) +{ + // Check if a supplier has already registered an inerface with the typed EC + if (this->supported_interface_.length() > 0) + { + // Check if the registered interface == the new supported_interface + if (this->supported_interface_ == ACE_CString (supported_interface_)) + { + return 0; + } + else + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** different supported_interface_ already registered *****\n")); + } + return -1; + } + } + + // Check if a consumer has already registered an inerface with the typed EC + if (this->uses_interface_.length() > 0) + { + // Check if the registered uses_interface_ == the new supported_interface + if (this->uses_interface_ == ACE_CString (supported_interface_)) + { + this->supported_interface_ = supported_interface_; + return 0; + } + else + { + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** different uses_interface_ already registered *****\n")); + } + return -1; + } + } + else + { + // Neither a consumer nor a supplier has connected yet + int result = cache_interface_description (supported_interface_); + if (result == 0) + { + this->supported_interface_ = supported_interface_; + } + return result; + } + // Should not get here! + return -1; +} + +// Function creates a NVList and populates it from the paramter information. +void +TAO_CEC_TypedEventChannel::create_operation_list (TAO_CEC_Operation_Params *oper_params, + CORBA::NVList_out new_list + ACE_ENV_ARG_DECL) +{ + this->orb_->create_list (0, new_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + for (CORBA::ULong param=0; param<oper_params->num_params_; param++) + { + + CORBA::Any any_1; + any_1._tao_set_typecode(oper_params->parameters_[param].type_.in()); + + new_list->add_value (oper_params->parameters_[param].name_, + any_1, + oper_params->parameters_[param].direction_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +// Function creates an empty NVList. +void +TAO_CEC_TypedEventChannel::create_list (CORBA::Long count, + CORBA::NVList_out new_list + ACE_ENV_ARG_DECL) +{ + this->orb_->create_list (count, new_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +// The CosTypedEventChannelAdmin::TypedEventChannel methods... +CosTypedEventChannelAdmin::TypedConsumerAdmin_ptr +TAO_CEC_TypedEventChannel::for_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->typed_consumer_admin_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosTypedEventChannelAdmin::TypedSupplierAdmin_ptr +TAO_CEC_TypedEventChannel::for_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->typed_supplier_admin_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_CEC_TypedEventChannel::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (!destroyed_) + { + destroyed_ = 1; + this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + } +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Hash_Map_Entry<const char *, TAO_CEC_Operation_Params *>; +template class ACE_Hash_Map_Manager_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Entry<const char *, TAO_CEC_Operation_Params *> +#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.h new file mode 100644 index 00000000000..58247032acb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.h @@ -0,0 +1,362 @@ +// $Id$ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file CEC_TypedEventChannel.h + * + * @author Jon Astle (jon@astle45.fsnet.co.uk) + * + * A new implementation of the COS Typed Event Channel, based on + * the untyped version by Carlos O'Ryan (coryan@cs.wustl.edu) + * + */ +//============================================================================= + +#ifndef TAO_CEC_TYPEDEVENTCHANNEL_H_ +#define TAO_CEC_TYPEDEVENTCHANNEL_H_ +#include "ace/pre.h" + +#include "CEC_Factory.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "CEC_Defaults.h" +#include "event_export.h" + +#include "orbsvcs/CosTypedEventChannelAdminS.h" +#include "tao/IFR_Client/IFR_BasicC.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/Null_Mutex.h" +#include "ace/SString.h" + +/** + * @class TAO_CEC_TypedEventChannel_Attributes + * + * @brief Defines the construction time attributes for the Typed + * Event Channel. + * + * The typed event channel implementation is controlled by + * two mechanisms: + * The CEC_Factory that provides the strategies for the EC + * implementation. + * The EC attributes that define constants and values required + * by the EC construction. + * This class encapsulates those constants and values, providing + * an easy mechanism to extend the attributes without requiring + * changes in the EC constructor. + */ +class TAO_Event_Export TAO_CEC_TypedEventChannel_Attributes +{ +public: + /** + * The basic constructor. + * The attributes listed as arguments are *required* by the EC, and + * no appropiate defaults are available for them. + */ + TAO_CEC_TypedEventChannel_Attributes (PortableServer::POA_ptr typed_supplier_poa, + PortableServer::POA_ptr typed_consumer_poa, + CORBA::ORB_ptr orb, + CORBA::Repository_ptr interface_repository); + + // Most fields are public, there is no need to protect them, in fact + // the user should be able to set any values she wants. + + /// Can consumers or suppliers invoke connect_push_* multiple times? + int consumer_reconnect; + int supplier_reconnect; + + /** + * It not zero the event channel will send disconnect callbacks when + * a disconnect method is called on a Proxy. In other words, if a + * consumer calls disconnect_push_supplier() on its proxy the EC + * will invoke disconnect_push_consumer() on the consumer. A + * similar thing is done for suppliers. + * It is a matter of debate what the spec requires for the regular + * event service. + */ + int disconnect_callbacks; + + /** + * If not zero the event channel will deactive its Impl and call + * orb->shutdown(0), when destoy is invoked. + */ + int destroy_on_shutdown; + +private: + /// Only the EC can read the private fields. + friend class TAO_CEC_TypedEventChannel; + + /// The POAs + PortableServer::POA_ptr typed_supplier_poa; + PortableServer::POA_ptr typed_consumer_poa; + + /// The ORB + CORBA::ORB_ptr orb; + + /// The Interface Repository + CORBA::Repository_ptr interface_repository; +}; + +class TAO_CEC_Operation_Params; + +//Class TAO_CEC_TypedEventChannel +class TAO_Event_Export TAO_CEC_TypedEventChannel : public virtual POA_CosTypedEventChannelAdmin::TypedEventChannel +{ +public: + + /** + * constructor + * If <own_factory> is not 0 it assumes ownership of the factory. + * If the factory is <nil> it uses the Service_Configurator to load + * the Factory, if not found it uses TAO_CEC_Default_Resource_Factory + */ + //Constructor + TAO_CEC_TypedEventChannel (const TAO_CEC_TypedEventChannel_Attributes& attributes, + TAO_CEC_Factory* factory = 0, + int own_factory = 0); + + //Destructor + virtual ~TAO_CEC_TypedEventChannel (void); + + /// Start the internal threads (if any), etc. + /// After this call the EC can be used. + virtual void activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + + /// Shutdown any internal threads, cleanup all the internal + /// structures, flush all the messages, etc. + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + + /// Access the dispatching module.... + TAO_CEC_Dispatching* dispatching (void) const; + + /// Access the consumer admin implementation. + TAO_CEC_TypedConsumerAdmin* typed_consumer_admin (void) const; + + /// Access the supplier admin implementation. + TAO_CEC_TypedSupplierAdmin* typed_supplier_admin (void) const; + + /// Access the consumer control strategy. + TAO_CEC_ConsumerControl* consumer_control (void) const; + + /// Access the supplier control strategy. + TAO_CEC_SupplierControl* supplier_control (void) const; + + // = The factory methods, they delegate on the CEC_Factory. + /// Create and destroy a ProxyPushSupplier + void create_proxy (TAO_CEC_ProxyPushSupplier*&); + void destroy_proxy (TAO_CEC_ProxyPushSupplier*); + + /// Create and destroy a TypedProxyPushConsumer + void create_proxy (TAO_CEC_TypedProxyPushConsumer*&); + void destroy_proxy (TAO_CEC_TypedProxyPushConsumer*); + + /// Create and destroy a the collections used to store + /// Proxy*Suppliers + void create_proxy_collection (TAO_CEC_ProxyPushSupplier_Collection*&); + void destroy_proxy_collection (TAO_CEC_ProxyPushSupplier_Collection*); + + /// Create and destroy a the collections used to store + /// Proxy*Consumers + void create_proxy_collection (TAO_CEC_TypedProxyPushConsumer_Collection*&); + void destroy_proxy_collection (TAO_CEC_TypedProxyPushConsumer_Collection*); + + /// Access the supplier and consumer POAs from the factory. + PortableServer::POA_ptr typed_supplier_poa (void); + PortableServer::POA_ptr typed_consumer_poa (void); + + /// Locking strategies for the ProxyPushConsumer and + /// ProxyPushSupplier objects + ACE_Lock* create_consumer_lock (void); + void destroy_consumer_lock (ACE_Lock*); + ACE_Lock* create_supplier_lock (void); + void destroy_supplier_lock (ACE_Lock*); + + /// Used to inform the EC that a Consumer has connected or + /// disconnected from it. + virtual void connected (TAO_CEC_TypedProxyPushConsumer* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void reconnected (TAO_CEC_TypedProxyPushConsumer* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void disconnected (TAO_CEC_TypedProxyPushConsumer* + ACE_ENV_ARG_DECL_NOT_USED); + + /// Used to inform the EC that a Supplier has connected or + /// disconnected from it. + virtual void connected (TAO_CEC_ProxyPushSupplier* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void reconnected (TAO_CEC_ProxyPushSupplier* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void disconnected (TAO_CEC_ProxyPushSupplier* + ACE_ENV_ARG_DECL_NOT_USED); + + /// Can the consumers reconnect to the EC? + int consumer_reconnect (void) const; + + /// Can the suppliers reconnect to the EC? + int supplier_reconnect (void) const; + + /// Should we send callback disconnect messages when a proxy is + /// disconnected by the client + int disconnect_callbacks (void) const; + + // Hash map which will operate as a IFR cache for the Supported Interface's operations and parameters + typedef ACE_Hash_Map_Manager_Ex<const char *, TAO_CEC_Operation_Params *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> InterfaceDescription; + typedef InterfaceDescription::iterator Iterator; + + // Finds a operation/parameter from the IFR cache + TAO_CEC_Operation_Params * find_from_ifr_cache (const char *operation); + + /// Function allows consumer admin to register the uses interface + int consumer_register_uses_interace (const char *uses_interface ACE_ENV_ARG_DECL); + + /// Function allows supplier admin to register the supported interface + int supplier_register_supported_interface (const char *supported_interface ACE_ENV_ARG_DECL); + + /// Function to return the supported_interface_ + const char * supported_interface (void) const; + + /// Function to return the base_interfaces_ + CORBA::RepositoryId base_interfaces (CORBA::ULong index) const; + + /// Function to return the number of base_interfaces_ + CORBA::ULong number_of_base_interfaces (void) const; + + /// Function populates the NVList from the provide param information + virtual void create_operation_list (TAO_CEC_Operation_Params *oper_params, + CORBA::NVList_out new_list + ACE_ENV_ARG_DECL); + + /// Function creates an empty NVList + virtual void create_list (CORBA::Long count, + CORBA::NVList_out new_list + ACE_ENV_ARG_DECL); + + // = The CosTypedEventChannelAdmin::TypedEventChannel methods... + virtual ::CosTypedEventChannelAdmin::TypedConsumerAdmin_ptr + for_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CosTypedEventChannelAdmin::TypedSupplierAdmin_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)); + +protected: + // Function caches the full interface description from the IFR + int cache_interface_description (const char *interface ACE_ENV_ARG_DECL); + + // Insert a operation/parameter into the IFR cache + int insert_into_ifr_cache (const char *operation, TAO_CEC_Operation_Params *parameters); + + // Function clears the IFR cache + int clear_ifr_cache (void); + +private: + /// The POAs used to activate "supplier-side" and "consumer-side" + /// objects. + PortableServer::POA_var typed_supplier_poa_; + PortableServer::POA_var typed_consumer_poa_; + + /// The ORB + CORBA::ORB_var orb_; + + /// Storage of the IFR reference + CORBA::Repository_var interface_repository_; + + /** + * This is the abstract factory that creates all the objects that + * compose an event channel, the event channel simply acts as a + * Mediator among them. + */ + TAO_CEC_Factory *factory_; + + /// Flag that indicates if we own the factory. + int own_factory_; + + /// The dispatching "module" + TAO_CEC_Dispatching *dispatching_; + + /// The ConsumerAdmin implementation + TAO_CEC_TypedConsumerAdmin *typed_consumer_admin_; + + /// The SupplierAdmin implementation + TAO_CEC_TypedSupplierAdmin *typed_supplier_admin_; + + /// Consumer/Supplier reconnection flags + int consumer_reconnect_; + int supplier_reconnect_; + + /// If not zero we send callbacks when a proxy is disconnected + int disconnect_callbacks_; + + /// If not zero the event channel is destroyed on shutdown + int destroy_on_shutdown_; + + /// Set if the event channel has been destroyed + int destroyed_; + + /// Strategies to disconnect misbehaving or destroyed consumers and + /// suppliers + TAO_CEC_ConsumerControl *consumer_control_; + TAO_CEC_SupplierControl *supplier_control_; + + /// The uses_interface_ for the TypedConsumerAdmin. + ACE_CString uses_interface_; + + /// The supported_interface_ for the TypedSupplierAdmin. + ACE_CString supported_interface_; + + /// The IFR cache for the interface description + InterfaceDescription interface_description_; + + /// The supported_interface_ base interfaces + CORBA::RepositoryIdSeq base_interfaces_; +}; + + +class TAO_Event_Export TAO_CEC_Param +{ +public: + /// constructor + TAO_CEC_Param (void); + + /// destructor + ~TAO_CEC_Param (void); + +private: + /// Only the TypedEventChannel can read the private fields. + friend class TAO_CEC_TypedEventChannel; + + CORBA::String_var name_; + CORBA::TypeCode_var type_; + CORBA::Flags direction_; +}; + + +class TAO_Event_Export TAO_CEC_Operation_Params +{ + /// constructor + TAO_CEC_Operation_Params (CORBA::ULong num_params); + /// destructor + ~TAO_CEC_Operation_Params (void); + +private: + /// Only the TypedEventChannel can read the private fields. + friend class TAO_CEC_TypedEventChannel; + + CORBA::ULong num_params_; + TAO_CEC_Param * parameters_; +}; + + +#if defined (__ACE_INLINE__) +#include "CEC_TypedEventChannel.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" + +#endif /* TAO_CEC_TYPEDEVENTCHANNEL_H_ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.i new file mode 100644 index 00000000000..d503ac6da19 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedEventChannel.i @@ -0,0 +1,193 @@ +// $Id$ + +ACE_INLINE +TAO_CEC_TypedEventChannel_Attributes:: +TAO_CEC_TypedEventChannel_Attributes (PortableServer::POA_ptr s_poa, + PortableServer::POA_ptr c_poa, + CORBA::ORB_ptr _orb, + CORBA::Repository_ptr _interface_repository) + : consumer_reconnect (TAO_CEC_DEFAULT_CONSUMER_RECONNECT), + supplier_reconnect (TAO_CEC_DEFAULT_SUPPLIER_RECONNECT), + disconnect_callbacks (TAO_CEC_DEFAULT_DISCONNECT_CALLBACKS), + destroy_on_shutdown (0), + //busy_hwm (TAO_CEC_DEFAULT_BUSY_HWM), + //max_write_delay (TAO_CEC_DEFAULT_MAX_WRITE_DELAY), + typed_supplier_poa (s_poa), + typed_consumer_poa (c_poa), + orb (_orb), + interface_repository (_interface_repository) +{ +} + +ACE_INLINE TAO_CEC_Dispatching* +TAO_CEC_TypedEventChannel::dispatching (void) const +{ + return this->dispatching_; +} + +ACE_INLINE TAO_CEC_TypedConsumerAdmin* +TAO_CEC_TypedEventChannel::typed_consumer_admin (void) const +{ + return this->typed_consumer_admin_; +} + +ACE_INLINE TAO_CEC_TypedSupplierAdmin* +TAO_CEC_TypedEventChannel::typed_supplier_admin (void) const +{ + return this->typed_supplier_admin_; +} + +ACE_INLINE TAO_CEC_ConsumerControl* +TAO_CEC_TypedEventChannel::consumer_control (void) const +{ + return this->consumer_control_; +} + +ACE_INLINE TAO_CEC_SupplierControl* +TAO_CEC_TypedEventChannel::supplier_control (void) const +{ + return this->supplier_control_; +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::create_proxy (TAO_CEC_ProxyPushSupplier* &x) +{ + x = this->factory_->create_proxy_push_supplier (this); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::destroy_proxy (TAO_CEC_ProxyPushSupplier* supplier) +{ + this->factory_->destroy_proxy_push_supplier (supplier); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::create_proxy (TAO_CEC_TypedProxyPushConsumer* &x) +{ + x = this->factory_->create_proxy_push_consumer (this); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::destroy_proxy (TAO_CEC_TypedProxyPushConsumer* consumer) +{ + this->factory_->destroy_proxy_push_consumer (consumer); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::create_proxy_collection (TAO_CEC_ProxyPushSupplier_Collection* &x) +{ + x = this->factory_->create_proxy_push_supplier_collection (this); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::destroy_proxy_collection (TAO_CEC_ProxyPushSupplier_Collection* x) +{ + this->factory_->destroy_proxy_push_supplier_collection (x); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::create_proxy_collection (TAO_CEC_TypedProxyPushConsumer_Collection* &x) +{ + x = this->factory_->create_proxy_push_consumer_collection (this); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::destroy_proxy_collection (TAO_CEC_TypedProxyPushConsumer_Collection* x) +{ + this->factory_->destroy_proxy_push_consumer_collection (x); +} + +ACE_INLINE PortableServer::POA_ptr +TAO_CEC_TypedEventChannel::typed_supplier_poa (void) +{ + return PortableServer::POA::_duplicate (this->typed_supplier_poa_.in ()); +} + +ACE_INLINE PortableServer::POA_ptr +TAO_CEC_TypedEventChannel::typed_consumer_poa (void) +{ + return PortableServer::POA::_duplicate (this->typed_consumer_poa_.in ()); +} + +ACE_INLINE ACE_Lock* +TAO_CEC_TypedEventChannel::create_consumer_lock (void) +{ + return this->factory_->create_consumer_lock (); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::destroy_consumer_lock (ACE_Lock* x) +{ + this->factory_->destroy_consumer_lock (x); +} + +ACE_INLINE ACE_Lock* +TAO_CEC_TypedEventChannel::create_supplier_lock (void) +{ + return this->factory_->create_supplier_lock (); +} + +ACE_INLINE void +TAO_CEC_TypedEventChannel::destroy_supplier_lock (ACE_Lock* x) +{ + this->factory_->destroy_supplier_lock (x); +} + +ACE_INLINE int +TAO_CEC_TypedEventChannel::consumer_reconnect (void) const +{ + return this->consumer_reconnect_; +} + +ACE_INLINE int +TAO_CEC_TypedEventChannel::supplier_reconnect (void) const +{ + return this->supplier_reconnect_; +} + +ACE_INLINE int +TAO_CEC_TypedEventChannel::disconnect_callbacks (void) const +{ + return this->disconnect_callbacks_; +} + +ACE_INLINE const char * +TAO_CEC_TypedEventChannel::supported_interface (void) const +{ + return this->supported_interface_.c_str (); +} + +ACE_INLINE CORBA::RepositoryId +TAO_CEC_TypedEventChannel::base_interfaces (CORBA::ULong index) const +{ + return ACE_const_cast (char *, this->base_interfaces_[index].in ()); +} + +ACE_INLINE CORBA::ULong +TAO_CEC_TypedEventChannel::number_of_base_interfaces (void) const +{ + return this->base_interfaces_.length (); +} + +ACE_INLINE +TAO_CEC_Param::TAO_CEC_Param (void) +{ +} + +ACE_INLINE +TAO_CEC_Param::~TAO_CEC_Param (void) +{ +} + +ACE_INLINE +TAO_CEC_Operation_Params::TAO_CEC_Operation_Params (CORBA::ULong num_params) + : num_params_ (num_params) +{ + parameters_ = new TAO_CEC_Param[num_params]; +} + +ACE_INLINE +TAO_CEC_Operation_Params::~TAO_CEC_Operation_Params (void) +{ + delete [] parameters_; +} diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.cpp new file mode 100644 index 00000000000..d6b6e3afd7e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.cpp @@ -0,0 +1,406 @@ +// -*- C++ -*- +// +// $Id$ + +#include "CEC_TypedProxyPushConsumer.h" +#include "CEC_TypedEventChannel.h" +#include "CEC_TypedConsumerAdmin.h" +#include "CEC_DynamicImplementation.h" + +#if ! defined (__ACE_INLINE__) +#include "CEC_TypedProxyPushConsumer.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/Reverse_Lock_T.h" + +typedef ACE_Reverse_Lock<ACE_Lock> TAO_CEC_Unlock; + +// Implementation skeleton constructor +TAO_CEC_TypedProxyPushConsumer::TAO_CEC_TypedProxyPushConsumer (TAO_CEC_TypedEventChannel* ec) + : typed_event_channel_ (ec), + refcount_ (1), + connected_ (0) +{ + this->lock_ = + this->typed_event_channel_->create_consumer_lock (); + + this->default_POA_ = + this->typed_event_channel_->typed_consumer_poa (); + + // DSI initialization + if (TAO_debug_level >= 10) + { + ACE_DEBUG ((LM_DEBUG, "***** Initializing the DSI for the new TypedProxyPushConsumer *****\n")); + } + + this->dsi_impl_ = new + TAO_CEC_DynamicImplementationServer (this->default_POA_.in(), + this, + this->typed_event_channel_); + + this->oid_ = + this->default_POA_->activate_object (this->dsi_impl_ + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; +} + +// Implementation skeleton destructor +TAO_CEC_TypedProxyPushConsumer::~TAO_CEC_TypedProxyPushConsumer (void) +{ + this->default_POA_->deactivate_object (this->oid_); + ACE_TRY_CHECK; + + delete dsi_impl_; + + this->typed_event_channel_->destroy_consumer_lock (this->lock_); +} + +void +TAO_CEC_TypedProxyPushConsumer::activate ( + CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr &activated_proxy + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CosTypedEventChannelAdmin::TypedProxyPushConsumer_var result; + ACE_TRY + { + result = this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + result = CosTypedEventChannelAdmin::TypedProxyPushConsumer::_nil (); + } + ACE_ENDTRY; + activated_proxy = result._retn (); +} + +void +TAO_CEC_TypedProxyPushConsumer::deactivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_TRY + { + PortableServer::POA_var poa = + this->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Exceptions here should not be propagated. They usually + // indicate that an object is beign disconnected twice, or some + // race condition, but not a fault that the user needs to know + // about. + } + ACE_ENDTRY; +} + +CORBA::Boolean +TAO_CEC_TypedProxyPushConsumer::supplier_non_existent ( + CORBA::Boolean_out disconnected + ACE_ENV_ARG_DECL) +{ + CORBA::Object_var supplier; + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + disconnected = 0; + if (this->is_connected_i () == 0) + { + disconnected = 1; + return 0; + } + if (CORBA::is_nil (this->typed_supplier_.in ())) + { + return 0; + } + supplier = CORBA::Object::_duplicate (this->typed_supplier_.in ()); + } + +#if (TAO_HAS_MINIMUM_CORBA == 0) + return supplier->_non_existent (ACE_ENV_SINGLE_ARG_PARAMETER); +#else + return 0; +#endif /* TAO_HAS_MINIMUM_CORBA */ +} + +void +TAO_CEC_TypedProxyPushConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + CosEventComm::PushSupplier_var supplier; + + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + supplier = this->typed_supplier_._retn (); + this->connected_ = 0; + } + + this->deactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (supplier.in ())) + return; + + ACE_TRY + { + supplier->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore exceptions, we must isolate other clients from + // failures on this one. + } + ACE_ENDTRY; +} + +void +TAO_CEC_TypedProxyPushConsumer::cleanup_i (void) +{ + this->typed_supplier_ = + CosEventComm::PushSupplier::_nil (); + this->connected_ = 0; +} + +CORBA::ULong +TAO_CEC_TypedProxyPushConsumer::_incr_refcnt (void) +{ + ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); + return this->refcount_++; +} + +CORBA::ULong +TAO_CEC_TypedProxyPushConsumer::_decr_refcnt (void) +{ + { + ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); + this->refcount_--; + if (this->refcount_ != 0) + return this->refcount_; + } + + // Notify the event channel + this->typed_event_channel_->destroy_proxy (this); + return 0; +} + +void +TAO_CEC_TypedProxyPushConsumer::connect_push_supplier ( + CosEventComm::PushSupplier_ptr push_supplier + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected)) +{ + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + if (this->is_connected_i ()) + { + if (this->typed_event_channel_->supplier_reconnect () == 0) + ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); + + // Re-connections are allowed, go ahead and disconnect the + // consumer... + this->cleanup_i (); + + // @@ Please read the comments in CEC_ProxyPushSupplier about + // possible race conditions in this area... + TAO_CEC_Unlock reverse_lock (*this->lock_); + + { + ACE_GUARD_THROW_EX ( + TAO_CEC_Unlock, ace_mon, reverse_lock, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + this->typed_event_channel_->disconnected (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + // What if a second thread connected us after this? + if (this->is_connected_i ()) + return; + } + this->typed_supplier_ = + CosEventComm::PushSupplier::_duplicate (push_supplier); + this->connected_ = 1; + } + + // Notify the event channel... + this->typed_event_channel_->connected (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedProxyPushConsumer::push (const CORBA::Any& /* event */ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +void +TAO_CEC_TypedProxyPushConsumer::disconnect_push_consumer ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CosEventComm::PushSupplier_var supplier; + + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + CORBA::INTERNAL ()); + // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + if (this->is_connected_i () == 0) + ACE_THROW (CORBA::BAD_INV_ORDER ()); // @@ add user exception? + + supplier = this->typed_supplier_._retn (); + + this->cleanup_i (); + } + + // Notify the event channel... + this->typed_event_channel_->disconnected (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (!CORBA::is_nil (supplier.in ())) + { + if (this->typed_event_channel_->disconnect_callbacks ()) + { + ACE_TRY + { + supplier->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore exceptions, we must isolate other clients from + // failures on this one. + } + ACE_ENDTRY; + } + } +} + +PortableServer::POA_ptr +TAO_CEC_TypedProxyPushConsumer::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} + +void +TAO_CEC_TypedProxyPushConsumer::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_CEC_TypedProxyPushConsumer::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +CORBA::Object_ptr +TAO_CEC_TypedProxyPushConsumer::get_typed_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + +{ + CORBA::Object_var server = + default_POA_->id_to_reference (this->oid_.in () + ACE_ENV_ARG_PARAMETER); + + return CORBA::Object::_duplicate (server.in()); +} + +void +TAO_CEC_TypedProxyPushConsumer::invoke (const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_CEC_TypedProxyPushConsumer_Guard ace_mon (this->lock_, + this->refcount_, + this->typed_event_channel_, + this); + if (!ace_mon.locked ()) + return; + + this->typed_event_channel_->typed_consumer_admin ()->invoke (typed_event + ACE_ENV_ARG_PARAMETER); +} + +// **************************************************************** + +TAO_CEC_TypedProxyPushConsumer_Guard:: + TAO_CEC_TypedProxyPushConsumer_Guard (ACE_Lock *lock, + CORBA::ULong &refcount, + TAO_CEC_TypedEventChannel *ec, + TAO_CEC_TypedProxyPushConsumer *proxy) + : lock_ (lock), + refcount_ (refcount), + typed_event_channel_ (ec), + proxy_ (proxy), + locked_ (0) +{ + ACE_Guard<ACE_Lock> ace_mon (*this->lock_); + // If the guard fails there is not much we can do, raising an + // exception is wrong, the client has *no* way to handle that kind + // of error. Even worse, there is no exception to raise in that + // case. + // @@ Returning something won't work either, the error should be + // logged though! + + if (proxy->is_connected_i () == 0) + return; + + this->locked_ = 1; + this->refcount_++; +} + +TAO_CEC_TypedProxyPushConsumer_Guard:: + ~TAO_CEC_TypedProxyPushConsumer_Guard (void) +{ + // This access is safe because guard objects are created on the + // stack, only one thread has access to them + if (!this->locked_) + return; + + { + ACE_Guard<ACE_Lock> ace_mon (*this->lock_); + // If the guard fails there is not much we can do, raising an + // exception is wrong, the client has *no* way to handle that kind + // of error. Even worse, there is no exception to raise in that + // case. + // @@ Returning something won't work either, the error should be + // logged though! + + this->refcount_--; + if (this->refcount_ != 0) + return; + } + this->typed_event_channel_->destroy_proxy (this->proxy_); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.h new file mode 100644 index 00000000000..c1d18c7bf90 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.h @@ -0,0 +1,184 @@ +// $Id$ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file CEC_TypedProxyPushConsumer.h + * + * + * @author Jon Astle (jon@astle45.fsnet.co.uk) + * + * Based on the untyped version by Carlos O'Ryan (coryan@cs.wustl.edu) + */ +//============================================================================= + + +#ifndef TAO_CEC_TYPEDPROXYPUSHCONSUMER_H_ +#define TAO_CEC_TYPEDPROXYPUSHCONSUMER_H_ +#include "ace/pre.h" + +#include "orbsvcs/CosTypedEventChannelAdminS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Worker.h" + +class TAO_CEC_TypedEvent; +class TAO_CEC_TypedEventChannel; +class TAO_CEC_DynamicImplementationServer; + +//Class TAO_CEC_TypedProxyPushConsumer +class TAO_Event_Export TAO_CEC_TypedProxyPushConsumer : public virtual POA_CosTypedEventChannelAdmin::TypedProxyPushConsumer +{ +public: + typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr _ptr_type; + typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_var _var_type; + + //Constructor + TAO_CEC_TypedProxyPushConsumer (TAO_CEC_TypedEventChannel* typed_event_channel); + + //Destructor + virtual ~TAO_CEC_TypedProxyPushConsumer (void); + + /// Activate in the POA + virtual void activate ( + CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr &activated_proxy + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Deactivate from the POA + virtual void deactivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /** + * Invoke the _non_existent() pseudo-operation on the supplier. If + * it is disconnected then it returns true and sets the + * <disconnected> flag. + */ + CORBA::Boolean supplier_non_existent (CORBA::Boolean_out disconnected + ACE_ENV_ARG_DECL); + + /// The event channel is shutting down + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + + /// Increment and decrement the reference count. + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + + // = The CosEventChannelAdmin::ProxyPushConsumer methods (abstract overloads)... + virtual void connect_push_supplier ( + CosEventComm::PushSupplier_ptr push_supplier + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected)); + + virtual void push (const CORBA::Any& event + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void invoke (const TAO_CEC_TypedEvent& typed_event + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // = The CosTypedEventComm::TypedPushConsumer methods (abstract overloads)... + virtual CORBA::Object_ptr get_typed_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // = The Servant methods + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL); + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + +protected: + // The guard needs access to the following protected methods. + friend class TAO_CEC_TypedProxyPushConsumer_Guard; + + /// The private version (without locking) of is_connected(). + CORBA::Boolean is_connected_i (void) const; + + /// Release the supplier + void cleanup_i (void); + +private: + /// The typed supplier admin, used for activation and memory managment. + TAO_CEC_TypedEventChannel* typed_event_channel_; + + /// The locking strategy. + ACE_Lock* lock_; + + /// The reference count. + CORBA::ULong refcount_; + + /// The typed supplier.... + CosEventComm::PushSupplier_var typed_supplier_; + + // The DSI impl + TAO_CEC_DynamicImplementationServer* dsi_impl_; + + /// The DSI Portable Server OID + PortableServer::ObjectId_var oid_; + + /// If the flag is not zero then we are connected, notice that the + /// supplier can be nil. + int connected_; + + /// Store the default POA. + PortableServer::POA_var default_POA_; +}; + +// **************************************************************** + +/** + * @class TAO_CEC_TypedProxyPushConsumer_Guard + * + * @brief A Guard for the TypedProxyPushConsumer reference count + * + * This is a helper class used in the implementation of + * TypedProxyPushConumer. It provides a Guard mechanism to increment + * the reference count on the proxy, eliminating the need to hold + * mutexes during long operations. + */ +class TAO_Event_Export TAO_CEC_TypedProxyPushConsumer_Guard +{ +public: + /// Constructor + TAO_CEC_TypedProxyPushConsumer_Guard (ACE_Lock *lock, + CORBA::ULong &refcount, + TAO_CEC_TypedEventChannel *ec, + TAO_CEC_TypedProxyPushConsumer *proxy); + + /// Destructor + ~TAO_CEC_TypedProxyPushConsumer_Guard (void); + + /// Returns 1 if the reference count successfully acquired + int locked (void) const; + +private: + /// The lock used to protect the reference count + ACE_Lock *lock_; + + /// The reference count + CORBA::ULong &refcount_; + + /// The event channel used to destroy the proxy + TAO_CEC_TypedEventChannel *typed_event_channel_; + + /// The proxy whose lifetime is controlled by the reference count + TAO_CEC_TypedProxyPushConsumer *proxy_; + + /// This flag is set to 1 if the reference count was successfully + /// acquired. + int locked_; +}; + +#if defined (__ACE_INLINE__) +#include "CEC_TypedProxyPushConsumer.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" + +#endif /* TAO_CEC_TYPEDPROXYPUSHCONSUMER_H_ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.i new file mode 100644 index 00000000000..6a1312c7e3e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedProxyPushConsumer.i @@ -0,0 +1,15 @@ +// $Id$ + +ACE_INLINE CORBA::Boolean +TAO_CEC_TypedProxyPushConsumer::is_connected_i (void) const +{ + return this->connected_; +} + +// **************************************************************** + +ACE_INLINE int +TAO_CEC_TypedProxyPushConsumer_Guard::locked (void) const +{ + return this->locked_; +} diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.cpp new file mode 100644 index 00000000000..69ff0cc5ff1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.cpp @@ -0,0 +1,123 @@ +// -*- C++ -*- +// +// $Id$ + +#include "CEC_TypedSupplierAdmin.h" + +#include "CEC_TypedEventChannel.h" + +#if ! defined (__ACE_INLINE__) +#include "CEC_TypedSupplierAdmin.i" +#endif /* __ACE_INLINE__ */ + +// Implementation skeleton constructor +TAO_CEC_TypedSupplierAdmin::TAO_CEC_TypedSupplierAdmin (TAO_CEC_TypedEventChannel *ec) + : typed_event_channel_ (ec), + typed_push_admin_ (ec) +{ + this->default_POA_ = + this->typed_event_channel_->typed_supplier_poa (); +} + +// Implementation skeleton destructor +TAO_CEC_TypedSupplierAdmin::~TAO_CEC_TypedSupplierAdmin (void) +{ +} + +PortableServer::POA_ptr +TAO_CEC_TypedSupplierAdmin::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} + +void +TAO_CEC_TypedSupplierAdmin::connected (TAO_CEC_TypedProxyPushConsumer *consumer + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.connected (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedSupplierAdmin::reconnected (TAO_CEC_TypedProxyPushConsumer *consumer + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.reconnected (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedSupplierAdmin::disconnected (TAO_CEC_TypedProxyPushConsumer *consumer + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.disconnected (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_CEC_TypedSupplierAdmin::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + this->typed_push_admin_.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr +TAO_CEC_TypedSupplierAdmin::obtain_typed_push_consumer ( + const char * supported_interface + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosTypedEventChannelAdmin::InterfaceNotSupported + )) + +{ + int result = this->typed_event_channel_->supplier_register_supported_interface (supported_interface); + + if (result == -1) + { + ACE_THROW (CosTypedEventChannelAdmin::InterfaceNotSupported ()); + } + + return this->typed_push_admin_.obtain (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosEventChannelAdmin::ProxyPullConsumer_ptr +TAO_CEC_TypedSupplierAdmin::obtain_typed_pull_consumer ( + const char * /* uses_interface */ + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosTypedEventChannelAdmin::NoSuchImplementation + )) + +{ + ACE_THROW (CosTypedEventChannelAdmin::NoSuchImplementation ()); +} + +CosEventChannelAdmin::ProxyPushConsumer_ptr +TAO_CEC_TypedSupplierAdmin::obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosEventChannelAdmin::ProxyPullConsumer_ptr +TAO_CEC_TypedSupplierAdmin::obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_ESF_Proxy_Admin<TAO_CEC_TypedEventChannel,TAO_CEC_TypedProxyPushConsumer,CosTypedEventChannelAdmin::TypedProxyPushConsumer>; +template class TAO_ESF_Shutdown_Proxy<TAO_CEC_TypedProxyPushConsumer>; +template class TAO_ESF_Worker<TAO_CEC_TypedProxyPushConsumer>; + +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_ESF_Proxy_Admin<TAO_CEC_TypedEventChannel,TAO_CEC_TypedProxyPushConsumer,CosTypedEventChannelAdmin::TypedProxyPushConsumer> +#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_CEC_TypedProxyPushConsumer> +#pragma instantiate TAO_ESF_Worker<TAO_CEC_TypedProxyPushConsumer> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.h b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.h new file mode 100644 index 00000000000..294643d7a87 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.h @@ -0,0 +1,98 @@ +// $Id$ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file CEC_TypedSupplierAdmin.h + * + * $Id: + * + * @author Jon Astle (jon@astle45.fsnet.co.uk) + * + * Based on the untyped version by Carlos O'Ryan (coryan@cs.wustl.edu) + */ +//============================================================================= + + +#ifndef TAO_CEC_TYPEDSUPPLIERADMIN_H_ +#define TAO_CEC_TYPEDSUPPLIERADMIN_H_ + +#include "ace/pre.h" + +#include "orbsvcs/CosTypedEventChannelAdminS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Proxy_Admin.h" +#include "CEC_TypedProxyPushConsumer.h" + +class TAO_CEC_TypedEventChannel; + +//Class TAO_CEC_TypedSupplierAdmin +class TAO_Event_Export TAO_CEC_TypedSupplierAdmin : public POA_CosTypedEventChannelAdmin::TypedSupplierAdmin +{ +public: + //Constructor + TAO_CEC_TypedSupplierAdmin (TAO_CEC_TypedEventChannel* event_channel); + + //Destructor + virtual ~TAO_CEC_TypedSupplierAdmin (void); + + /// For each elements call <worker->work()>. + void for_each (TAO_ESF_Worker<TAO_CEC_TypedProxyPushConsumer> *worker + ACE_ENV_ARG_DECL); + + /// Keep track of connected consumers. + virtual void connected (TAO_CEC_TypedProxyPushConsumer* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void reconnected (TAO_CEC_TypedProxyPushConsumer* + ACE_ENV_ARG_DECL_NOT_USED); + virtual void disconnected (TAO_CEC_TypedProxyPushConsumer* + ACE_ENV_ARG_DECL_NOT_USED); + + /// The typed event channel is shutting down, inform all the consumers of + /// this + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + + // = The CosTypedEventChannelAdmin::TypedSupplierAdmin methods... + virtual CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr + obtain_typed_push_consumer (const char * supported_interface) + ACE_THROW_SPEC ((CORBA::SystemException, + CosTypedEventChannelAdmin::InterfaceNotSupported)); + + virtual CosEventChannelAdmin::ProxyPullConsumer_ptr + obtain_typed_pull_consumer (const char * uses_interface) + ACE_THROW_SPEC ((CORBA::SystemException, + CosTypedEventChannelAdmin::NoSuchImplementation)); + + // = The CosEventChannelAdmin::SupplierAdmin methods... + virtual CosEventChannelAdmin::ProxyPushConsumer_ptr + obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CosEventChannelAdmin::ProxyPullConsumer_ptr + obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // = The PortableServer::ServantBase methods + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// The Event Channel we belong to + TAO_CEC_TypedEventChannel *typed_event_channel_; + + /// Store the default POA. + PortableServer::POA_var default_POA_; + + /// The push and pull aspects are implemented using these classes + TAO_ESF_Proxy_Admin<TAO_CEC_TypedEventChannel,TAO_CEC_TypedProxyPushConsumer,CosTypedEventChannelAdmin::TypedProxyPushConsumer> typed_push_admin_; +}; + +#if defined (__ACE_INLINE__) +#include "CEC_TypedSupplierAdmin.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" + +#endif /* TAO_CEC_TYPEDSUPPLIERADMIN_H_ */ diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.i b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.i new file mode 100644 index 00000000000..2d6dd17e750 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_TypedSupplierAdmin.i @@ -0,0 +1,9 @@ +// $Id$ + +ACE_INLINE void +TAO_CEC_TypedSupplierAdmin:: + for_each (TAO_ESF_Worker<TAO_CEC_TypedProxyPushConsumer> *worker + ACE_ENV_ARG_DECL) +{ + this->typed_push_admin_.for_each (worker ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/CosTypedEventChannelAdmin.idl b/TAO/orbsvcs/orbsvcs/CosTypedEventChannelAdmin.idl new file mode 100644 index 00000000000..e1c9da89bd9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosTypedEventChannelAdmin.idl @@ -0,0 +1,62 @@ + +//============================================================================= +/** +* @file: CosTypedEventChannelAdmin.idl +* +* $Id$ +* +* @brief: Part of the Event Service +* See http://www.omg.org/docs/formal/01-03-01.pdf +*/ +//============================================================================= + +#ifndef _COS_TYPED_EVENT_CHANNEL_ADMIN_IDL_ +#define _COS_TYPED_EVENT_CHANNEL_ADMIN_IDL_ + +#include "CosEventChannelAdmin.idl" +#include "CosTypedEventComm.idl" + +#pragma prefix "omg.org" + +module CosTypedEventChannelAdmin { + + exception InterfaceNotSupported {}; + exception NoSuchImplementation {}; + typedef string Key; + + interface TypedProxyPushConsumer : + CosEventChannelAdmin::ProxyPushConsumer, + CosTypedEventComm::TypedPushConsumer { }; + + interface TypedProxyPullSupplier : + CosEventChannelAdmin::ProxyPullSupplier, + CosTypedEventComm::TypedPullSupplier { }; + + interface TypedSupplierAdmin : + CosEventChannelAdmin::SupplierAdmin { + TypedProxyPushConsumer obtain_typed_push_consumer( + in Key supported_interface) + raises(InterfaceNotSupported); + CosEventChannelAdmin::ProxyPullConsumer obtain_typed_pull_consumer ( + in Key uses_interface) + raises(NoSuchImplementation); + }; + + interface TypedConsumerAdmin : + CosEventChannelAdmin::ConsumerAdmin { + TypedProxyPullSupplier obtain_typed_pull_supplier( + in Key supported_interface) + raises (InterfaceNotSupported); + CosEventChannelAdmin::ProxyPushSupplier obtain_typed_push_supplier( + in Key uses_interface) + raises(NoSuchImplementation); + }; + + interface TypedEventChannel { + TypedConsumerAdmin for_consumers(); + TypedSupplierAdmin for_suppliers(); + void destroy (); + }; +}; + +#endif /* _COS_TYPED_EVENT_CHANNEL_ADMIN_IDL_ */ diff --git a/TAO/orbsvcs/orbsvcs/CosTypedEventComm.idl b/TAO/orbsvcs/orbsvcs/CosTypedEventComm.idl new file mode 100644 index 00000000000..8c2458af1fa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/CosTypedEventComm.idl @@ -0,0 +1,32 @@ + +//============================================================================= +/** +* @file: CosTypedEventComm.idl +* +* $Id$ +* +* @brief: Part of the Event Service +* See http://www.omg.org/docs/formal/01-03-01.pdf +*/ +//============================================================================= + +#ifndef _COS_TYPED_EVENT_COMM_IDL_ +#define _COS_TYPED_EVENT_COMM_IDL_ + +#include "CosEventComm.idl" + +#pragma prefix "omg.org" + +module CosTypedEventComm { + + interface TypedPushConsumer : CosEventComm::PushConsumer { + Object get_typed_consumer(); + }; + + interface TypedPullSupplier : CosEventComm::PullSupplier { + Object get_typed_supplier(); + }; + +}; + +#endif // _COS_TYPED_EVENT_COMM_IDL diff --git a/TAO/orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/AVStreams_Simple_Two_Stage_With_QoS.mpc b/TAO/orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/AVStreams_Simple_Two_Stage_With_QoS.mpc index db3edaf54b4..89f740dfeed 100644 --- a/TAO/orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/AVStreams_Simple_Two_Stage_With_QoS.mpc +++ b/TAO/orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/AVStreams_Simple_Two_Stage_With_QoS.mpc @@ -1,5 +1,4 @@ project(*sender): avstreamsexe, qos { - requires += rapi exename = sender Source_Files { sender.cpp @@ -7,7 +6,6 @@ project(*sender): avstreamsexe, qos { } project(*receiver): avstreamsexe, qos { - requires += rapi exename = receiver Source_Files { receiver.cpp diff --git a/TAO/orbsvcs/tests/Security/Secure_Invocation/Secure_Invocation.mpc b/TAO/orbsvcs/tests/Security/Secure_Invocation/Secure_Invocation.mpc index 5e37463cfc5..2164d5133bb 100644 --- a/TAO/orbsvcs/tests/Security/Secure_Invocation/Secure_Invocation.mpc +++ b/TAO/orbsvcs/tests/Security/Secure_Invocation/Secure_Invocation.mpc @@ -1,5 +1,4 @@ project(*security server): taoserver, orbsvcsexe, security, ssl { - ssl = 1 Source_Files { Foo_i.cpp server.cpp diff --git a/TAO/orbsvcs/tests/Security/SecurityLevel1/SecurityLevel1.mpc b/TAO/orbsvcs/tests/Security/SecurityLevel1/SecurityLevel1.mpc index 116fa15bce0..f6d5f7a0e8d 100644 --- a/TAO/orbsvcs/tests/Security/SecurityLevel1/SecurityLevel1.mpc +++ b/TAO/orbsvcs/tests/Security/SecurityLevel1/SecurityLevel1.mpc @@ -1,5 +1,4 @@ project(*security server): taoserver, orbsvcsexe, ssl, security { - ssl = 1 Source_Files { SLevel1_Test_i.cpp server.cpp diff --git a/ace/SSL/ssl.mpc b/ace/SSL/ssl.mpc index 41dfb6314a2..254ccf9af85 100644 --- a/ace/SSL/ssl.mpc +++ b/ace/SSL/ssl.mpc @@ -1,5 +1,4 @@ -project(SSL) : acelib, core { - ssl = 1 +project(SSL) : acelib, core, openssl { requires += ssl sharedname = ACE_SSL dynamicflags = ACE_SSL_BUILD_DLL diff --git a/apps/gperf/src/gperf.mpc b/apps/gperf/src/gperf.mpc index 9c508a258ca..bdbf3e77fce 100644 --- a/apps/gperf/src/gperf.mpc +++ b/apps/gperf/src/gperf.mpc @@ -1,4 +1,4 @@ -project(gperf_exe) : aceexe, core { +project(gperf) : aceexe, core { install = $(ACE_ROOT)/bin exename = gperf Source_Files { diff --git a/bin/MakeProjectCreator/config/acedefaults.mpb b/bin/MakeProjectCreator/config/acedefaults.mpb index 676857a6317..f316f344eeb 100644 --- a/bin/MakeProjectCreator/config/acedefaults.mpb +++ b/bin/MakeProjectCreator/config/acedefaults.mpb @@ -1,10 +1,5 @@ -project: qt, zzip, openssl { +project: qt, zzip { staticflags += ACE_AS_STATIC_LIBS includes += $(ACE_ROOT) libpaths += $(ACE_ROOT)/lib - - // The following is a temporary workaround so that mpc-generated projects - // can work with an ACE/TAO that was built without mpc. This should be - // removed as soon as MPC is used for all project generation. - // libpaths += $(ACE_ROOT)/ace $(ACE_ROOT)/ace/QoS $(ACE_ROOT)/ace/SSL $(ACE_ROOT)/ACEXML/common $(ACE_ROOT)/ACEXML/parser/parser $(TAO_ROOT)/orbsvcs/IFR_Service $(TAO_ROOT)/orbsvcs/orbsvcs $(TAO_ROOT)/tao $(TAO_ROOT)/tao/BiDir_GIOP $(TAO_ROOT)/tao/Domain $(TAO_ROOT)/tao/DynamicAny $(TAO_ROOT)/tao/DynamicInterface $(TAO_ROOT)/tao/IFR_Client $(TAO_ROOT)/tao/IORManipulation $(TAO_ROOT)/tao/IORTable $(TAO_ROOT)/tao/Messaging $(TAO_ROOT)/tao/Messaging $(TAO_ROOT)/tao/PortableServer $(TAO_ROOT)/tao/RTCORBA $(TAO_ROOT)/tao/RTPortableServer $(TAO_ROOT)/tao/SmartProxies $(TAO_ROOT)/tao/Strategies $(TAO_ROOT)/tao/TypeCodeFactory $(TAO_ROOT)/TAO_IDL $(TAO_ROOT)/orbsvcs/orbsvcs/ETCL } diff --git a/bin/MakeProjectCreator/config/openssl.mpb b/bin/MakeProjectCreator/config/openssl.mpb index 04313394a02..876750f80c6 100644 --- a/bin/MakeProjectCreator/config/openssl.mpb +++ b/bin/MakeProjectCreator/config/openssl.mpb @@ -1,14 +1,17 @@ -feature(ssl) { -// When all of ACE and TAO are switched over to MPC, uncomment the -// following lines and remove this comment. -// includes += $(SSL_ROOT)/include -// libpaths += $(SSL_ROOT)/lib - +// openssl is a completely different feature than ssl. +// Currently ssl uses openssl, and openssl is enabled by +// default. If we ever add a new ssl library, then you +// would likely enable only one ssl library feature. +feature(openssl) { specific(borland, nmake, em3, vc6, vc7, vc71) { lit_libs += libeay32 ssleay32 + includes += $(SSL_ROOT)/inc32 + libpaths += $(SSL_ROOT)/out32dll } specific(gnuace, make) { lit_libs += ssl crypto + includes += $(SSL_ROOT)/include + libpaths += $(SSL_ROOT)/lib } } diff --git a/bin/MakeProjectCreator/config/ssl.mpb b/bin/MakeProjectCreator/config/ssl.mpb index 4e7373191c9..8b9cfe673e2 100644 --- a/bin/MakeProjectCreator/config/ssl.mpb +++ b/bin/MakeProjectCreator/config/ssl.mpb @@ -1,6 +1,9 @@ -project : acelib { +// In the future, other ssl libraries could be supported +// by creating a new xyzssl.mpb similar to openssl.mpb. +// You would then derive the following project from this base. +project : acelib, openssl { after += SSL libs += ACE_SSL requires += ssl - ssl = 1 + macros += ACE_HAS_SSL=1 } diff --git a/bin/MakeProjectCreator/modules/ProjectCreator.pm b/bin/MakeProjectCreator/modules/ProjectCreator.pm index 753209db4cf..9b12a2caabb 100644 --- a/bin/MakeProjectCreator/modules/ProjectCreator.pm +++ b/bin/MakeProjectCreator/modules/ProjectCreator.pm @@ -2076,7 +2076,7 @@ sub write_project { my($self) = shift; my($status) = 1; my($error) = ''; - my($name) = $self->transform_file_name($self->project_file_name()); + my($file_name) = $self->transform_file_name($self->project_file_name()); my($progress) = $self->get_progress_callback(); if (defined $progress) { @@ -2089,17 +2089,17 @@ sub write_project { ## Writing the non-static file so set it to 0 if ($self->get_dynamic()) { $self->{'writing_type'} = 0; - ($status, $error) = $self->write_output_file($name); + ($status, $error) = $self->write_output_file($file_name); } if ($status && $self->get_static() && $self->separate_static_project()) { - $name = $self->transform_file_name( + $file_name = $self->transform_file_name( $self->static_project_file_name()); ## Writing the static file so set it to 1 $self->{'writing_type'} = 1; - ($status, $error) = $self->write_output_file($name); + ($status, $error) = $self->write_output_file($file_name); } } } @@ -2225,7 +2225,7 @@ sub update_project_info { ## If we haven't seen this value yet, put it on the array if (!defined $self->{'project_info_hash_table'}->{"@narr $value"}) { $self->{'project_info_hash_table'}->{"@narr $value"} = 1; - $self->save_project_value("@narr", $value); + #$self->save_project_value("@narr", $value); push(@$arr, $value); } @@ -2355,20 +2355,6 @@ sub get_default_element_name { # Virtual Methods To Be Overridden # ************************************************************ -sub specific_lookup { - #my($self) = shift; - #my($key) = shift; - return undef; -} - - -sub save_project_value { - #my($self) = shift; - #my($name) = shift; - #my($value) = shift; -} - - sub translate_value { my($self) = shift; my($key) = shift; diff --git a/bin/MakeProjectCreator/modules/VC6WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/VC6WorkspaceCreator.pm index cbb1cfe80bf..92ac7e8866b 100644 --- a/bin/MakeProjectCreator/modules/VC6WorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/VC6WorkspaceCreator.pm @@ -46,6 +46,10 @@ sub pre_workspace { $crlf; } +sub allow_duplicates { + my($self) = shift; + return 0; +} sub write_comps { my($self) = shift; @@ -53,19 +57,10 @@ sub write_comps { my($projects) = $self->get_projects(); my($pjs) = $self->get_project_info(); my($crlf) = $self->crlf(); - my(%names) = (); - my($dupfound) = 0; foreach my $project (@$projects) { my($name) = $$pjs{$project}->[0]; my($deps) = $self->get_validated_ordering($project); - if (defined $names{$name}) { - ## Having duplicate project names is an error in a VC6 Workspace. - ++$dupfound; - } - else { - $names{$name} = 1; - } print $fh "###############################################################################$crlf" . $crlf . @@ -94,11 +89,6 @@ sub write_comps { print $fh "}}}$crlf$crlf"; } - if ($dupfound > 0) { - print "WARNING: $dupfound duplicate project" . - ($dupfound == 1 ? '' : 's') . - " found. This workspace will not load properly.\n"; - } } diff --git a/bin/MakeProjectCreator/modules/VC71WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/VC71WorkspaceCreator.pm index 3d15b1ba472..8f9d499956e 100644 --- a/bin/MakeProjectCreator/modules/VC71WorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/VC71WorkspaceCreator.pm @@ -38,19 +38,22 @@ sub print_inner_project { my($gen) = shift; my($pguid) = shift; my($deps) = shift; + my($project_name) = shift; + my($name_to_guid_map) = shift; - if (defined $deps && $deps ne '') { - my($crlf) = $self->crlf(); - print $fh "\tProjectSection(ProjectDependencies) = postProject$crlf"; - my($darr) = $self->create_array($deps); - foreach my $dep (@$darr) { - my($val) = $gen->specific_lookup($dep); - if (defined $val && $pguid ne $val) { - print $fh "\t\t{$val} = {$val}$crlf"; + my($crlf) = $self->crlf(); + print $fh "\tProjectSection(ProjectDependencies) = postProject$crlf"; + my($darr) = $self->create_array($deps); + foreach my $dep (@$darr) { + ## Avoid cirular dependencies + if ($project_name ne $dep) { + my($guid) = $name_to_guid_map->{$dep}; + if (defined $guid) { + print $fh "\t\t{$guid} = {$guid}$crlf"; } } - print $fh "\tEndProjectSection$crlf"; } + print $fh "\tEndProjectSection$crlf"; } @@ -66,12 +69,6 @@ sub print_configs { sub print_dependencies { - #my($self) = shift; - #my($fh) = shift; - #my($gen) = shift; - #my($list) = shift; - #my($pjs) = shift; - ## These are done in the print_inner_project method } diff --git a/bin/MakeProjectCreator/modules/VC7ProjectCreator.pm b/bin/MakeProjectCreator/modules/VC7ProjectCreator.pm index bf18200244b..6be9b130f17 100644 --- a/bin/MakeProjectCreator/modules/VC7ProjectCreator.pm +++ b/bin/MakeProjectCreator/modules/VC7ProjectCreator.pm @@ -29,32 +29,20 @@ sub file_sorter { return lc($left) cmp lc($right); } - -sub specific_lookup { +sub translate_value { my($self) = shift; - my($tag) = shift; - my($val) = undef; - - if (defined $self->{'guid_names'} && - defined $self->{'guid_names'}->{$tag}) { - $val = $self->{'guid_names'}->{$tag}; - } - - return $val; -} - - -sub save_project_value { - my($self) = shift; - my($name) = shift; - my($value) = shift; - - if ($name eq 'guid') { - if (!defined $self->{'guid_names'}) { - $self->{'guid_names'} = {}; + my($key) = shift; + my($val) = shift; + + if ($key eq 'after' && $val ne '') { + my($arr) = $self->create_array($val); + $val = ''; + foreach my $entry (@$arr) { + $val .= '"' . $entry . '" '; } - $self->{'guid_names'}->{$self->project_file_name()} = $value; + $val =~ s/\s+$//; } + return $val; } diff --git a/bin/MakeProjectCreator/modules/VC7WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/VC7WorkspaceCreator.pm index 146a775d033..a1161200cd9 100644 --- a/bin/MakeProjectCreator/modules/VC7WorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/VC7WorkspaceCreator.pm @@ -22,6 +22,10 @@ use vars qw(@ISA); # Subroutine Section # ************************************************************ +sub allow_duplicates { + my($self) = shift; + return 0; +} sub crlf { my($self) = shift; @@ -51,6 +55,7 @@ sub print_inner_project { #my($gen) = shift; #my($pguid) = shift; #my($deps) = shift; + #my($name) = shift; } @@ -76,18 +81,26 @@ sub print_dependencies { my($pjs) = shift; my($crlf) = $self->crlf(); + ## I hate to add yet another loop through all the projects, but + ## we must have some way to map plain project names to guids. + my(%name_to_guid_map) = (); + foreach my $project(@$list) { + my($name, $deps, $guid) = @{$$pjs{$project}}; + $name_to_guid_map{$name} = $guid; + } + ## Project Dependencies print $fh "\tGlobalSection(ProjectDependencies) = postSolution$crlf"; foreach my $project (@$list) { - my($name, $rawdeps, $pguid) = @{$$pjs{$project}}; + my($name, $rawdeps, $project_guid) = @{$$pjs{$project}}; my($deps) = $self->get_validated_ordering($project); if (defined $deps && $deps ne '') { my($darr) = $self->create_array($deps); my($i) = 0; foreach my $dep (@$darr) { - my($val) = $gen->specific_lookup($dep); - if (defined $val && $pguid ne $val) { - print $fh "\t\t{$pguid}.$i = {$val}$crlf"; + my($guid) = $name_to_guid_map{$dep}; + if (defined $guid && $guid ne $project_guid) { + print $fh "\t\t{$project_guid}.$i = {$guid}$crlf"; $i++; } } @@ -102,22 +115,27 @@ sub write_comps { my($fh) = shift; my($gen) = shift; my($projects) = $self->get_projects(); - my($guid) = '8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942'; + my($vc7guid) = '8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942'; my($pjs) = $self->get_project_info(); my(@list) = $self->sort_dependencies($projects, $pjs); my($crlf) = $self->crlf(); - ## $guid above is the VC7 Project GUID. It should not change. + ## I hate to add yet another loop through all the projects, but + ## we must have some way to map plain project names to guids. + my(%name_to_guid_map) = (); + foreach my $project(sort @list) { + my($name, $deps, $guid) = @{$$pjs{$project}}; + $name_to_guid_map{$name} = $guid; + } ## Project Information foreach my $project (sort @list) { - my($name, $rawdeps, $pguid) = @{$$pjs{$project}}; + my($name, $rawdeps, $guid) = @{$$pjs{$project}}; my($deps) = $self->get_validated_ordering($project); - ## Convert all /'s to \ my($cpy) = $self->slash_to_backslash($project); - print $fh "Project(\"{$guid}\") = \"$name\", \"$cpy\", \"{$pguid}\"$crlf"; - $self->print_inner_project($fh, $gen, $pguid, $deps); + print $fh "Project(\"{$vc7guid}\") = \"$name\", \"$cpy\", \"{$guid}\"$crlf"; + $self->print_inner_project($fh, $gen, $guid, $deps, $name, \%name_to_guid_map); print $fh "EndProject$crlf"; } diff --git a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm index 4ed23b3db8e..89618c48ea1 100644 --- a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm @@ -468,22 +468,18 @@ sub write_workspace { my($addfile) = shift; my($status) = 1; my($error) = ''; + my($duplicates) = 0; if ($self->get_toplevel()) { if ($addfile) { - ## NOTE: If support for VC6 is ever removed, then we can remove - ## this block of code. So far, VC6 is the only tool we support - ## that can not handle projects that exist in different directories - ## but have the same name. + ## VC6 is the only tool that currently cannot work with duplicate names, but + ## duplicates really don't make sense for anything but Makefile-style projects. my(%names) = (); foreach my $project (@{$self->{'projects'}}) { my($name) = $self->{'project_info'}->{$project}->[0]; if (defined $names{$name}) { - ## Having duplicate project names is an error in a VC6 Workspace. - ## We will create the project, but we will warn the user that - ## the project has duplicate names. - print "WARNING: A duplicate project named '$name' " . - "has already been added.\n"; + ++$duplicates; + print "WARNING: Duplicate project '$name'.\n"; } else { $names{$name} = 1; @@ -493,8 +489,22 @@ sub write_workspace { else { $self->{'per_project_workspace_name'} = 1; } + my($name) = $self->transform_file_name($self->workspace_file_name()); - if (defined $self->{'projects'}->[0]) { + + my($abort_creation) = 0; + + if ($duplicates > 0 && ! $self->allow_duplicates()) { + print "WARNING: Duplicates not allowed.\n"; + $abort_creation = 1; + } else { + if (! defined $self->{'projects'}->[0]) { + print "WARNING: No projects were created.\n"; + $abort_creation = 1; + } + } + + if (! $abort_creation) { my($fh) = new FileHandle(); my($dir) = dirname($name); @@ -548,10 +558,8 @@ sub write_workspace { } } } - } - else { - print "WARNING: No projects were created.\n" . - " Workspace $name has not been created.\n"; + } else { + print " Workspace $name has not been created.\n"; } if (!$addfile) { $self->{'per_project_workspace_name'} = undef; @@ -1048,6 +1056,11 @@ sub get_validated_ordering { # Virtual Methods To Be Overridden # ************************************************************ +sub allow_duplicates { + my($self) = shift; + return 1; +} + sub workspace_file_name { #my($self) = shift; return ''; diff --git a/bin/MakeProjectCreator/templates/bor.mpd b/bin/MakeProjectCreator/templates/bor.mpd index a1ef5bb5f49..cc033c17cb0 100644 --- a/bin/MakeProjectCreator/templates/bor.mpd +++ b/bin/MakeProjectCreator/templates/bor.mpd @@ -1,13 +1,5 @@ # Makefile for building the <%if(exename)%><%exename%> exe<%endif%><%if(sharedname)%><%sharedname%> library<%endif%> with Borland C++ Builder -<%if(ssl)%> -!ifdef SSL_ROOT -<%endif%> -NAME = <%if(exename)%><%exename%><%endif%><%if(sharedname)%><%sharedname%><%endif%> -<%if(ssl)%> -!endif -<%endif%> - <%if(idl_files)%> TAO_IDL = $(CORE_BINDIR)\tao_idl -g $(CORE_BINDIR)\gperf.exe diff --git a/bin/MakeProjectCreator/templates/vc7.mpd b/bin/MakeProjectCreator/templates/vc7.mpd index fe547b05150..51c97474d20 100644 --- a/bin/MakeProjectCreator/templates/vc7.mpd +++ b/bin/MakeProjectCreator/templates/vc7.mpd @@ -14,8 +14,8 @@ <%foreach(configurations)%> <Configuration Name="<%configuration%>|<%platform%>" - OutputDirectory=".\<%if(type_is_dynamic)%><%libout%><%else%><%output_dir%><%endif%>" - IntermediateDirectory=".\<%intermediate_dir%>\<%noextension(project_file)%>" + OutputDirectory="<%if(type_is_dynamic)%><%if(dllout)%><%dllout%><%else%><%libout%><%endif%><%else%><%if(type_is_static)%><%libout%><%else%><%if(install)%><%install%><%else%><%output_dir%><%endif%><%endif%><%endif%>" + IntermediateDirectory="<%intermediate_dir%>/<%noextension(project_file)%>" ConfigurationType="<%configuration_type("2")%>" UseOfMFC="<%use_mfc("0")%>" ATLMinimizesCRunTimeLibraryUsage="FALSE"> @@ -24,61 +24,66 @@ <%if(optimization)%> Optimization="<%optimization%>" <%endif%> -<%if(!debug)%> - InlineFunctionExpansion="<%inline("2")%>" +<%if(OptimizeForProcessor)%> + Optimization="<%OptimizeForProcessor%>" <%endif%> AdditionalIncludeDirectories="<%foreach(includes)%><%include%><%fornotlast(",")%><%endfor%>" - PreprocessorDefinitions="<%if(type_is_dynamic)%><%foreach(dynamicflags)%><%dynamicflag%>;<%endfor%><%endif%><%if(need_staticflags)%><%foreach(staticflags)%><%libflag%>;<%endfor%><%endif%><%if(pch_header)%><%foreach(pch_defines)%><%pch_define%>;<%endfor%><%endif%><%foreach(defines common_defines macros)%><%define%><%fornotlast(";")%><%endfor%>" -<%if(!debug)%> - StringPooling="<%string_pooling("TRUE")%>" + PreprocessorDefinitions="<%if(type_is_dynamic)%><%foreach(dynamicflags)%><%dynamicflag%>;<%endfor%><%endif%><%if(need_staticflags)%><%foreach(staticflags)%><%staticflag%>;<%endfor%><%endif%><%if(pch_header)%><%foreach(pch_defines)%><%pch_define%>;<%endfor%><%endif%><%foreach(defines common_defines macros)%><%define%><%fornotlast(";")%><%endfor%>" + MinimalRebuild="<%MinimalRebuild("FALSE")%>" + ExceptionHandling="TRUE" +<%if(debug)%> + BasicRuntimeChecks="<%BasicRuntimeChecks("3")%>" +<%endif%> +<%if(StringPooling)%> + StringPooling="<%StringPooling%>" <%endif%> - RuntimeLibrary="<%runtime_library%>" - EnableFunctionLevelLinking="TRUE" + RuntimeLibrary="<%if(debug)%><%runtime_library("3")%><%else%><%runtime_library("2")%><%endif%>" + BufferSecurityCheck="<%BufferSecurityCheck("TRUE")%>" + EnableFunctionLevelLinking="<%EnableFunctionLevelLinking("TRUE")%>" + TreatWChar_tAsBuiltInType="TRUE" + ForceConformanceInForLoopScope="TRUE" RuntimeTypeInfo="<%rtti("TRUE")%>" <%if(pch_header)%> - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="<%pch_header%>" <%if(pch_source)%> - PrecompiledHeaderFile=".\<%intermediate_dir%>\<%noextension(project_file)%>\<%noextension(pch_source)%>.pch" + UsePrecompiledHeader="3" +<%else%> + UsePrecompiledHeader="2" <%endif%> + PrecompiledHeaderThrough="<%pch_header%>" <%endif%> - AssemblerListingLocation=".\<%intermediate_dir%>\<%noextension(project_file)%>" - ObjectFile=".\<%intermediate_dir%>\<%noextension(project_file)%>\" WarningLevel="<%warning_level("3")%>" SuppressStartupBanner="TRUE" - DebugInformationFormat="<%debug_format("3")%>" - CompileAs="0"/> + Detect64BitPortabilityProblems="<%Detect64BitPortabilityProblems("FALSE")%>" + DebugInformationFormat="<%debug_format("3")%>"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" - AdditionalOptions="/MACHINE:<%machine("I386")%>" <%if(type_is_binary)%> AdditionalDependencies="<%foreach(lit_libs)%><%lit_lib%>.lib <%endfor%><%foreach(libs defaultlibs)%><%lib%><%lib_modifier%>.lib<%fornotlast(" ")%><%endfor%>" <%endif%> - OutputFile="<%if(type_is_dynamic)%><%if(dllout)%><%dllout%><%else%><%libout%><%endif%>\<%sharedname%><%lib_modifier%>.dll<%endif%><%if(exename)%><%if(install)%><%install%><%else%><%output_dir%><%endif%>\<%exename%>.exe<%endif%><%if(type_is_static)%><%libout%>\<%staticname%><%lib_modifier%>.lib<%endif%>" + OutputFile="$(OutDir)/<%if(type_is_dynamic)%><%sharedname%><%lib_modifier%>.dll<%else%><%if(type_is_static)%><%staticname%><%lib_modifier%>.lib<%else%><%exename%>.exe<%endif%><%endif%>" Version="<%version("1.0")%>" - LinkIncremental="<%incremental("1")%>" + LinkIncremental="<%LinkIncremental("1")%>" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="<%foreach(libpaths)%><%libpath%><%fornotlast(";")%><%endfor%>" -<%if(debug)%> GenerateDebugInformation="TRUE" -<%endif%> -<%if(pdb)%> -<%if(sharedname)%> - ProgramDatabaseFile="<%if(dllout)%><%dllout%><%else%><%libout%><%endif%>\<%sharedname%><%lib_modifier%>.pdb" +<%if(type_is_dynamic)%> + ProgramDatabaseFile="$(OutDir)/<%sharedname%><%lib_modifier%>.pdb" <%else%> -<%if(exename)%> - ProgramDatabaseFile="<%if(install)%><%install%><%else%><%output_dir%><%endif%>\<%exename%>.pdb" -<%endif%> + <%if(type_is_binary)%> + ProgramDatabaseFile="$(OutDir)/<%exename%>.pdb" + <%endif%> <%endif%> + SubSystem="<%subsystem("1")%>" +<%if(!debug)%> + OptimizeReferences="<%optref("2")%>" + EnableCOMDATFolding="<%opticf("2")%>" <%endif%> <%if(type_is_dynamic)%> - SubSystem="<%subsystem("2")%>" - ImportLibrary="<%libout%>\<%sharedname%><%lib_modifier%>.lib"/> -<%else%> - SubSystem="<%subsystem("2")%>"/> + ImportLibrary="$(OutDir)/<%sharedname%><%lib_modifier%>.lib" <%endif%> + /> <Tool Name="VCMIDLTool"/> <Tool @@ -155,21 +160,21 @@ Description="Invoking IDL Compiler on <%basename(idl_file)%> located in <%dirname(idl_file)%>" <%if(flag_overrides(idl_file, idlgendir))%> CommandLine="PATH=%PATH%;<%idl_compiler_libs%> -<%idl_compiler%> -o <%flag_overrides(idl_file, idlgendir)%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags%><%endif%> <%idl_file%>" +<%idl_compiler%> -o <%flag_overrides(idl_file, idlgendir)%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags("-Sc")%><%endif%> <%idl_file%>" Outputs="<%flag_overrides(idl_file, idlgendir)%>\<%basenoextension(idl_file)%>C.h;<%flag_overrides(idl_file, idlgendir)%>\<%basenoextension(idl_file)%>C.i;<%flag_overrides(idl_file, idlgendir)%>\<%basenoextension(idl_file)%>C.cpp;<%flag_overrides(idl_file, idlgendir)%>\<%basenoextension(idl_file)%>S.h;<%flag_overrides(idl_file, idlgendir)%>\<%basenoextension(idl_file)%>S.i;<%flag_overrides(idl_file, idlgendir)%>\<%basenoextension(idl_file)%>S.cpp"/> <%else%> <%if(idlgendir)%> CommandLine="PATH=%PATH%;<%idl_compiler_libs%> -<%idl_compiler%> -o <%idlgendir%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags%><%endif%> <%idl_file%>" +<%idl_compiler%> -o <%idlgendir%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags("-Sc")%><%endif%> <%idl_file%>" Outputs="<%idlgendir%>\<%basenoextension(idl_file)%>C.h;<%idlgendir%>\<%basenoextension(idl_file)%>C.i;<%idlgendir%>\<%basenoextension(idl_file)%>C.cpp;<%idlgendir%>\<%basenoextension(idl_file)%>S.h;<%idlgendir%>\<%basenoextension(idl_file)%>S.i;<%idlgendir%>\<%basenoextension(idl_file)%>S.cpp"/> <%else%> <%if(dirname_found)%> CommandLine="PATH=%PATH%;<%idl_compiler_libs%> -<%idl_compiler%> -o <%dirname(idl_file)%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags%><%endif%> <%idl_file%>" +<%idl_compiler%> -o <%dirname(idl_file)%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags("-Sc")%><%endif%> <%idl_file%>" Outputs="<%basenoextension(idl_file)%>C.h;<%basenoextension(idl_file)%>C.i;<%basenoextension(idl_file)%>C.cpp;<%basenoextension(idl_file)%>S.h;<%basenoextension(idl_file)%>S.i;<%basenoextension(idl_file)%>S.cpp"/> <%else%> CommandLine="PATH=%PATH%;<%idl_compiler_libs%> -<%idl_compiler%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags%><%endif%> <%idl_file%>" +<%idl_compiler%> <%if(flag_overrides(idl_file, idlflags))%><%flag_overrides(idl_file, idlflags)%><%else%><%idlflags("-Sc")%><%endif%> <%idl_file%>" Outputs="<%noextension(idl_file)%>C.h;<%noextension(idl_file)%>C.i;<%noextension(idl_file)%>C.cpp;<%noextension(idl_file)%>S.h;<%noextension(idl_file)%>S.i;<%noextension(idl_file)%>S.cpp"/> <%endif%> <%endif%> |