Working with sequence containing object reference
"Decoster Jean Louis" <[email protected]> Mon, 7 Aug 2006 08:52:22 +0200
| Newsgroups | gmane.comp.corba.orbacus |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============90905031041597906==
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C6B9EE.08B62EC5"
Content-class: urn:content-classes:message
This is a multi-part message in MIME format.
------_=_NextPart_001_01C6B9EE.08B62EC5
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,=20
I am working with sequences containing objects references with C++ and =
orbacus 4.3.0.=20
I consulted the advanced Corba Programming wih C++ book from Michi =
Henning Steve Vinoski too=20
and found informations about sequence mapping in pages 180,=20
Informations about insertion and deletion of elements in pages 196.=20
In IDL I declare the following:=20
interface groupCorba {=20
...=20
...=20
}=20
interface lockCorba {=20
...=20
typedef sequence<groupCorba> lockgroupSeq;=20
...=20
}=20
...::lockCorba::lockGroupSeq groupSeq;=20
add ref in the sequence:=20
void ...::addGroup( ...::groupCorba_ptr inGroup) {=20
groupSeq.length(group.length()+1);=20
groupSeq[groupSeq.length(group.length()-1]=3D in Group;=20
remove ref in the sequence=20
void ...::remove group(...::groupCorba_ptr inGroup) {=20
for (unsigned long l =3D 0; l < groupSeq.length()-1; l++) {=20
..::groupCorba_ptr curGroup;
curGroup =3D inGroup;
if (curGroup =3D inGroup) {=20
for (unsigned long l1 =3D l; l1 < groupSeq.length()-1; l1++) {=20
groupSeq[l1] =3D grouSeq[l1+1];=20
}=20
groupSeq.length(groupSeq.length()-1);=20
l =3D l1;=20
}=20
}=20
}=20
With this construct I can add ref in the sequence; but when I try to=20
remove one the system crash when I decrement the length of the=20
sequence. The system first returns the decreased length=20
in line CORBA::ULong length() const=20
( return len_;)=20
Then executes the following sequence and crash by trying to wrongly=20
remove the referenced object=20
template<T, u>::length(CORBA::ULong newLen>) {=20
if (newlen < len_&& rel_) {=20
for (CORBA::ULong i =3D newlen; i < len_; i++) {=20
T* old =3D data[i];=20
data_[i] =3D 0;=20
OBRelease(old);=20
...=20
...=20
OBRelease(...::groupCorba_ptr p) {=20
if(p)=20
p -> _remove_ref();=20
(system crash here with a not excepted exception at 0x0048e70 in the=20
application.exe:0xC0000005; access violation when reading the place=20
0xcec478b9)=20
I don't understand why CORBA tries in this case to delete the=20
referenced object?=20
I hope somebody will can help to correct my programm or send me=20
informations to find why my code doesn't work. Do I have to initialyze=20
the sequence in a special way? or something like that? has the sequence=20
release flag something to do for that?=20
Many thanks in advance for your answer.=20
Kind returns=20
Jean-Lou=20
------_=_NextPart_001_01C6B9EE.08B62EC5
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">=0A=
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">=0A=
<HTML>=0A=
<HEAD>=0A=
=0A=
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7226.0">=0A=
<TITLE>Re: [OB-Users] RE: OB-Users Digest, Vol 38, Issue 2</TITLE>=0A=
</HEAD>=0A=
<BODY>=0A=
<DIV id=3DidOWAReplyText57245 dir=3Dltr>=0A=
<DIV dir=3Dltr><FONT face=3DArial color=3D#000000 size=3D2>=0A=
<DIV style=3D"PADDING-LEFT: 6px"><A name=3Dmsg_fc57026a44008c28></A>Hi, =
<BR>=0A=
<P>I am working with sequences containing objects references with C++ =
and =0A=
orbacus 4.3.0. <BR>I consulted the advanced Corba Programming wih C++ =
book from =0A=
Michi Henning Steve Vinoski too <BR>and found informations about =
sequence =0A=
mapping in pages 180, <BR>Informations about insertion and deletion of =
elements =0A=
in pages 196. <BR>In IDL I declare the following: <BR>interface =
groupCorba { =0A=
<BR>... <BR>... <BR>} <BR></P>interface lockCorba { <BR>... <BR>typedef =0A=
sequence<groupCorba> lockgroupSeq; <BR>... <BR>=0A=
<P>=0A=
<DIV class=3Dqt id=3Dqhide_386912 style=3D"DISPLAY: block">} =
<BR><BR></DIV><BR>=0A=
<P>...::lockCorba::lockGroupSeq groupSeq; <BR>=0A=
<P>add ref in the sequence: =0A=
<P>void ...::addGroup( ...::groupCorba_ptr inGroup) { <BR> =0A=
groupSeq.length(group.length()+1); <BR> =0A=
groupSeq[groupSeq.length(group.length()-1]=3D in Group; <BR>=0A=
<P>remove ref in the sequence <BR>=0A=
<P>void ...::remove group(...::groupCorba_ptr inGroup) { <BR> =
for =0A=
(unsigned long l =3D 0; l < groupSeq.length()-1; l++) { <BR> =
=0A=
..::groupCorba_ptr curGroup;</P>=0A=
<P> curGroup =3D =0A=
inGroup;<BR> if (curGroup =3D inGroup) { =
<BR> =0A=
for (unsigned long l1 =3D l; l1 < =0A=
groupSeq.length()-1; l1++) { <BR> =
=0A=
groupSeq[l1] =3D grouSeq[l1+1]; <BR> } =
<BR> =0A=
groupSeq.length(groupSeq.length()-1); =
<BR> =0A=
l =3D l1; <BR> } =
<BR> } =0A=
<BR></P>=0A=
<P>=0A=
<DIV class=3Dqt id=3Dqhide_386913 style=3D"DISPLAY: block">} =
<BR><BR></DIV>With this =0A=
construct I can add ref in the sequence; but when I try to <BR>remove =
one the =0A=
system crash when I decrement the length of the <BR>sequence. The system =
first =0A=
returns the decreased length <BR>in line CORBA::ULong length() const =
<BR> =0A=
( return len_;) <BR>Then executes the following sequence and crash =
by =0A=
trying to wrongly <BR>remove the referenced object <BR>=0A=
<P>template<T, u>::length(CORBA::ULong newLen>) { <BR> =
if =0A=
(newlen < len_&& rel_) { <BR> for =
(CORBA::ULong i =0A=
=3D newlen; i < len_; i++) { <BR> T* =
old =3D =0A=
data[i]; <BR> data_[i] =3D 0; =
<BR> =0A=
OBRelease(old); <BR> ... <BR>... <BR>=0A=
<P>OBRelease(...::groupCorba_ptr p) { <BR> if(p) <BR> =
=0A=
p -> _remove_ref(); <BR>(system crash here with a not excepted =0A=
exception at 0x0048e70 in the <BR>application.exe:0xC0000005; access =
violation =0A=
when reading the place <BR>0xcec478b9) <BR>=0A=
<P>I don't understand why CORBA tries in this case to delete the =
<BR>referenced =0A=
object? <BR>=0A=
<P>I hope somebody will can help to correct my programm or send me =0A=
<BR>informations to find why my code doesn't work. Do I have to =
initialyze =0A=
<BR>the sequence in a special way? or something like that? has the =
sequence =0A=
<BR>release flag something to do for that? <BR>Many thanks in advance =
for your =0A=
answer. <BR>Kind returns <BR>Jean-Lou =0A=
<BR></P></DIV></FONT></DIV></DIV>=0A=
=0A=
</BODY>=0A=
</HTML>
------_=_NextPart_001_01C6B9EE.08B62EC5--
--===============90905031041597906==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
_______________________________________________
OB-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/ob-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html
--===============90905031041597906==--