📄 request.cc
字号:
voidRequestImpl::send_oneway(){ if( pd_state != RS_READY ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_RequestAlreadySent, CORBA::COMPLETED_NO); try{ CORBA::ULong operation_len = strlen(pd_operation) + 1; omniObjRef* o = pd_target->_PR_getobj(); omni_RequestImpl_callDesc call_desc(pd_operation,operation_len,1,*this); o->_invoke(call_desc); } // Either throw system exceptions, or store in pd_environment. catch(CORBA::SystemException& ex){ INVOKE_DONE(); if( orbParameters::diiThrowsSysExceptions ) { pd_sysExceptionToThrow = CORBA::Exception::_duplicate(&ex); throw; } else pd_environment->exception(CORBA::Exception::_duplicate(&ex)); } INVOKE_DONE();}voidRequestImpl::send_deferred(){ if( pd_state != RS_READY ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_RequestAlreadySent, CORBA::COMPLETED_NO); pd_state = RS_DEFERRED; pd_deferredRequest = new DeferredRequest(this); orbAsyncInvoker->insert(pd_deferredRequest);}voidRequestImpl::get_response(){ if( pd_state == RS_READY ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_RequestNotSentYet, CORBA::COMPLETED_NO); if( !pd_deferredRequest ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_RequestIsSynchronous, CORBA::COMPLETED_NO); if( pd_sysExceptionToThrow ) pd_sysExceptionToThrow->_raise(); if( pd_state == RS_POLLED_DONE ) pd_state = RS_DONE; if( pd_state == RS_DONE ) return; OMNIORB_ASSERT(pd_state == RS_DEFERRED); pd_deferredRequest->get_response(); pd_sysExceptionToThrow = pd_deferredRequest->get_exception(); pd_deferredRequest->die(); pd_state = RS_DONE; if( pd_sysExceptionToThrow ) pd_sysExceptionToThrow->_raise();}CORBA::BooleanRequestImpl::poll_response(){ if( pd_state == RS_READY ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_RequestNotSentYet, CORBA::COMPLETED_NO); if( !pd_deferredRequest ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_RequestIsSynchronous, CORBA::COMPLETED_NO); if( pd_state == RS_DONE ) OMNIORB_THROW(BAD_INV_ORDER, BAD_INV_ORDER_ResultAlreadyReceived, CORBA::COMPLETED_NO); if( pd_state == RS_POLLED_DONE ) return CORBA::Boolean(1); OMNIORB_ASSERT(pd_state == RS_DEFERRED); CORBA::Boolean result = pd_deferredRequest->poll_response(); if( result ) { pd_sysExceptionToThrow = pd_deferredRequest->get_exception(); pd_deferredRequest->die(); pd_state = RS_POLLED_DONE; // XXX Opengroup vsOrb tests for poll_response to raise an // exception when the invocation results in a system exception. if( orbParameters::diiThrowsSysExceptions ) { if (pd_sysExceptionToThrow) pd_sysExceptionToThrow->_raise(); } } else { omni_thread::yield(); } return result;}CORBA::BooleanRequestImpl::NP_is_nil() const{ return 0;}CORBA::Request_ptrRequestImpl::NP_duplicate(){ incrRefCount(); return this;}voidRequestImpl::marshalArgs(cdrStream& s){ CORBA::ULong num_args = pd_arguments->count(); for( CORBA::ULong i = 0; i < num_args; i++ ){ CORBA::NamedValue_ptr arg = pd_arguments->item(i); if( arg->flags() & CORBA::ARG_IN ) arg->value()->NP_marshalDataOnly(s); } if( !CORBA::is_nil(pd_contexts) ) { ContextListImpl* context_list = (ContextListImpl*) (CORBA::ContextList_ptr)pd_contexts; CORBA::Context::marshalContext(pd_context, context_list->NP_list(), context_list->count(), s); }}voidRequestImpl::unmarshalResults(cdrStream& s){ pd_result->value()->NP_unmarshalDataOnly(s); CORBA::ULong num_args = pd_arguments->count(); for( CORBA::ULong i = 0; i < num_args; i++){ CORBA::NamedValue_ptr arg = pd_arguments->item(i); if( arg->flags() & CORBA::ARG_OUT ) arg->value()->NP_unmarshalDataOnly(s); }}CORBA::BooleanRequestImpl::unmarshalUserException(cdrStream& s, const char* repoId){ CORBA::ULong exListLen = CORBA::is_nil(pd_exceptions) ? 0 : pd_exceptions->count(); // Search for a match in the exception list. for( CORBA::ULong i = 0; i < exListLen; i++ ){ CORBA::TypeCode_ptr exType = pd_exceptions->item(i); if( omni::strMatch(repoId, exType->id()) ){ // Unmarshal the exception into an Any. CORBA::Any* newAny = new CORBA::Any(exType, 0); try { newAny->NP_unmarshalDataOnly(s); } catch(...) { delete newAny; throw; } // Encapsulate this in an UnknownUserException, which is // placed into pd_environment. CORBA::UnknownUserException* ex = new CORBA::UnknownUserException(newAny); pd_environment->exception(ex); return 1; } } return 0;}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////static CORBA::Any dummy_any;class omniNilRequest : public CORBA::Request, public omniTrackedObject {public: virtual CORBA::Object_ptr target() const { _CORBA_invoked_nil_pseudo_ref(); return CORBA::Object::_nil(); } virtual const char* operation() const { _CORBA_invoked_nil_pseudo_ref(); return 0; } virtual CORBA::NVList_ptr arguments() { _CORBA_invoked_nil_pseudo_ref(); return CORBA::NVList::_nil(); } virtual CORBA::NamedValue_ptr result() { _CORBA_invoked_nil_pseudo_ref(); return CORBA::NamedValue::_nil(); } virtual CORBA::Environment_ptr env() { _CORBA_invoked_nil_pseudo_ref(); return CORBA::Environment::_nil(); } virtual CORBA::ExceptionList_ptr exceptions() { _CORBA_invoked_nil_pseudo_ref(); return CORBA::ExceptionList::_nil(); } virtual CORBA::ContextList_ptr contexts() { _CORBA_invoked_nil_pseudo_ref(); return CORBA::ContextList::_nil(); } virtual CORBA::Context_ptr ctx() const { _CORBA_invoked_nil_pseudo_ref(); return CORBA::Context::_nil(); } virtual void ctx(CORBA::Context_ptr) { _CORBA_invoked_nil_pseudo_ref(); } virtual CORBA::Any& add_in_arg() { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual CORBA::Any& add_in_arg(const char* name) { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual CORBA::Any& add_inout_arg() { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual CORBA::Any& add_inout_arg(const char* name) { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual CORBA::Any& add_out_arg() { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual CORBA::Any& add_out_arg(const char* name) { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual void set_return_type(CORBA::TypeCode_ptr tc) { _CORBA_invoked_nil_pseudo_ref(); } virtual CORBA::Any& return_value() { _CORBA_invoked_nil_pseudo_ref(); return dummy_any; } virtual void invoke() { _CORBA_invoked_nil_pseudo_ref(); } virtual void send_oneway() { _CORBA_invoked_nil_pseudo_ref(); } virtual void send_deferred() { _CORBA_invoked_nil_pseudo_ref(); } virtual void get_response() { _CORBA_invoked_nil_pseudo_ref(); } virtual CORBA::Boolean poll_response() { _CORBA_invoked_nil_pseudo_ref(); return 0; } virtual CORBA::Boolean NP_is_nil() const { return 1; } virtual CORBA::Request_ptr NP_duplicate() { return _nil(); }};OMNI_NAMESPACE_END(omni)OMNI_USING_NAMESPACE(omni)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////CORBA::Request::~Request() { pd_magic = 0; }CORBA::Request_ptrCORBA::Request::_duplicate(Request_ptr p){ if (!PR_is_valid(p)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidRequest, CORBA::COMPLETED_NO); if( !CORBA::is_nil(p) ) return p->NP_duplicate(); else return _nil();}CORBA::Request_ptrCORBA::Request::_nil(){ static omniNilRequest* _the_nil_ptr = 0; if( !_the_nil_ptr ) { omni::nilRefLock().lock(); if( !_the_nil_ptr ) { _the_nil_ptr = new omniNilRequest; registerTrackedObject(_the_nil_ptr); } omni::nilRefLock().unlock(); } return _the_nil_ptr;}////////////////////////////////////////////////////////////////////////////////////////////////// CORBA::Object /////////////////////////////////////////////////////////////////////////////////////////////////voidCORBA::release(CORBA::Request_ptr p){ if( CORBA::Request::PR_is_valid(p) && !CORBA::is_nil(p) ) ((RequestImpl*)p)->decrRefCount();}voidCORBA::Object::_create_request(CORBA::Context_ptr ctx, const char* operation, CORBA::NVList_ptr arg_list, CORBA::NamedValue_ptr result, CORBA::Request_out request, CORBA::Flags req_flags){ if( _NP_is_pseudo() ) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_IsPseudoObject, CORBA::COMPLETED_NO); // NB. req_flags is ignored - ref. CORBA 2.2 section 20.28 if (!CORBA::Context::PR_is_valid(ctx)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidContext, CORBA::COMPLETED_NO); if (!operation) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_NullStringUnexpected, CORBA::COMPLETED_NO); if (!CORBA::NVList::PR_is_valid(arg_list)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidNVList, CORBA::COMPLETED_NO); if (!CORBA::NamedValue::PR_is_valid(result)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidNamedValue, CORBA::COMPLETED_NO); request = new RequestImpl(this, operation, ctx, arg_list, result);}void CORBA::Object::_create_request(CORBA::Context_ptr ctx, const char* operation, CORBA::NVList_ptr arg_list, CORBA::NamedValue_ptr result, CORBA::ExceptionList_ptr exceptions, CORBA::ContextList_ptr ctxlist, CORBA::Request_out request, CORBA::Flags req_flags){ if( _NP_is_pseudo() ) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_IsPseudoObject, CORBA::COMPLETED_NO); // NB. req_flags is ignored - ref. CORBA 2.2 section 20.28 if (!CORBA::Context::PR_is_valid(ctx)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidContext, CORBA::COMPLETED_NO); if (!operation) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_NullStringUnexpected, CORBA::COMPLETED_NO); if (!CORBA::NVList::PR_is_valid(arg_list)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidNVList, CORBA::COMPLETED_NO); if (!CORBA::NamedValue::PR_is_valid(result)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidNamedValue, CORBA::COMPLETED_NO); if (!CORBA::ExceptionList::PR_is_valid(exceptions)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidExceptionList, CORBA::COMPLETED_NO); if (!CORBA::ContextList::PR_is_valid(ctxlist)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_InvalidContextList, CORBA::COMPLETED_NO); request = new RequestImpl(this, operation, ctx, arg_list, result, exceptions, ctxlist);}CORBA::Request_ptrCORBA::Object::_request(const char* operation) { if( _NP_is_pseudo() ) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_IsPseudoObject, CORBA::COMPLETED_NO); if( !operation ) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_NullStringUnexpected, CORBA::COMPLETED_NO); return new RequestImpl(this, operation);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -