From 6819f29fc99e572b6e23a8a90b8f986a123917aa Mon Sep 17 00:00:00 2001 From: msmit Date: Tue, 5 Jan 2010 08:48:51 +0000 Subject: Tue Jan 5 08:51:51 UTC 2010 Marcel Smit * connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp: * connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp: Optimized error logging. * connectors/dds4ccm/impl/ndds/DDS_Read_T.h: * connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp: * connectors/dds4ccm/impl/ndds/DDS_StateListen_T.h: * connectors/dds4ccm/impl/ndds/DDS_StateListen_T.cpp: * connectors/dds4ccm/impl/ndds/DDS_State_Connector_T.cpp: Separate DDS lifecycle from CCM lifecycle. DDS_Read_T and DDS_StateListen_T now have a configuration_complete, activate, passivate and remove methods. --- CIAO/ChangeLog | 15 +++ CIAO/connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp | 8 +- CIAO/connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp | 8 +- CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp | 103 ++++++++++++++----- CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.h | 10 +- .../dds4ccm/impl/ndds/DDS_StateListen_T.cpp | 109 +++++++++++++++------ .../dds4ccm/impl/ndds/DDS_StateListen_T.h | 12 ++- .../dds4ccm/impl/ndds/DDS_State_Connector_T.cpp | 32 +++--- 8 files changed, 216 insertions(+), 81 deletions(-) diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 120707640fe..2416304064b 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,18 @@ +Tue Jan 5 08:51:51 UTC 2010 Marcel Smit + + * connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp: + * connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp: + Optimized error logging. + + * connectors/dds4ccm/impl/ndds/DDS_Read_T.h: + * connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp: + * connectors/dds4ccm/impl/ndds/DDS_StateListen_T.h: + * connectors/dds4ccm/impl/ndds/DDS_StateListen_T.cpp: + * connectors/dds4ccm/impl/ndds/DDS_State_Connector_T.cpp: + Separate DDS lifecycle from CCM lifecycle. DDS_Read_T and DDS_StateListen_T + now have a configuration_complete, activate, passivate and remove + methods. + Tue Jan 5 07:31:33 UTC 2010 Marcel Smit * connectors/dds4ccm/impl/ndds/DDS_Event_Connector_T.cpp: diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp index 6ba29336363..cc40c2909a7 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Get_T.cpp @@ -62,7 +62,7 @@ DDS_Get_T::configuration_complete ( } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in configuration_complete in DDS_Get_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Get_T::configuration_complete: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } @@ -86,7 +86,7 @@ DDS_Get_T::activate ( } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in activate in DDS_Get_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Get_T::activate: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } @@ -104,7 +104,7 @@ DDS_Get_T::passivate (void) } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in passivate in DDS_Get_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Get_T::passivate: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } @@ -121,7 +121,7 @@ DDS_Get_T::remove (void) } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in remove in DDS_Get_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Get_T::remove: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp index 36c3f5d9e12..b87be9032e3 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Listen_T.cpp @@ -66,7 +66,7 @@ DDS_Listen_T::configuration_complete ( } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception configuration_complete in DDS_Listen_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Listen_T::configuration_complete: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } @@ -94,7 +94,7 @@ DDS_Listen_T::activate ( } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in activate in DDS_Listen_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Listen_T::activate: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } @@ -112,7 +112,7 @@ DDS_Listen_T::passivate () } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in passivate in DDS_Listen_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Listen_T::passivate: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } @@ -129,7 +129,7 @@ DDS_Listen_T::remove () } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception in remove in DDS_Listen_T\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Listen_T::remove: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp index 46f42bd980a..238775e4bb6 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.cpp @@ -22,58 +22,109 @@ DDS_Read_T::~DDS_Read_T (void) template void -DDS_Read_T::init ( - ::CCM_DDS::PortStatusListener_ptr listener, +DDS_Read_T::configuration_complete ( ::DDS::Topic_ptr topic, ::DDS::Subscriber_ptr subscriber, const char* library_name, const char* profile_name) { - CIAO_TRACE ("DDS_Read_T::init"); + CIAO_TRACE ("DDS_Read_T::configuration_complete"); try { - if (CORBA::is_nil (this->status_.in ())) - { - this->status_ = new ::CIAO::DDS4CCM::RTI::PortStatusListener_T - (listener); - } - if (CORBA::is_nil (this->data_.in ())) { + ::DDS::DataReader_var reader; if (profile_name && library_name) { - ::DDS::DataReader_var reader = - subscriber->create_datareader_with_profile ( + reader = subscriber->create_datareader_with_profile ( topic, library_name, profile_name, - this->status_.in (), - ::CIAO::DDS4CCM::RTI::PortStatusListener_T::get_mask ()); - DDSDataReader *rd = dynamic_cast < DDSDataReader *> (reader.in ()); - this->rti_reader_.set_impl (rd); - this->data_ = ::DDS::CCM_DataReader::_narrow (reader); - this->dds_read_.set_impl (reader); + ::DDS::DataReaderListener::_nil (), + 0); } else { ::DDS::DataReaderQos drqos; - ::DDS::DataReader_var reader = - subscriber->create_datareader ( + reader = subscriber->create_datareader ( topic, drqos, - this->status_.in (), - ::CIAO::DDS4CCM::RTI::PortStatusListener_T::get_mask ()); - DDSDataReader *rd = dynamic_cast < DDSDataReader *> (reader.in ()); - this->rti_reader_.set_impl (rd); - this->data_ = ::DDS::CCM_DataReader::_narrow (reader); - this->dds_read_.set_impl (reader); + ::DDS::DataReaderListener::_nil (), + 0); } + ::CIAO::DDS4CCM::RTI::RTI_DataReader_i *rd = + dynamic_cast < ::CIAO::DDS4CCM::RTI::RTI_DataReader_i *> (reader.in ()); + this->rti_reader_.set_impl (rd->get_impl ()); + this->data_ = ::DDS::CCM_DataReader::_narrow (reader); + this->dds_read_.set_impl (reader); } } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception while creating subscriber entities\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Read_T::configuration_complete: Caught unknown c++ exception.\n")); + throw CORBA::INTERNAL (); + } +} + +template +void +DDS_Read_T::activate ( + ::CCM_DDS::PortStatusListener_ptr listener) +{ + CIAO_TRACE ("DDS_Read_T::activate"); + + try + { + if (CORBA::is_nil (this->status_.in ())) + { + this->status_ = new ::CIAO::DDS4CCM::RTI::PortStatusListener_T + (listener); + } + this->rti_reader_.set_listener ( + this->status_.in (), + ::CIAO::DDS4CCM::RTI::PortStatusListener_T::get_mask ()); + } + catch (...) + { + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Read_T::activate: Caught unknown c++ exception.\n")); + throw CORBA::INTERNAL (); + } +} + +template +void +DDS_Read_T::passivate () +{ + CIAO_TRACE ("DDS_Read_T::passivate"); + + try + { + this->rti_reader_.set_listener ( + ::DDS::DataReaderListener::_nil (), + 0); + } + catch (...) + { + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Read_T::passivate: Caught unknown c++ exception.\n")); + throw CORBA::INTERNAL (); + } +} + +template +void +DDS_Read_T::remove () +{ + CIAO_TRACE ("DDS_Read_T::remove"); + + try + { + this->rti_reader_.delete_contained_entities (); + this->rti_reader_.set_impl (0); + } + catch (...) + { + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_Read_T::remove: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.h b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.h index 0867a2a0ba0..cb57d23578f 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.h +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_Read_T.h @@ -27,13 +27,19 @@ public: ::DDS::CCM_DataReader_ptr get_dds_entity (void); //@} - void init ( - ::CCM_DDS::PortStatusListener_ptr listener, + void configuration_complete ( ::DDS::Topic_ptr topic, ::DDS::Subscriber_ptr subscriber, const char* library_name, const char* profile_name); + void activate ( + ::CCM_DDS::PortStatusListener_ptr listener); + + void passivate (void); + + void remove (void); + private: /** * DDS_Read diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.cpp b/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.cpp index 6fec33974ca..7d10b312431 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.cpp @@ -22,62 +22,111 @@ DDS_StateListen_T::~DDS_StateListen_T (void) template void -DDS_StateListen_T::init ( - typename CCM_TYPE::statelistener_type::_ptr_type listener, - ::CCM_DDS::PortStatusListener_ptr status, +DDS_StateListen_T::configuration_complete ( ::DDS::Topic_ptr topic, ::DDS::Subscriber_ptr subscriber, const char* library_name, const char* profile_name) { - CIAO_TRACE ("DDS_StateListen_T::init"); + CIAO_TRACE ("DDS_StateListen_T::configuration_complete"); try { - if (CORBA::is_nil (this->data_listener_.in ())) - { - this->data_listener_ = new ::CIAO::DDS4CCM::RTI::DataReaderStateListener_T - ( - listener, - status, - data_control_.in ()); - } - if (CORBA::is_nil (this->data_reader_.in ())) { + ::DDS::DataReader_var reader; if (library_name && profile_name) { - ::DDS::DataReader_var reader = - subscriber->create_datareader_with_profile ( + reader = subscriber->create_datareader_with_profile ( topic, library_name, profile_name, - this->data_listener_.in (), - ::CIAO::DDS4CCM::RTI::DataReaderStateListener_T::get_mask ()); - DDSDataReader *rd = dynamic_cast < DDSDataReader *> (reader.in ()); - this->rti_reader_.set_impl (rd); - this->data_reader_ = ::DDS::CCM_DataReader::_narrow (reader); - this->dds_read_.set_impl (this->data_reader_.in ()); + ::DDS::DataReaderListener::_nil (), + 0); } else { ::DDS::DataReaderQos drqos; - ::DDS::DataReader_var reader = - subscriber->create_datareader ( + reader = subscriber->create_datareader ( topic, drqos, - this->data_listener_.in (), - ::CIAO::DDS4CCM::RTI::DataReaderStateListener_T::get_mask ()); - DDSDataReader *rd = dynamic_cast < DDSDataReader *> (reader.in ()); - this->rti_reader_.set_impl (rd); - this->data_reader_ = ::DDS::CCM_DataReader::_narrow (reader); - this->dds_read_.set_impl (this->data_reader_.in ()); + ::DDS::DataReaderListener::_nil (), + 0); } + ::CIAO::DDS4CCM::RTI::RTI_DataReader_i *rd = + dynamic_cast < ::CIAO::DDS4CCM::RTI::RTI_DataReader_i *> (reader.in ()); + this->rti_reader_.set_impl (rd->get_impl ()); + this->data_reader_ = ::DDS::CCM_DataReader::_narrow (reader); + this->dds_read_.set_impl (this->data_reader_.in ()); + } + } + catch (...) + { + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_StateListen_T::configuration_complete: Caught unknown c++ exception.\n")); + throw CORBA::INTERNAL (); + } +} + +template +void +DDS_StateListen_T::activate ( + typename CCM_TYPE::statelistener_type::_ptr_type listener, + ::CCM_DDS::PortStatusListener_ptr status) +{ + CIAO_TRACE ("DDS_StateListen_T::activate"); + + try + { + if (CORBA::is_nil (this->data_listener_.in ())) + { + this->data_listener_ = new ::CIAO::DDS4CCM::RTI::DataReaderStateListener_T + ( + listener, + status, + data_control_.in ()); } + this->rti_reader_.set_listener ( + this->data_listener_.in (), + 0); + } + catch (...) + { + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_StateListen_T::activate: Caught unknown c++ exception.\n")); + throw CORBA::INTERNAL (); + } +} + +template +void +DDS_StateListen_T::passivate (void) +{ + CIAO_TRACE ("DDS_StateListen_T::passivate"); + try + { + this->rti_reader_.set_listener ( + ::DDS::DataReaderListener::_nil (), + 0); + } + catch (...) + { + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_StateListen_T::passivate: Caught unknown c++ exception.\n")); + throw CORBA::INTERNAL (); + } +} + +template +void +DDS_StateListen_T::remove (void) +{ + CIAO_TRACE ("DDS_StateListen_T::remove"); + try + { + this->rti_reader_.delete_contained_entities (); + this->rti_reader_.set_impl (0); } catch (...) { - CIAO_ERROR (1, (LM_EMERGENCY, "Caught unknown c++ exception while creating subscriber entities\n")); + CIAO_ERROR (1, (LM_EMERGENCY, "DDS_StateListen_T::remove: Caught unknown c++ exception.\n")); throw CORBA::INTERNAL (); } } diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.h b/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.h index 9d4361f5631..b56a98d9f32 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.h +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_StateListen_T.h @@ -27,14 +27,20 @@ public: ::DDS::CCM_DataReader_ptr get_dds_entity (void); //@} - void init ( - typename CCM_TYPE::statelistener_type::_ptr_type listener, - ::CCM_DDS::PortStatusListener_ptr status, + void configuration_complete ( ::DDS::Topic_ptr topic, ::DDS::Subscriber_ptr subscriber, const char* library_name, const char* profile_name); + void activate ( + typename CCM_TYPE::statelistener_type::_ptr_type listener, + ::CCM_DDS::PortStatusListener_ptr status); + + void passivate (void); + + void remove (void); + private: /** * DDS_Listen diff --git a/CIAO/connectors/dds4ccm/impl/ndds/DDS_State_Connector_T.cpp b/CIAO/connectors/dds4ccm/impl/ndds/DDS_State_Connector_T.cpp index 521574df5af..37c1eb8de49 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/DDS_State_Connector_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/DDS_State_Connector_T.cpp @@ -126,11 +126,23 @@ DDS_State_Connector_T::configuration_complete (void) this->library_name_, this->profile_name_); + this->push_state_observer_.configuration_complete ( + this->topic_.in (), + this->subscriber_.in (), + this->library_name_, + this->profile_name_); + this->pull_observer_.configuration_complete ( this->topic_.in (), this->subscriber_.in (), this->library_name_, this->profile_name_); + + this->passive_observer_.configuration_complete ( + this->topic_.in (), + this->subscriber_.in (), + this->library_name_, + this->profile_name_); } template @@ -148,23 +160,15 @@ DDS_State_Connector_T::ccm_activate (void) this->context_->get_connection_push_observer_data_listener (), this->context_->get_connection_push_observer_status ()); - this->push_state_observer_.init ( + this->push_state_observer_.activate ( this->context_->get_connection_push_state_observer_data_listener (), - this->context_->get_connection_push_state_observer_status (), - this->topic_.in (), - this->subscriber_.in (), - this->library_name_, - this->profile_name_); + this->context_->get_connection_push_state_observer_status ()); this->pull_observer_.activate ( this->context_->get_connection_pull_observer_status ()); - this->passive_observer_.init ( - this->context_->get_connection_passive_observer_status (), - this->topic_.in (), - this->subscriber_.in (), - this->library_name_, - this->profile_name_); + this->passive_observer_.activate ( + this->context_->get_connection_passive_observer_status ()); } template @@ -173,7 +177,9 @@ DDS_State_Connector_T::ccm_passivate (void) { DDS_TopicBase_Connector_T::ccm_passivate (); this->push_observer_.passivate (); + this->push_state_observer_.passivate (); this->pull_observer_.passivate (); + this->passive_observer_.passivate (); } template @@ -182,6 +188,8 @@ DDS_State_Connector_T::ccm_remove (void) { DDS_TopicBase_Connector_T::ccm_remove (); this->push_observer_.remove (); + this->push_state_observer_.remove (); this->pull_observer_.remove (); + this->passive_observer_.remove (); } -- cgit v1.2.1