I'm using openDDS for Data-centric publish subscribe model. Publisher is continuously sending data and subscriber will receive it.but in the case of subscriber ,it has to receive filtered data based on the condition I have given.
suppose my topic structure used by both publisher and subscriber is :
module Messenger {
#pragma DCPS_DATA_TYPE "Messenger::ChannelData"
#pragma DCPS_DATA_KEY "Messenger::ChannelData subject_id"
struct ChannelData {
string from;
string subject;
long subject_id;
string text;
long count;
};
};
OpenDDS has one concept named as content-filtering topic. same I have used.
Code :
// Register Type (Messenger::Message)
Messenger::ChannelDataTypeSupport_var ts =
new Messenger::ChannelDataTypeSupportImpl();
if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: register_type() failed!\n")), -1);
}
// Create Topic (Movie Discussion List)
CORBA::String_var type_name = ts->get_type_name();
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in(),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
DDS::ContentFilteredTopic_var cft =
participant->create_contentfilteredtopic("MyTopic-Filtered",
topic,
"count <= 0 ",DDS::StringSeq());
But In above code I have hard coded filter condition count <=0 .
so,is there any way to provide dynamic filter condition for subscriber to receive filtered data?
Instead of 0 pass %0 and instead of DDS::StringSeq() pass a sequence of length 1 that contains the value that should be used for %0. A quick search on google would have given you several examples!