CORBA::Boolean TAO_ChunkInfo::write_previous_chunk_size(TAO_OutputCDR &strm) { if (this->chunk_size_pos_ != 0) { // Calculate the chunk size. CORBA::Long const chunk_size = static_cast<CORBA::Long> (strm.total_length () - this->length_to_chunk_octets_pos_); // This should not happen since this is called in end_chunk() and // the idl generated code always have the matched start_chunk() and // end_chunk() pair. There is always data written to the stream between // the start_chunk() and end_chunk() calls. if (chunk_size == 0) { return false; } // Write the actual chunk size to the reserved chunk size position // in the stream. if (!strm.replace (chunk_size, this->chunk_size_pos_)) { return false; } // We finish writing the actual chunk size, now we need reset the state. this->chunk_size_pos_ = 0; this->length_to_chunk_octets_pos_ = 0; } return true; }
bool TAO::TypeCode::Alias<StringType, TypeCodeType, RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, CORBA::ULong offset) const { // A tk_alias TypeCode has a "complex" parameter list type (see // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of // the CORBA specification), meaning that it must be marshaled into // a CDR encapsulation. // Create a CDR encapsulation. TAO_OutputCDR enc; // Account for the encoded CDR encapsulation length and byte order. // // Aligning on an octet since the next value after the CDR // encapsulation length will always be the byte order octet/boolean // in this case. offset = ACE_Utils::truncate_cast<CORBA::ULong> ( ACE_align_binary (offset + 4, ACE_CDR::OCTET_ALIGN)); return enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0) && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0) && marshal (enc, Traits<StringType>::get_typecode (this->content_type_), ACE_Utils::truncate_cast<CORBA::ULong> ( offset + enc.total_length ())) && cdr << static_cast<CORBA::ULong> (enc.total_length ()) && cdr.write_octet_array_mb (enc.begin ()); }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL bool TAO::TypeCode::Union<char const *, CORBA::TypeCode_ptr const *, TAO::TypeCode::Case<char const *, CORBA::TypeCode_ptr const *> const * const *, TAO::Null_RefCount_Policy>::tao_marshal ( TAO_OutputCDR & cdr, CORBA::ULong offset) const { // A tk_union TypeCode has a "complex" parameter list type (see // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of // the CORBA specification), meaning that it must be marshaled into // a CDR encapsulation. // Create a CDR encapsulation. TAO_OutputCDR enc; // Account for the encoded CDR encapsulation length and byte order. // // Aligning on an octet since the next value after the CDR // encapsulation length will always be the byte order octet/boolean // in this case. offset = ACE_Utils::truncate_cast<CORBA::ULong> ( ACE_align_binary (offset + 4, ACE_CDR::OCTET_ALIGN)); bool const success = (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) && marshal (enc, Traits<char const *>::get_typecode (this->discriminant_type_), ACE_Utils::truncate_cast<CORBA::ULong> ( offset + enc.total_length ())) && (enc << this->default_index_) && (enc << this->ncases_); if (!success) { return false; } // Note that we handle the default case below, too. for (CORBA::ULong i = 0; i < this->ncases_; ++i) { case_type const & c = *this->cases_[i]; if (!c.marshal (enc, offset)) { return false; } } return cdr << static_cast<CORBA::ULong> (enc.total_length ()) && cdr.write_octet_array_mb (enc.begin ()); }
bool TAO_Operation_Details::marshal_args (TAO_OutputCDR &cdr) { try { for (CORBA::ULong i = 0; i != this->num_args_; ++i) { if (!((*this->args_[i]).marshal (cdr))) return false; } // Nothing else to fragment. We're also guaranteed to have // data in the CDR stream since the operation was a marshaling // operation, not a fragmentation operation. cdr.more_fragments (false); #ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION cdr.reset_vt_indirect_maps (); #endif } catch (...) { #ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION cdr.reset_vt_indirect_maps (); #endif throw; } return true; }
void Replication_Service::replicate_request(const FtRtecEventChannelAdmin::Operation& update, RollbackOperation rollback) { TAO_OutputCDR cdr; cdr << update; ACE_Message_Block mb; ACE_CDR::consolidate(&mb, cdr.begin()); #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) FTRT::State state(mb.length(), &mb); #else // If the form of the constructor is not available, we will need // to do the copy manually. First, set the octet sequence length. FTRT::State state; CORBA::ULong length = mb.length (); state.length (length); // Now copy over each byte. char* base = mb.data_block ()->base (); for(CORBA::ULong i = 0; i < length; i++) { state[i] = base[i]; } #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */ replication_strategy->replicate_request( state, rollback, update.object_id); }
bool operator ()( DeviceProxy& device, CORBA::ULong cmd, CORBA::ULong cls ) const { TAO_OutputCDR cdr; device.prepare_data( cdr ) << cmd; cdr << cls; cdr << d_; return device.sendto( cdr.begin() ); }
CORBA::Boolean TAO_ChunkInfo::reserve_chunk_size(TAO_OutputCDR &strm) { // This is called in the start_chunk(). // Reserve the chunk size the first time the start_chunk () is called // if there are several start_chunk () called continuously without // calling end_chunk (). This could happen in the _tao_marshal_state() // in the most derived valuetype. if (this->chunk_size_pos_ == 0) { // Align the wr_ptr before we reserve the space for chunk size. strm.align_write_ptr (ACE_CDR::LONG_SIZE); // Remember begin of the chunk (at chunk size position) that is needed // when we write back actual chunk size to the stream. this->chunk_size_pos_ = strm.current ()->wr_ptr (); // Insert four bytes here as a place-holder, we need to go back // later and write the actual size. if (! strm.write_long (0)) { return 0; } // Remember length before writing chunk data. This is used to calculate // the actual size of the chunk. this->length_to_chunk_octets_pos_ = strm.total_length (); } return 1; }
CORBA::Boolean CORBA::ValueBase::_tao_write_repository_id (TAO_OutputCDR &strm, ACE_CString& id) { #ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION VERIFY_MAP (TAO_OutputCDR, repo_id_map, Repo_Id_Map); char* pos = 0; if (strm.get_repo_id_map ()->get()->find (id, pos) == 0) { if (!strm.write_long (TAO_OBV_GIOP_Flags::Indirection_tag)) { return false; } CORBA::Long offset= -strm.offset (pos); if (TAO_debug_level) { TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id, id %C indirection %d\n"), id.c_str(), offset)); } if (!strm.write_long (offset)) { return false; } } else { if (strm.align_write_ptr (ACE_CDR::LONG_SIZE) != 0) { throw CORBA::INTERNAL (); } if (strm.get_repo_id_map ()->get ()->bind (id, strm.current()->wr_ptr ()) != 0) { throw CORBA::INTERNAL (); } if (TAO_debug_level) { TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id, bound %C - %x\n"), id.c_str (), strm.current()->wr_ptr ())); } if (! strm.write_string (id.c_str ())) { return false; } } #else if (! strm.write_string (id.c_str ())) { return 0; } #endif return 1; }
void Logging::commit_to_task() { // Broker::EventLog, that is not EventLog if ( msg.get().format.in() && *msg.get().format.in() != 0 ) { TAO_OutputCDR cdr; cdr << msg.get(); ACE_Message_Block * mb = cdr.begin()->duplicate(); mb->msg_type( constants::MB_EVENTLOG ); iTask::instance()->putq( mb ); } }
bool TAO::TypeCode::Struct<StringType, TypeCodeType, FieldArrayType, RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, CORBA::ULong offset) const { // A tk_struct TypeCode has a "complex" parameter list type (see // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of // the CORBA specification), meaning that it must be marshaled into // a CDR encapsulation. // Create a CDR encapsulation. TAO_OutputCDR enc; // Account for the encoded CDR encapsulation length and byte order. // // Aligning on an octet since the next value after the CDR // encapsulation length will always be the byte order octet/boolean // in this case. offset = ACE_align_binary (offset + 4, ACE_CDR::OCTET_ALIGN); bool const success = (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) && (enc << this->nfields_); if (!success) return false; Struct_Field<StringType, TypeCodeType> const * const begin = &this->fields_[0]; Struct_Field<StringType, TypeCodeType> const * const end = begin + this->nfields_; for (Struct_Field<StringType, TypeCodeType> const * i = begin; i != end; ++i) { Struct_Field<StringType, TypeCodeType> const & field = *i; if (!(enc << TAO_OutputCDR::from_string ( Traits<StringType>::get_string (field.name), 0)) || !marshal (enc, Traits<StringType>::get_typecode (field.type), offset + enc.total_length ())) return false; } return cdr << static_cast<CORBA::ULong> (enc.total_length ()) && cdr.write_octet_array_mb (enc.begin ()); }
void CORBA::SystemException::_tao_encode (TAO_OutputCDR &cdr) const { if (cdr.write_string (this->_rep_id ()) && cdr.write_ulong (this->minor ()) && cdr.write_ulong (this->completed ())) { return; } throw ::CORBA::MARSHAL (); }
void Delivery_Request::marshal (TAO_OutputCDR & cdr) { if (this->delivery_type_ != 0) { cdr.write_octet (this->delivery_type_); CORBA::ULong dest_count = ACE_Utils::truncate_cast<CORBA::ULong> (this->destination_id_.size ()); cdr.write_ulong (dest_count); for (size_t ndest = 0; ndest < dest_count; ++ ndest) { cdr.write_ulong (this->destination_id_ [ndest]); } } }
CORBA::Boolean operator<< (TAO_OutputCDR & cdr, CORBA::Principal * x) { if (x != 0) { CORBA::ULong length = x->id.length (); cdr.write_long (length); cdr.write_octet_array (x->id.get_buffer (), length); } else { cdr.write_ulong (0); } return (CORBA::Boolean) cdr.good_bit (); }
// this method is called by the IDL generated _tao_marshal_state() method. CORBA::Boolean TAO_ChunkInfo::end_chunk(TAO_OutputCDR &strm) { if (this->chunking_) { // Write actual chunk size at the reserved chunk size place. if (! this->write_previous_chunk_size(strm)) { return false; } // Write an end tag which is negation of value_nesting_level_. if (! strm.write_long(- this->value_nesting_level_)) { return false; } // -- this->value_nesting_level_; if ( -- this->value_nesting_level_ == 0 ) { // ending chunk for outermost value this->chunking_ = 0; } } return true; }
void Task::dispatch_command( ACE_Message_Block * mblk ) { CORBA::ULong cmd = marshal<CORBA::ULong>::get( mblk ); //SESSION_INITIALIZE, MB_COMMAND ); acewrapper::scoped_mutex_t<> lock( mutex_ ); for ( map_type::iterator it = device_proxies_.begin(); it != device_proxies_.end(); ++it ) { TAO_OutputCDR cdr; it->second->prepare_data( cdr ) << cmd; const ACE_Message_Block * mb = cdr.begin(); logger log; log.dump( mb->length(), mb->rd_ptr() ); log << " sendto: " << it->first; it->second->sendto( cdr.begin() ); } }
void TAO_AMH_DSI_Response_Handler::gateway_exception_reply ( CORBA::ULong reply_status, TAO_OutputCDR & encap) { // for this to be effective, ACE & TAO must be built with // ACE_ENABLE_SWAP_ON_WRITE defined in ace/config.h this->_tao_out.reset_byte_order (encap.byte_order ()); // This reply path handles only user exceptions. switch (reply_status) { case TAO_AMI_REPLY_USER_EXCEPTION: this->reply_status_ = GIOP::USER_EXCEPTION; break; case TAO_AMI_REPLY_SYSTEM_EXCEPTION: this->reply_status_ = GIOP::SYSTEM_EXCEPTION; break; // TODO: we don't handle location forward at this moment. // need to be addressed later. // //case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD: // this->exception_type_ = TAO_GIOP_LOCATION_FORWARD; // break; } try { this->_tao_rh_init_reply (); // We know nothing about this exception, so we marshal it as a block // of bytes. The outgoing stream's byte order has already been matched // to the original source of the reply. this->_tao_out.write_char_array (encap.buffer (), encap.length ()); // This will prevent the marshaling of any parameters into this reply. // this->sent_gateway_exception_ = 1; this->_tao_rh_send_reply (); } catch (const CORBA::Exception &) { // TODO: } }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL bool TAO::TypeCode::Enum<char const *, char const * const *, TAO::Null_RefCount_Policy>::tao_marshal ( TAO_OutputCDR & cdr, CORBA::ULong) const { // A tk_enum TypeCode has a "complex" parameter list type (see // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of // the CORBA specification), meaning that it must be marshaled into // a CDR encapsulation. // Create a CDR encapsulation. TAO_OutputCDR enc; bool const success = (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) && (enc << this->nenumerators_); if (!success) return false; char const * const * const begin = &this->enumerators_[0]; char const * const * const end = begin + this->nenumerators_; for (char const * const * i = begin; i != end; ++i) { char const * const & enumerator = *i; if (!(enc << TAO_OutputCDR::from_string ( Traits<char const *>::get_string (enumerator), 0))) return false; } return cdr << static_cast<CORBA::ULong> (enc.total_length ()) && cdr.write_octet_array_mb (enc.begin ()); }
CORBA::Boolean operator<< (TAO_OutputCDR& cdr, ECM_Data& x) { // We are a little careless about error checking in this routine, // because one the CDR gets the error bit on it is never disabled. CORBA::ULong count = x.inventory.current_size (); if (cdr << x.description.in () && cdr << count ) { for (ECM_Data::Inventory::ITERATOR i = x.inventory.begin (); i != x.inventory.end () && cdr.good_bit (); ++i) { const ECM_Data::Inventory::ENTRY& v = *i; cdr << v.ext_id_; cdr << v.int_id_; } } return cdr.good_bit (); }
int Task::handle_timeout( const ACE_Time_Value& tv, const void * ) { do { ACE_Message_Block * mb = new ACE_Message_Block( sizeof( tv ) ); *reinterpret_cast< ACE_Time_Value *>(mb->wr_ptr()) = tv; mb->wr_ptr( sizeof(tv) ); putq( mb ); } while(0); do { TAO_OutputCDR cdr; cdr << constants::SESSION_QUERY_DEVICE; cdr << TOFConstants::ClassID_AnalyzerDeviceData; cdr << TOFConstants::ClassID_MSMethod; cdr << GlobalConstants::EOR; ACE_Message_Block * mb = cdr.begin()->duplicate(); mb->msg_type( constants::MB_QUERY_DEVICE ); this->putq( mb ); } while(0); return 0; }
bool Lorica::EvaluatorBase::evaluate_exception(const char *, PortableServer::POA_ptr, const char *ex_type, TAO_InputCDR &incoming, TAO_OutputCDR &encap ) const { const ACE_Message_Block *buffer = incoming.start(); encap << ex_type; encap.write_octet_array_mb (buffer); return true; }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL bool TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::tao_marshal ( TAO_OutputCDR & cdr, CORBA::ULong) const { // A tk_objref TypeCode has a "complex" parameter list type (see // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of // the CORBA specification), meaning that it must be marshaled into // a CDR encapsulation. // Create a CDR encapsulation. TAO_OutputCDR enc; return enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0) && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0) && cdr << static_cast<CORBA::ULong> (enc.total_length ()) && cdr.write_octet_array_mb (enc.begin ()); }
int ACE_TMAIN (int, ACE_TCHAR *[]) { // setup mb's char buf[1024]; m1=new ACE_Message_Block(1024); ACE_OS::memset(buf,'1',512); m1->copy(buf,512); m2=new ACE_Message_Block(1024); ACE_OS::memset(buf,'2',512); m2->copy(buf,512); m3=new ACE_Message_Block(1024); ACE_OS::memset(buf,'3',512); m3->copy(buf,512); m1->cont(m2); m2->cont(m3); dump("expect 1,1,1"); ACE_Message_Block* m = ACE_Message_Block::duplicate (m1); dump("expect 2,2,2"); { TAO_OutputCDR cdr; cdr.write_octet_array_mb(m1); dump("expect 3,3,3"); // that's what I expected, anyway ACE_DEBUG ((LM_INFO, "total cdr length is %u\n", static_cast<u_int> (cdr.total_length()))); } dump("expect 2,2,2"); // that's what I expected, anyway ACE_Message_Block::release (m); dump("expect 1,1,1"); // that's what I expected, anyway ACE_Message_Block::release (m1); return 0; }
void Routing_Slip::marshal (TAO_OutputCDR & cdr) { size_t request_count = this->delivery_requests_.size(); cdr.write_ulong ( ACE_Utils::truncate_cast<CORBA::ULong> (request_count - this->complete_requests_)); for (size_t nreq = 0; nreq < request_count; ++nreq) { Delivery_Request * request = this->delivery_requests_[nreq].get (); if (request != 0) { request->marshal (cdr); } } }
static int test_write (TAO_OutputCDR &cdr, int n) { CORBA::Long l = 0xdeadbeef; for (int i = 0; i < n; ++i) { if (cdr.write_long (l) == 0) ACE_ERROR_RETURN ((LM_ERROR, "write_long[%d] failed\n", i), 1); } return 0; }
int TAO_DIOP_Transport::send_message (TAO_OutputCDR &stream, TAO_Stub *stub, TAO_ServerRequest *request, TAO_Message_Semantics message_semantics, ACE_Time_Value *max_wait_time) { // Format the message in the stream first if (this->messaging_object ()->format_message (stream, stub, request) != 0) { return -1; } // Strictly speaking, should not need to loop here because the // socket never gets set to a nonblocking mode ... some Linux // versions seem to need it though. Leaving it costs little. // This guarantees to send all data (bytes) or return an error. ssize_t const n = this->send_message_shared (stub, message_semantics, stream.begin (), max_wait_time); if (n == -1) { if (TAO_debug_level) TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - DIOP_Transport::send_message, ") ACE_TEXT ("closing transport %d after fault %p\n"), this->id (), ACE_TEXT ("send_message ()\n"))); return -1; } return 1; }
int TAO_Log_Constraint_Visitor::visit_union_pos ( ETCL_Union_Pos *union_pos) { try { if (union_pos->union_value ()->accept (this) == 0) { TAO_ETCL_Literal_Constraint disc_val; this->queue_.dequeue_head (disc_val); TAO_DynUnion_i dyn_union; dyn_union.init (this->current_member_.in ()); CORBA::TypeCode_var tc = this->current_member_->type (); switch (disc_val.expr_type ()) { case ETCL_INTEGER: case ETCL_SIGNED: case ETCL_UNSIGNED: { CORBA::Any disc_any; CORBA::TypeCode_var disc_tc = tc->discriminator_type (); CORBA::TCKind disc_kind = TAO_DynAnyFactory::unalias (disc_tc.in ()); switch (disc_kind) { case CORBA::tk_boolean: disc_any <<= CORBA::Any::from_boolean ((CORBA::Boolean) disc_val); break; case CORBA::tk_short: disc_any <<= (CORBA::Short) ((CORBA::Long) disc_val); break; case CORBA::tk_ushort: disc_any <<= (CORBA::UShort) ((CORBA::ULong) disc_val); break; case CORBA::tk_long: disc_any <<= (CORBA::Long) disc_val; break; case CORBA::tk_ulong: disc_any <<= (CORBA::ULong) disc_val; break; case CORBA::tk_enum: { TAO_OutputCDR cdr; cdr.write_ulong ((CORBA::ULong) disc_val); TAO_InputCDR in_cdr (cdr); TAO::Unknown_IDL_Type *unk = 0; ACE_NEW_RETURN (unk, TAO::Unknown_IDL_Type (disc_tc.in (), in_cdr), -1); disc_any.replace (unk); break; } // @@@ (JP) I don't think ETCL handles 64-bit // integers at this point, and I also think that // chars and/or wchars will just come out in the // constraint as (w)strings of length 1. case CORBA::tk_longlong: case CORBA::tk_ulonglong: case CORBA::tk_char: case CORBA::tk_wchar: default: return -1; } DynamicAny::DynAny_var dyn_any = TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any &> ( disc_tc.in (), disc_any); dyn_union.set_discriminator (dyn_any.in ()); DynamicAny::DynAny_var u_member = dyn_union.member (); this->current_member_ = u_member->to_any (); break; } case ETCL_STRING: { const char *name = (const char *) disc_val; CORBA::ULong count = tc->member_count (); const char *member_name = 0; CORBA::ULong i = 0; for (i = 0; i < count; ++i) { member_name = tc->member_name (i); if (ACE_OS::strcmp (name, member_name) == 0) { break; } } // If there's no match, member_label will throw // CORBA::TypeCode::Bounds and the catch block will // return -1; this->current_member_ = tc->member_label (i); break; } // The TAO_ETCL_Union_Value that was put on the queue // shouldn't have any other type. default: return -1; } ETCL_Constraint *nested = union_pos->component (); // If there's no nested component, then we just want the // union member value on the queue. Otherwise, we want // the member value in current_member_ while we visit // the nested component. if (nested == 0) { TAO_ETCL_Literal_Constraint lit (this->current_member_.ptr ()); this->queue_.enqueue_head (lit); return 0; } else { return nested->accept (this); } } else { return -1; } } catch (const CORBA::Exception&) { return -1; } }
void TAO_UnionDef_i::fetch_label (const ACE_Configuration_Section_Key member_key, CORBA::UnionMember &member) { ACE_Configuration::VALUETYPE vt; this->repo_->config ()->find_value (member_key, "label", vt); if (vt == ACE_Configuration::STRING) { member.label <<= CORBA::Any::from_octet (0); return; } u_int value = 0; this->repo_->config ()->get_integer_value (member_key, "label", value); CORBA::TypeCode_var tc = this->discriminator_type_i (); CORBA::TCKind kind = tc->kind (); switch (kind) { case CORBA::tk_char: member.label <<= CORBA::Any::from_char (static_cast<CORBA::Char> (value)); break; case CORBA::tk_wchar: member.label <<= CORBA::Any::from_wchar (static_cast<CORBA::WChar> (value)); break; case CORBA::tk_boolean: member.label <<= CORBA::Any::from_boolean (static_cast<CORBA::Boolean> (value)); break; case CORBA::tk_short: member.label <<= static_cast<CORBA::Short> (value); break; case CORBA::tk_ushort: member.label <<= static_cast<CORBA::UShort> (value); break; case CORBA::tk_long: member.label <<= static_cast<CORBA::Long> (value); break; case CORBA::tk_ulong: member.label <<= static_cast<CORBA::ULong> (value); break; case CORBA::tk_longlong: member.label <<= static_cast<CORBA::LongLong> (value); break; case CORBA::tk_ulonglong: member.label <<= static_cast<CORBA::ULongLong> (value); break; case CORBA::tk_enum: { TAO_OutputCDR cdr; cdr.write_ulong (static_cast<CORBA::ULong> (value)); TAO_InputCDR in_cdr (cdr); TAO::Unknown_IDL_Type *impl = 0; ACE_NEW (impl, TAO::Unknown_IDL_Type (tc.in (), in_cdr)); member.label.replace (impl); break; } default: break; } }
int ECMS_Driver::supplier_task (Test_Supplier *supplier, void* /* cookie */) { try { ACE_Time_Value tv (0, this->event_period_); CORBA::ULong n = this->event_size_; ECM_IDLData::Info info; info.mobile_name = CORBA::string_dup ("test"); info.mobile_speed = 1; info.trajectory.length (n); ECM_Data other; other.description = CORBA::string_dup ("some data"); for (CORBA::ULong j = 0; j < n; ++j) { info.trajectory[j].x = j; info.trajectory[j].y = j * j; other.inventory.bind (j, j + 1); } ACE_DEBUG ((LM_DEBUG, "The inventory contains (%d) elements\n", other.inventory.current_size ())); // We have to make it big enough so we get a contiguous block, // otherwise the octet sequence will not work correctly. // NOTE: we could pre-allocate enough memory in the CDR stream // but we want to show that chaining works! TAO_OutputCDR cdr; CORBA::Boolean byte_order = TAO_ENCAP_BYTE_ORDER; cdr << CORBA::Any::from_boolean (byte_order); // The typecode name standard, the encode method is not (in // general the CDR interface is not specified). if (!(cdr << info)) throw CORBA::MARSHAL (); // Here we marshall a non-IDL type. cdr << other; if (!cdr.good_bit ()) ACE_ERROR ((LM_ERROR, "Problem marshalling C++ data\n")); const ACE_Message_Block* mb = cdr.begin (); // NOTE: total_length () return the length of the complete // chain. CORBA::ULong mblen = cdr.total_length (); for (CORBA::Long i = 0; i < this->event_count_; ++i) { RtecEventComm::EventSet event (1); event.length (1); event[0].header.source = supplier->supplier_id (); event[0].header.ttl = 1; ACE_hrtime_t t = ACE_OS::gethrtime (); ORBSVCS_Time::hrtime_to_TimeT (event[0].header.creation_time, t); if (i == static_cast<CORBA::Long> (this->event_count_) - 1) event[0].header.type = ACE_ES_EVENT_SHUTDOWN; else if (i % 2 == 0) event[0].header.type = this->event_a_; else event[0].header.type = this->event_b_; // We use replace to minimize the copies, this should result // in just one memory allocation; #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) event[0].data.payload.replace (mblen, mb); #else // If the replace method is not available, we will need // to do the copy manually. First, set the octet sequence length. event[0].data.payload.length (mblen); // Now copy over each byte. char* base = mb->data_block ()->base (); for(CORBA::ULong i = 0; i < mblen; i++) { event[0].data.payload[i] = base[i]; } #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */ supplier->consumer_proxy ()->push(event); // ACE_DEBUG ((LM_DEBUG, "(%t) supplier push event\n")); ACE_OS::sleep (tv); } } catch (const CORBA::SystemException& sys_ex) { sys_ex._tao_print_exception ("SYS_EX"); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("NON SYS EX"); } return 0; }
void CORBA::NVList::_tao_encode (TAO_OutputCDR &cdr, int flag) { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); if (this->incoming_ != 0) { if (this->max_ == 0) { // The list is empty aggressively reduce copies and just send // the CDR stream, we assume that // TAO_Server_Request::init_reply // has inserted appropriated padding already to make this // operation correct cdr.write_octet_array_mb (this->incoming_->start ()); return; } // Then unmarshal each "in" and "inout" parameter. ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); for (i.first (); !i.done (); i.advance ()) { CORBA::NamedValue_ptr *item = 0; (void) i.next (item); CORBA::NamedValue_ptr nv = *item; if (ACE_BIT_DISABLED (nv->flags (), flag)) { continue; } if (TAO_debug_level > 3) { const char* arg = nv->name (); if (arg == 0) { arg = "(nil)"; } TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("NVList::_tao_encode - parameter <%C>\n"), arg)); } CORBA::TypeCode_ptr tc = nv->value ()->_tao_get_typecode (); (void) TAO_Marshal_Object::perform_append (tc, this->incoming_, &cdr); } delete this->incoming_; this->incoming_ = 0; return; } // The list is already evaluated, we cannot optimize the copies, go // ahead with the slow way to do things. // Then marshal each "in" and "inout" parameter. ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); for (i.first (); !i.done (); i.advance ()) { CORBA::NamedValue_ptr *item = 0; (void) i.next (item); CORBA::NamedValue_ptr nv = *item; if (ACE_BIT_DISABLED (nv->flags (), flag)) { continue; } nv->value ()->impl ()->marshal_value (cdr); } }
CORBA::Boolean TAO_Stub::marshal (TAO_OutputCDR &cdr) { // do as many outside of locked else-branch as posssible // STRING, a type ID hint if ((cdr << this->type_id.in()) == 0) return 0; if ( ! this->forward_profiles_perm_) { const TAO_MProfile& mprofile = this->base_profiles_; CORBA::ULong const profile_count = mprofile.profile_count (); if ((cdr << profile_count) == 0) return 0; // @@ The MProfile should be locked during this iteration, is there // anyway to achieve that? for (CORBA::ULong i = 0; i < profile_count; ++i) { const TAO_Profile* p = mprofile.get_profile (i); if (p->encode (cdr) == 0) return 0; } } else { ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->profile_lock_, 0)); if (TAO_debug_level > 5) { TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - Stub::marshal, acquired ") ACE_TEXT ("profile lock this = 0x%x\n"), this)); } ACE_ASSERT(this->forward_profiles_ !=0); // paranoid - in case of FT the basic_profiles_ would do, too, // but might be dated const TAO_MProfile& mprofile = this->forward_profiles_perm_ ? *(this->forward_profiles_perm_) : this->base_profiles_; CORBA::ULong const profile_count = mprofile.profile_count (); if ((cdr << profile_count) == 0) return 0; // @@ The MProfile should be locked during this iteration, is there // anyway to achieve that? for (CORBA::ULong i = 0; i < profile_count; ++i) { const TAO_Profile* p = mprofile.get_profile (i); if (p->encode (cdr) == 0) return 0; } // release ACE_Lock } return (CORBA::Boolean) cdr.good_bit (); }