C++ maps in IDL

2 posts / 0 new
Last post
Last seen: 11 months 1 week ago
Joined: 05/27/2020
Posts: 1
C++ maps in IDL


I need to use a data structure like a maps 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 maps?

Thanks a lot.

Last seen: 6 months 3 weeks ago
Joined: 08/20/2012
Posts: 25

Essentially yes, but by a combination of data type and DataReader behavior. Consider something like this:

struct map {
    @key string<128> key;
    string<1024> value;

Also assume a history depth of 1. As your DataWriter(s) populate the data space by writing instances and your DataReader(s) receive them, you could iterate over them with a basic read(). Or if you wanted to look up an instance by a specific key value, you could use lookup_instance() and then (in modern C++) select() and instance(). Technically, at the cost of efficiency, you could even use a Query Condition to look up instances by value.