RTI Routing Service  Version 6.0.0
 All Data Structures Files Functions Typedefs Enumerations Enumerator Groups Pages
Query.hpp
1 /* $Id$
2 
3 (c) Copyright, Real-Time Innovations, 2015-2016.
4 All rights reserved.
5 
6 No duplications, whole or partial, manual or electronic, may be made
7 without express written permission. Any such copies, or
8 revisions thereof, must display this notice unaltered.
9 This code contains trade secrets of Real-Time Innovations, Inc.
10 
11 
12 ============================================================================= */
13 
14 #ifndef RTI_ROUTING_PROCESSOR_QUERY_HPP_
15 #define RTI_ROUTING_PROCESSOR_QUERY_HPP_
16 
17 #include <dds/core/Reference.hpp>
18 #include <rti/core/detail/SelfReference.hpp>
19 #include <rti/routing/adapter/StreamReader.hpp>
20 
21 namespace rti { namespace routing { namespace processor {
22 
23 class Input;
24 
25 class QueryHolder : public rti::core::detail::RetainableType<QueryHolder>{
26 public:
27 
28  QueryHolder() : stream_reader_(NULL), query_data_(NULL)
29  {
30  }
31 
32  QueryHolder(
33  rti::routing::adapter::StreamReader *the_stream_reader,
34  const dds::topic::Filter& the_filter)
35  : stream_reader_(the_stream_reader),
36  query_data_(NULL)
37  {
38  filter(the_filter);
39  }
40 
41  ~QueryHolder()
42  {
43  if (query_data_ != NULL) {
44  stream_reader_->delete_content_query(query_data_);
45  }
46  }
47 
48  void filter(const dds::topic::Filter& filter)
49  {
50  query_data_ = stream_reader_->create_content_query(query_data_, filter);
51  }
52 
54  void* query_data_;
55 };
56 
73 class Query : public dds::core::Reference<rti::routing::processor::QueryHolder> {
74 public:
75  typedef dds::core::Reference<QueryHolder> Base;
76  OMG_DDS_REF_TYPE_NOTYPENAME(
77  Query,
78  dds::core::Reference,
79  rti::routing::processor::QueryHolder);
80 
81  explicit Query(Base::DELEGATE_REF_T reference) : Base(reference)
82  {
83  if (this->delegate()) {
84  this->delegate()->remember_reference(this->delegate());
85  }
86  }
87 
98  const dds::topic::Filter& filter)
99  : Base(new QueryHolder(stream_reader, filter))
100  {
101  this->delegate()->remember_reference(this->delegate());
102  }
103 
104 
112  void filter(const dds::topic::Filter& filter)
113  {
114  this->delegate()->filter(filter);
115  }
116 };
117 
118 } } }
119 
120 #endif // RTI_ROUTING_PROCESSOR_QUERY_HPP_

RTI Routing Service Version 6.0.0 Copyright © Sun Mar 3 2019 Real-Time Innovations, Inc