diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-15 14:59:15 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-15 14:59:15 +0000 |
commit | 46600fc3c02e5d31c048980a4620a4b78db51b30 (patch) | |
tree | a2873f5062c24fc3d44ea60c65a3a5582614d391 | |
parent | 79401a1dcd8228acff3aaa9df7aa19b47a459e8e (diff) | |
download | ATCD-46600fc3c02e5d31c048980a4620a4b78db51b30.tar.gz |
New file names
-rw-r--r-- | TAO/tests/Quoter/Quoter_Impl.cpp | 173 | ||||
-rw-r--r-- | TAO/tests/Quoter/Quoter_Impl.h | 85 |
2 files changed, 258 insertions, 0 deletions
diff --git a/TAO/tests/Quoter/Quoter_Impl.cpp b/TAO/tests/Quoter/Quoter_Impl.cpp new file mode 100644 index 00000000000..e79bbb73cdd --- /dev/null +++ b/TAO/tests/Quoter/Quoter_Impl.cpp @@ -0,0 +1,173 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Quoter +// +// = FILENAME +// quoter_impl.cpp +// +// = AUTHOR +// Darrell Brunsch +// +// ============================================================================ + +#include "tao/corba.h" +#include "QuoterImpl.h" +#include "QuoterC.h" + +// Constructor + +Quoter_Factory_Impl::Quoter_Factory_Impl (void) +{ +} + +// Destructor + +Quoter_Factory_Impl::~Quoter_Factory_Impl (void) +{ +} + +Stock::Quoter_ptr +Quoter_Factory_Impl::create_quoter (const char *name, + CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "Quoter Created\n")); + ACE_UNUSED_ARG (name); + return my_quoter_._this (env); +} + +// Constructor + +Quoter_Impl::Quoter_Impl (const char *) +{ +} + +// Destructor + +Quoter_Impl::~Quoter_Impl (void) +{ +} + +Quoter_Impl::get_quote (char const *stock_name, + class CORBA_Environment &env) +{ + ACE_UNUSED_ARG (stock_name); + ACE_UNUSED_ARG (env); + + return 42; +} + +// Shutdown. + +void Quoter_Impl::destroy (CORBA::Environment &env) +{ + ACE_UNUSED_ARG (env); + + ACE_DEBUG ((LM_DEBUG, + "%s", + "I have been asked to shut down ")); + + TAO_ORB_Core_instance ()->orb ()->shutdown (); +} + +CosLifeCycle::LifeCycleObject_ptr +Quoter_Impl::copy (CosLifeCycle::FactoryFinder_ptr there, + const CosLifeCycle::Criteria &the_criteria, + CORBA::Environment &_env_there) +{ + TAO_TRY + { + // The name of the Quoter Factory + CosLifeCycle::Key factoryKey (1); // max = 1 + factoryKey.length(1); + factoryKey[0].id = + CORBA::string_dup ("quoter_factory"); + + // Find an appropriate factory over there. + CosLifeCycle::Factories_ptr factories_ptr = + there->find_factories (factoryKey, _env_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. + 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_var quoter_FactoryObj_var = (*factories_ptr)[i]; + + // Narrow it to a Quoter Factory. + Stock::Quoter_Factory_var quoter_Factory_var = + Stock::Quoter_Factory::_narrow (quoter_FactoryObj_var.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + + // Try to get a Quoter created by this factory. + quoter_var = + quoter_Factory_var->create_quoter ("quoter_copied", TAO_TRY_ENV); + + // @@ mk1: The create_quoter should return an exception + TAO_CHECK_ENV; + + if (CORBA::is_nil (quoter_var.in ())) + { + // If we had already our last chance, then give up. + if (i == factories_ptr->length ()) + { + _env_there.exception (new CosLifeCycle::NoFactory (factoryKey)); + return CosLifeCycle::LifeCycleObject::_nil(); + } + else + { + ACE_ERROR ((LM_ERROR, + "Quoter::copy: Factory did not create the Quoter properly.\n")); + // Else tell what's wrong and try the next factory. + } + } + else + break; + // if succeeded in creating a new Quoter over there, then stop trying + } + + // Return an object reference to the newly created Quoter. + return (CosLifeCycle::LifeCycleObject_ptr) quoter_var; + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("SYS_EX"); + return CosLifeCycle::LifeCycleObject::_nil(); + } + TAO_ENDTRY; + return CosLifeCycle::LifeCycleObject::_nil(); +} + +void +Quoter_Impl::move (CosLifeCycle::FactoryFinder_ptr there, + const CosLifeCycle::Criteria &the_criteria, + CORBA::Environment &_env_there) +{ + // for later + // this->copy (there, the_criteria, _env_there); + + // the move operation is not implemented yet, because of the issue, + // that the object reference has to stay the same. But if it has + // to stay the same this object. the old object, has to forward + // further calls. + + _env_there.exception (new CosLifeCycle::NotMovable()); +} + +void +Quoter_Impl::remove (CORBA::Environment &_tao_environment) +{ +} diff --git a/TAO/tests/Quoter/Quoter_Impl.h b/TAO/tests/Quoter/Quoter_Impl.h new file mode 100644 index 00000000000..a548e52640d --- /dev/null +++ b/TAO/tests/Quoter/Quoter_Impl.h @@ -0,0 +1,85 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Quoter +// +// = FILENAME +// quoter_impl.h +// +// = AUTHOR +// Darrell Brunsch +// +// ============================================================================ + +#if !defined (QUOTER_IMPL_H) +#define QUOTER_IMPL_H + +#include "quoterS.h" + +// Forward declarations. +class Quoter_Impl; + +// Typedefs. +typedef Quoter_Impl *Quoter_Impl_ptr; +typedef Quoter_Impl_ptr Quoter_Impl_ref; + +class Quoter_Impl: public POA_Stock::Quoter +{ + // = TITLE + // @@ Write + // + // = DESCRIPTION + // @@ Write +public: + Quoter_Impl (const char *obj_name = 0); + // Constructor + + ~Quoter_Impl (void); + // Destructor + + virtual CORBA::Long get_quote (const char *stock_name, + CORBA::Environment &env); + + virtual void destroy (CORBA_Environment &env); + + virtual CosLifeCycle::LifeCycleObject_ptr copy (CosLifeCycle::FactoryFinder_ptr there, + const CosLifeCycle::Criteria &the_criteria, + CORBA::Environment &_tao_environment); + + virtual void move (CosLifeCycle::FactoryFinder_ptr there, + const CosLifeCycle::Criteria &the_criteria, + CORBA::Environment &_tao_environment); + + virtual void remove (CORBA::Environment &_tao_environment); +}; + +class Quoter_Factory_Impl; + +typedef Quoter_Factory_Impl *Quoter_Factory_Impl_ptr; + +class Quoter_Factory_Impl: public POA_Stock::Quoter_Factory +{ + // = TITLE + // Quoter_Factory_Impl + // + // = DESCRIPTION + // Factory object returning the quoter_impl objrefs. +public: + Quoter_Factory_Impl (void); + // Constructor. + + ~Quoter_Factory_Impl (void); + // Destructor. + + virtual Stock::Quoter_ptr create_quoter (const char *name, + CORBA::Environment &env); + // Return the quoter by the id <name>. + +private: + Quoter_Impl my_quoter_; + // @@ Do we just want one of these?! +}; + +#endif /* QUOTER_IMPL_H */ |