[omniORB] A question about sequences
DSSol@aol.com
DSSol@aol.com
Wed, 4 Aug 1999 19:16:34 EDT
In a message dated 8/4/99 7:33:39 AM US Eastern Standard Time,
b.keeping@ic.ac.uk writes:
<< To Tony:
You should just be passing seq itself here. A _var can be used like a
pointer, except that it cleans up the thing it points to when it goes
out of scope. So think of the call as passing a pointer to a sequence (by
reference, so that it can be changed).
Your client code could look like this:
doSomething( seq );
for (int i=0;i<seq->length();i++)
cout<<seq[i];
incidentally the server code could look like this (assuming unbounded
sequence)
void doSomething( MySequence *&parm )
{
parm=new MySequence(2);
parm->length(2);
(*parm)[0]=val1; // where val1 and val2 are some values of whatever
(*parm)[1]=val2; // type it's a sequence of!
}
To All:
This question demonstrates a need for an example on sequences in the
distribution. They took me a while to work out and I didn't find a
book that seemed to consider them very important!
Also, any comments on the way I'm doing things here welcome.
Ben Keeping
Imperial College
>>
Ben,
Thanks for the reply. I have a book that does have an example of how to pass
sequences as in, inout, and out parameters. From the client, they declared
the sequence with the _var and passed it like doSomething( seq.out() ) as I
described in my original message. Their server code is implemented much like
the code you described above. The book I am using based their code on the
Visigenic ORB.
In your example above, how should the sequence be declared on the client side
(MySequence seq or MySequence_var seq)? If I declared it with the _var and
pass it without the .out(), the servant faults, even though it does compile
in this case. Is it possible that omniidl2 is not generating the proper code
for the seq.out() case that is causing it not to compile?
Thanks again.
Tony Thompson