Discussion:
[omniORB] Looking for examples of sequence manipulation
Perham, David A. (Mission Systems)
2007-03-28 23:49:09 UTC
Permalink
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 );
}
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
Carlos
2007-03-29 04:53:41 UTC
Permalink
El mi?, 28-03-2007 a las 10:48 -0700, Perham, David A. (Mission Systems)
Post by Perham, David A. (Mission Systems)
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?
(*ptx)[0].x = 29;

for example

and if you want to populate all the sequence

for (CORBA::ULong i = 0; i < ptx->length(); i++) {
(*ptx)[i].x = ...;
(*ptx)[i].y = ...;
}

I expect this helps you.

Cheers.
Post by Perham, David A. (Mission Systems)
Thanks,
Dave P
Howdy,
Hope the following sample helps you.
IDL: > interface MyInterface
{
typedef sequence<octet> randSeq;
void getRandSeq( out randSeq tx );
}
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
}
}
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Perham, David A. (Mission Systems)
2007-03-29 21:38:15 UTC
Permalink
Thanks for the post.

I must still be doing something wrong.

This is a sample of the code I am trying to implement:

// IDL

typedef sequence <EntityInventoryType, 10> EntityInventorySequence ;

// Impl

bool ObjectServerImpl::RequestEntityInventory( long EntityId, EntityInventorySequence_out EntityInventory )
{
EntityInventorySequence*& ptr = EntityInventory.ptr() ;
(*ptr)[0].InventoryCode = 5 ;
}

This builds, however I am not very confident that it is correct, because the .NET intellisensor tool is not filling out the "InventoryCode" when I type "(*ptr)[0].".

Am I still missing something?

Thanks again for the help, I still haven't found any examples on the net.

Take care

-----Original Message-----
From: Carlos [mailto:***@canama.net]
Sent: Wednesday, March 28, 2007 4:04 PM
To: Perham, David A. (Mission Systems)
Cc: omniorb-***@omniorb-support.com
Subject: Re: [omniORB] Looking for examples of sequence manipulation

El mi?, 28-03-2007 a las 10:48 -0700, Perham, David A. (Mission Systems)
Post by Perham, David A. (Mission Systems)
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?
(*ptx)[0].x = 29;

for example

and if you want to populate all the sequence

for (CORBA::ULong i = 0; i < ptx->length(); i++) {
(*ptx)[i].x = ...;
(*ptx)[i].y = ...;
}

I expect this helps you.

Cheers.
Post by Perham, David A. (Mission Systems)
Thanks,
Dave P
Howdy,
Hope the following sample helps you.
IDL: > interface MyInterface
{
typedef sequence<octet> randSeq;
void getRandSeq( out randSeq tx ); }
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
}
}
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Carlos
2007-03-30 04:45:08 UTC
Permalink
El jue, 29-03-2007 a las 08:37 -0700, Perham, David A. (Mission Systems)
Post by Perham, David A. (Mission Systems)
Thanks for the post.
I must still be doing something wrong.
// IDL
typedef sequence <EntityInventoryType, 10> EntityInventorySequence ;
// Impl
bool ObjectServerImpl::RequestEntityInventory( long EntityId, EntityInventorySequence_out EntityInventory )
{
EntityInventorySequence*& ptr = EntityInventory.ptr() ;
(*ptr)[0].InventoryCode = 5 ;
}
// At first you must allocate memory for the sequence

EntityInventorySequence*& ptr = EntityInventory.ptr() ;
ptr = new EntityInventorySequence;

// or directly

EntityInventory.ptr() = new EntityInventorySequence;

// Second you must set the sequence length, because is a bounded
// sequence length must be less or equal than the limit
// (10 in your case), I only set an element
// In my previous message I did a mistake if the sequence is unbounded
// the contructor Seq(ULong) sets the maximum sequence length,
// but not the current length so you must indicate the current
// length like to bounded sequence.

ptr->length(1);

// Now you can assign the InventoryCode

(*ptr)[0].InventoryCode = 5;

// and at last because your function is bool f(...)

return true;

I expect this help you.

Cheers
Post by Perham, David A. (Mission Systems)
This builds, however I am not very confident that it is correct, because the .NET intellisensor tool is not filling out the "InventoryCode" when I type "(*ptr)[0].".
Am I still missing something?
Thanks again for the help, I still haven't found any examples on the net.
Take care
-----Original Message-----
Sent: Wednesday, March 28, 2007 4:04 PM
To: Perham, David A. (Mission Systems)
Subject: Re: [omniORB] Looking for examples of sequence manipulation
El mi?, 28-03-2007 a las 10:48 -0700, Perham, David A. (Mission Systems)
Post by Perham, David A. (Mission Systems)
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?
(*ptx)[0].x = 29;
for example
and if you want to populate all the sequence
for (CORBA::ULong i = 0; i < ptx->length(); i++) {
(*ptx)[i].x = ...;
(*ptx)[i].y = ...;
}
I expect this helps you.
Cheers.
Post by Perham, David A. (Mission Systems)
Thanks,
Dave P
Howdy,
Hope the following sample helps you.
IDL: > interface MyInterface
{
typedef sequence<octet> randSeq;
void getRandSeq( out randSeq tx ); }
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
}
}
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Carlos
2007-03-30 04:59:57 UTC
Permalink
Post by Carlos
El jue, 29-03-2007 a las 08:37 -0700, Perham, David A. (Mission Systems)
Post by Perham, David A. (Mission Systems)
Thanks for the post.
I must still be doing something wrong.
// IDL
typedef sequence <EntityInventoryType, 10> EntityInventorySequence ;
// Impl
bool ObjectServerImpl::RequestEntityInventory( long EntityId, EntityInventorySequence_out EntityInventory )
{
EntityInventorySequence*& ptr = EntityInventory.ptr() ;
(*ptr)[0].InventoryCode = 5 ;
}
// At first you must allocate memory for the sequence
EntityInventorySequence*& ptr = EntityInventory.ptr() ;
ptr = new EntityInventorySequence;
// or directly
EntityInventory.ptr() = new EntityInventorySequence;
// Second you must set the sequence length, because is a bounded
// sequence length must be less or equal than the limit
// (10 in your case), I only set an element
// In my previous message I did a mistake if the sequence is unbounded
// the contructor Seq(ULong) sets the maximum sequence length,
// but not the current length so you must indicate the current
// length like to bounded sequence.
ptr->length(1);
// Now you can assign the InventoryCode
(*ptr)[0].InventoryCode = 5;
SORRY my english isn't good and perhaps I don't undertand you. I'm
assuming EntityInventoryType is

// IDL
struct EntityInventoryType {
short InventoryCode;
....
}

// C++
(*ptr)[0].InventoryCode = 5;

is correct but if EntityInventoryType is

// IDL

typedef short EntityInventoryType;

// C++
(*ptr)[0] = 5;

Cheers.
Post by Carlos
// and at last because your function is bool f(...)
return true;
I expect this help you.
Cheers
Post by Perham, David A. (Mission Systems)
This builds, however I am not very confident that it is correct, because the .NET intellisensor tool is not filling out the "InventoryCode" when I type "(*ptr)[0].".
Am I still missing something?
Thanks again for the help, I still haven't found any examples on the net.
Take care
-----Original Message-----
Sent: Wednesday, March 28, 2007 4:04 PM
To: Perham, David A. (Mission Systems)
Subject: Re: [omniORB] Looking for examples of sequence manipulation
El mi?, 28-03-2007 a las 10:48 -0700, Perham, David A. (Mission Systems)
Post by Perham, David A. (Mission Systems)
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?
(*ptx)[0].x = 29;
for example
and if you want to populate all the sequence
for (CORBA::ULong i = 0; i < ptx->length(); i++) {
(*ptx)[i].x = ...;
(*ptx)[i].y = ...;
}
I expect this helps you.
Cheers.
Post by Perham, David A. (Mission Systems)
Thanks,
Dave P
Howdy,
Hope the following sample helps you.
IDL: > interface MyInterface
{
typedef sequence<octet> randSeq;
void getRandSeq( out randSeq tx ); }
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
}
}
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Loading...