1 #ifndef OMG_DDS_TOPIC_DETAIL_CONTENTFILTEREDTOPIC_HPP_ 2 #define OMG_DDS_TOPIC_DETAIL_CONTENTFILTEREDTOPIC_HPP_ 29 #include <org/opensplice/topic/TopicDescriptionDelegate.hpp> 30 #include <org/opensplice/core/ScopedLock.hpp> 33 #include "v_kernelParser.h" 35 #ifdef OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT 47 class ContentFilteredTopic :
public virtual org::opensplice::topic::TopicDescriptionDelegate
52 const std::string& name,
54 :
org::opensplice::topic::TopicDescriptionDelegate(topic.domain_participant(), name, topic.type_name()),
58 ISOCPP_REPORT_STACK_DDS_BEGIN(topic);
60 topic.delegate()->incrNrDependents();
61 this->myParticipant.delegate()->add_cfTopic(*
this);
64 virtual ~ContentFilteredTopic()
77 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
78 org::opensplice::core::ScopedObjectLock scopedLock(*
this);
80 myTopic.delegate()->decrNrDependents();
83 this->myParticipant.delegate()->remove_cfTopic(*
this);
85 org::opensplice::core::ObjectDelegate::close();
89 init(org::opensplice::core::ObjectDelegate::weak_ref_type weak_ref)
91 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
94 this->set_weak_ref(weak_ref);
96 this->myParticipant.delegate()->add_cfTopic(*
this);
100 void validate_filter()
104 std::vector<c_value> params;
106 length = myFilter.parameters_length();
108 expr = v_parser_parse(myFilter.expression().c_str());
110 ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
111 "filter_expression '%s' is invalid", myFilter.expression().c_str());
114 ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
115 "Invalid number of filter_parameters '%d', maximum is 99", length);
118 u_topic uTopic = (u_topic)(myTopic.delegate()->get_user_handle());
120 params = reader_parameters();
121 if (!u_topicContentFilterValidate2(uTopic, expr, params.empty() ? NULL : ¶ms[0], (os_uint32)params.size())) {
123 ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
124 "filter_expression '%s' is invalid.", myFilter.expression().c_str());
130 std::string reader_expression()
const 132 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
135 rExpr +=
"select * from ";
136 rExpr += myTopic.name();
138 rExpr += myFilter.expression();
142 std::vector<c_value> reader_parameters()
const 144 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
145 std::vector<c_value> params;
147 org::opensplice::topic::FilterDelegate::const_iterator paramIterator;
149 length = myFilter.parameters_length();
151 for (n = 0, paramIterator = myFilter.begin(); n < length; n++, paramIterator++) {
152 params.push_back(c_stringValue(const_cast<char *>(paramIterator->c_str())));
172 template <
typename FWIterator>
173 void filter_parameters(
const FWIterator& begin,
const FWIterator& end)
175 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
176 ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR,
"Changing of Filter parameters is currently not supported.");
177 myFilter.parameters(begin, end);
186 const std::string& filter_expression()
const 188 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
189 return myFilter.expression();
194 ISOCPP_REPORT_STACK_DELEGATE_BEGIN(
this);
Filter objects contain SQL expressions that allow the application to specify a filter on the locally ...
Topic is the most basic description of the data to be published and subscribed.
std::vector< std::string > StringSeq