[omniORB] Looking for examples of sequence manipulation
Perham, David A. (Mission Systems)
david.perham at ngc.com
Wed Mar 28 11:48:44 BST 2007
Howdy:
Looking for tips on how to manipulate sequences I came across this
example in the mailing list archives.
The example demonstrates how to create the sequence in idl, and how to
pass a pointer to the sequence in the implementation code.
Unfortunately, it does not show the syntax required to access this
pointer within the implementation after it is created. In other words,
after
ptx = new MyInterface::randSeq(len,len,p);
I'd like to do something with the sequence, like assign a value to
something within it.
For example if I have declared a sequence like this in IDL
Typedef struct theStruct
{
short x ;
short y ;
} theStructType ;
Typedef sequence <theStructType> theStructSeq ;
Boolean DoSomethingWithTheStructSeq( out theStructSeq myStructSeq) ;
And the implementation has
Bool DoSomethingWithTheStructSeq( theStructSeq_out ss )
{
theStructSeq *& ptx = ss.ptr() ;
ptx = new theStructSeq(3) ;
}
What is the syntax to assign a value to 'x' within an element of the
sequence?
Thanks,
Dave P
> Howdy,
> Hope the following sample helps you.
>
> IDL: > interface MyInterface
> {
> typedef sequence<octet> randSeq;
> void getRandSeq( out randSeq tx );
> }
>
> Object Implementation:
> void MyInterface_i::getRandSeq( randSeq_out tx )
> {
> MyInterface::randSeq*& ptx = tx.ptr();
> //.... > CORBA::Octet* p = new CORBA::Octet[ len ];
> //....
> ptx = new MyInterface::randSeq(len,len,p);
> }
>
> Client: > void hello( MyInterface_ptr e )
> {
> MyInterface::randSeq_var tx;
> e->getRandSeq( tx.out() );
> long len = tx.length();
> for ( i = 0; i < len; i++ )
> {
> cout << tx[i] << endl; // access
> }
> }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20070328/116ed5f5/attachment.htm
More information about the omniORB-list
mailing list