[omniORB] A question about sequences

b.keeping@ic.ac.uk b.keeping@ic.ac.uk
Thu, 5 Aug 1999 08:29:40 +0100


Tony,

seq.out() must be something specific to Visigenic I think.

The answer to your question is that seq should be declared as
MySequence_var. The problem you describe must be caused by something
else, such as not getting the client and server talking to each other
properly.

To demonstrate, I have now modified the famous echo example by adding
a method that returns a sequence of longs.

The differences are as follows (orig being the original example
directory)

1) Add sequence definition and method to the idl file:
diff ./echo.idl orig/echo.idl
3c3
< typedef sequence<long> MySeq;
---
> 
6d5
<   void getSeq(out MySeq list);

2) Add declaration and implementation of method to the server:
diff echo_i.cc orig/echo_i.cc 
13d12
<   virtual void getSeq(MySeq *& parm);
21,30d19
< 
< void
< Echo_i::getSeq( MySeq *&parm )
< {
<   parm=new MySeq(2);
<   parm->length(2);
<   (*parm)[0]=1;
<   (*parm)[1]=2;
< }
< 

3) Add code to call it to the client:
diff greeting.cc orig/greeting.cc 
25c25
<   MySeq_var seq;
---
> 
30,34d29
<   cerr << " The Object also said, ";
<   e->getSeq( seq );
<   for (int i=0;i<seq->length();i++)
<     cerr<<" "<<seq[i];
<   cerr<<endl;

This works!

Ben Keeping