// -*- C++ -*- // $Id$ #include "dds4ccm/impl/dds/DataReaderListener_T.h" #include "dds4ccm/impl/dds/DataWriterListener_T.h" #include "dds4ccm/impl/dds/DataListenerControl_T.h" #include "dds4ccm/impl/dds/PortStatusListener_T.h" #include "dds4ccm/impl/logger/Log_Macros.h" template DDS_Write_T::DDS_Write_T (void) : ccm_dds_writer_ (0) { } template DDS_Write_T::~DDS_Write_T (void) { } template void DDS_Write_T::configuration_complete ( ::DDS::Topic_ptr topic, ::DDS::Publisher_ptr publisher, const char* library_name, const char* profile_name) { DDS4CCM_TRACE ("DDS_Write_T::configuration_complete"); try { if (!this->ccm_dds_writer_.get_impl ()) { ::DDS::DataWriter_var dwv_tmp; if (library_name && profile_name) { dwv_tmp = publisher->create_datawriter_with_profile ( topic, library_name, profile_name, ::DDS::DataWriterListener::_nil (), 0); } else { ::DDS::DataWriterQos dwqos; dwv_tmp = publisher->create_datawriter ( topic, dwqos, ::DDS::DataWriterListener::_nil (), 0); } ::CIAO::DDS4CCM::CCM_DDS_DataWriter_i *rw = dynamic_cast < ::CIAO::DDS4CCM::CCM_DDS_DataWriter_i *> (dwv_tmp.in ()); this->ccm_dds_writer_.set_impl (rw->get_impl ()); this->writer_t_.set_impl (&this->ccm_dds_writer_); } } catch (...) { DDS4CCM_ERROR (1, (LM_EMERGENCY, "DDS_Write_T::configuration_complete: Caught unexpected exception.\n")); throw CORBA::INTERNAL (); } } template void DDS_Write_T::activate () { DDS4CCM_TRACE ("DDS_Write_T::activate"); try { if (::CORBA::is_nil (this->data_listener_.in ())) { ACE_NEW_THROW_EX (this->data_listener_, DataWriterListener (), CORBA::NO_MEMORY ()); } this->ccm_dds_writer_.set_listener ( this->data_listener_.in (), DataWriterListener::get_mask ()); } catch (...) { DDS4CCM_ERROR (1, (LM_EMERGENCY, "DDS_Write_T::activate: Caught unexpected exception.\n")); throw CORBA::INTERNAL (); } } template void DDS_Write_T::passivate () { DDS4CCM_TRACE ("DDS_Write_T::passivate"); try { this->ccm_dds_writer_.set_listener ( ::DDS::DataWriterListener::_nil (), 0); this->data_listener_ = ::DDS::DataWriterListener::_nil (); } catch (...) { DDS4CCM_ERROR (1, (LM_EMERGENCY, "DDS_Write_T::passivate: Caught unexpected exception.\n")); throw CORBA::INTERNAL (); } } template void DDS_Write_T::remove ( ::DDS::Publisher_ptr publisher) { DDS4CCM_TRACE ("DDS_Write_T::remove"); try { DDS::ReturnCode_t const retval = publisher->delete_datawriter (&this->ccm_dds_writer_); if (retval != DDS::RETCODE_OK) { DDS4CCM_ERROR (1, (LM_ERROR, CLINFO "DDS_Write_T::remove - " "Unable to delete DataWriter: <%C>\n", ::CIAO::DDS4CCM::translate_retcode (retval))); throw CORBA::INTERNAL (); } this->ccm_dds_writer_.set_impl (0); this->writer_t_.set_impl (0); } catch (...) { DDS4CCM_ERROR (1, (LM_EMERGENCY, "DDS_Write_T::remove: Caught unexpected exception.\n")); throw CORBA::INTERNAL (); } } template typename CCM_TYPE::writer_type::_ptr_type DDS_Write_T::get_data (void) { DDS4CCM_TRACE ("DDS_Write_T::get_data"); return &this->writer_t_; } template ::DDS::CCM_DataWriter_ptr DDS_Write_T::get_dds_entity (void) { DDS4CCM_TRACE ("DDS_Write_T::get_dds_entity"); return &this->ccm_dds_writer_; }