[omniORB] DynAny and sequence<octet>

Renzo Tomaselli renzo.tomaselli@tecnotp.it
Wed, 13 Oct 1999 10:55:07 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0017_01BF1569.69482B70
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0018_01BF1569.69482B70"


------=_NextPart_001_0018_01BF1569.69482B70
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Sai-Lai,
            I'm attaching a little replacement for =
DynSequenceImpl::copy_to/from methods. This tries to optimize handling =
octet sequences by avoiding the actual byte-by-byte processing through =
normal DynAny subcomponents.
This optimization should work since I noticed as tcParser::copyTo/From =
methods are already optimized for this operation (they do memcpy the =
entire sequence across streams).
For bridge handling of anys through DynAnys byte-by-byte processing is =
definitely a no-go. The proposed patch allows to fetch/insert DynAny =
subcomponents through anys when a recursive scan detects such sequences; =
then such anys can by reversed to streams or whatever else the bridge =
requires.
Since I didn't check this patch yet, there might be side-effects, I =
don't know.
Comments are much welcome, thanks

                                             Renzo Tomaselli     =20
-------------------------------------------------------------------------=
--
TecnoTP s.n.c. Special Information System Design
Maso Pelauchi I38050 Ronchi Valsugana,  Trento TN  ITALY
Tel. +39 0461 773164      Fax. +39 0461 771514
e-mail: renzo.tomaselli@tecnotp.it  =20
-------------------------------------------------------------------------=
--

------=_NextPart_001_0018_01BF1569.69482B70
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Sai-Lai,</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; I'm=20
attaching a little replacement for DynSequenceImpl::copy_to/from =
methods. This=20
tries to optimize handling octet sequences by avoiding the actual =
byte-by-byte=20
processing through normal DynAny subcomponents.</FONT></DIV>
<DIV><FONT size=3D2>This optimization should work since I noticed as=20
tcParser::copyTo/From methods are already optimized for this operation =
(they do=20
memcpy the entire sequence across streams).</FONT></DIV>
<DIV><FONT size=3D2>For bridge handling of anys through DynAnys =
byte-by-byte=20
processing is definitely a no-go. The proposed patch allows to =
fetch/insert=20
DynAny subcomponents through anys when a recursive scan detects such =
sequences;=20
then such anys can by reversed to streams or whatever else the bridge=20
requires.</FONT></DIV>
<DIV><FONT size=3D2>Since I didn't check this patch yet, there might be=20
side-effects, I don't know.</FONT></DIV>
<DIV><FONT size=3D2>Comments are much welcome, thanks</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Renzo Tomaselli&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>---------------------------------------------------------------------=
------<BR>TecnoTP=20
s.n.c. Special Information System Design<BR>Maso Pelauchi I38050 Ronchi=20
Valsugana,&nbsp; Trento TN&nbsp; ITALY<BR>Tel. +39 0461=20
773164&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax. +39 0461 771514<BR>e-mail: <A=20
href=3D"mailto:renzo.tomaselli@tecnotp.it">renzo.tomaselli@tecnotp.it</A>=
&nbsp;&nbsp;=20
<BR>---------------------------------------------------------------------=
------</FONT></DIV></BODY></HTML>

------=_NextPart_001_0018_01BF1569.69482B70--

------=_NextPart_000_0017_01BF1569.69482B70
Content-Type: text/plain;
	name="dyn.cpp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="dyn.cpp"

//////////////
// internal //
//////////////

int
DynSequenceImpl::copy_to(MemBufferedStream& mbs)
{
  // Write the length of the sequence. This can't fail.
  CORBA::ULong(pd_n_components) >>=3D mbs;

  // Copy the elements.

  if (tc()->NP_content_type()->NP_kind() =3D=3D CORBA::tk_octet) {

	// optimization for octet sequences

	pd_buf.rewind_in_mkr();
	try {
		tcParser tcp(pd_buf, tc());
		tcp.copyTo(mbs, 0);
	}
	catch(CORBA::MARSHAL&) {
		return 0;
	}
	return 1;
  }

  // else take the normal way

  return DynAnyConstrBase::copy_to(mbs);
}


int
DynSequenceImpl::copy_from(MemBufferedStream& mbs)
{
  CORBA::ULong len;
  try {
    // Read the length of the sequence.
    len <<=3D mbs;
  }
  catch(CORBA::MARSHAL&) {
    return 0;
  }
  if (tc()->NP_content_type()->NP_kind() =3D=3D CORBA::tk_octet) {

	// optimization for octet sequences; avoid creating an useless =
pd_components array

	pd_buf.rewind_inout_mkr();
	pd_read_index =3D 0;
	try {
		tcParser tcp(pd_buf, tc());
		tcp.copyFrom(mbs, 0);
    }
	catch(CORBA::MARSHAL&) {
		pd_buf.rewind_inout_mkr();
		pd_n_in_buf =3D pd_n_really_in_buf =3D 0;
		return 0;
	}
	pd_n_really_in_buf =3D pd_n_in_buf =3D pd_first_in_comp =3D =
pd_n_components =3D len;
	return 1;
  }

  // else take the normal way

  setNumComponents(len);
  return DynAnyConstrBase::copy_from(mbs);
}


------=_NextPart_000_0017_01BF1569.69482B70--