本文整理汇总了C++中TAO_OutputCDR::total_length方法的典型用法代码示例。如果您正苦于以下问题:C++ TAO_OutputCDR::total_length方法的具体用法?C++ TAO_OutputCDR::total_length怎么用?C++ TAO_OutputCDR::total_length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAO_OutputCDR
的用法示例。
在下文中一共展示了TAO_OutputCDR::total_length方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: marshal
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 ());
}
示例2: marshal
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 ());
}
示例3: marshal
bool
TAO::TypeCode::Value<StringType,
TypeCodeType,
FieldArrayType,
RefCountPolicy>::tao_marshal (
TAO_OutputCDR & cdr,
CORBA::ULong offset) const
{
// A tk_value 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->type_modifier_)
&& marshal (enc,
Traits<StringType>::get_typecode (this->concrete_base_),
offset + enc.total_length ())
&& (enc << this->nfields_);
if (!success)
return false;
Value_Field<StringType, TypeCodeType> const * const begin =
&this->fields_[0];
Value_Field<StringType, TypeCodeType> const * const end =
begin + this->nfields_;
for (Value_Field<StringType, TypeCodeType> const * i = begin; i != end; ++i)
{
Value_Field<StringType, TypeCodeType> const & field = *i;
if (!(enc << Traits<StringType>::get_string (field.name))
|| !marshal (enc,
Traits<StringType>::get_typecode (field.type),
offset + enc.total_length ())
|| !(enc << field.visibility))
return false;
}
return
cdr << static_cast<CORBA::ULong> (enc.total_length ())
&& cdr.write_octet_array_mb (enc.begin ());
}
示例4:
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;
}
示例5:
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 ());
}
示例6:
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 ());
}
示例7: ACE_TMAIN
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;
}
示例8: tv
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)
//.........这里部分代码省略.........
示例9:
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
bool
TAO::TypeCode::Struct<char const *,
CORBA::TypeCode_ptr const *,
TAO::TypeCode::Struct_Field<char const *,
CORBA::TypeCode_ptr const *> const *,
TAO::Null_RefCount_Policy>::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_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))
&& (enc << this->nfields_);
if (!success)
return false;
Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * const begin =
&this->fields_[0];
Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * const end =
begin + this->nfields_;
for (Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * i =
begin;
i != end;
++i)
{
Struct_Field<char const *, CORBA::TypeCode_ptr const *> const & field =
*i;
if (!(enc << TAO_OutputCDR::from_string (
Traits<char const *>::get_string (field.name), 0))
|| !marshal (enc,
Traits<char const *>::get_typecode (field.type),
ACE_Utils::truncate_cast<CORBA::ULong> (
offset + enc.total_length ())))
return false;
}
return
cdr << static_cast<CORBA::ULong> (enc.total_length ())
&& cdr.write_octet_array_mb (enc.begin ());
}
示例10:
int
TAO::SSLIOP::Acceptor::create_shared_profile (const TAO::ObjectKey &object_key,
TAO_MProfile &mprofile,
CORBA::Short priority)
{
size_t index = 0;
TAO_Profile *pfile = 0;
TAO_SSLIOP_Profile *ssliop_profile = 0;
// First see if <mprofile> already contains a SSLIOP profile.
for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i)
{
pfile = mprofile.get_profile (i);
if (pfile->tag () == IOP::TAG_INTERNET_IOP)
{
ssliop_profile = dynamic_cast<TAO_SSLIOP_Profile *> (pfile);
if (ssliop_profile == 0)
return -1;
break;
}
}
// If <mprofile> doesn't contain SSLIOP_Profile, we need to create
// one.
if (ssliop_profile == 0)
{
// @@ We need to create an SSLIOP::SSL component for the object
// we're creating an MProfile for. This will allow us to
// properly embed secure invocation policies in the generated
// IOR, i.e. secure invocation policies on a per-object
// basis, rather than on a per-endpoint basis. If no secure
// invocation policies have been set then we should use the
// below default SSLIOP::SSL component.
ACE_NEW_RETURN (ssliop_profile,
TAO_SSLIOP_Profile (this->hosts_[0],
this->addrs_[0].get_port_number (),
object_key,
this->addrs_[0],
this->version_,
this->orb_core_,
&(this->ssl_component_)),
-1);
TAO_SSLIOP_Endpoint * const ssliop_endp =
dynamic_cast<TAO_SSLIOP_Endpoint *> (ssliop_profile->endpoint ());
if (!ssliop_endp)
return -1;
ssliop_endp->priority (priority);
ssliop_endp->iiop_endpoint ()->priority (priority);
if (mprofile.give_profile (ssliop_profile) == -1)
{
ssliop_profile->_decr_refcnt ();
ssliop_profile = 0;
return -1;
}
if (this->orb_core_->orb_params ()->std_profile_components () != 0)
{
ssliop_profile->tagged_components ().set_orb_type (TAO_ORB_TYPE);
TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager();
if (csm)
csm->set_codeset(ssliop_profile->tagged_components());
IOP::TaggedComponent component;
component.tag = ::SSLIOP::TAG_SSL_SEC_TRANS;
// @@???? Check this code, only intended as guideline...
TAO_OutputCDR cdr;
cdr << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
// @@ We need to create an SSLIOP::SSL component for the
// object we're creating an MProfile for. This will
// allow us to properly embed secure invocation policies
// in the generated IOR, i.e. secure invocation policies
// on a per-object basis, rather than on a per-endpoint
// basis. If no secure invocation policies have been set
// then we should use the below default SSLIOP::SSL
// component.
cdr << this->ssl_component_;
// TAO extension, replace the contents of the octet sequence with
// the CDR stream
CORBA::ULong length = cdr.total_length ();
component.component_data.length (length);
CORBA::Octet *buf = component.component_data.get_buffer ();
for (const ACE_Message_Block *i = cdr.begin ();
i != 0;
i = i->cont ())
{
ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
buf += i->length ();
}
ssliop_profile->tagged_components ().set_component (component);
}
index = 1;
//.........这里部分代码省略.........
示例11:
/*static*/ CORBA::Boolean
PG_Utils::set_tagged_component (
PortableGroup::ObjectGroup *&ior,
PortableGroup::TagGroupTaggedComponent &tg)
{
if (ior->_stubobj () == 0)
return 0;
// We need to apply the property for every profile in the IOR
TAO_MProfile &tmp_pfiles =
ior->_stubobj ()->base_profiles ();
// Create the output CDR stream
TAO_OutputCDR cdr;
IOP::TaggedComponent tagged_components;
tagged_components.tag = IOP::TAG_FT_GROUP;
// Encode the property in to the tagged_components
CORBA::Boolean retval =
PG_Utils::encode_properties (cdr,
tg);
if (retval == 0)
return retval;
// Get the length of the CDR stream
CORBA::ULong length = static_cast<CORBA::ULong> (cdr.total_length ());
// Set the length
tagged_components.component_data.length (length);
// Get the pointer to the underlying buffer
CORBA::Octet *buf =
tagged_components.component_data.get_buffer ();
for (const ACE_Message_Block *i = cdr.begin ();
i != 0;
i = i->cont ())
{
ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
buf += i->length ();
}
const IOP::TaggedComponent &tmp_tc = tagged_components;
// Get the profile count.
CORBA::ULong count =
ior->_stubobj ()->base_profiles ().profile_count ();
// Go through every profile and set the TaggedComponent field
for (CORBA::ULong p_idx = 0; p_idx < count ; ++p_idx)
{
// Get the tagged components in the profile
TAO_Tagged_Components &tag_comp =
tmp_pfiles.get_profile (p_idx)->tagged_components ();
// Finally set the <tagged_component> in the
// <TAO_Tagged_Component>
tag_comp.set_component (tmp_tc);
}
// Success
return 1;
}
示例12: size
break;
}
}
/*
cerr << "OUT: "
<< e.header.fixed_header.event_type.domain_name << "::"
<< e.header.fixed_header.event_type.type_name << " "
<< e.header.fixed_header.event_name << endl;
*/
TAO_OutputCDR cdr;
cdr << e;
CORBA::ULong size (ACE_Utils::truncate_cast<CORBA::ULong> (cdr.total_length ()));
OctetSeq seq (size);
seq.length (size);
char* buffer = reinterpret_cast<char*> (seq.get_buffer ());
{
char* buf = buffer;
for (ACE_Message_Block const* mb = cdr.begin ();
mb != 0;
mb = mb->cont ())
{
ACE_OS::memcpy (buf, mb->rd_ptr (), mb->length ());
buf += mb->length ();
示例13: ftr
void
ReplicaController::send_reply (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
FT::FTRequestServiceContext_var ftr (
extract_context (ri));
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Sending reply for %s with rid %i\n",
ftr->client_id.in (),
ftr->retention_id));
// Prepare reply for logging.
CORBA::Any_var result =
ri->result ();
TAO_OutputCDR cdr;
result->impl ()->marshal_value (cdr);
Dynamic::ParameterList_var pl =
ri->arguments ();
CORBA::ULong len = pl->length ();
for (CORBA::ULong index = 0; index != len ; ++index)
{
//@@ No chance for PARAM_OUT
if ((*pl)[index].mode == CORBA::PARAM_INOUT)
{
(*pl)[index].argument.impl ()->marshal_value (cdr);
}
}
CORBA::OctetSeq_var reply;
ACE_NEW (reply.out (), CORBA::OctetSeq (cdr.total_length ()));
reply->length (cdr.total_length ());
CORBA::Octet* buf = reply->get_buffer ();
// @@ What if this throws an exception?? We don't have any way to
// check whether this succeeded
for (ACE_Message_Block const* mb = cdr.begin ();
mb != 0;
mb = mb->cont ())
{
ACE_OS::memcpy (buf, mb->rd_ptr (), mb->length ());
buf += mb->length ();
}
// Logging the reply and state update.
//
// First send message to members.
//
{
// Extract state update.
CORBA::OctetSeq_var oid = ri->object_id ();
PortableInterceptor::AdapterName_var an = ri->adapter_name ();
CORBA::Any_var state = ri->get_slot (state_slot_id ());
CORBA::TypeCode_var tc = state->type ();
if (tc->kind () == CORBA::tk_null)
{
ACE_DEBUG ((LM_DEBUG, "Slot update is void\n"));
PortableServer::POA_var poa = resolve_poa (an.in ());
PortableServer::ServantBase_var servant =
poa->id_to_servant (oid.in ());
Checkpointable* target =
dynamic_cast<Checkpointable*> (servant.in ());
if (target)
{
CORBA::Any_var tmp = target->get_state ();
if (tmp.ptr () != 0) state = tmp._retn ();
}
}
TAO_OutputCDR cdr;
cdr << oid.in ();
cdr << an.in ();
cdr << ftr->client_id.in ();
cdr << ftr->retention_id;
cdr << reply.in ();
cdr << state.in ();
size_t size = cdr.total_length ();
//.........这里部分代码省略.........