diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-27 15:22:55 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-27 15:22:55 +0000 |
commit | 45c6b2c02166a0b1c6115cc04cb27efbd4932ba2 (patch) | |
tree | bc007744fef8f5b0e6e160419c30d5e16392741b /TAO | |
parent | 8c467cda429d139655db4f2cb442694a5edf0f49 (diff) | |
download | ATCD-45c6b2c02166a0b1c6115cc04cb27efbd4932ba2.tar.gz |
(copy): wrapped final return 0 statement with ACE_NOTREACHED.
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/examples/Quoter/Quoter_i.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/TAO/examples/Quoter/Quoter_i.cpp b/TAO/examples/Quoter/Quoter_i.cpp index e3e5c488add..e733606fd64 100644 --- a/TAO/examples/Quoter/Quoter_i.cpp +++ b/TAO/examples/Quoter/Quoter_i.cpp @@ -24,12 +24,12 @@ Quoter_Factory_i::Quoter_Factory_i (size_t num, PortableServer::POA_ptr poa_ptr) : my_quoters_ (0), quoter_num_ (num), next_quoter_ (0) - + { - { + { CORBA::Environment env; ACE_NEW(this->my_quoters_, Quoter_i *[num]); - + for (size_t i = 0; i < num; i++) { ACE_NEW(this->my_quoters_[i], Quoter_i("x", // name @@ -42,11 +42,11 @@ Quoter_Factory_i::Quoter_Factory_i (size_t num, PortableServer::POA_ptr poa_ptr) { env.print_exception ("POA::activate"); } - + // Stringify the object reference and print it out. CORBA::String_var quoter_ior = TAO_ORB_Core_instance()->orb()->object_to_string (this->my_quoters_[i]->_this(env), env); - + if (env.exception () != 0) { env.print_exception ("CORBA::ORB::object_to_string"); @@ -86,9 +86,9 @@ Quoter_Factory_i::create_quoter (const char *name, // Constructor -Quoter_i::Quoter_i (const char *name, - const unsigned char use_LifeCycle_Service, - PortableServer::POA_ptr poa_ptr) +Quoter_i::Quoter_i (const char *name, + const unsigned char use_LifeCycle_Service, + PortableServer::POA_ptr poa_ptr) : use_LifeCycle_Service_ (use_LifeCycle_Service), poa_var_ (PortableServer::POA::_duplicate (poa_ptr)) { @@ -128,21 +128,21 @@ Quoter_i::copy (CosLifeCycle::FactoryFinder_ptr there, { // The name of the Generic Factory CosLifeCycle::Key factoryKey (2); // max = 2 - + if (this->use_LifeCycle_Service_ == 1) - { - // use the LifeCycle Service - factoryKey.length(1); - factoryKey[0].id = CORBA::string_dup ("Life_Cycle_Service"); - } + { + // use the LifeCycle Service + factoryKey.length(1); + factoryKey[0].id = CORBA::string_dup ("Life_Cycle_Service"); + } else - { - // use a Generic Factory - factoryKey.length(2); - factoryKey[0].id = CORBA::string_dup ("IDL_Quoter"); - factoryKey[1].id = CORBA::string_dup ("Quoter_Generic_Factory"); - } - + { + // use a Generic Factory + factoryKey.length(2); + factoryKey[0].id = CORBA::string_dup ("IDL_Quoter"); + factoryKey[1].id = CORBA::string_dup ("Quoter_Generic_Factory"); + } + // Find an appropriate factory over there. CosLifeCycle::Factories_ptr factories_ptr = there->find_factories (factoryKey, _env_there); @@ -150,53 +150,53 @@ Quoter_i::copy (CosLifeCycle::FactoryFinder_ptr there, // Only a NoFactory exception might have occured, so if it // occured, then go immediately back. if (_env_there.exception() != 0) - { - // _env_there contains already the exception. - ACE_ERROR ((LM_ERROR, - "Quoter::copy: Exception occured while trying to find a factory.\n")); - - return CosLifeCycle::LifeCycleObject::_nil(); - } - + { + // _env_there contains already the exception. + ACE_ERROR ((LM_ERROR, + "Quoter::copy: Exception occured while trying to find a factory.\n")); + + return CosLifeCycle::LifeCycleObject::_nil(); + } + // Now it is known that there is at least one factory. Stock::Quoter_var quoter_var; - + for (u_int i = 0; i < factories_ptr->length (); i++) { // Get the first object reference to a factory. CORBA::Object_ptr generic_FactoryObj_ptr = (*factories_ptr)[i]; - + // Narrow it to a Quoter Factory. CosLifeCycle::GenericFactory_var generic_Factory_var = CosLifeCycle::GenericFactory::_narrow (generic_FactoryObj_ptr, TAO_TRY_ENV); TAO_CHECK_ENV; - + if (CORBA::is_nil (generic_Factory_var.in ())) - { - ACE_ERROR ((LM_ERROR, - "Quoter::copy: Narrow failed. Generic Factory is not valid.\n")); + { + ACE_ERROR ((LM_ERROR, + "Quoter::copy: Narrow failed. Generic Factory is not valid.\n")); return CosLifeCycle::LifeCycleObject::_nil(); - } - - CosLifeCycle::Key genericFactoryName (1); // max = 1 - genericFactoryName.length(1); - genericFactoryName[0].id = CORBA::string_dup ("Quoter_Factory"); - - CosLifeCycle::Criteria criteria(1); - criteria.length (1); - criteria[0].name = CORBA::string_dup ("filter"); - criteria[0].value <<= CORBA::string_dup ("name=='Quoter_Generic_Factory'"); - - CORBA::Object_var quoterObject_var = - generic_Factory_var->create_object (genericFactoryName, - criteria, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - quoter_var = Stock::Quoter::_narrow (quoterObject_var.in(), TAO_TRY_ENV); - TAO_CHECK_ENV; - + } + + CosLifeCycle::Key genericFactoryName (1); // max = 1 + genericFactoryName.length(1); + genericFactoryName[0].id = CORBA::string_dup ("Quoter_Factory"); + + CosLifeCycle::Criteria criteria(1); + criteria.length (1); + criteria[0].name = CORBA::string_dup ("filter"); + criteria[0].value <<= CORBA::string_dup ("name=='Quoter_Generic_Factory'"); + + CORBA::Object_var quoterObject_var = + generic_Factory_var->create_object (genericFactoryName, + criteria, + TAO_TRY_ENV); + TAO_CHECK_ENV; + + quoter_var = Stock::Quoter::_narrow (quoterObject_var.in(), TAO_TRY_ENV); + TAO_CHECK_ENV; + if (CORBA::is_nil (quoter_var.in ())) { // If we had already our last chance, then give up. @@ -206,7 +206,7 @@ Quoter_i::copy (CosLifeCycle::FactoryFinder_ptr there, ACE_ERROR ((LM_ERROR, "Quoter::copy: Last factory did not work. \n" "No more factories are available. I give up.\n")); - return CosLifeCycle::LifeCycleObject::_nil(); + return CosLifeCycle::LifeCycleObject::_nil(); } else { @@ -217,13 +217,13 @@ Quoter_i::copy (CosLifeCycle::FactoryFinder_ptr there, } else // if succeeded in creating a new Quoter over there, then stop trying - break; + break; } - + if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "Quoter copied\n")); - CosLifeCycle::LifeCycleObject_ptr lifeCycleObject_ptr = + CosLifeCycle::LifeCycleObject_ptr lifeCycleObject_ptr = CosLifeCycle::LifeCycleObject::_duplicate ((CosLifeCycle::LifeCycleObject_ptr) quoter_var.in()); // Duplicate and eturn an object reference to the newly created Quoter. return lifeCycleObject_ptr; @@ -236,7 +236,7 @@ Quoter_i::copy (CosLifeCycle::FactoryFinder_ptr there, return CosLifeCycle::LifeCycleObject::_nil(); } TAO_ENDTRY; - return CosLifeCycle::LifeCycleObject::_nil(); + ACE_NOTREACHED (return CosLifeCycle::LifeCycleObject::_nil()); } @@ -248,89 +248,89 @@ Quoter_i::move (CosLifeCycle::FactoryFinder_ptr there, CORBA::Environment &_env_there) { ACE_DEBUG ((LM_DEBUG,"Quoter_i::move: being called\n")); - + TAO_TRY { // We need to have a Factory Finder if (CORBA::is_nil (there)) - { - ACE_ERROR ((LM_ERROR, - "Quoter_i::move: No Factory Finder, don't know how to go on.\n")); - _env_there.exception (new CosLifeCycle::NoFactory ()); - return; - } + { + ACE_ERROR ((LM_ERROR, + "Quoter_i::move: No Factory Finder, don't know how to go on.\n")); + _env_there.exception (new CosLifeCycle::NoFactory ()); + return; + } // We need to have access to the POA if (CORBA::is_nil (this->poa_var_.in())) - { - ACE_ERROR ((LM_ERROR, - "Quoter_i::move: No access to the POA. Cannot move.\n")); - _env_there.exception (new CosLifeCycle::NotMovable ()); - return; - } + { + ACE_ERROR ((LM_ERROR, + "Quoter_i::move: No access to the POA. Cannot move.\n")); + _env_there.exception (new CosLifeCycle::NotMovable ()); + return; + } // Create a new Quoter over there - CosLifeCycle::LifeCycleObject_var lifeCycleObject_var = - this->copy (there, the_criteria, _env_there); + CosLifeCycle::LifeCycleObject_var lifeCycleObject_var = + this->copy (there, the_criteria, _env_there); if (_env_there.exception () != 0) - { - ACE_ERROR ((LM_ERROR, - "Quoter_i::move: Exception while creating new Quoter.\n")); - // The exception is already contained in the right environment - return; - } + { + ACE_ERROR ((LM_ERROR, + "Quoter_i::move: Exception while creating new Quoter.\n")); + // The exception is already contained in the right environment + return; + } if (CORBA::is_nil (lifeCycleObject_var.in ())) - { - ACE_ERROR ((LM_ERROR, - "Quoter_i::move: Created Quoter is not valid.\n")); - _env_there.exception (new CosLifeCycle::NoFactory ()); - return; - } - + { + ACE_ERROR ((LM_ERROR, + "Quoter_i::move: Created Quoter is not valid.\n")); + _env_there.exception (new CosLifeCycle::NoFactory ()); + return; + } + // Set the POA, so that the requests will be forwarded to the new location - + // new location CORBA::Object_var forward_to_var = CORBA::Object::_duplicate ((CORBA::Object_ptr) lifeCycleObject_var.in()); - + if (!CORBA::is_nil (forward_to_var.in ())) - { - PortableServer::ObjectId_var oid = this->poa_var_->servant_to_id (this, TAO_TRY_ENV); - TAO_CHECK_ENV; - - PortableServer::Servant servant = this->poa_var_->_servant (); - - if (servant == 0) - { - ACE_ERROR ((LM_ERROR,"Quoter_i::move: Could not find servant.\n")); - _env_there.exception (new CosLifeCycle::NotMovable()); - return; - } - - void *ptr = servant->_downcast ("IDL:PortableServer/POA:1.0"); - POA_PortableServer::POA *poa = (POA_PortableServer::POA *) ptr; - TAO_POA *tao_poa = ACE_dynamic_cast (TAO_POA *, poa); - - tao_poa->forward_object (oid.in (), - forward_to_var.in (), - TAO_TRY_ENV); - TAO_CHECK_ENV; - } + { + PortableServer::ObjectId_var oid = this->poa_var_->servant_to_id (this, TAO_TRY_ENV); + TAO_CHECK_ENV; + + PortableServer::Servant servant = this->poa_var_->_servant (); + + if (servant == 0) + { + ACE_ERROR ((LM_ERROR,"Quoter_i::move: Could not find servant.\n")); + _env_there.exception (new CosLifeCycle::NotMovable()); + return; + } + + void *ptr = servant->_downcast ("IDL:PortableServer/POA:1.0"); + POA_PortableServer::POA *poa = (POA_PortableServer::POA *) ptr; + TAO_POA *tao_poa = ACE_dynamic_cast (TAO_POA *, poa); + + tao_poa->forward_object (oid.in (), + forward_to_var.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + } else - { - ACE_ERROR ((LM_ERROR,"Quoter_i::move: forward_to refenence is nil.\n")); - _env_there.exception (new CosLifeCycle::NotMovable()); - return; - } - + { + ACE_ERROR ((LM_ERROR,"Quoter_i::move: forward_to refenence is nil.\n")); + _env_there.exception (new CosLifeCycle::NotMovable()); + return; + } + } TAO_CATCHANY { TAO_TRY_ENV.print_exception ("SYS_EX"); return; } - TAO_ENDTRY; + TAO_ENDTRY; } @@ -343,6 +343,6 @@ Quoter_i::remove (CORBA::Environment &_tao_environment) if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "I have been asked to shut down.\n")); - + TAO_ORB_Core_instance ()->orb ()->shutdown (); } |