diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2010-04-12 14:11:44 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2010-04-12 14:11:44 +0000 |
commit | e30c0be78e222e708fc5010c5b678a72fc8ca4be (patch) | |
tree | fe2dde0d9d3e5aba67984c94c561b7f70f5a2cde /modules/CIAO/connectors/dds4ccm/tests/Reader/Sender/Reader_Test_Sender_exec.cpp | |
parent | 7627760802fdf292403c971e81c2dd113ebf4912 (diff) | |
download | ATCD-e30c0be78e222e708fc5010c5b678a72fc8ca4be.tar.gz |
branching/tagging
Diffstat (limited to 'modules/CIAO/connectors/dds4ccm/tests/Reader/Sender/Reader_Test_Sender_exec.cpp')
-rw-r--r-- | modules/CIAO/connectors/dds4ccm/tests/Reader/Sender/Reader_Test_Sender_exec.cpp | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/modules/CIAO/connectors/dds4ccm/tests/Reader/Sender/Reader_Test_Sender_exec.cpp b/modules/CIAO/connectors/dds4ccm/tests/Reader/Sender/Reader_Test_Sender_exec.cpp new file mode 100644 index 00000000000..242249bbcd2 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/Reader/Sender/Reader_Test_Sender_exec.cpp @@ -0,0 +1,202 @@ +// -*- C++ -*- +// $Id$ + +#include "Reader_Test_Sender_exec.h" +#include "ace/Log_Msg.h" + +namespace CIAO_Reader_Test_Sender_Impl +{ + //============================================================ + // ConnectorStatusListener_exec_i + //============================================================ + ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (Sender_exec_i &callback) + : callback_ (callback) + { + } + + ConnectorStatusListener_exec_i::~ConnectorStatusListener_exec_i (void) + { + } + + // Operations from ::CCM_DDS::ConnectorStatusListener + void ConnectorStatusListener_exec_i::on_inconsistent_topic( + ::DDS::Topic_ptr , + const DDS::InconsistentTopicStatus & ) + { + } + + void ConnectorStatusListener_exec_i::on_requested_incompatible_qos( + ::DDS::DataReader_ptr , + const DDS::RequestedIncompatibleQosStatus & ) + { + } + + void ConnectorStatusListener_exec_i::on_sample_rejected( + ::DDS::DataReader_ptr , + const DDS::SampleRejectedStatus & ) + { + } + + void ConnectorStatusListener_exec_i::on_offered_deadline_missed( + ::DDS::DataWriter_ptr , + const DDS::OfferedDeadlineMissedStatus & ) + { + } + + void ConnectorStatusListener_exec_i::on_offered_incompatible_qos( + ::DDS::DataWriter_ptr , + const DDS::OfferedIncompatibleQosStatus & ) + { + } + + void ConnectorStatusListener_exec_i::on_unexpected_status( + ::DDS::Entity_ptr /*the_entity*/, + ::DDS::StatusKind status_kind) + { + if (status_kind == ::DDS::PUBLICATION_MATCHED_STATUS) + this->callback_.start (); + } + + + //============================================================ + // Component Executor Implementation Class: Sender_exec_i + //============================================================ + Sender_exec_i::Sender_exec_i (void) + : iterations_ (10), + keys_ (5), + done_ (false), + ccm_activated_ (false) + { + } + + Sender_exec_i::~Sender_exec_i (void) + { + } + + void + Sender_exec_i::start (void) + { + //start can be called more than once... + if (!this->done_ && this->ccm_activated_) + { + this->done_ = true; + if (! ::CORBA::is_nil (this->starter_)) + { + this->starter_->set_reader_properties (this->keys_, this->iterations_); + this->starter_->read_no_data (); + } + else + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: Unable to start the reader\n"))); + return; + } + for (CORBA::UShort iter_key = 1; iter_key < this->keys_ + 1; ++iter_key) + { + char key[7]; + ReaderTest *new_key = new ReaderTest; + ACE_OS::sprintf (key, "KEY_%d", iter_key); + new_key->key = CORBA::string_dup(key); + for (CORBA::UShort iter = 1; iter < this->iterations_ + 1; ++iter) + { + new_key->iteration = iter; + this->writer_->write_one (*new_key, ::DDS::HANDLE_NIL); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Written key <%C> with <%d>\n"), + key, iter)); + } + } + this->starter_->start_read (); + } + } + + ::CORBA::UShort + Sender_exec_i::iterations (void) + { + return this->iterations_; + } + + void + Sender_exec_i::iterations (::CORBA::UShort iterations) + { + this->iterations_ = iterations; + } + + ::CORBA::UShort + Sender_exec_i::keys (void) + { + return this->keys_; + } + + void + Sender_exec_i::keys (::CORBA::UShort keys) + { + this->keys_ = keys; + } + + ::CCM_DDS::CCM_ConnectorStatusListener_ptr + Sender_exec_i::get_info_out_connector_status (void) + { + return new ConnectorStatusListener_exec_i (*this); + } + + void + Sender_exec_i::set_session_context (::Components::SessionContext_ptr ctx) + { + this->context_ = + ::Reader_Test::CCM_Sender_Context::_narrow (ctx); + + if ( ::CORBA::is_nil (this->context_.in ())) + { + throw ::CORBA::INTERNAL (); + } + } + + void + Sender_exec_i::configuration_complete (void) + { + } + + void + Sender_exec_i::ccm_activate (void) + { + try + { + this->writer_ = this->context_->get_connection_info_write_data (); + this->starter_ = this->context_->get_connection_start_reader (); + this->ccm_activated_ = true; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: GET_CONNECTION_START_READER : Exception caught\n"))); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: GET_CONNECTION_START_READER : Unknown exception caught\n"))); + } + } + + void + Sender_exec_i::ccm_passivate (void) + { + } + + void + Sender_exec_i::ccm_remove (void) + { + } + + extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr + create_Reader_Test_Sender_Impl (void) + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_NORETURN ( + retval, + Sender_exec_i); + + return retval; + } +} |