Sequence of pointers in IDL

6 posts / 0 new
Last post
Offline
Last seen: 6 years 4 months ago
Joined: 09/17/2015
Posts: 53
Sequence of pointers in IDL

Hello,

Why can't I write something like:

sequence< double *  > ptr_seq
 

Is there a workaround for that? I mean arrays of pointers are supported.

Thank you and best regards,

Andreas 

jwillemsen's picture
Offline
Last seen: 2 years 10 months ago
Joined: 09/24/2013
Posts: 55

IDL doesn't have a concept of pointers so the IDL you have is illegal (see the OMG site for the IDL3.5 specification), I really doubt if arrays of pointers is supported, probably it is a bug or it behaves differently then you expect.

In the concept of DDS, what is the meaning if you publish a pointer value, a subscriber can't do anything with a pointer because it is something in a different process space and very likely on another system.

Offline
Last seen: 6 years 4 months ago
Joined: 09/17/2015
Posts: 53

Everything works flawlessly now: 

struct myPoint {
 short x;
 short y;
};
struct SubObject {
 short id;
 myPoint val_sub;
};
 typedef SubObject* ptr_SubObject;
struct ODB_Test {
 short id;
 myPoint val;
 sequence< ptr_SubObject > ptrSeq;
 };

The pointer gets dereferenced and serialized before it gets sent on the wire by DDS.

 

Gerardo Pardo's picture
Offline
Last seen: 1 day 1 hour ago
Joined: 06/02/2010
Posts: 601

Regarding the pointer syntax in IDL, the DDS-XTYPES specification has the concept of Optional members as well as the concept of Shared members.  These are indicated via annotations. These are now incorporated into IDL4, except that there the annotation Shared was renamed to external.

The Shared / External annotations affect the mapping of the member. Quiting the IDL4 specification on this:

Usually when a data object is mapped in memory, it is implemented as a whole, meaning that, when feasible, its data members are placed next to each other in a single data space. This annotation forces the annotated element to be put elsewhere, in a dedicated place. This is useful for instance to save resources when the element may be huge and is not always present or to allow sharing of the element between data objects. 

So basically this annotation has similar meaning a the "*" pointer in C/C++.

RTI already (prior to DDS-XTYPES or IDL4) supported this concept and we allow the use of the "*" as an alternative notation to indicate that a member should be treated as shared/external.  This is consistent with the fact that the specified mapping of that to C/C++ is a pointer, as expected.

Gerardo

 

jwillemsen's picture
Offline
Last seen: 2 years 10 months ago
Joined: 09/24/2013
Posts: 55

Didn't realize that the * is a RTI specific extension, it is illegal in formal IDL, it will cause problems when you share your IDL with others that are using some other DDS vendor.

I would recommend to use the IDL4 annotations, these are part of the IDL specification and are portable between vendors.

Gerardo Pardo's picture
Offline
Last seen: 1 day 1 hour ago
Joined: 06/02/2010
Posts: 601

Agreed that would be best going forward. But it needs to wait a bit until we and other vendors support the new IDL4 annotation syntax...