I was wondering if there's a way to get a typecode from a sequence dynamic data object that's empty.
For example, I create a new DynamicData object with DynamicData(TypeCode, DynamicDataProperty_t) but all sequences are created with size 0, and I'd like to add sequence members. The problem is, that I need to know the typecode of the inner members of the sequence, in order to create them.
Is there a way to get that typecode without actually having any members?
Hi Michael,
You can always use the methods:
to access the type information associated with a DynamicData sample.
However, you don't explicitly need to know the type-code of the sequece in order to set its elements. Using the Dynamic Data API for sequences is almost like using it for structured types.
You can do
with a sequence type, just as you would do with a structured type (e.g. struct).Also take into account that you can do:
to obtain the member information, which should provide you with the kind of element contained by the sequence
When accessing sequence elements, remember that the members have to be accessed by ID (they don't have names), and that the member IDs index the sequence starting with 1. For example, to access member index 0 in the sequence, you use member ID 1; to access member index 5 in the sequence, you use member ID 6. So if you have a sequence of primitive types, you could call
You could also set arrays of primitive types and sequences of primitive types directly using the convenience methods:
If your sequence contained structured types, like structs or unions, then you could bind them normally by using the indexing schema I mentioned above:
Then you can process every complex member in the sequence separately. It's important to call
every time you finish processing a complex member.
I hope this helps, let me know if you have any more doubts.
Thanks,
Juanlu
Hi Juanlu,
I'm doing all of the above to go over the DynamicData members but I reach a point where I have a dynamic data that:
data.get_type_kind() is TK_SEQUENCE
data.get_type() is null
data.get_member_count() is 0
At this point, I cant call get_member_info_by_index as there are no members (the sequence is empty), yet I'd like to create new members, but I need to know the typecode of the underlying sequence members, but I don't actually have any to bind them and call get_type().
Is there a way to get the typecode without actually having any members to bind?
Thanks,
Michael
Hi Michael,
If you have the type-code of the parent type then you can navigate the type-code as much as you can navigate the DynamicData information. With the parent type-code, method
will give you the type of the contained elements in the sequence. Have you tried this approach? I don't know if you're traversing the type-code structure as you traverse the DynamicData sample.
Thanks,
Juanlu
Hi Juanlu,
Using the parent type code indeed solved the problem
Thanks a lot!
Michael
No worries! Glad I could help.
Juanlu