diff options
Diffstat (limited to 'TAO/CIAO/examples/handcrafted/BasicSP')
22 files changed, 3820 insertions, 21 deletions
diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.idl b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.idl index b8d98e90156..86477c12f8b 100644 --- a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.idl +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.idl @@ -17,9 +17,9 @@ module BasicSP { component BMDevice { - provides ReadData data_out; - publishes DataAvailable out_data; - consumes TimeOut timeout20; + provides ReadData data_read; + publishes DataAvailable data_available; + consumes TimeOut timeout; }; home BMDeviceHome manages BMDevice diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.mpc b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.mpc index 35f60fa1e4a..fc59b4bec01 100644 --- a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.mpc +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice.mpc @@ -1,11 +1,10 @@ // $Id$ -// This file is generated with "generate_component_mpc.pl -l .. -p HUDisplay -i NavDisplay" project(BMDevice_stub): ciao_client { depends += BMDevice_stub sharedname = BMDevice_stub idlflags += -Wb,stub_export_macro=BMDEVICE_STUB_Export -Wb,stub_export_include=BMDevice_stub_export.h -Wb,skel_export_macro=BMDEVICE_SVNT_Export -Wb,skel_export_include=BMDevice_svnt_export.h - dllflags = NAVDISPLAY_STUB_BUILD_DLL + dllflags = BMDEVICE_STUB_BUILD_DLL IDL_Files { BMDevice.idl @@ -19,7 +18,7 @@ project(BMDevice_stub): ciao_client { project(BMDevice_svnt) : ciao_server { depends += BMDevice_svnt BMDevice_stub sharedname = BMDevice_svnt - libs += BMDevice_stub BMDevice_stub BMDevice_svnt + libs += BMDevice_stub BasicSP_stub BasicSP_svnt libpaths += .. idlflags += -Wb,export_macro=BMDEVICE_SVNT_Export -Wb,export_include=BMDevice_svnt_export.h dllflags = BMDEVICE_SVNT_BUILD_DLL @@ -29,19 +28,19 @@ project(BMDevice_svnt) : ciao_server { } Source_Files { - NavDisplayEC.cpp - NavDisplayS.cpp - NavDisplay_svnt.cpp + BMDeviceEC.cpp + BMDeviceS.cpp + BMDevice_svnt.cpp } } -project(NavDisplay_exec) : ciao_server { +project(BMDevice_exec) : ciao_server { depends += BMDevice_svnt sharedname = BMDevice_exec libs += BMDevice_stub BMDevice_svnt BasicSP_stub BasicSP_svnt libpaths += .. - idlflags += -Wb,export_macro=BMDEVICE_EXEC_Export -Wb,export_include=BMDEVICE_exec_export.h + idlflags += -Wb,export_macro=BMDEVICE_EXEC_Export -Wb,export_include=BMDevice_exec_export.h dllflags = BMDEVICE_EXEC_BUILD_DLL IDL_Files { diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceE.idl b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceE.idl index 85dba9d7c1c..1754890a5fa 100644 --- a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceE.idl +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceE.idl @@ -27,8 +27,8 @@ module BasicSP local interface CCM_BMDevice : Components::EnterpriseComponent { - CCM_ReadData get_data_out (); - void push_timeout20 (in TimeOut ev); + CCM_ReadData get_data_read (); + void push_timeout (in TimeOut ev); }; /** Context Interface @@ -40,7 +40,7 @@ module BasicSP local interface CCM_BMDevice_Context : Components::SessionContext { - void push_out_data (in DataAvailable ev); + void push_data_available (in DataAvailable ev); }; local interface CCM_BMDeviceHomeExplicit @@ -55,10 +55,10 @@ module BasicSP }; local interface CCM_BMDeviceHome - : CCM_NavDisplayHomeExplicit, - CCM_NavDisplayHomeImplicit + : CCM_BMDeviceHomeExplicit, + CCM_BMDeviceHomeImplicit { }; }; -#endif /* NAVDISPLAYE_IDL */ +#endif /* CIAO_BMDEVICEE_IDL */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceEI.idl b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceEI.idl index 7d1e6c01747..18a4ad9eaa4 100644 --- a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceEI.idl +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDeviceEI.idl @@ -19,7 +19,8 @@ module BasicSP * @interface BMDevice_Exec */ local interface BMDevice_Exec : - CCM_BM_Device, + CCM_BMDevice, + CCM_ReadData, Components::SessionComponent { }; diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_exec.cpp b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_exec.cpp new file mode 100644 index 00000000000..f92e205b170 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_exec.cpp @@ -0,0 +1,117 @@ +// $Id$ + +#include "BMDevice_exec.h" +#include "../BasicSPEC.h" + +#define DISPLACEMENT 256 + +/// Default constructor. +MyImpl::BMDevice_exec_i::BMDevice_exec_i (void) + : str_ ("starting_data") +{ + +} + +/// Default destructor. +MyImpl::BMDevice_exec_i::~BMDevice_exec_i () +{ +} + +// Operations from HUDisplay::BMDevice +BasicSP::CCM_ReadData_ptr +MyImpl::BMDevice_exec_i::get_data_read (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return BasicSP::CCM_ReadData::_duplicate (this); +} + +void +MyImpl::BMDevice_exec_i::push_timeout (BasicSP::TimeOut * + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Nitify others + BasicSP::DataAvailable_var event = new OBV_BasicSP::DataAvailable; + + this->context_->push_data_available (event + ACE_ENV_ARG_PARAMETER); +} + +char * +MyImpl::BMDevice_exec_i::data_read (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->str_; +} + +// Operations from Components::SessionComponent +void +MyImpl::BMDevice_exec_i::set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDevice_exec_i::set_session_context\n")); + + this->context_ = + BasicSP::CCM_BMDevice_Context::_narrow (ctx + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->context_.in ())) + ACE_THROW (CORBA::INTERNAL ()); + // Urm, we actually discard exceptions thown from this operation. +} + +void +MyImpl::BMDevice_exec_i::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDevice_exec_i::ccm_activate\n")); +} + +void +MyImpl::BMDevice_exec_i::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDevice_exec_i::ccm_passivate\n")); +} + +void +MyImpl::BMDevice_exec_i::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDevice_exec_i::ccm_remove\n")); +} + +/// Default ctor. +MyImpl::BMDeviceHome_exec_i::BMDeviceHome_exec_i () +{ +} + +/// Default dtor. +MyImpl::BMDeviceHome_exec_i::~BMDeviceHome_exec_i () +{ +} + +// Explicit home operations. + +// Implicit home operations. + +::Components::EnterpriseComponent_ptr +MyImpl::BMDeviceHome_exec_i::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + return new MyImpl::BMDevice_exec_i; +} + + +extern "C" BMDEVICE_EXEC_Export ::Components::HomeExecutorBase_ptr +createBMDeviceHome_Impl (void) +{ + return new MyImpl::BMDeviceHome_exec_i; +} diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_exec.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_exec.h new file mode 100644 index 00000000000..55576bc3966 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_exec.h @@ -0,0 +1,118 @@ +// $Id$ + +// ================================================================ +/** + * @file BMDevice_exec.h + * + * Header file for the actual BMDevice and BMDeviceHome component + * implementations. These classes are the implementations of local + * interfaces defined in BMDeviceEI.idl. + * + * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +// ================================================================ + +#ifndef CIAO_BMDEVICE_EXEC_H +#define CIAO_BMDEVICE_EXEC_H + +#include "BMDeviceEIC.h" +#include "tao/LocalObject.h" + +namespace MyImpl +{ + /** + * @class BMDEVICE_exec_i + * + * An example RateGen executor implementation class. + */ + class BMDEVICE_EXEC_Export BMDevice_exec_i : + public virtual BasicSP::BMDevice_Exec, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default constructor. + BMDevice_exec_i (); + + /// Default destructor. + ~BMDevice_exec_i (); + + // Operations from BasicSP::BMDevice + + virtual BasicSP::CCM_ReadData_ptr + get_data_read (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + push_timeout (BasicSP::TimeOut *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from BasicSP::position + + virtual char * + data_read (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + protected: + char *str_; + + /// Copmponent specific context + BasicSP::CCM_BMDevice_Context_var context_; + }; + + /** + * @class BMDeviceHome_exec_i + * + * BMDevice home executor implementation class. + */ + class BMDEVICE_EXEC_Export BMDeviceHome_exec_i : + public virtual BasicSP::CCM_BMDeviceHome, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default ctor. + BMDeviceHome_exec_i (); + + /// Default dtor. + ~BMDeviceHome_exec_i (); + + // Explicit home operations. + + // Implicit home operations. + + virtual ::Components::EnterpriseComponent_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + }; + +} + +// Executor DLL entry point. CIAO's deployment and assembly framework +// invokes this function on the resulting DLL to get the home executor. +extern "C" BMDEVICE_EXEC_Export ::Components::HomeExecutorBase_ptr +createBMDeviceHome_Impl (void); + +#endif /* CIAO_BMDEVICE_EXEC_H*/ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_svnt.cpp b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_svnt.cpp new file mode 100644 index 00000000000..93c9583571f --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_svnt.cpp @@ -0,0 +1,978 @@ +// $Id$ +#include "BMDevice_svnt.h" +#include "Cookies.h" +#include "../BasicSP_svnt.h" + +void +CIAO_GLUE_BasicSP::BMDevice_Context::push_data_available ( + BasicSP::DataAvailable *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_Active_Map_Manager<BasicSP::DataAvailableConsumer_var>::iterator + end = this->ciao_publishes_Ready_map_.end (); + for (ACE_Active_Map_Manager<BasicSP::DataAvailableConsumer_var>::iterator + iter = this->ciao_publishes_Ready_map_.begin (); + iter != end; + ++iter) + { + ACE_Active_Map_Manager<BasicSP::DataAvailableConsumer_var>::ENTRY &entry = *iter; + BasicSP::DataAvailableConsumer_var c + = BasicSP::DataAvailableConsumer::_narrow (entry.int_id_.in ()); + c->push_DataAvailable (ev + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +// Operations for publishes interfaces. +::Components::Cookie * +CIAO_GLUE_BasicSP::BMDevice_Context::subscribe_data_available ( + BasicSP::DataAvailableConsumer_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); + + BasicSP::DataAvailableConsumer_var sub + = BasicSP::DataAvailableConsumer::_duplicate (c); + + ACE_Active_Map_Manager_Key key; + this->ciao_publishes_Ready_map_.bind (sub.in (), + key); + + sub._retn (); // Release ownership. + + ::Components::Cookie_var retv = new CIAO::Map_Key_Cookie (key); + return retv._retn (); +} + +BasicSP::DataAvailableConsumer_ptr +CIAO_GLUE_BasicSP::BMDevice_Context::unsubscribe_data_available ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)) +{ + BasicSP::DataAvailableConsumer_var retv; + + ACE_Active_Map_Manager_Key key; + if (ck == 0 || + CIAO::Map_Key_Cookie::extract (ck, key) == -1) + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + + if (this->ciao_publishes_Ready_map_.unbind (key, + retv) != 0) + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + + return retv._retn (); +} + + +// Operations for ::Components::SessionContext interface +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDevice_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ How do I check for IllegalState here? When it's not in a + // callback operation... + // ACE_THROW_RETURN (::Components::IllegalState (), 0); + + if (CORBA::is_nil (this->component_.in ())) + { + CORBA::Object_var obj = this->container_->get_objref (this->servant_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->component_ = BasicSP::BMDevice::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (this->component_.in ())) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); // This should not happen... + } + + return BasicSP::BMDevice::_duplicate (this->component_.in ()); +} + +CIAO_GLUE_BasicSP::BMDevice_Context::BMDevice_Context (::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c, + CIAO_GLUE_BasicSP::BMDevice_Servant *sv) + : home_ (::Components::CCMHome::_duplicate (home)), + container_ (c), + servant_ (sv) +{ +} + +CIAO_GLUE_BasicSP::BMDevice_Context::~BMDevice_Context () +{ +} + +// Operations for emits interfaces. + +// Operations for ::Components::CCMContext +ACE_INLINE ::Components::Principal_ptr +CIAO_GLUE_BasicSP::BMDevice_Context::get_caller_principal (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ We don't support Security in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE ::Components::CCMHome_ptr +CIAO_GLUE_BasicSP::BMDevice_Context::get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return ::Components::CCMHome::_duplicate (this->home_.in ()); +} + +ACE_INLINE CORBA::Boolean +CIAO_GLUE_BasicSP::BMDevice_Context::get_rollback_only (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE ::Components::Transaction::UserTransaction_ptr +CIAO_GLUE_BasicSP::BMDevice_Context::get_user_transaction (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE CORBA::Boolean +CIAO_GLUE_BasicSP::BMDevice_Context::is_caller_in_role (const char * role + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG (role); + + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE void +CIAO_GLUE_BasicSP::BMDevice_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + + +/********************************************************************************/ +CIAO_GLUE_BasicSP::BMDevice_Servant::BMDevice_Servant (BasicSP::CCM_BMDevice_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (BasicSP::CCM_BMDevice::_duplicate (exe)), + container_ (c) +{ + this->context_ = new CIAO_GLUE_BasicSP::BMDevice_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_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; +} + +CIAO_GLUE_BasicSP::BMDevice_Servant::~BMDevice_Servant (void) +{ + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; + this->context_->_remove_ref (); +} + +BasicSP::ReadData_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::provide_data_read (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (this->provide_ReadData_.in ())) + { + BasicSP::CCM_ReadData_var fexe + = this->executor_->get_data_read (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (fexe.in ())) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + CIAO_GLUE_BasicSP::ReadData_Servant *svt = + new CIAO_GLUE_BasicSP::ReadData_Servant (fexe.in (), + this->context_); + + PortableServer::ServantBase_var safe_servant (svt); + + CORBA::Object_var obj = this->container_->install_servant (svt + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::ReadData_var fo + = BasicSP::ReadData::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->provide_ReadData_ = fo; + } + + return BasicSP::ReadData::_duplicate (this->provide_ReadData_.in ()); +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant::push_event ( + ::Components::EventBase *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::BadEventType)) +{ + BasicSP::TimeOut_var ev_type = BasicSP::TimeOut::_downcast (ev); + if (ev_type != 0) + { + this->push_TimeOut (ev_type.in () + ACE_ENV_ARG_PARAMETER); + return; + } + + ACE_THROW (::Components::BadEventType ()); +} + +// get_component implementation. +BasicSP::TimeOutConsumer_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::get_consumer_timeout (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (this->consumes_timeout_.in ())) + { + CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant *svt = + new CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant (this->executor_.in (), + this->context_); + PortableServer::ServantBase_var safe_servant (svt); + + CORBA::Object_var obj = this->container_->install_servant (svt + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::TimeOutConsumer_var eco + = BasicSP::TimeOutConsumer::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->consumes_timeout_ = eco; + } + + return BasicSP::TimeOutConsumer::_duplicate (this->consumes_timeout_.in ()); +} + +::Components::Cookie * +CIAO_GLUE_BasicSP::BMDevice_Servant::subscribe_data_available ( + BasicSP::DataAvailableConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)) +{ + return this->context_->subscribe_data_available (c + ACE_ENV_ARG_PARAMETER); +} + +BasicSP::DataAvailableConsumer_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::unsubscribe_data_available (::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)) +{ + return this->context_->unsubscribe_data_available (ck + ACE_ENV_ARG_PARAMETER); +} + +// Operations for Navigation interface +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::provide_facet (const char * name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)) +{ + ACE_UNUSED_ARG (name); + ACE_THROW_RETURN (::Components::InvalidName (), 0); +} + +::Components::FacetDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_all_facets (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::FacetDescriptions_var collection + = new ::Components::FacetDescriptions (0); // #99 = number of all provided + // facets including those inherited + // from parent component(s). + return collection._retn (); + +} + +::Components::FacetDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_named_facets (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ACE_UNUSED_ARG (names); + ACE_THROW_RETURN (::Components::InvalidName (), 0); +} + +CORBA::Boolean +CIAO_GLUE_BasicSP::BMDevice_Servant::same_component (CORBA::Object_ptr object_ref + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (object_ref)) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + CORBA::Object_var the_other = object_ref->_get_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Object_var me = this->context_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return me->_is_equivalent (object_ref + ACE_ENV_ARG_PARAMETER); +} + +// Operations for Receptacles interface +::Components::Cookie * +CIAO_GLUE_BasicSP::BMDevice_Servant::connect (const char *, + CORBA::Object_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::AlreadyConnected, + Components::ExceededConnectionLimit)) +{ + // @@ We can omit this if clause if there's no receptacle in this component. + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::disconnect (const char * , + Components::Cookie * + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::CookieRequired, + Components::NoConnection)) +{ + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::ConnectionDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_connections (const char * + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::ReceptacleDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::ReceptacleDescriptions_var retv = + new ::Components::ReceptacleDescriptions (1); // #99 is number of receptacles + // this component has. + retv->length (1); + CORBA::ULong i = 0; + + retv[i] = new OBV_Components::ReceptacleDescription; + + retv[i]->Name ((const char *) "GPSLocation"); + retv[i]->type_id ((const char *) "IDL:BasicSP/position:1.0"); + retv[i]->is_multiple (0); + retv[i]->connections (*this->get_connections ("GPSLocation" + ACE_ENV_ARG_PARAMETER)); + return retv._retn (); +} + +::Components::ReceptacleDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_named_receptacles (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::ReceptacleDescriptions_var retv = + new ::Components::ReceptacleDescriptions (names.length ()); + retv->length (names.length ()); + + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + retv[i] = new ::OBV_Components::ReceptacleDescription; + if (ACE_OS_String::strcmp (names[i].in (), "GPSLocation") == 0) + { + retv[i]->Name ((const char *) "GPSLocation"); + retv[i]->type_id ((const char *) "IDL:BasicSP/position:1.0"); + retv[i]->is_multiple (0); + retv[i]->connections (*this->get_connections ("GPSLocation" + ACE_ENV_ARG_PARAMETER)); + } + else + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return retv._retn (); +} + +// Operations for Events interface +::Components::EventConsumerBase_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::get_consumer (const char * sink_name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ We can omit this if clause if there's no event sinks in this component. + if (sink_name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (sink_name, "timeout") == 0) + return this->get_consumer_timeout (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::Cookie * +CIAO_GLUE_BasicSP::BMDevice_Servant::subscribe (const char *publisher_name, + Components::EventConsumerBase_ptr subscriber + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::ExceededConnectionLimit)) +{ + if (publisher_name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (publisher_name, "data_available") == 0) + { + BasicSP::DataAvailableConsumer_var _ciao_consumer = + BasicSP::DataAvailableConsumer::_narrow (subscriber + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (_ciao_consumer.in ())) + ACE_THROW_RETURN (Components::InvalidConnection (), 0); + + return this->subscribe_data_available (_ciao_consumer.in () + ACE_ENV_ARG_PARAMETER); + } + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::EventConsumerBase_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::unsubscribe (const char * publisher_name, + Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection)) +{ + // @@ We can omit this if clause if there's no publisher in this component. + if (publisher_name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (publisher_name, "data_available") == 0) + { + return this->unsubscribe_data_available (ck + ACE_ENV_ARG_PARAMETER); + } + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::connect_consumer (const char * , + Components::EventConsumerBase_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::AlreadyConnected, + Components::InvalidConnection)) +{ + ACE_THROW (Components::InvalidName ()); +} + +::Components::EventConsumerBase_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::disconnect_consumer (const char * + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::NoConnection)) +{ + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::ConsumerDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_all_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::ConsumerDescriptions_var retv = + new ::Components::ConsumerDescriptions (1); // #99 is the number of consumers + // this component has. + retv->length (1); + + CORBA::ULong i = 0; + retv[i] = new OBV_Components::ConsumerDescription; + retv[i]->Name ("timeout"); + retv[i]->type_id ("IDL:BasicSP/TimeOutConsumer:1.0"); + BasicSP::TimeOutConsumer_var c + = this->get_consumer_timeout (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + retv[i]->consumer (c.in ()); + + return retv._retn (); +} + +::Components::ConsumerDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_named_consumers (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::ConsumerDescriptions_var retv = + new ::Components::ConsumerDescriptions (names.length ()); + retv->length (names.length ()); + + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + retv[i] = new OBV_Components::ConsumerDescription; + + if (ACE_OS_String::strcmp (names[i].in (), "timeout") == 0) + { + retv[i]->Name ("timeout"); + retv[i]->type_id ("IDL:BasicSP/TimeOutConsumer:1.0"); + BasicSP::TimeOutConsumer_var c = + this->get_consumer_timeout (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + retv[i]->consumer (c.in ()); + } + else + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return retv._retn (); +} + +::Components::EmitterDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_all_emitters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::EmitterDescriptions_var retv = + new ::Components::EmitterDescriptions (0); // #99 is the number of emitters + // this component has. + return retv._retn (); +} + +::Components::EmitterDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_named_emitters (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::EmitterDescriptions_var retv = + new ::Components::EmitterDescriptions (names.length ()); + retv->length (names.length ()); + + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return retv._retn (); +} + +::Components::PublisherDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_all_publishers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do + + // Need to add interfaces in the Context class to gather the information. + // Or we can just relay it to the Context object. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +::Components::PublisherDescriptions * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_named_publishers (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ACE_UNUSED_ARG (names); + // @@ to-do + + // Need to add interfaces in the Context class to gather the information. + // Or we can just relay it to the Context object. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +// Operations for CCMObject interface +::CORBA::IRObject_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do: Connect to an IfR? + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +::Components::CCMHome_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::get_ccm_home (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->context_->get_CCM_home (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +::Components::PrimaryKeyBase * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_primary_key (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::NoKeyAvailable)) +{ + // This is a keyless component. + ACE_THROW_RETURN (::Components::NoKeyAvailable (), 0); +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::configuration_complete (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidConfiguration)) +{ + // @@ to-do + // No-op. Don't know how to pass this info to monolithic executor. +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::remove (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)) +{ + // @@ to-do + // Need to figure out what to do here. E.g., tear down the all the connections + // this component has? +} + +::Components::ComponentPortDescription * +CIAO_GLUE_BasicSP::BMDevice_Servant::get_all_ports (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::ComponentPortDescription_var retv = + new OBV_Components::ComponentPortDescription; + + ::Components::FacetDescriptions_var facets_desc + = this->get_all_facets (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::ReceptacleDescriptions_var receptacle_desc + = get_all_receptacles (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::ConsumerDescriptions_var consumer_desc + = this->get_all_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::EmitterDescriptions_var emitter_desc + = this->get_all_emitters (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::PublisherDescriptions_var publisher_desc + = this->get_all_publishers (ACE_ENV_SINGLE_ARG_PARAMETER); + + retv->facets (facets_desc.in()); + retv->receptacles (receptacle_desc.in()); + retv->consumers (consumer_desc.in()); + retv->emitters (emitter_desc.in()); + retv->publishers (publisher_desc.in()); + + return retv._retn(); +} + +// get_component implementation. +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionContext_var sc = + ::Components::SessionContext::_narrow (this->context_); + + if (! CORBA::is_nil(sc.in ())) + return sc->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + // @@ Do we need to try the following case here? We are afterall implementing + // a session component here. + ::Components::EntityContext_var ec = + ::Components::EntityContext::_narrow (this->context_); + + if (! CORBA::is_nil(ec.in ())) + return ec->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (! CORBA::is_nil (temp.in ())) + temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (! CORBA::is_nil (temp.in ())) + temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +// Constructor and destructor. +CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant::TimeOutConsumer_timeout_Servant +(BasicSP::CCM_BMDevice_ptr executor, + BasicSP::CCM_BMDevice_Context_ptr c) + : executor_ (BasicSP::CCM_BMDevice::_duplicate (executor)), + ctx_ (BasicSP::CCM_BMDevice_Context::_duplicate (c)) +{ +} + +CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant::~TimeOutConsumer_timeout_Servant () +{ +} + +void +CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant::push_TimeOut ( + BasicSP::TimeOut *evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->executor_->push_timeout (evt + ACE_ENV_ARG_PARAMETER); +} + +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDevice_Servant::TimeOutConsumer_timeout_Servant::_get_component ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->ctx_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); +} + + +/********************************************************************************/ +BasicSP::BMDevice_ptr +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::_ciao_activate_component (BasicSP::CCM_BMDevice_ptr exe + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Object_var hobj + = this->container_->get_objref (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + ::Components::CCMHome_var home + = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CIAO_GLUE_BasicSP::BMDevice_Servant *svt = + new CIAO_GLUE_BasicSP::BMDevice_Servant (exe, + home.in (), + this->container_); + PortableServer::ServantBase_var safe (svt); + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref + = this->container_->install_component (svt, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::BMDevice_var ho + = BasicSP::BMDevice::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->component_map_.bind (oid.in (), svt) == 0) + { + // @@ what should happen if bind fail? + safe._retn (); + } + return ho._retn (); +} + +void +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::_ciao_passivate_component (BasicSP::BMDevice_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CIAO_GLUE_BasicSP::BMDevice_Servant *servant = 0; + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + // What happen if unbind failed? + +} + +// Operations for Implicit Home interface +BasicSP::BMDevice_ptr +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)) +{ + if (this->executor_.in () == 0) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + Components::EnterpriseComponent_var _ciao_ec = + this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::CCM_BMDevice_var _ciao_comp + = BasicSP::CCM_BMDevice::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); +} + +// Operations for CCMHome interface +void +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::remove_component (Components::CCMObject_ptr comp + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)) +{ + BasicSP::BMDevice_var _ciao_comp + = BasicSP::BMDevice::_narrow (comp + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (_ciao_comp.in ())) + ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here? + + // @@ It seems to me that we need to make sure this is a component + // generated by this home before calling remove on this component. + _ciao_comp->remove (ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + + // Removing the object reference? get the servant from the POA with + // the objref, and call remove() on the component, deactivate the + // component, and then remove-ref the servant? + this->_ciao_passivate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); +} + +extern "C" BMDEVICE_SVNT_Export ::PortableServer::Servant +createBMDeviceHome_Servant (::Components::HomeExecutorBase_ptr p, + CIAO::Session_Container *c + ACE_ENV_ARG_DECL) +{ + if (p == 0) + return 0; + + BasicSP::CCM_BMDeviceHome_var x + = BasicSP::CCM_BMDeviceHome::_narrow (p + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (x.in ())) + return 0; + + return new CIAO_GLUE_BasicSP::BMDeviceHome_Servant (x.in (), + c); +} + +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::BMDeviceHome_Servant (BasicSP::CCM_BMDeviceHome_ptr exe, + CIAO::Session_Container *c) + : executor_ (BasicSP::CCM_BMDeviceHome::_duplicate (exe)), + container_ (c) +{ +} + +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::~BMDeviceHome_Servant (void) +{ +} + +// Operations for KeylessHome interface +::Components::CCMObject_ptr +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::create_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)) +{ + // Simply forward to the create method. + return this->create (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +// Operations for CCMHome interface +::CORBA::IRObject_ptr +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ TO-DO. Contact IfR? + + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +CORBA::IRObject_ptr +CIAO_GLUE_BasicSP::BMDeviceHome_Servant::get_home_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ TO-DO. Contact IfR? + + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_svnt.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_svnt.h new file mode 100644 index 00000000000..282246a2d31 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDevice/BMDevice_svnt.h @@ -0,0 +1,475 @@ +// $Id$ + +// =========================================================== +/** + * + * @file BMDevice_svnt.h + * + * Internals of the BMDevice component that would mostly be + * generated. + * + * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +// =========================================================== + +#ifndef CIAO_GLUE_SESSION_BMDEVICE_SVNT_H +#define CIAO_GLUE_SESSION_BMDEVICE_SVNT_H +#include "ace/pre.h" + +#include "BMDeviceS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "BMDeviceEC.h" +#include "ciao/Container_Base.h" +#include "tao/LocalObject.h" +#include "tao/PortableServer/Key_Adapters.h" + +namespace CIAO_GLUE_BasicSP +{ + /** + * + * @brief + * + * The BMDevice communicates with just one component in BasicSP and + * that is the airframe which is a BM_ClosedEDComponent, as per + * Boeing's OEP terminology. + */ + class BMDEVICE_SVNT_Export BMDevice_Context : + public virtual BasicSP::CCM_BMDevice_Context, + public virtual TAO_Local_RefCounted_Object + { + public: + friend class BMDevice_Servant; + + // Ctor. + BMDevice_Context (::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c, + BMDevice_Servant *sv); + + // Dtor. + virtual ~BMDevice_Context (); + + /// Template methods... + // Operations for [component name] event source, and + // receptacles defined in CCM_[component name]_Context. + + virtual void push_data_available (BasicSP::DataAvailable *av + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Template operations for ::Components::CCMContext + virtual ::Components::Principal_ptr + get_caller_principal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::CCMHome_ptr + get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Boolean + get_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + + virtual ::Components::Transaction::UserTransaction_ptr + get_user_transaction (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + + virtual CORBA::Boolean + is_caller_in_role (const char * role + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + set_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + + // Operations for ::Components::SessionContext interface + virtual CORBA::Object_ptr + get_CCM_object (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + protected: + // We need to generate, in protected section, stuff that manage + // connections and consumers of this component. + + // Operations for publishes interfaces. + ::Components::Cookie * + subscribe_data_available (BasicSP::DataAvailableConsumer *c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + BasicSP::DataAvailableConsumer_ptr + unsubscribe_data_available (::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); + + ACE_Active_Map_Manager<BasicSP::DataAvailableConsumer_var> ciao_publishes_Ready_map_; + + protected: + /// Cached component home reference. + ::Components::CCMHome_var home_; + + /// session container + ::CIAO::Session_Container *container_; + + /// Reference back to owner. + BMDevice_Servant *servant_; + + /// @@ Cached component reference. + BasicSP::BMDevice_var component_; + }; + + class BMDEVICE_STUB_Export BMDevice_Servant + : public virtual POA_BasicSP::BMDevice, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Ctor. + BMDevice_Servant (BasicSP::CCM_BMDevice_ptr executor, + ::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c); + + // Dtor. + ~BMDevice_Servant (void); + + // Operations for provides interfaces. + virtual BasicSP::ReadData_ptr + provide_data_read (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // First we need to generate the event sink specific servant + class BMDEVICE_SVNT_Export TimeOutConsumer_timeout_Servant + : public virtual POA_BasicSP::TimeOutConsumer, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Constructor and destructor. + TimeOutConsumer_timeout_Servant (BasicSP::CCM_BMDevice_ptr executor, + BasicSP::CCM_BMDevice_Context_ptr c); + + ~TimeOutConsumer_timeout_Servant (void); + + virtual void push_TimeOut (BasicSP::TimeOut *evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Inherit from ::Compopnents::EventBConsumerBase + virtual void push_event (Components::EventBase *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::BadEventType)); + + // get_component implementation. + virtual CORBA::Object_ptr + _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + // Consumer Executor + BasicSP::CCM_BMDevice_var executor_; + + // Context object. + BasicSP::CCM_BMDevice_Context_var ctx_; + }; + + + virtual BasicSP::TimeOutConsumer_ptr + get_consumer_timeout (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + + // Operations for publishes interfaces. + virtual ::Components::Cookie * + subscribe_data_available (BasicSP::DataAvailableConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual BasicSP::DataAvailableConsumer_ptr + unsubscribe_data_available (::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); + + virtual CORBA::Object_ptr + provide_facet (const char * name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)) ; + + virtual ::Components::FacetDescriptions * + get_all_facets (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::FacetDescriptions * + get_named_facets (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)); + + virtual CORBA::Boolean + same_component (CORBA::Object_ptr object_ref + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations for Receptacles interface + virtual ::Components::Cookie * + connect (const char * name, + CORBA::Object_ptr connection + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::AlreadyConnected, + Components::ExceededConnectionLimit)); + + virtual CORBA::Object_ptr + disconnect (const char * name, + Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::CookieRequired, + Components::NoConnection)); + + virtual ::Components::ConnectionDescriptions * + get_connections (const char * name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::ReceptacleDescriptions * + get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::ReceptacleDescriptions * + get_named_receptacles (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + // Operations for Events interface + virtual ::Components::EventConsumerBase_ptr + get_consumer (const char * sink_name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::Cookie * + subscribe (const char * publisher_name, + Components::EventConsumerBase_ptr subscriber + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::ExceededConnectionLimit)); + + virtual ::Components::EventConsumerBase_ptr + unsubscribe (const char * publisher_name, + Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection)); + + virtual void + connect_consumer (const char * emitter_name, + Components::EventConsumerBase_ptr consumer + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::AlreadyConnected, + Components::InvalidConnection)); + + virtual ::Components::EventConsumerBase_ptr + disconnect_consumer (const char * source_name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::NoConnection)); + + virtual ::Components::ConsumerDescriptions * + get_all_consumers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::ConsumerDescriptions * + get_named_consumers (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::EmitterDescriptions * + get_all_emitters (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::EmitterDescriptions * + get_named_emitters (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::PublisherDescriptions * + get_all_publishers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::PublisherDescriptions * + get_named_publishers (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + // Operations for CCMObject interface + virtual ::CORBA::IRObject_ptr + get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::CCMHome_ptr + get_ccm_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::PrimaryKeyBase * + get_primary_key (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::NoKeyAvailable)); + + virtual void + configuration_complete (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidConfiguration)); + + virtual void + remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)); + + virtual ::Components::ComponentPortDescription * + get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // get_component implementation. + virtual CORBA::Object_ptr + _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // CIAO specific operations. + + // Activate the object in the container_ + void + _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + // My Executor. + BasicSP::CCM_BMDevice_var executor_; + + // My Run-time Context. + BMDevice_Context *context_; + + // Managing container. + ::CIAO::Session_Container *container_; + + // Cached provided interfaces. + BasicSP::TimeOutConsumer_var consumes_timeout_; + + // Cached provided interfaces. + BasicSP::ReadData_var provide_ReadData_; + + }; + + + ////////////////////////////////////////////////////////////////// + // Component Home Glue code implementation + + // Foreach component home + class BMDEVICE_SVNT_Export BMDeviceHome_Servant : + public virtual POA_BasicSP::BMDeviceHome, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Ctor. + BMDeviceHome_Servant (BasicSP::CCM_BMDeviceHome_ptr exe, + CIAO::Session_Container *c); + + // Dtor. + ~BMDeviceHome_Servant (void); + + // Factory operations + + // Finder operations + + // Operations for KeylessHome interface + virtual ::Components::CCMObject_ptr + create_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)); + + // Operations for Implicit Home interface + virtual BasicSP::BMDevice_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)); + + // Operations for CCMHome interface + virtual ::CORBA::IRObject_ptr + get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CORBA::IRObject_ptr + get_home_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void remove_component (Components::CCMObject_ptr comp + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)); + + protected: + + // Helper method for factory operations. + BasicSP::BMDevice_ptr + _ciao_activate_component (BasicSP::CCM_BMDevice_ptr exe + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component (BasicSP::BMDevice_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // My Executor. + BasicSP::CCM_BMDeviceHome_var executor_; + + // My Container + CIAO::Session_Container *container_; + + // Components this home manages. + ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId, + BMDevice_Servant*, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> component_map_; + }; + + extern "C" BMDEVICE_SVNT_Export ::PortableServer::Servant + createBMDeviceHome_Servant (::Components::HomeExecutorBase_ptr p, + CIAO::Session_Container *c + ACE_ENV_ARG_DECL_WITH_DEFAULTS); +} + + + +#include "ace/post.h" +#endif /* CIAO_GLUE_SESSION_NAVDISPLAY_SVNT_H */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.idl b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.idl index a703e89e421..cbeed950b07 100644 --- a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.idl +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.idl @@ -5,8 +5,8 @@ module BasicSP { component BMDisplay { - uses ReadData dataIn; - consumes DataAvailable inDataAvailable; + consumes DataAvailable data_ready; + uses ReadData comp_data; }; home BMDisplayHome manages BMDisplay diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.mpc b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.mpc new file mode 100644 index 00000000000..86102b6bdf4 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay.mpc @@ -0,0 +1,58 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl -l .. -p BasicSP -i BMDisplay" + +project(BMDisplay_stub): ciao_client { + depends += BasicSP_stub + sharedname = BMDisplay_stub + idlflags += -Wb,stub_export_macro=BMDISPLAY_STUB_Export -Wb,stub_export_include=BMDisplay_stub_export.h -Wb,skel_export_macro=BMDISPLAY_SVNT_Export -Wb,skel_export_include=BMDisplay_svnt_export.h + dllflags = BMDISPLAY_STUB_BUILD_DLL + + IDL_Files { + BMDisplay.idl + } + + Source_Files { + BMDisplayC.cpp + } +} + +project(BMDisplay_svnt) : ciao_server { + depends += BasicSP_svnt BMDisplay_stub + sharedname = BMDisplay_svnt + libs += BMDisplay_stub BasicSP_stub BasicSP_svnt + libpaths += .. + idlflags += -Wb,export_macro=BMDISPLAY_SVNT_Export -Wb,export_include=BMDisplay_svnt_export.h + dllflags = BMDISPLAY_SVNT_BUILD_DLL + + IDL_Files { + BMDisplayE.idl + } + + Source_Files { + BMDisplayEC.cpp + BMDisplayS.cpp + BMDisplay_svnt.cpp + } +} + + +project(BMDisplay_exec) : ciao_server { + depends += BMDisplay_svnt + sharedname = BMDisplay_exec + libs += BMDisplay_stub BMDisplay_svnt BasicSP_stub BasicSP_svnt + libpaths += .. + idlflags += -Wb,export_macro=BMDISPLAY_EXEC_Export -Wb,export_include=BMDisplay_exec_export.h + dllflags = BMDISPLAY_EXEC_BUILD_DLL + + IDL_Files { + BMDisplayEI.idl + } + + Source_Files { + BMDisplayEIC.cpp + BMDisplay_exec.cpp + } +} + + + diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplayE.idl b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplayE.idl new file mode 100644 index 00000000000..c8b8345564d --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplayE.idl @@ -0,0 +1,73 @@ +// $Id$ + +// =========================================================== +// +// @file BMDisplayE.idl +// +// Handlecrafted "generated" code. :) +// +// @author Balachandran Natarajan <bala@dre.vanderbilt.edu> +// +// =========================================================== + +#ifndef CIAO_BMDISPLAYE_IDL +#define CIAO_BMDISPLAYE_IDL + +#include "CCM_Container.idl" // Found in $(CIAO_ROOT)/ciao + // For various definitions of container + // internal/callback interfaces +#include "BMDisplay.idl" // Original component IDL definition +#include "../BasicSP.idl" + +module BasicSP +{ + // Component Main Executor Interface. We currently do not + // support Executor-based implementation. + + local interface CCM_BMDisplay_Executor + : Components::EnterpriseComponent + { + }; + + // Monolithic component executor. + // For implementing monolithic component call back interface. + + local interface CCM_BMDisplay + : Components::EnterpriseComponent + { + void push_data_ready (in DataAvailable ev); + }; + + /** + * Component Context Interface + * + * Notice that we are taking a shortcut here to inherit the + * component-specific context from SessionContext directly instead + * of CCMContext. + */ + local interface CCM_BMDisplay_Context + : Components::SessionContext + { + ReadData get_connection_comp_data (); + }; + + + local interface CCM_BMDisplayHomeExplicit + : Components::HomeExecutorBase + { + }; + + local interface CCM_BMDisplayHomeImplicit + { + ::Components::EnterpriseComponent create () + raises (::Components::CCMException); + }; + + local interface CCM_BMDisplayHome + : CCM_BMDisplayHomeExplicit, + CCM_BMDisplayHomeImplicit + { + }; +}; + +#endif /* CIAO_BMDISPLAYE_IDL */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplayEI.idl b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplayEI.idl new file mode 100644 index 00000000000..8a218debab1 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplayEI.idl @@ -0,0 +1,33 @@ +// $Id$ +//=========================================================== +/** + * @file BMDisplayEI.idl + * + * Definition of the BMDisplay (navigation display) component + * implementation. + * + * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +//=========================================================== +#ifndef CIAO_BMDISPLAYEI_IDL +#define CIAO_BMDISPLAYEI_IDL + +#include "BMDisplayE.idl" + +module BasicSP +{ + /** + * @interface BMDisplay_Exec + * + * The actually BMDisplay executor inherits from both CCM_BMDisplay + * and session_component interfaces as a monolithic implementation. + */ + local interface BMDisplay_Exec : + CCM_BMDisplay, + Components::SessionComponent + { + }; + +}; + +#endif /* CIAO_BMDISPLAYEI_IDL */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec.cpp b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec.cpp new file mode 100644 index 00000000000..1067316acee --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec.cpp @@ -0,0 +1,134 @@ +// $Id$ + +#include "CIAO_common.h" +#include "BMDisplay_exec.h" + +/// Default constructor. +MyImpl::BMDisplay_exec_impl::BMDisplay_exec_impl () +{ +} + +/// Default destructor. +MyImpl::BMDisplay_exec_impl::~BMDisplay_exec_impl () +{ +} + +// Operations from BasicSP::BMDisplay + +void +MyImpl::BMDisplay_exec_impl::push_data_ready ( + BasicSP::DataAvailable *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG (ev); + + ACE_DEBUG ((LM_DEBUG, + "BMDisplay - Doing computations \n")); + + ACE_DEBUG ((LM_DEBUG, + "BMDisplay - Doing data fecth \n")); + + // Refresh position + BasicSP::ReadData_var dat + = this->context_->get_connection_comp_data (ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (dat.in ())) + ACE_THROW (CORBA::BAD_INV_ORDER ()); + + char *str = + dat->get_data (); + + ACE_DEBUG ((LM_DEBUG, + "BMDisplay - Display data is [%s] \n", + str)); + +} + +// Operations from Components::SessionComponent +void +MyImpl::BMDisplay_exec_impl::set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDisplay_exec_impl::set_session_context\n")); + + this->context_ = + BasicSP::CCM_BMDisplay_Context::_narrow (ctx + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->context_.in ())) + ACE_THROW (CORBA::INTERNAL ()); + // Urm, we actually discard exceptions thown from this operation. +} + +void +MyImpl::BMDisplay_exec_impl::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDisplay_exec_impl::ccm_activate\n")); + + // @@ This hack work around a missing feature in CIAO's assembly + // mechanism where a Softpkg descriptor can specify it's dependency + // to a valuetype factory and instruct the deployment framework to + // initialize and register the corresponding valuefactory in the + // component server. Here, we are registering the valuefactory + // explicitly to work around this problem. + + char *argv[1] = { "BMDisplay_exec"}; + + int argc = sizeof(argv)/sizeof(argv[0]); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv ACE_ENV_ARG_PARAMETER); + + CIAO_REGISTER_VALUE_FACTORY (orb.in(), BasicSP::DataAvailable_init, + BasicSP::DataAvailable); +} + +void +MyImpl::BMDisplay_exec_impl::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDisplay_exec_impl::ccm_passivate\n")); +} + +void +MyImpl::BMDisplay_exec_impl::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + ACE_DEBUG ((LM_DEBUG, "MyImpl::BMDisplay_exec_impl::ccm_remove\n")); +} + +/// Default ctor. +MyImpl::BMDisplayHome_exec_impl::BMDisplayHome_exec_impl () +{ +} + +/// Default dtor. +MyImpl::BMDisplayHome_exec_impl::~BMDisplayHome_exec_impl () +{ +} + +// Explicit home operations. + +// Implicit home operations. + +::Components::EnterpriseComponent_ptr +MyImpl::BMDisplayHome_exec_impl::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + return new MyImpl::BMDisplay_exec_impl; +} + + +extern "C" BMDISPLAY_EXEC_Export ::Components::HomeExecutorBase_ptr +createBMDisplayHome_Impl (void) +{ + return new MyImpl::BMDisplayHome_exec_impl; +} diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec.h new file mode 100644 index 00000000000..25c5c4f3488 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec.h @@ -0,0 +1,102 @@ +// $Id$ + +//============================================================== +/** + * @file BMDisplay_exec.h + * + * Header file for the actual BMDisplay and BMDisplayHome component + * implementations. + * + * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +//============================================================== +#ifndef CIAO_BMDISPLAY_EXEC_H +#define CIAO_BMDISPLAY_EXEC_H + +#include "BMDisplayEIC.h" +#include "tao/LocalObject.h" + +namespace MyImpl +{ + /** + * @class BMDisplay_exec_impl + * + * RateGen executor implementation class. + */ + class BMDISPLAY_EXEC_Export BMDisplay_exec_impl : + public virtual BasicSP::BMDisplay_Exec, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default constructor. + BMDisplay_exec_impl (); + + /// Default destructor. + ~BMDisplay_exec_impl (); + + // Operations from BasicSP::BMDisplay + + virtual void + push_data_ready (BasicSP::DataAvailable *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + protected: + /// Copmponent specific context + BasicSP::CCM_BMDisplay_Context_var context_; + }; + + /** + * @class BMDisplayHome_exec_impl + * + * BMDisplay home executor implementation class. + */ + class BMDISPLAY_EXEC_Export BMDisplayHome_exec_impl : + public virtual BasicSP::CCM_BMDisplayHome, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default ctor. + BMDisplayHome_exec_impl (); + + /// Default dtor. + ~BMDisplayHome_exec_impl (); + + // Explicit home operations. + + // Implicit home operations. + + virtual ::Components::EnterpriseComponent_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + }; + +} + +extern "C" BMDISPLAY_EXEC_Export ::Components::HomeExecutorBase_ptr +createBMDisplayHome_Impl (void); + +#endif /* BMDISPLAY_EXEC_H */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec_export.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec_export.h new file mode 100644 index 00000000000..1f684e4e2c0 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_exec_export.h @@ -0,0 +1,50 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl BMDISPLAY_EXEC +// ------------------------------ +#ifndef BMDISPLAY_EXEC_EXPORT_H +#define BMDISPLAY_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (BMDISPLAY_EXEC_HAS_DLL) +# define BMDISPLAY_EXEC_HAS_DLL 1 +#endif /* ! BMDISPLAY_EXEC_HAS_DLL */ + +#if defined (BMDISPLAY_EXEC_HAS_DLL) && (BMDISPLAY_EXEC_HAS_DLL == 1) +# if defined (BMDISPLAY_EXEC_BUILD_DLL) +# define BMDISPLAY_EXEC_Export ACE_Proper_Export_Flag +# define BMDISPLAY_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BMDISPLAY_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BMDISPLAY_EXEC_BUILD_DLL */ +# define BMDISPLAY_EXEC_Export ACE_Proper_Import_Flag +# define BMDISPLAY_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BMDISPLAY_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BMDISPLAY_EXEC_BUILD_DLL */ +#else /* BMDISPLAY_EXEC_HAS_DLL == 1 */ +# define BMDISPLAY_EXEC_Export +# define BMDISPLAY_EXEC_SINGLETON_DECLARATION(T) +# define BMDISPLAY_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BMDISPLAY_EXEC_HAS_DLL == 1 */ + +// Set BMDISPLAY_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BMDISPLAY_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define BMDISPLAY_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BMDISPLAY_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BMDISPLAY_EXEC_NTRACE */ + +#if (BMDISPLAY_EXEC_NTRACE == 1) +# define BMDISPLAY_EXEC_TRACE(X) +#else /* (BMDISPLAY_EXEC_NTRACE == 1) */ +# define BMDISPLAY_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +#endif /* (BMDISPLAY_EXEC_NTRACE == 1) */ + +#endif /* BMDISPLAY_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_stub_export.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_stub_export.h new file mode 100644 index 00000000000..399dbb7425d --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_stub_export.h @@ -0,0 +1,50 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl BMDISPLAY_STUB +// ------------------------------ +#ifndef BMDISPLAY_STUB_EXPORT_H +#define BMDISPLAY_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (BMDISPLAY_STUB_HAS_DLL) +# define BMDISPLAY_STUB_HAS_DLL 1 +#endif /* ! BMDISPLAY_STUB_HAS_DLL */ + +#if defined (BMDISPLAY_STUB_HAS_DLL) && (BMDISPLAY_STUB_HAS_DLL == 1) +# if defined (BMDISPLAY_STUB_BUILD_DLL) +# define BMDISPLAY_STUB_Export ACE_Proper_Export_Flag +# define BMDISPLAY_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BMDISPLAY_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BMDISPLAY_STUB_BUILD_DLL */ +# define BMDISPLAY_STUB_Export ACE_Proper_Import_Flag +# define BMDISPLAY_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BMDISPLAY_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BMDISPLAY_STUB_BUILD_DLL */ +#else /* BMDISPLAY_STUB_HAS_DLL == 1 */ +# define BMDISPLAY_STUB_Export +# define BMDISPLAY_STUB_SINGLETON_DECLARATION(T) +# define BMDISPLAY_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BMDISPLAY_STUB_HAS_DLL == 1 */ + +// Set BMDISPLAY_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BMDISPLAY_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define BMDISPLAY_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BMDISPLAY_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BMDISPLAY_STUB_NTRACE */ + +#if (BMDISPLAY_STUB_NTRACE == 1) +# define BMDISPLAY_STUB_TRACE(X) +#else /* (BMDISPLAY_STUB_NTRACE == 1) */ +# define BMDISPLAY_STUB_TRACE(X) ACE_TRACE_IMPL(X) +#endif /* (BMDISPLAY_STUB_NTRACE == 1) */ + +#endif /* BMDISPLAY_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt.cpp b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt.cpp new file mode 100644 index 00000000000..c574360909e --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt.cpp @@ -0,0 +1,955 @@ +// $Id$ +#include "BMDisplay_svnt.h" +#include "Cookies.h" + +BasicSP::ReadData_ptr +CIAO_GLUE_BasicSP::BMDisplay_Context::get_connection_comp_data (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return BasicSP::ReadData::_duplicate (this->ciao_uses_comp_data_.in ()); +} + +// Simplex [receptacle name] connection management operations +void +CIAO_GLUE_BasicSP::BMDisplay_Context::connect_comp_data (BasicSP::ReadData_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)) +{ + if (! CORBA::is_nil (this->ciao_uses_comp_data_.in ())) + ACE_THROW (::Components::AlreadyConnected ()); + + if (CORBA::is_nil (c)) + ACE_THROW (::Components::InvalidConnection ()); + + // When do we throw InvalidConnection exception? + this->ciao_uses_comp_data_ = BasicSP::ReadData::_duplicate (c); +} + +BasicSP::ReadData_ptr +CIAO_GLUE_BasicSP::BMDisplay_Context::disconnect_comp_data (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)) +{ + if (CORBA::is_nil (this->ciao_uses_comp_data_.in ())) + ACE_THROW (::Components::NoConnection ()); + + return this->ciao_uses_comp_data_._retn (); +} + +// Operations for ::Components::SessionContext interface +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDisplay_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ How do I check for IllegalState here? When it's not in a + // callback operation... + // ACE_THROW_RETURN (::Components::IllegalState (), 0); + + if (CORBA::is_nil (this->component_.in ())) + { + CORBA::Object_var obj = this->container_->get_objref (this->servant_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->component_ = BasicSP::BMDisplay::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (this->component_.in ())) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); // This should not happen... + } + return BasicSP::BMDisplay::_duplicate (this->component_.in ()); +} + + +CIAO_GLUE_BasicSP::BMDisplay_Context::BMDisplay_Context (::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c, + CIAO_GLUE_BasicSP::BMDisplay_Servant *sv) + : home_ (::Components::CCMHome::_duplicate (home)), + container_ (c), + servant_ (sv) +{ + +} + + +CIAO_GLUE_BasicSP::BMDisplay_Context::~BMDisplay_Context () +{ +} + +// Operations for emits interfaces. + +// Operations for ::Components::CCMContext + ::Components::Principal_ptr +CIAO_GLUE_BasicSP::BMDisplay_Context::get_caller_principal (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ We don't support Security in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + ::Components::CCMHome_ptr +CIAO_GLUE_BasicSP::BMDisplay_Context::get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return ::Components::CCMHome::_duplicate (this->home_.in ()); +} + + CORBA::Boolean +CIAO_GLUE_BasicSP::BMDisplay_Context::get_rollback_only (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + ::Components::Transaction::UserTransaction_ptr +CIAO_GLUE_BasicSP::BMDisplay_Context::get_user_transaction (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + CORBA::Boolean +CIAO_GLUE_BasicSP::BMDisplay_Context::is_caller_in_role (const char * role + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG (role); + + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + void +CIAO_GLUE_BasicSP::BMDisplay_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + + +////////////////////////////////////////////////////////////////// +// Component Servant Glue code implementation +////////////////////////////////////////////////////////////////// + +CIAO_GLUE_BasicSP::BMDisplay_Servant::BMDisplay_Servant (BasicSP::CCM_BMDisplay_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (BasicSP::CCM_BMDisplay::_duplicate (exe)), + container_ (c) +{ + this->context_ = new CIAO_GLUE_BasicSP::BMDisplay_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_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; +} + +CIAO_GLUE_BasicSP::BMDisplay_Servant::~BMDisplay_Servant (void) +{ + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; + this->context_->_remove_ref (); +} + +// Operations for provides interfaces. + +// Operations for consumers interfaces. + +// EventConsumer Glue Code implementation +// Inherit from ::Compopnents::EventBConsumerBase +void +CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant::push_event (::Components::EventBase *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::BadEventType)) +{ + BasicSP::DataAvailable_var ev_type = BasicSP::DataAvailable::_downcast (ev); + if (ev_type != 0) + { + this->push_DataAvailable (ev_type.in () + ACE_ENV_ARG_PARAMETER); + return; + } + + // @@ This include the case when we receive a parent eventtype of [eventtype] + + ACE_THROW (::Components::BadEventType ()); +} + +// get_component implementation. +BasicSP::DataAvailableConsumer_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_consumer_data_ready (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (this->consumes_data_ready_.in ())) + { + CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant *svt = + new CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant (this->executor_.in (), + this->context_); + PortableServer::ServantBase_var safe_servant (svt); + + CORBA::Object_var obj = this->container_->install_servant (svt + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::DataAvailableConsumer_var eco + = BasicSP::DataAvailableConsumer::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->consumes_data_ready_ = eco; + } + + return BasicSP::DataAvailableConsumer::_duplicate (this->consumes_data_ready_.in ()); +} + +// Operations for Navigation interface +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::provide_facet (const char * name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)) +{ + ACE_UNUSED_ARG (name); + ACE_THROW_RETURN (::Components::InvalidName (), 0); +} + +::Components::FacetDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_all_facets (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::FacetDescriptions_var collection + = new ::Components::FacetDescriptions (0); // #99 = number of all provided + // facets including those inherited + // from parent component(s). + return collection._retn (); + +} + +::Components::FacetDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_named_facets (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ACE_UNUSED_ARG (names); + ACE_THROW_RETURN (::Components::InvalidName (), 0); +} + +CORBA::Boolean +CIAO_GLUE_BasicSP::BMDisplay_Servant::same_component (CORBA::Object_ptr object_ref + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (object_ref)) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + CORBA::Object_var the_other = object_ref->_get_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Object_var me = this->context_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return me->_is_equivalent (object_ref + ACE_ENV_ARG_PARAMETER); +} + +// Operations for Receptacles interface +::Components::Cookie * +CIAO_GLUE_BasicSP::BMDisplay_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)) +{ + // @@ We can omit this if clause if there's no receptacle in this component. + if (name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (name, "comp_data") == 0) + { + BasicSP::ReadData_var _ciao_conn = + BasicSP::ReadData::_narrow (connection + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (_ciao_conn.in ())) + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + + this->connect_comp_data (_ciao_conn.in () + ACE_ENV_ARG_PARAMETER); + return 0; + } + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDisplay_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)) +{ + ACE_UNUSED_ARG (ck); + // @@ We can omit this if clause if there's no receptacle in this component. + if (name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (name, "comp_data") == 0) + return this->disconnect_comp_data (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::ConnectionDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_connections (const char * name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ We can omit this if clause if there's no receptacle in this component. + if (name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (name, "comp_data") == 0) + { + ::Components::ConnectionDescriptions_var retv + = new ::Components::ConnectionDescriptions; + retv->length (1); + + ::Components::ConnectionDescription_var x + = new OBV_Components::ConnectionDescription; + x ->ck (0); + x ->objref (this->get_connection_comp_data (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_CHECK_RETURN (0); + + // retv[0] = x._retn (); + + return retv._retn (); + } + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::ReceptacleDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::ReceptacleDescriptions_var retv = + new ::Components::ReceptacleDescriptions (1); // #99 is number of receptacles + // this component has. + retv->length (1); + CORBA::ULong i = 0; + + retv[i] = new OBV_Components::ReceptacleDescription; + + retv[i]->Name ((const char *) "comp_data"); + retv[i]->type_id ((const char *) "IDL:BasicSP/ReadData:1.0"); + retv[i]->is_multiple (0); + retv[i]->connections (*this->get_connections ("comp_data" + ACE_ENV_ARG_PARAMETER)); + return retv._retn (); +} + +::Components::ReceptacleDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_named_receptacles (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::ReceptacleDescriptions_var retv = + new ::Components::ReceptacleDescriptions (names.length ()); + retv->length (names.length ()); + + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + retv[i] = new ::OBV_Components::ReceptacleDescription; + if (ACE_OS_String::strcmp (names[i].in (), "comp_data") == 0) + { + retv[i]->Name ((const char *) "comp_data"); + retv[i]->type_id ((const char *) "IDL:BasicSP/ReadData:1.0"); + retv[i]->is_multiple (0); + retv[i]->connections (*this->get_connections ("comp_data" + ACE_ENV_ARG_PARAMETER)); + } + else + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return retv._retn (); +} + +// Operations for Events interface +::Components::EventConsumerBase_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_consumer (const char * sink_name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ We can omit this if clause if there's no event sinks in this component. + if (sink_name == 0) + ACE_THROW_RETURN (Components::InvalidName (), 0); + + if (ACE_OS_String::strcmp (sink_name, "data_ready") == 0) + return this->get_consumer_data_ready (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::Cookie * +CIAO_GLUE_BasicSP::BMDisplay_Servant::subscribe (const char * , + Components::EventConsumerBase_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::ExceededConnectionLimit)) +{ + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::EventConsumerBase_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::unsubscribe (const char * , + Components::Cookie * + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection)) +{ + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +void +CIAO_GLUE_BasicSP::BMDisplay_Servant::connect_consumer (const char * , + Components::EventConsumerBase_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::AlreadyConnected, + Components::InvalidConnection)) +{ + ACE_THROW (Components::InvalidName ()); +} + +::Components::EventConsumerBase_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::disconnect_consumer (const char * + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::NoConnection)) +{ + ACE_THROW_RETURN (Components::InvalidName (), 0); +} + +::Components::ConsumerDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_all_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::ConsumerDescriptions_var retv = + new ::Components::ConsumerDescriptions (1); // #99 is the number of consumers + // this component has. + retv->length (1); + + CORBA::ULong i = 0; + retv[i] = new OBV_Components::ConsumerDescription; + retv[i]->Name ("data_ready"); + retv[i]->type_id ("IDL:BasicSP/DataAvailableConsumer:1.0"); + BasicSP::DataAvailableConsumer_var c + = this->get_consumer_data_ready (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + retv[i]->consumer (c.in ()); + + return retv._retn (); +} + +::Components::ConsumerDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_named_consumers (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::ConsumerDescriptions_var retv = + new ::Components::ConsumerDescriptions (names.length ()); + retv->length (names.length ()); + + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + retv[i] = new OBV_Components::ConsumerDescription; + + if (ACE_OS_String::strcmp (names[i].in (), "data_ready") == 0) + { + retv[i]->Name ("data_ready"); + retv[i]->type_id ("IDL:BasicSP/DataAvailableConsumer:1.0"); + BasicSP::DataAvailableConsumer_var c = + this->get_consumer_data_ready (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + retv[i]->consumer (c.in ()); + } + else + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return retv._retn (); +} + +::Components::EmitterDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_all_emitters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::EmitterDescriptions_var retv = + new ::Components::EmitterDescriptions (0); // #99 is the number of emitters + // this component has. + return retv._retn (); +} + +::Components::EmitterDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_named_emitters (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::EmitterDescriptions_var retv = + new ::Components::EmitterDescriptions (names.length ()); + retv->length (names.length ()); + + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return retv._retn (); +} + +::Components::PublisherDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_all_publishers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do + + // Need to add interfaces in the Context class to gather the information. + // Or we can just relay it to the Context object. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +::Components::PublisherDescriptions * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_named_publishers (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ACE_UNUSED_ARG (names); + // @@ to-do + + // Need to add interfaces in the Context class to gather the information. + // Or we can just relay it to the Context object. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +// Operations for CCMObject interface +::CORBA::IRObject_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do: Connect to an IfR? + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +::Components::CCMHome_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_ccm_home (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->context_->get_CCM_home (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +::Components::PrimaryKeyBase * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_primary_key (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::NoKeyAvailable)) +{ + // This is a keyless component. + ACE_THROW_RETURN (::Components::NoKeyAvailable (), 0); +} + +void +CIAO_GLUE_BasicSP::BMDisplay_Servant::configuration_complete (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidConfiguration)) +{ + // @@ to-do + // No-op. Don't know how to pass this info to monolithic executor. +} + +void +CIAO_GLUE_BasicSP::BMDisplay_Servant::remove (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)) +{ + // @@ to-do + // Need to figure out what to do here. E.g., tear down the all the connections + // this component has? +} + +::Components::ComponentPortDescription * +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_all_ports (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::ComponentPortDescription_var retv = + new OBV_Components::ComponentPortDescription; + + ::Components::FacetDescriptions_var facets_desc + = this->get_all_facets (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::ReceptacleDescriptions_var receptacle_desc + = get_all_receptacles (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::ConsumerDescriptions_var consumer_desc + = this->get_all_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::EmitterDescriptions_var emitter_desc + = this->get_all_emitters (ACE_ENV_SINGLE_ARG_PARAMETER); + ::Components::PublisherDescriptions_var publisher_desc + = this->get_all_publishers (ACE_ENV_SINGLE_ARG_PARAMETER); + + retv->facets (facets_desc.in()); + retv->receptacles (receptacle_desc.in()); + retv->consumers (consumer_desc.in()); + retv->emitters (emitter_desc.in()); + retv->publishers (publisher_desc.in()); + + return retv._retn(); +} + +// get_component implementation. +CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionContext_var sc = + ::Components::SessionContext::_narrow (this->context_); + + if (! CORBA::is_nil(sc.in ())) + return sc->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + // @@ Do we need to try the following case here? We are afterall implementing + // a session component here. + ::Components::EntityContext_var ec = + ::Components::EntityContext::_narrow (this->context_); + + if (! CORBA::is_nil(ec.in ())) + return ec->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); +} + +void +CIAO_GLUE_BasicSP::BMDisplay_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (! CORBA::is_nil (temp.in ())) + temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +CIAO_GLUE_BasicSP::BMDisplay_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (! CORBA::is_nil (temp.in ())) + temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); +} + + void +CIAO_GLUE_BasicSP::BMDisplay_Servant::connect_comp_data (BasicSP::ReadData_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)) +{ + this->context_->connect_comp_data (c + ACE_ENV_ARG_PARAMETER); +} + + BasicSP::ReadData_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::disconnect_comp_data (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)) +{ + return this->context_->disconnect_comp_data (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +BasicSP::ReadData_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::get_connection_comp_data (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->context_->get_connection_comp_data (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +// Constructor and destructor. + +CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant::DataAvailableConsumer_data_ready_Servant +(BasicSP::CCM_BMDisplay_ptr executor, + BasicSP::CCM_BMDisplay_Context_ptr c) + : executor_ (BasicSP::CCM_BMDisplay::_duplicate (executor)), + ctx_ (BasicSP::CCM_BMDisplay_Context::_duplicate (c)) +{ +} + + +CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant::~DataAvailableConsumer_data_ready_Servant () +{ +} + + CORBA::Object_ptr +CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->ctx_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); +} + + void +CIAO_GLUE_BasicSP::BMDisplay_Servant::DataAvailableConsumer_data_ready_Servant::push_DataAvailable +(BasicSP::DataAvailable *evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->executor_->push_data_ready (evt + ACE_ENV_ARG_PARAMETER); +} + + +////////////////////////////////////////////////////////////////// +// Component Home Glue code implementation +////////////////////////////////////////////////////////////////// + +BasicSP::BMDisplay_ptr +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::_ciao_activate_component (BasicSP::CCM_BMDisplay_ptr exe + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Object_var hobj + = this->container_->get_objref (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + ::Components::CCMHome_var home + = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CIAO_GLUE_BasicSP::BMDisplay_Servant *svt = + new CIAO_GLUE_BasicSP::BMDisplay_Servant (exe, + home.in (), + this->container_); + PortableServer::ServantBase_var safe (svt); + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref + = this->container_->install_component (svt, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::BMDisplay_var ho + = BasicSP::BMDisplay::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->component_map_.bind (oid.in (), svt) == 0) + { + // @@ what should happen if bind fail? + safe._retn (); + } + return ho._retn (); +} + +void +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::_ciao_passivate_component (BasicSP::BMDisplay_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CIAO_GLUE_BasicSP::BMDisplay_Servant *servant = 0; + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + // What happen if unbind failed? + +} + +// Operations for Implicit Home interface +BasicSP::BMDisplay_ptr +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)) +{ + if (this->executor_.in () == 0) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + Components::EnterpriseComponent_var _ciao_ec = + this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + BasicSP::CCM_BMDisplay_var _ciao_comp + = BasicSP::CCM_BMDisplay::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); +} + +// Operations for CCMHome interface +void +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::remove_component (Components::CCMObject_ptr comp + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)) +{ + BasicSP::BMDisplay_var _ciao_comp + = BasicSP::BMDisplay::_narrow (comp + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (_ciao_comp.in ())) + ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here? + + // @@ It seems to me that we need to make sure this is a component + // generated by this home before calling remove on this component. + _ciao_comp->remove (ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + + // Removing the object reference? get the servant from the POA with + // the objref, and call remove() on the component, deactivate the + // component, and then remove-ref the servant? + this->_ciao_passivate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); +} + + +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::BMDisplayHome_Servant (BasicSP::CCM_BMDisplayHome_ptr exe, + CIAO::Session_Container *c) + : executor_ (BasicSP::CCM_BMDisplayHome::_duplicate (exe)), + container_ (c) +{ +} + + +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::~BMDisplayHome_Servant (void) +{ +} + +// Operations for KeylessHome interface + ::Components::CCMObject_ptr +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::create_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)) +{ + // Simply forward to the create method. + return this->create (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +// Operations for CCMHome interface + ::CORBA::IRObject_ptr +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ TO-DO. Contact IfR? + + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +CORBA::IRObject_ptr +CIAO_GLUE_BasicSP::BMDisplayHome_Servant::get_home_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ TO-DO. Contact IfR? + + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + +extern "C" BMDISPLAY_SVNT_Export ::PortableServer::Servant +createBMDisplayHome_Servant (::Components::HomeExecutorBase_ptr p, + CIAO::Session_Container *c + ACE_ENV_ARG_DECL) +{ + if (p == 0) + return 0; + + BasicSP::CCM_BMDisplayHome_var x + = BasicSP::CCM_BMDisplayHome::_narrow (p + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (x.in ())) + return 0; + + return new CIAO_GLUE_BasicSP::BMDisplayHome_Servant (x.in (), + c); +} diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt.h new file mode 100644 index 00000000000..a0df1dfbef2 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt.h @@ -0,0 +1,472 @@ +// $Id$ + +// =========================================================== +// +// @file BMDisplay_svnt.h +// +// @author Balachandran Natarajan <bala@dre.vanderbilt.edu> +// +// =========================================================== + +#ifndef CIAO_GLUE_SESSION_BMDISPLAY_SVNT_H +#define CIAO_GLUE_SESSION_BMDISPLAY_SVNT_H +#include "ace/pre.h" + +#include "BMDisplayS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "BMDisplayEC.h" +#include "ciao/Container_Base.h" +#include "tao/LocalObject.h" +#include "tao/PortableServer/Key_Adapters.h" +#include "ace/Active_Map_Manager_T.h" + +namespace CIAO_GLUE_BasicSP +{ + + ////////////////////////////////////////////////////////////////// + // Component specific context implementation + class BMDISPLAY_SVNT_Export BMDisplay_Context : + public virtual BasicSP::CCM_BMDisplay_Context, + public virtual TAO_Local_RefCounted_Object + { + public: + // We will allow the the servant glue code we generate to access + // our states. + friend class BMDisplay_Servant; + + // Ctor. + BMDisplay_Context (::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c, + BMDisplay_Servant *sv); + + // Dtor. + virtual ~BMDisplay_Context (); + + // Operations for [component name] event source, and + // receptacles defined in CCM_[component name]_Context. + + BasicSP::ReadData_ptr + get_connection_comp_data (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations for ::Components::CCMContext + virtual ::Components::Principal_ptr + get_caller_principal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::CCMHome_ptr + get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Boolean + get_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + + virtual ::Components::Transaction::UserTransaction_ptr + get_user_transaction (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + + virtual CORBA::Boolean + is_caller_in_role (const char * role + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + set_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + + // Operations for ::Components::SessionContext interface + virtual CORBA::Object_ptr + get_CCM_object (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)); + protected: + // We need to generate, in protected section, stuff that manage + // connections and consumers of this component. + + // Simplex [receptacle name] connection management operations + void + connect_comp_data (BasicSP::ReadData_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)); + + BasicSP::ReadData_ptr + disconnect_comp_data (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)); + + // Simplex [receptacle name] connection + BasicSP::ReadData_var ciao_uses_comp_data_; + + protected: + /// Cached component home reference. + ::Components::CCMHome_var home_; + + /// session container + ::CIAO::Session_Container *container_; + + /// Reference back to owner. + BMDisplay_Servant *servant_; + + /// @@ Cached component reference. + BasicSP::BMDisplay_var component_; + + }; + + ////////////////////////////////////////////////////////////////// + // Component Servant Glue code implementation + class BMDISPLAY_SVNT_Export BMDisplay_Servant + : public virtual POA_BasicSP::BMDisplay, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Ctor. + BMDisplay_Servant (BasicSP::CCM_BMDisplay_ptr executor, + ::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c); + + // Dtor. + ~BMDisplay_Servant (void); + + // Operations for provides interfaces. + + // Operations for receptacles interfaces. + + // Simplex [receptacle name] connection management operations + virtual void + connect_comp_data (BasicSP::ReadData_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)); + + virtual BasicSP::ReadData_ptr + disconnect_comp_data (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)); + + virtual BasicSP::ReadData_ptr + get_connection_comp_data (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations for consumers interfaces. + // First we need to generate the event sink specific servant + class BMDISPLAY_SVNT_Export DataAvailableConsumer_data_ready_Servant + : public virtual POA_BasicSP::DataAvailableConsumer, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Constructor and destructor. + DataAvailableConsumer_data_ready_Servant (BasicSP::CCM_BMDisplay_ptr executor, + BasicSP::CCM_BMDisplay_Context_ptr c); + + ~DataAvailableConsumer_data_ready_Servant (); + + virtual void push_DataAvailable (BasicSP::DataAvailable *evt + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Inherit from ::Compopnents::EventBConsumerBase + virtual void push_event (::Components::EventBase *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::BadEventType)); + + // get_component implementation. + virtual CORBA::Object_ptr + _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + // Executor + BasicSP::CCM_BMDisplay_var executor_; + + // Context object. + BasicSP::CCM_BMDisplay_Context_var ctx_; + }; + + virtual BasicSP::DataAvailableConsumer_ptr + get_consumer_data_ready (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations for emits interfaces. + + // Operations for publishes interfaces. + + // Operations for Navigation interface + virtual CORBA::Object_ptr + provide_facet (const char * name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)) ; + + virtual ::Components::FacetDescriptions * + get_all_facets (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::FacetDescriptions * + get_named_facets (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)); + + virtual CORBA::Boolean + same_component (CORBA::Object_ptr object_ref + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations for Receptacles interface + virtual ::Components::Cookie * + connect (const char * name, + CORBA::Object_ptr connection + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::AlreadyConnected, + Components::ExceededConnectionLimit)); + + virtual CORBA::Object_ptr + disconnect (const char * name, + Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::CookieRequired, + Components::NoConnection)); + + virtual ::Components::ConnectionDescriptions * + get_connections (const char * name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::ReceptacleDescriptions * + get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::ReceptacleDescriptions * + get_named_receptacles (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + // Operations for Events interface + virtual ::Components::EventConsumerBase_ptr + get_consumer (const char * sink_name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::Cookie * + subscribe (const char * publisher_name, + Components::EventConsumerBase_ptr subscriber + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::ExceededConnectionLimit)); + + virtual ::Components::EventConsumerBase_ptr + unsubscribe (const char * publisher_name, + Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection)); + + virtual void + connect_consumer (const char * emitter_name, + Components::EventConsumerBase_ptr consumer + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::AlreadyConnected, + Components::InvalidConnection)); + + virtual ::Components::EventConsumerBase_ptr + disconnect_consumer (const char * source_name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::NoConnection)); + + virtual ::Components::ConsumerDescriptions * + get_all_consumers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::ConsumerDescriptions * + get_named_consumers (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::EmitterDescriptions * + get_all_emitters (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::EmitterDescriptions * + get_named_emitters (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + virtual ::Components::PublisherDescriptions * + get_all_publishers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::PublisherDescriptions * + get_named_publishers (const Components::NameList & names + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)); + + // Operations for CCMObject interface + virtual ::CORBA::IRObject_ptr + get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::CCMHome_ptr + get_ccm_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::PrimaryKeyBase * + get_primary_key (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::NoKeyAvailable)); + + virtual void + configuration_complete (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidConfiguration)); + + virtual void + remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)); + + virtual ::Components::ComponentPortDescription * + get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // get_component implementation. + virtual CORBA::Object_ptr + _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // CIAO specific operations. + + // Activate the object in the container_ + void + _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + // My Executor. + BasicSP::CCM_BMDisplay_var executor_; + + // My Run-time Context. + BMDisplay_Context *context_; + + // Managing container. + ::CIAO::Session_Container *container_; + + // Cached provided interfaces. + BasicSP::DataAvailableConsumer_var consumes_data_ready_; + }; + + + ////////////////////////////////////////////////////////////////// + // Component Home Glue code implementation + + // Foreach component home + class BMDISPLAY_SVNT_Export BMDisplayHome_Servant : + public virtual POA_BasicSP::BMDisplayHome, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Ctor. + BMDisplayHome_Servant (BasicSP::CCM_BMDisplayHome_ptr exe, + CIAO::Session_Container *c); + + // Dtor. + ~BMDisplayHome_Servant (void); + + // Factory operations + + // Finder operations + + // Operations for KeylessHome interface + virtual ::Components::CCMObject_ptr + create_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)); + + // Operations for Implicit Home interface + virtual BasicSP::BMDisplay_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)); + + // Operations for CCMHome interface + virtual ::CORBA::IRObject_ptr + get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CORBA::IRObject_ptr + get_home_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void remove_component (Components::CCMObject_ptr comp + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)); + + protected: + // Helper method for factory operations. + BasicSP::BMDisplay_ptr + _ciao_activate_component (BasicSP::CCM_BMDisplay_ptr exe + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component (BasicSP::BMDisplay_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // My Executor. + BasicSP::CCM_BMDisplayHome_var executor_; + + // My Container + CIAO::Session_Container *container_; + + // Components this home manages. + ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId, + BMDisplay_Servant*, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> component_map_; + }; + + extern "C" BMDISPLAY_SVNT_Export ::PortableServer::Servant + createBMDisplayHome_Servant (::Components::HomeExecutorBase_ptr p, + CIAO::Session_Container *c + ACE_ENV_ARG_DECL_WITH_DEFAULTS); +} + +#include "ace/post.h" +#endif /* CIAO_GLUE_SESSION_BMDISPLAY_SVNT_H */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt_export.h b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt_export.h new file mode 100644 index 00000000000..2392da154d7 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BMDisplay/BMDisplay_svnt_export.h @@ -0,0 +1,50 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl BMDISPLAY_SVNT +// ------------------------------ +#ifndef BMDISPLAY_SVNT_EXPORT_H +#define BMDISPLAY_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (BMDISPLAY_SVNT_HAS_DLL) +# define BMDISPLAY_SVNT_HAS_DLL 1 +#endif /* ! BMDISPLAY_SVNT_HAS_DLL */ + +#if defined (BMDISPLAY_SVNT_HAS_DLL) && (BMDISPLAY_SVNT_HAS_DLL == 1) +# if defined (BMDISPLAY_SVNT_BUILD_DLL) +# define BMDISPLAY_SVNT_Export ACE_Proper_Export_Flag +# define BMDISPLAY_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BMDISPLAY_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BMDISPLAY_SVNT_BUILD_DLL */ +# define BMDISPLAY_SVNT_Export ACE_Proper_Import_Flag +# define BMDISPLAY_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BMDISPLAY_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BMDISPLAY_SVNT_BUILD_DLL */ +#else /* BMDISPLAY_SVNT_HAS_DLL == 1 */ +# define BMDISPLAY_SVNT_Export +# define BMDISPLAY_SVNT_SINGLETON_DECLARATION(T) +# define BMDISPLAY_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BMDISPLAY_SVNT_HAS_DLL == 1 */ + +// Set BMDISPLAY_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BMDISPLAY_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define BMDISPLAY_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BMDISPLAY_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BMDISPLAY_SVNT_NTRACE */ + +#if (BMDISPLAY_SVNT_NTRACE == 1) +# define BMDISPLAY_SVNT_TRACE(X) +#else /* (BMDISPLAY_SVNT_NTRACE == 1) */ +# define BMDISPLAY_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +#endif /* (BMDISPLAY_SVNT_NTRACE == 1) */ + +#endif /* BMDISPLAY_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BasicSP_svnt.cpp b/TAO/CIAO/examples/handcrafted/BasicSP/BasicSP_svnt.cpp new file mode 100644 index 00000000000..fed871b7860 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BasicSP_svnt.cpp @@ -0,0 +1,61 @@ +// $Id$ + +// The generated filename for files using this template shoule be +// [idl-basename]GS.cpp GS --> GlueSession + +// @@ Notice: [ciao module name] can expand to either CIAO_GLUE or +// CIAO_GLUE_[module name] as defined in the header file. + +#include "BasicSP_svnt.h" + +ACE_RCSID (examples, + BasicSP_svnt, + "$Id$") + +CIAO_GLUE_BasicSP::ReadData_Servant::ReadData_Servant ( + BasicSP::CCM_ReadData_ptr executor, + Components::CCMContext_ptr c) + : executor_ (BasicSP::CCM_ReadData::_duplicate (executor)), + ctx_ (Components::CCMContext::_duplicate (c)) +{ +} + + + +CIAO_GLUE_BasicSP::ReadData_Servant::~ReadData_Servant (void) +{ +} + +// This is only a guideline... we always relay the operation to underlying +// executor. + +char * +CIAO_GLUE_BasicSP::ReadData_Servant::get_data (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Simply relay to executor. May not need to return the result... + return this->executor_->get_data (ACE_ENV_SINGLE_ARG_PARAMETER); +} + + +// get_component implementation. +// get_component is a standard CORBA::Object operations that returns +// the component reference that an object interface associates to. +CORBA::Object_ptr +CIAO_GLUE_BasicSP::ReadData_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + Components::SessionContext_var sc = + Components::SessionContext::_narrow (this->ctx_.in ()); + + 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 ()); + + if (! CORBA::is_nil(ec.in ())) + return ec->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); +} diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/BasicSP_svnt.h b/TAO/CIAO/examples/handcrafted/BasicSP/BasicSP_svnt.h new file mode 100644 index 00000000000..54b1f893386 --- /dev/null +++ b/TAO/CIAO/examples/handcrafted/BasicSP/BasicSP_svnt.h @@ -0,0 +1,73 @@ +// $Id$ + +// =========================================================== +// +// @file BasicSP_svnt.h +// +// Servant Glue code (supposedly should be) generated using CIAO'S +// CIDL compiler. This file implement the servants that bridge the +// executor and the container. +// +// This file is "generated" using the template code under +// $(CIAO_ROOT)/docs/templates/ +// +// Remember to refect any changes back to the code templates. +// +// @author Balachandran Natarajan <bala@cs.wustl.edu> +// +// =========================================================== + +#ifndef CIAO_GLUE_SESSION_BASICSP_H +#define CIAO_GLUE_SESSION_BASICSP_H +#include "ace/pre.h" + +///Source in the container interface definitions +#include "ciao/Container_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/// Source in the skeletons for component client-view equivalent +/// interfaces +#include "BasicSPS.h" + +// Source in the executor mapping that component implementations use +#include "BasicSPEC.h" + +/// @@@ Notice that all component and interface names may need to be +/// fully qualified as we are creating a new namespace for the CIAO's +/// container glue code. + +namespace CIAO_GLUE_BasicSP +{ + class BASICSP_SVNT_Export ReadData_Servant : + public virtual POA_BasicSP::ReadData, + public virtual PortableServer::RefCountServantBase + { + public: + + ReadData_Servant (BasicSP::CCM_ReadData_ptr executor, + Components::CCMContext_ptr ctx_); + ~ReadData_Servant (void); + + /// Template method. + virtual char *get_data (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // get_component implementation. + virtual CORBA::Object_ptr _get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + + // Facet executor. + BasicSP::CCM_ReadData_var executor_; + + // Context object. + Components::CCMContext_var ctx_; + }; +} + +#include "ace/post.h" +#endif /* CIAO_GLUE_SESSION_HUDISPLAYGS_H */ diff --git a/TAO/CIAO/examples/handcrafted/BasicSP/EC/EC.idl b/TAO/CIAO/examples/handcrafted/BasicSP/EC/EC.idl index 88e7f6a3270..88c5442e4a5 100644 --- a/TAO/CIAO/examples/handcrafted/BasicSP/EC/EC.idl +++ b/TAO/CIAO/examples/handcrafted/BasicSP/EC/EC.idl @@ -1,7 +1,7 @@ // $Id$ //============================================================================= /** - * @file HUDisplay.idl + * @file EC.idl * * Definition of events, and common interfaces used in the BasicSP module. * |