Hello!
I need to use a data structure with an array of variable dimension, (like a vector) in c++, defining it into my idl file. I've read the DDS guide and i've seen several types but i cannot find a solution to my problem.
Anyone can tell me if is possibile to create dynamica array??
Thanks a lot.
What you are looking for is called a "sequence" in IDL. It can have elements of any kind including primitive types and other structured types. For example:
Hi Gerardo Pardo, thanks for the useful reply! Now i can create a dynamic array!
Hi guys,
I am kind of newbie in this DDS. What I am trying to do exactly what Gerardo has posted above, but it doesn't work for me. In detail, I shortened the IDL struct to be:
const long LABEL_MAX_LEN=128;
typedef string<LABEL_MAX_LEN> Label;
const long MAX_LABELS=64;
struct StructWithSequences {
Label smaple_test;
sequence<Label, MAX_LABELS> labels;
};
Just before to publish I can see that the labels array is filled with string values. In the QoS profile I have it set up to be TRANSIENT_DURABILITY_QOS. After I publish I can see that the sample_test variable is exactly what I published, but the labels array consists of 64 null values. So, all my string values disappeared somewhere on the way and they turned into null values. Again, pay attention on the fact that it is exactly the topic data that I published since the sample_test value is the one that I published, only the array values turn into nulls.
I appreciate any help, any comments.
Thanks in advance.
Hi,
My suspicion would be that you are not setting the maximum value or the length of the sequence correctly... Which language are you using?
This DDS Sequences HOWTO may help: http://community.rti.com/content/forum-topic/howto-use-omg-dds-sequences-c-rti-connext-dds it explains in detail how to use sequences.
Gerardo