Dds query condition

6 posts / 0 new
Last post
Offline
Last seen: 8 years 7 months ago
Joined: 11/28/2015
Posts: 8
Dds query condition

How to apply dds query condition to attribute within a structure of a topic?

Gerardo Pardo's picture
Offline
Last seen: 1 week 2 days ago
Joined: 06/02/2010
Posts: 602

Hi Shweta,

Can you be more specific about what you mean? Maybe provide the IDL and explain when you want the QueryCondition to become active...

In general you refer to the attributes of a structure by their name direcly. See take a look at this example https://community.rti.com/examples/waitset-query-condition. Since the structure has an attribute called name of type string the conditon expression can be something like:   name match 'Fred'

Gerardo

Offline
Last seen: 8 years 7 months ago
Joined: 11/28/2015
Posts: 8

 

Hi
Thanks for your reply.
Take for example following is the idl:
struct STRUCT_USER_LIST
{
DDS_Char* username;
UINT_8 user role;
}
struct USER_FUNCTION_LIST
{
STRUCT_USER_LIST struct_user_list;
}
I want to retrieve that sample whose username is User1.
So I want to apply ddsquerycondition to attribute username within a structure struct_user_list of topic USER_FUNCTION_LIST.

Gerardo Pardo's picture
Offline
Last seen: 1 week 2 days ago
Joined: 06/02/2010
Posts: 602

Oh I see your question was about nested structures. You can use the "." notation to refer to the nested members as you would do in C++, Java, or C#.

In your exaple you would use the expression:   struct_user_list.username match 'User1'

Gerardo

Offline
Last seen: 8 years 7 months ago
Joined: 11/28/2015
Posts: 8

Hi

Take for example 

Char* qc_params_list[1];

qc_params_list[0] = "'User1'";

DDS_StringSeq qc_params(1);

qc_params.from_array(qc_params_list,1);

DDSQueryCondition *query= reader->create_querycondition(DDS_ANY_SAMPLE_STATE,DDS_ANY_VIEW_STATE,DDS_ALIVE_INSTANCE_STATE,"struct_user_list.username=",qc_params);

Here null pointer is returned to query. 

 

Offline
Last seen: 8 years 7 months ago
Joined: 11/28/2015
Posts: 8

Sry second last argument is taken as "struct_user_list.username = %0"