From 095ce5674bfa3c48b0cabbc2e37a10c0433a46aa Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 13 Dec 2007 14:49:32 -0330 Subject: Added multicast demo --- cpp/demo/Ice/multicast/Hello.cpp | 477 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 477 insertions(+) create mode 100644 cpp/demo/Ice/multicast/Hello.cpp (limited to 'cpp/demo/Ice/multicast/Hello.cpp') diff --git a/cpp/demo/Ice/multicast/Hello.cpp b/cpp/demo/Ice/multicast/Hello.cpp new file mode 100644 index 00000000000..f1ade87c664 --- /dev/null +++ b/cpp/demo/Ice/multicast/Hello.cpp @@ -0,0 +1,477 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +// Ice version 3.3.0 +// Generated from file `Hello.ice' + +#include +#include +#include +#include +#include +#include + +#ifndef ICE_IGNORE_VERSION +# if ICE_INT_VERSION / 100 != 303 +# error Ice version mismatch! +# endif +# if ICE_INT_VERSION % 100 > 50 +# error Beta header file detected +# endif +# if ICE_INT_VERSION % 100 < 0 +# error Ice patch level mismatch! +# endif +#endif + +static const ::std::string __Demo__Hello__sayHello_name = "sayHello"; + +static const ::std::string __Demo__Hello__shutdown_name = "shutdown"; + +::Ice::Object* IceInternal::upCast(::Demo::Hello* p) { return p; } +::IceProxy::Ice::Object* IceInternal::upCast(::IceProxy::Demo::Hello* p) { return p; } + +void +Demo::__read(::IceInternal::BasicStream* __is, ::Demo::HelloPrx& v) +{ + ::Ice::ObjectPrx proxy; + __is->read(proxy); + if(!proxy) + { + v = 0; + } + else + { + v = new ::IceProxy::Demo::Hello; + v->__copyFrom(proxy); + } +} + +void +IceProxy::Demo::Hello::sayHello(const ::Ice::Context* __ctx) +{ + int __cnt = 0; + while(true) + { + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase; + try + { + __delBase = __getDelegate(false); + ::IceDelegate::Demo::Hello* __del = dynamic_cast< ::IceDelegate::Demo::Hello*>(__delBase.get()); + __del->sayHello(__ctx); + return; + } + catch(const ::IceInternal::LocalExceptionWrapper& __ex) + { + __handleExceptionWrapperRelaxed(__delBase, __ex, __cnt); + } + catch(const ::Ice::LocalException& __ex) + { + __handleException(__delBase, __ex, __cnt); + } + } +} + +void +IceProxy::Demo::Hello::shutdown(const ::Ice::Context* __ctx) +{ + int __cnt = 0; + while(true) + { + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase; + try + { + __delBase = __getDelegate(false); + ::IceDelegate::Demo::Hello* __del = dynamic_cast< ::IceDelegate::Demo::Hello*>(__delBase.get()); + __del->shutdown(__ctx); + return; + } + catch(const ::IceInternal::LocalExceptionWrapper& __ex) + { + __handleExceptionWrapper(__delBase, __ex); + } + catch(const ::Ice::LocalException& __ex) + { + __handleException(__delBase, __ex, __cnt); + } + } +} + +const ::std::string& +IceProxy::Demo::Hello::ice_staticId() +{ + return ::Demo::Hello::ice_staticId(); +} + +::IceInternal::Handle< ::IceDelegateM::Ice::Object> +IceProxy::Demo::Hello::__createDelegateM() +{ + return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM::Demo::Hello); +} + +::IceInternal::Handle< ::IceDelegateD::Ice::Object> +IceProxy::Demo::Hello::__createDelegateD() +{ + return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::Demo::Hello); +} + +::IceProxy::Ice::Object* +IceProxy::Demo::Hello::__newInstance() const +{ + return new Hello; +} + +void +IceDelegateM::Demo::Hello::sayHello(const ::Ice::Context* __context) +{ + ::IceInternal::Outgoing __og(__handler.get(), __Demo__Hello__sayHello_name, ::Ice::Idempotent, __context); + bool __ok = __og.invoke(); + try + { + ::IceInternal::BasicStream* __is = __og.is(); + if(!__ok) + { + try + { + __is->throwException(); + } + catch(const ::Ice::UserException& __ex) + { + throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name()); + } + } + } + catch(const ::Ice::LocalException& __ex) + { + throw ::IceInternal::LocalExceptionWrapper(__ex, false); + } +} + +void +IceDelegateM::Demo::Hello::shutdown(const ::Ice::Context* __context) +{ + ::IceInternal::Outgoing __og(__handler.get(), __Demo__Hello__shutdown_name, ::Ice::Normal, __context); + bool __ok = __og.invoke(); + try + { + ::IceInternal::BasicStream* __is = __og.is(); + if(!__ok) + { + try + { + __is->throwException(); + } + catch(const ::Ice::UserException& __ex) + { + throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name()); + } + } + } + catch(const ::Ice::LocalException& __ex) + { + throw ::IceInternal::LocalExceptionWrapper(__ex, false); + } +} + +void +IceDelegateD::Demo::Hello::sayHello(const ::Ice::Context* __context) +{ + class _DirectI : public ::IceInternal::Direct + { + public: + + _DirectI(const ::Ice::Current& __current) : + ::IceInternal::Direct(__current) + { + } + + virtual ::Ice::DispatchStatus + run(::Ice::Object* object) + { + ::Demo::Hello* servant = dynamic_cast< ::Demo::Hello*>(object); + if(!servant) + { + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, _current.id, _current.facet, _current.operation); + } + servant->sayHello(_current); + return ::Ice::DispatchOK; + } + + private: + + }; + + ::Ice::Current __current; + __initCurrent(__current, __Demo__Hello__sayHello_name, ::Ice::Idempotent, __context); + try + { + _DirectI __direct(__current); + try + { + __direct.servant()->__collocDispatch(__direct); + } + catch(...) + { + __direct.destroy(); + throw; + } + __direct.destroy(); + } + catch(const ::Ice::SystemException&) + { + throw; + } + catch(const ::IceInternal::LocalExceptionWrapper&) + { + throw; + } + catch(const ::std::exception& __ex) + { + ::IceInternal::LocalExceptionWrapper::throwWrapper(__ex); + } + catch(...) + { + throw ::IceInternal::LocalExceptionWrapper(::Ice::UnknownException(__FILE__, __LINE__, "unknown c++ exception"), false); + } +} + +void +IceDelegateD::Demo::Hello::shutdown(const ::Ice::Context* __context) +{ + class _DirectI : public ::IceInternal::Direct + { + public: + + _DirectI(const ::Ice::Current& __current) : + ::IceInternal::Direct(__current) + { + } + + virtual ::Ice::DispatchStatus + run(::Ice::Object* object) + { + ::Demo::Hello* servant = dynamic_cast< ::Demo::Hello*>(object); + if(!servant) + { + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, _current.id, _current.facet, _current.operation); + } + servant->shutdown(_current); + return ::Ice::DispatchOK; + } + + private: + + }; + + ::Ice::Current __current; + __initCurrent(__current, __Demo__Hello__shutdown_name, ::Ice::Normal, __context); + try + { + _DirectI __direct(__current); + try + { + __direct.servant()->__collocDispatch(__direct); + } + catch(...) + { + __direct.destroy(); + throw; + } + __direct.destroy(); + } + catch(const ::Ice::SystemException&) + { + throw; + } + catch(const ::IceInternal::LocalExceptionWrapper&) + { + throw; + } + catch(const ::std::exception& __ex) + { + ::IceInternal::LocalExceptionWrapper::throwWrapper(__ex); + } + catch(...) + { + throw ::IceInternal::LocalExceptionWrapper(::Ice::UnknownException(__FILE__, __LINE__, "unknown c++ exception"), false); + } +} + +::Ice::ObjectPtr +Demo::Hello::ice_clone() const +{ + throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__); + return 0; // to avoid a warning with some compilers +} + +static const ::std::string __Demo__Hello_ids[2] = +{ + "::Demo::Hello", + "::Ice::Object" +}; + +bool +Demo::Hello::ice_isA(const ::std::string& _s, const ::Ice::Current&) const +{ + return ::std::binary_search(__Demo__Hello_ids, __Demo__Hello_ids + 2, _s); +} + +::std::vector< ::std::string> +Demo::Hello::ice_ids(const ::Ice::Current&) const +{ + return ::std::vector< ::std::string>(&__Demo__Hello_ids[0], &__Demo__Hello_ids[2]); +} + +const ::std::string& +Demo::Hello::ice_id(const ::Ice::Current&) const +{ + return __Demo__Hello_ids[0]; +} + +const ::std::string& +Demo::Hello::ice_staticId() +{ + return __Demo__Hello_ids[0]; +} + +::Ice::DispatchStatus +Demo::Hello::___sayHello(::IceInternal::Incoming&, const ::Ice::Current& __current) const +{ + __checkMode(::Ice::Idempotent, __current.mode); + sayHello(__current); + return ::Ice::DispatchOK; +} + +::Ice::DispatchStatus +Demo::Hello::___shutdown(::IceInternal::Incoming&, const ::Ice::Current& __current) +{ + __checkMode(::Ice::Normal, __current.mode); + shutdown(__current); + return ::Ice::DispatchOK; +} + +static ::std::string __Demo__Hello_all[] = +{ + "ice_id", + "ice_ids", + "ice_isA", + "ice_ping", + "sayHello", + "shutdown" +}; + +::Ice::DispatchStatus +Demo::Hello::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current) +{ + ::std::pair< ::std::string*, ::std::string*> r = ::std::equal_range(__Demo__Hello_all, __Demo__Hello_all + 6, current.operation); + if(r.first == r.second) + { + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation); + } + + switch(r.first - __Demo__Hello_all) + { + case 0: + { + return ___ice_id(in, current); + } + case 1: + { + return ___ice_ids(in, current); + } + case 2: + { + return ___ice_isA(in, current); + } + case 3: + { + return ___ice_ping(in, current); + } + case 4: + { + return ___sayHello(in, current); + } + case 5: + { + return ___shutdown(in, current); + } + } + + assert(false); + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation); +} + +void +Demo::Hello::__write(::IceInternal::BasicStream* __os) const +{ + __os->writeTypeId(ice_staticId()); + __os->startWriteSlice(); + __os->endWriteSlice(); +#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + Object::__write(__os); +#else + ::Ice::Object::__write(__os); +#endif +} + +void +Demo::Hello::__read(::IceInternal::BasicStream* __is, bool __rid) +{ + if(__rid) + { + ::std::string myId; + __is->readTypeId(myId); + } + __is->startReadSlice(); + __is->endReadSlice(); +#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + Object::__read(__is, true); +#else + ::Ice::Object::__read(__is, true); +#endif +} + +void +Demo::Hello::__write(const ::Ice::OutputStreamPtr&) const +{ + Ice::MarshalException ex(__FILE__, __LINE__); + ex.reason = "type Demo::Hello was not generated with stream support"; + throw ex; +} + +void +Demo::Hello::__read(const ::Ice::InputStreamPtr&, bool) +{ + Ice::MarshalException ex(__FILE__, __LINE__); + ex.reason = "type Demo::Hello was not generated with stream support"; + throw ex; +} + +void +Demo::__patch__HelloPtr(void* __addr, ::Ice::ObjectPtr& v) +{ + ::Demo::HelloPtr* p = static_cast< ::Demo::HelloPtr*>(__addr); + assert(p); + *p = ::Demo::HelloPtr::dynamicCast(v); + if(v && !*p) + { + IceInternal::Ex::throwUOE(::Demo::Hello::ice_staticId(), v->ice_id()); + } +} + +bool +Demo::operator==(const ::Demo::Hello& l, const ::Demo::Hello& r) +{ + return static_cast(l) == static_cast(r); +} + +bool +Demo::operator<(const ::Demo::Hello& l, const ::Demo::Hello& r) +{ + return static_cast(l) < static_cast(r); +} -- cgit v1.2.3