// $Id$ // // **** Code generated by the **** // **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** // CIAO has been developed by: // Center for Distributed Object Computing // Washington University // St. Louis, MO // USA // http://www.cs.wustl.edu/~schmidt/doc-center.html // CIDL Compiler has been developed by: // Institute for Software Integrated Systems // Vanderbilt University // Nashville, TN // USA // http://www.isis.vanderbilt.edu/ // // Information about CIAO is available at: // http://www.dre.vanderbilt.edu/CIAO #include "Sender_svnt.h" #include "Cookies.h" #include "ciao/Servant_Activator.h" #include "ciao/Dynamic_Component_Activator.h" #include "ciao/Port_Activator_T.h" namespace Sender_Impl { namespace CIAO_GLUE_Hello { template ReadMessage_Servant_T::ReadMessage_Servant_T ( ::Hello::CCM_ReadMessage_ptr executor, ::Components::CCMContext_ptr c) : executor_ (::Hello::CCM_ReadMessage::_duplicate (executor)), ctx_ (::Components::CCMContext::_duplicate (c)) { } template ReadMessage_Servant_T::~ReadMessage_Servant_T (void) { } template char * ReadMessage_Servant_T::get_message ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { return this->executor_->get_message ( ACE_ENV_SINGLE_ARG_PARAMETER); } template CORBA::Object_ptr ReadMessage_Servant_T::_get_component ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ::Components::SessionContext_var sc = ::Components::SessionContext::_narrow ( this->ctx_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); if (! CORBA::is_nil (sc.in ())) { return sc->get_CCM_object ( ACE_ENV_SINGLE_ARG_PARAMETER); } ::Components::EntityContext_var ec = ::Components::EntityContext::_narrow ( this->ctx_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); if (! CORBA::is_nil (ec.in ())) { return ec->get_CCM_object ( ACE_ENV_SINGLE_ARG_PARAMETER); } ACE_THROW_RETURN (CORBA::INTERNAL (), 0); } } namespace CIAO_GLUE_Hello { Sender_Context::Sender_Context ( ::Components::CCMHome_ptr home, ::CIAO::Session_Container *c, Sender_Servant *sv) : ACE_NESTED_CLASS (CIAO, Context_Impl_Base (home, c)), ctx_svnt_base (home, c, sv) { } Sender_Context::~Sender_Context (void) { } // Operations for Sender receptacles and event sources, // defined in ::Hello::CCM_Sender_Context. ::Components::ConsumerDescriptions * Sender_Context::get_registered_consumer ( const char* publisher_name ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ::Components::ConsumerDescriptions *tmp = 0; ACE_NEW_THROW_EX (tmp, ::Components::ConsumerDescriptions (this->ciao_publishes_click_out_map_.current_size ()), CORBA::NO_MEMORY ()); ::Components::ConsumerDescriptions_var retval = tmp; retval->length (this->ciao_publishes_click_out_map_.current_size ()); CORBA::ULong i = 0; ACE_Active_Map_Manager< ::Hello::TimeOutConsumer_var>::iterator end = this->ciao_publishes_click_out_map_.end (); for (ACE_Active_Map_Manager< ::Hello::TimeOutConsumer_var>::iterator iter = this->ciao_publishes_click_out_map_.begin (); iter != end; ++iter) { ACE_Active_Map_Manager< ::Hello::TimeOutConsumer_var>::ENTRY &entry = *iter; ::Hello::TimeOutConsumer_var c = ::Hello::TimeOutConsumer::_narrow ( entry.int_id_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; ::Components::ConsumerDescription *cd = 0; ACE_NEW_THROW_EX (cd, OBV_Components::ConsumerDescription (), CORBA::NO_MEMORY ()); ::Components::ConsumerDescription_var safe = cd; safe->name (""); safe->type_id (""); safe->consumer (c); retval[i] = safe; } return retval._retn (); } void Sender_Context::push_click_out ( ::Hello::TimeOut *ev ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_Active_Map_Manager< ::Hello::TimeOutConsumer_var>::iterator end = this->ciao_publishes_click_out_map_.end (); for (ACE_Active_Map_Manager< ::Hello::TimeOutConsumer_var>::iterator iter = this->ciao_publishes_click_out_map_.begin (); iter != end; ++iter) { ACE_Active_Map_Manager< ::Hello::TimeOutConsumer_var>::ENTRY &entry = *iter; ::Hello::TimeOutConsumer_var c = ::Hello::TimeOutConsumer::_narrow ( entry.int_id_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; entry.int_id_->push_TimeOut ( ev ACE_ENV_ARG_PARAMETER); ACE_CHECK; } } ::Components::Cookie * Sender_Context::subscribe_click_out ( ::Hello::TimeOutConsumer_ptr c ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::ExceededConnectionLimit)) { if (CORBA::is_nil (c)) { ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); } ::Hello::TimeOutConsumer_var sub = ::Hello::TimeOutConsumer::_duplicate (c); ACE_Active_Map_Manager_Key key; this->ciao_publishes_click_out_map_.bind (sub.in (), key); sub._retn (); ::Components::Cookie_var retv = new ::CIAO::Map_Key_Cookie (key); return retv._retn (); } ::Hello::TimeOutConsumer_ptr Sender_Context::unsubscribe_click_out ( ::Components::Cookie *ck ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidConnection)) { ::Hello::TimeOutConsumer_var retv; ACE_Active_Map_Manager_Key key; if (ck == 0 || ::CIAO::Map_Key_Cookie::extract (ck, key) == false) { ACE_THROW_RETURN ( ::Components::InvalidConnection (), ::Hello::TimeOutConsumer::_nil ()); } if (this->ciao_publishes_click_out_map_.unbind (key, retv) != 0) { ACE_THROW_RETURN ( ::Components::InvalidConnection (), ::Hello::TimeOutConsumer::_nil ()); } return retv._retn (); } // CIAO-specific. Sender_Context * Sender_Context::_narrow ( ::Components::SessionContext_ptr p ACE_ENV_ARG_DECL_NOT_USED) { return dynamic_cast (p); } } namespace CIAO_GLUE_Hello { Sender_Servant::Sender_Servant ( ::Hello::CCM_Sender_ptr exe, ::Components::CCMHome_ptr h, ::CIAO::Home_Servant_Impl_Base *home_servant, ::CIAO::Session_Container *c) : ACE_NESTED_CLASS (CIAO, Servant_Impl_Base (h, home_servant, c)), comp_svnt_base (exe, h, home_servant, c) { this->context_ = new Sender_Context (h, c, this); ACE_TRY_NEW_ENV { ::Components::SessionComponent_var scom = ::Components::SessionComponent::_narrow ( exe ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (! ::CORBA::is_nil (scom.in ())) { scom->set_session_context ( this->context_ ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } this->populate_port_tables ( ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_CATCHANY { } ACE_ENDTRY; } Sender_Servant::~Sender_Servant (void) { } void Sender_Servant::set_attributes ( const ::Components::ConfigValues &descr ACE_ENV_ARG_DECL_NOT_USED) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } for (CORBA::ULong i = 0; i < descr.length (); ++i) { const char *descr_name = descr[i]->name (); ::CORBA::Any &descr_value = descr[i]->value (); if (ACE_OS::strcmp (descr_name, "local_message") == 0) { const char * _ciao_extract_val = 0; descr_value >>= _ciao_extract_val; this->local_message (_ciao_extract_val); continue; } ACE_UNUSED_ARG (descr_name); ACE_UNUSED_ARG (descr_value); } } ::Hello::ReadMessage_ptr Sender_Servant::provide_push_message ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } if (! ::CORBA::is_nil (this->provide_push_message_.in ())) { return ::Hello::ReadMessage::_duplicate (this->provide_push_message_.in ()); } ::CORBA::Object_var obj = this->provide_push_message_i (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (::Hello::ReadMessage::_nil ()); ::Hello::ReadMessage_var fo = ::Hello::ReadMessage::_narrow ( obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (::Hello::ReadMessage::_nil ()); this->provide_push_message_ = fo; return ::Hello::ReadMessage::_duplicate (this->provide_push_message_.in ()); } ::CORBA::Object_ptr Sender_Servant::provide_push_message_i ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ::CORBA::Object_ptr ret = this->lookup_facet ("push_message"); if (! ::CORBA::is_nil (ret)) { return ret; } CIAO::Port_Activator_T< CIAO_GLUE_Hello::ReadMessage_Servant, ::Hello::CCM_ReadMessage, ::Components::CCMContext, Sender_Servant > *tmp = 0; typedef CIAO::Port_Activator_T< CIAO_GLUE_Hello::ReadMessage_Servant, ::Hello::CCM_ReadMessage, ::Components::CCMContext, Sender_Servant > MACRO_MADNESS_TYPEDEF; ACE_NEW_THROW_EX ( tmp, MACRO_MADNESS_TYPEDEF ( "Hello_Sender_push_message", "push_message", CIAO::Port_Activator::Facet, 0, this->context_, this), CORBA::NO_MEMORY ()); CIAO::Servant_Activator *sa = this->container_->ports_servant_activator (); if (!sa->register_port_activator (tmp)) { return 0; } ::CORBA::Object_var obj = this->container_->generate_reference ( "Hello_Sender_push_message", "IDL:Hello/ReadMessage:1.0", CIAO::Container::Facet_Consumer ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (::Hello::ReadMessage::_nil ()); this->add_facet ( "push_message", obj.in ()); return obj._retn (); } ::Components::Cookie * Sender_Servant::subscribe_click_out ( ::Hello::TimeOutConsumer_ptr c ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::ExceededConnectionLimit)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } return this->context_->subscribe_click_out ( c ACE_ENV_ARG_PARAMETER); } ::Hello::TimeOutConsumer_ptr Sender_Servant::unsubscribe_click_out ( ::Components::Cookie *ck ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidConnection)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } return this->context_->unsubscribe_click_out ( ck ACE_ENV_ARG_PARAMETER); } ::Components::Cookie * Sender_Servant::connect ( const char *name, ::CORBA::Object_ptr connection ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidName, ::Components::InvalidConnection, ::Components::AlreadyConnected, ::Components::ExceededConnectionLimit)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } // If the component has no receptacles, this will be unused. ACE_UNUSED_ARG (connection); if (name == 0) { ACE_THROW_RETURN (::Components::InvalidName (), 0); } ACE_THROW_RETURN (::Components::InvalidName (), 0); } CORBA::Object_ptr Sender_Servant::disconnect ( const char *name, ::Components::Cookie * ck ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidName, ::Components::InvalidConnection, ::Components::CookieRequired, ::Components::NoConnection)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } if (name == 0) { ACE_THROW_RETURN ( ::Components::InvalidName (), ::CORBA::Object::_nil ()); } ACE_THROW_RETURN ( ::Components::InvalidName (), ::CORBA::Object::_nil ()); ACE_UNUSED_ARG (ck); } void Sender_Servant::connect_consumer ( const char * emitter_name, ::Components::EventConsumerBase_ptr consumer ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidName, ::Components::AlreadyConnected, ::Components::InvalidConnection)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } if (emitter_name == 0) { ACE_THROW (::CORBA::BAD_PARAM ()); } ACE_UNUSED_ARG (consumer); ACE_THROW (::Components::InvalidName ()); } ::Components::Cookie * Sender_Servant::subscribe ( const char *publisher_name, ::Components::EventConsumerBase_ptr subscribe ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidName, ::Components::InvalidConnection, ::Components::ExceededConnectionLimit)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } // Just in case there are no if blocks ACE_UNUSED_ARG (subscribe); if (publisher_name == 0) { ACE_THROW_RETURN (::Components::InvalidName (), 0); } if (ACE_OS::strcmp (publisher_name, "click_out") == 0) { ::Hello::TimeOutConsumer_var _ciao_consumer = ::Hello::TimeOutConsumer::_narrow ( subscribe ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); if (::CORBA::is_nil (_ciao_consumer.in ())) { ACE_THROW_RETURN (::Components::InvalidConnection (), 0); } return this->subscribe_click_out ( _ciao_consumer.in () ACE_ENV_ARG_PARAMETER); } ACE_THROW_RETURN (::Components::InvalidName (), 0); } ::Components::EventConsumerBase_ptr Sender_Servant::unsubscribe ( const char *publisher_name, ::Components::Cookie *ck ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException, ::Components::InvalidName, ::Components::InvalidConnection)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } // Just in case there are no if blocks ACE_UNUSED_ARG (ck); if (publisher_name == 0) { ACE_THROW_RETURN ( ::Components::InvalidName (), ::Components::EventConsumerBase::_nil ()); } if (ACE_OS::strcmp (publisher_name, "click_out") == 0) { return this->unsubscribe_click_out ( ck ACE_ENV_ARG_PARAMETER); } ACE_THROW_RETURN ( ::Components::InvalidName (), ::Components::EventConsumerBase::_nil ()); } CORBA::Object_ptr Sender_Servant::get_facet_executor (const char *name ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( ::CORBA::SystemException)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } if (name == 0) { ACE_THROW_RETURN ( ::CORBA::BAD_PARAM (), ::CORBA::Object::_nil ()); } if (ACE_OS::strcmp (name, "push_message") == 0) { return this->executor_->get_push_message (ACE_ENV_SINGLE_ARG_PARAMETER); } return CORBA::Object::_nil (); } // Supported operations. void Sender_Servant::start ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } this->executor_->start ( ACE_ENV_SINGLE_ARG_PARAMETER); } // Component attribute operations. char * Sender_Servant::local_message ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } return this->executor_->local_message ( ACE_ENV_SINGLE_ARG_PARAMETER); } void Sender_Servant::local_message ( const char * local_message ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { if (this->is_activated () == 0) { this->ciao_preactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_activate ( ACE_ENV_SINGLE_ARG_PARAMETER); this->ciao_postactivate ( ACE_ENV_SINGLE_ARG_PARAMETER); } this->executor_->local_message ( local_message ACE_ENV_ARG_PARAMETER); } // Private method to populate the port tables. void Sender_Servant::populate_port_tables ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_ENV_ARG_NOT_USED; ::CORBA::Object_var obj_var; ::Components::EventConsumerBase_var ecb_var; obj_var = this->provide_push_message_i ( ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; } } namespace CIAO_GLUE_Hello { SenderHome_Servant::SenderHome_Servant ( ::Hello::CCM_SenderHome_ptr exe, ::CIAO::Session_Container *c) : ACE_NESTED_CLASS (CIAO, Home_Servant_Impl_Base (c)), home_svnt_base (exe, c, "Sender_Impl_Hello_Sender", "Sender_Impl_Hello_Sender") { } SenderHome_Servant::~SenderHome_Servant (void) { } // Home operations. // Home supported interface operations. // Home factory and finder operations. // Home attribute operations. } extern "C" SENDER_SVNT_Export ::PortableServer::Servant createSenderHome_Servant ( ::Components::HomeExecutorBase_ptr p, CIAO::Session_Container *c ACE_ENV_ARG_DECL) { if (p == 0) { return 0; } ::Hello::CCM_SenderHome_var x = ::Hello::CCM_SenderHome::_narrow ( p ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); if (::CORBA::is_nil (x.in ())) { return 0; } return new CIAO_GLUE_Hello::SenderHome_Servant ( x.in (), c); } }