Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 订户opendds中的动态内容过滤?_C++_C_Publish Subscribe_Data Distribution Service - Fatal编程技术网

C++ 订户opendds中的动态内容过滤?

C++ 订户opendds中的动态内容过滤?,c++,c,publish-subscribe,data-distribution-service,C++,C,Publish Subscribe,Data Distribution Service,我将openDDS用于以数据为中心的发布-订阅模型。 Publisher正在连续发送数据,订阅服务器将接收数据。但对于订阅服务器,它必须根据我给出的条件接收过滤后的数据 假设发布者和订阅者使用的主题结构为: module Messenger { #pragma DCPS_DATA_TYPE "Messenger::ChannelData" #pragma DCPS_DATA_KEY "Messenger::ChannelData subject_id" struct ChannelDat

我将openDDS用于以数据为中心的发布-订阅模型。 Publisher正在连续发送数据,订阅服务器将接收数据。但对于订阅服务器,它必须根据我给出的条件接收过滤后的数据

假设发布者和订阅者使用的主题结构为:

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有一个称为内容过滤主题的概念。和我用过的一样

代码:

  // 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());
//寄存器类型(Messenger::Message)
Messenger::ChannelDataTypeSupport\u var ts=
新Messenger::ChannelDataTypeSupportImpl();
if(ts->register_type(participant.in(),“”)!=DDS::RETCODE_OK){
ACE_错误返回((LM_错误,
ACE_文本(“%N:%l main()”)
ACE_TEXT(“错误:寄存器类型()失败!\n”),-1);
}
//创建主题(电影讨论列表)
CORBA::String_var type_name=ts->get_type_name();
DDS::Topic\u var Topic=
参与者->创建主题(“电影讨论列表”,
在()中键入_name.in,
主题\u QOS\u默认值,
DDS::TopicListener::nil(),
OpenDDS::DCPS::默认\U状态\U掩码);
DDS::ContentFilteredTopic\u var cft=
参与者->创建内容过滤主题(“MyTopic FilteredTopic”,
话题,,

“count而不是0传递%0,而不是DDS::StringSeq()传递一个长度为1的序列,该序列包含应用于%0的值。在google上快速搜索可能会给出几个示例